/team.h

http://cutefootball.googlecode.com/ · C Header · 105 lines · 70 code · 11 blank · 24 comment · 0 complexity · 8f303d4e77cb837773a69d30d0546df1 MD5 · raw file

  1. /*
  2. * Copyright 2010,2011 Timothy Rochford
  3. *
  4. * This file is part of CuteFootball.
  5. *
  6. * CuteFootball is free software: you can redistribute it and/or modify
  7. * it under the terms of the Lesser GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * CuteFootball is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * Lesser GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the Lesser GNU General Public License
  17. * along with CuteFootball. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. #ifndef TEAM_H
  21. #define TEAM_H
  22. #include <QObject>
  23. #include <QColor>
  24. #include <QString>
  25. #include <QList>
  26. //#include <qmap.h>
  27. class Team;
  28. class TeamManager {
  29. public:
  30. TeamManager();
  31. ~TeamManager();
  32. QList<Team*> teams() { return m_teams; }
  33. Team* at(int index) { return m_teams.at(index); }
  34. void createTeams();
  35. static QString translateTeamName(QString untranslated);
  36. private:
  37. enum TeamFileFormat {
  38. Ranking = 0,
  39. BriefName,
  40. FullName,
  41. ShirtColor,
  42. ShortColor,
  43. PlayerSpeed
  44. };
  45. QList<Team*> m_teams;
  46. };
  47. class Team : public QObject {
  48. Q_OBJECT;
  49. public:
  50. // the attacking direction
  51. enum Direction { SouthToNorth, NorthToSouth };
  52. Team(int ranking,
  53. QString briefName,
  54. QString teamName,
  55. QColor shirtColor,
  56. QColor shortColor,
  57. int playerSpeed);
  58. QString fullName() const { return m_name; }
  59. QString localisedName() const { return TeamManager::translateTeamName(m_name); }
  60. void setDirection(Direction dir) { m_direction = dir; }
  61. Direction getDirection() const { return m_direction; }
  62. void setHasBall(bool hasBall);
  63. bool scoredLastGoal() const { return m_scoredLastGoal; }
  64. void setShots(int newValue) { m_shotCount = newValue; }
  65. inline int shots() const { return m_shotCount; }
  66. void newGame() { m_goals = 0; m_scoredLastGoal = false; m_teamHasBall = false; m_shotCount = 0; }
  67. inline bool teamHasBall() const { return m_teamHasBall; }
  68. inline qreal speed() const { return m_speed; }
  69. inline QString briefName() const { return m_briefName; }
  70. inline int ranking() const { return m_rank; }
  71. inline QString flag() const { return QString(":/images/flags/" + m_name + ".png");}
  72. inline bool humanControlled() const { return m_humanControlled; }
  73. void setHumanControlled(bool human) { m_humanControlled = human; }
  74. public slots:
  75. void goalScored(bool isNorthGoal);
  76. public:
  77. QColor m_shirtColor;
  78. QColor m_shortColor;
  79. Direction m_direction;
  80. int m_goals;
  81. private:
  82. QString m_briefName;
  83. QString m_name;
  84. bool m_teamHasBall;
  85. // this team scored the last goal
  86. bool m_scoredLastGoal;
  87. int m_shotCount;
  88. qreal m_speed;
  89. // the teams ranking
  90. int m_rank;
  91. // is the team controlled by human player
  92. bool m_humanControlled;
  93. };
  94. #endif // TEAM_H