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