PageRenderTime 37ms CodeModel.GetById 13ms app.highlight 18ms RepoModel.GetById 2ms app.codeStats 0ms

/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
 23#include <QObject>
 24#include <QColor>
 25#include <QString>
 26#include <QList>
 27//#include <qmap.h>
 28
 29class Team;
 30
 31class TeamManager {
 32public:
 33    TeamManager();
 34    ~TeamManager();
 35    QList<Team*> teams() { return m_teams; }
 36    Team* at(int index) { return m_teams.at(index); }
 37    void createTeams();
 38    static QString translateTeamName(QString untranslated);
 39private:
 40    enum TeamFileFormat {
 41        Ranking = 0,
 42        BriefName,
 43        FullName,
 44        ShirtColor,
 45        ShortColor,
 46        PlayerSpeed
 47    };
 48
 49
 50   QList<Team*> m_teams;
 51};
 52
 53class Team : public QObject {
 54    Q_OBJECT;
 55public:
 56    // the attacking direction
 57    enum Direction { SouthToNorth, NorthToSouth };
 58    Team(int ranking,
 59         QString briefName,
 60         QString teamName,
 61         QColor shirtColor,
 62         QColor shortColor,
 63         int playerSpeed);
 64    QString fullName() const { return m_name; }
 65    QString localisedName() const { return TeamManager::translateTeamName(m_name); }
 66    void setDirection(Direction dir) { m_direction = dir; }
 67    Direction getDirection() const { return m_direction; }
 68    void setHasBall(bool hasBall);
 69    bool scoredLastGoal() const { return m_scoredLastGoal; }
 70    void setShots(int newValue) { m_shotCount = newValue; }
 71    inline int shots() const { return m_shotCount; }
 72    void newGame() { m_goals = 0; m_scoredLastGoal = false; m_teamHasBall = false; m_shotCount = 0; }
 73    inline bool teamHasBall() const { return m_teamHasBall; }
 74    inline qreal speed() const { return m_speed; }
 75    inline QString briefName() const { return m_briefName; }
 76    inline int ranking() const { return m_rank; }
 77    inline QString flag() const { return QString(":/images/flags/" + m_name + ".png");}
 78    inline bool humanControlled() const { return m_humanControlled; }
 79    void setHumanControlled(bool human) { m_humanControlled = human; }
 80
 81public slots:
 82    void goalScored(bool isNorthGoal);
 83
 84public:
 85    QColor m_shirtColor;
 86    QColor m_shortColor;
 87    Direction m_direction;
 88    int m_goals;
 89
 90private:
 91    QString m_briefName;
 92    QString m_name;
 93    bool m_teamHasBall;
 94    // this team scored the last goal
 95    bool m_scoredLastGoal;
 96    int m_shotCount;
 97    qreal m_speed;
 98    // the teams ranking
 99    int m_rank;
100    // is the team controlled by human player
101    bool m_humanControlled;
102};
103
104
105#endif // TEAM_H