SRules.hxx

00001 /*
00002 ** TowBowlTactics, an adaptation of the tabletop game Blood Bowl.
00003 ** 
00004 ** Copyright (C) 2006 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 "STeam.hh"
00018 
00019 inline void SRules::sendIllegal(int token, int from) const
00020 {
00021   sendIllegal(token, from, ERR_UNASSIGNED);
00022 }
00023 
00024 inline void SRules::sendIllegal(int token, int from, enum eError error) const
00025 {
00026   MsgIllegal pkt(from);
00027   pkt.was_token = token;
00028   pkt.error = error;
00029   sendPacket(pkt);
00030 }
00031 
00032 inline int SRules::getCurrentTeamId() const
00033 {
00034   if (getState() == GS_COACH1)
00035     return 0;
00036   if (getState() == GS_COACH2)
00037     return 1;
00038   if (getState() == GS_INITKICKOFF
00039       || getState() == GS_KICKOFF
00040       || getState() == GS_TOUCHBACK)
00041     return coach_receiver_;
00042   return -1;
00043 }
00044 
00045 inline int SRules::getCurrentOpponentTeamId() const
00046 {
00047   int id = getCurrentTeamId();
00048   if (id == -1)
00049     return -1;
00050   return (id + 1) % 2;
00051 }
00052 
00053 inline int SRules::getOpponentTeamId(int team_id) const
00054 {
00055   return (team_id == 0) ? 1 : 0;
00056 }
00057 
00058 inline int SRules::getOpponentTeamId(STeam* team) const
00059 {
00060   return getOpponentTeamId(team->getTeamId());
00061 }
00062 
00063 inline STeam* SRules::getCurrentTeam()
00064 {
00065   return getTeam(getCurrentTeamId());
00066 }
00067 
00068 inline STeam* SRules::getCurrentOpponentTeam()
00069 {
00070   return getTeam(getCurrentOpponentTeamId());
00071 }
00072 
00073 inline STeam* SRules::getOpponentTeam(int team_id)
00074 {
00075   return getTeam(getOpponentTeamId(team_id));
00076 }
00077 
00078 inline STeam* SRules::getOpponentTeam(STeam* team)
00079 {
00080   return getTeam(getOpponentTeamId(team));
00081 }
00082 
00083 inline SField* SRules::getField()
00084 {
00085   return field_;
00086 }
00087 
00088 inline SBall* SRules::getBall()
00089 {
00090   return ball_;
00091 }
00092 
00093 inline STeam* SRules::getTeam(int team_id)
00094 {
00095   if (team_id == 0 || team_id == 1)
00096     return team_[team_id];
00097   return NULL;
00098 }
00099 
00100 inline Dice* SRules::getDice()
00101 {
00102   return dice_;
00103 }
00104 
00105 inline SActionHandler* SRules::getActionHandler()
00106 {
00107   return action_handler_;
00108 }

Generated on Sat Jun 23 16:07:24 2007 for Stechec/TBT by  doxygen 1.4.7