00001 /* 00002 ** TowBowlTactics, a turn-based strategy football game. 00003 ** 00004 ** Copyright (C) 2006-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 #include "SRules.hh" 00018 00019 inline int SMatch::getCurrentTeamId() const 00020 { 00021 if (r_->getState() == GS_TURN) 00022 return active_team_id_; 00023 if (r_->getState() == GS_INITKICKOFF 00024 || r_->getState() == GS_KICKOFF 00025 || r_->getState() == GS_TOUCHBACK) 00026 return receiving_team_id_; 00027 return -1; 00028 } 00029 00030 inline int SMatch::getCurrentOpponentTeamId() const 00031 { 00032 int id = getCurrentTeamId(); 00033 if (id == -1) 00034 return -1; 00035 return (id + 1) % 2; 00036 } 00037 00038 inline int SMatch::getOpponentTeamId(int team_id) const 00039 { 00040 return (team_id == 0) ? 1 : 0; 00041 } 00042 00043 inline int SMatch::getOpponentTeamId(STeam* team) const 00044 { 00045 return getOpponentTeamId(team->getTeamId()); 00046 } 00047 00048 inline STeam* SMatch::getCurrentTeam() 00049 { 00050 return getTeam(getCurrentTeamId()); 00051 } 00052 00053 inline STeam* SMatch::getCurrentOpponentTeam() 00054 { 00055 return getTeam(getCurrentOpponentTeamId()); 00056 } 00057 00058 inline STeam* SMatch::getOpponentTeam(int team_id) 00059 { 00060 return getTeam(getOpponentTeamId(team_id)); 00061 } 00062 00063 inline STeam* SMatch::getOpponentTeam(STeam* team) 00064 { 00065 return getTeam(getOpponentTeamId(team)); 00066 } 00067 00068 inline SBall* SMatch::getBall() 00069 { 00070 return static_cast<SBall*>(Match<SPlayer>::getBall()); 00071 } 00072 00073 inline STeam* SMatch::getTeam(int team_id) 00074 { 00075 return static_cast<STeam*>(Match<SPlayer>::getTeam(team_id)); 00076 } 00077 00078 inline Dice* SMatch::getDice() 00079 { 00080 return dice_; 00081 } 00082 00083 inline std::ostream& operator<< (std::ostream& os, const SMatch& m) 00084 { 00085 return os << static_cast<const Match<SPlayer>&>(m); 00086 } 00087
1.6.3