Ball.hxx

00001 /*
00002 ** TowBowlTactics, a turn-based strategy football game.
00003 ** 
00004 ** Copyright (C) 2007-2010 The TBT Team.
00005 ** 
00006 ** This program is free software; you can redistribute it and/or
00007 ** modify it under the terms of the GNU General Public License
00008 ** as published by the Free Software Foundation; either version 2
00009 ** of the License, or (at your option) any later version.
00010 ** 
00011 ** The complete GNU General Public Licence Notice can be found as the
00012 ** `NOTICE' file in the root directory.
00013 ** 
00014 ** The TBT Team consists of people listed in the `AUTHORS' file.
00015 */
00016 
00017 template <typename T>
00018 inline Ball<T>::Ball()
00019   : owner_(NULL)
00020 {
00021   coord_ = Coordinates(-1,-1);
00022 }
00023 
00024 template <typename T>
00025 inline Ball<T>::~Ball()
00026 {
00027 }
00028 
00029 template <typename T>
00030 inline void Ball<T>::setCoordinates(const Coordinates& pt)
00031 {
00032   coord_ = pt;
00033 }
00034 
00035 template <typename T>
00036 inline const Coordinates& Ball<T>::getCoordinates() const
00037 {
00038   return coord_;
00039 }
00040 
00041 template <typename T>
00042 inline T* Ball<T>::getOwner() const
00043 {
00044   return owner_;
00045 }
00046 
00047 template <typename T>
00048 inline void Ball<T>::setOwner(T* player)
00049 {
00050   owner_ = player;
00051 }
00052 
00053 template <typename U>
00054 inline std::ostream& operator<< (std::ostream& os, const Ball<U>& b)
00055 {
00056   b.printDebug(os);
00057   return os;
00058 }
00059 
00060 template <typename T>
00061 inline void Ball<T>::printDebug(std::ostream& os) const
00062 {
00063   os << "Ball is ";
00064   if (owner_ == NULL)
00065     os << "free";
00066   else
00067     os << "hold by player `" << owner_->getId()
00068        << "' of team `" << owner_->getTeamId() << "'";
00069   os << " at coordinates " << coord_ << "." << std::endl;
00070 }
00071 
Generated on Mon Apr 5 21:17:11 2010 for Stechec/TBT by  doxygen 1.6.3