5#ifndef WARC2SIM_PLAYER_H
6#define WARC2SIM_PLAYER_H
31 std::string name =
"[NO NAME]";
34 int _getNextPrevUnitIdx();
46 int targetedUnitID = -1;
49 bool defeated =
false;
92 [[nodiscard]]
int getId()
const;
98 [[nodiscard]]
int getFood()
const;
101 [[maybe_unused]] [[nodiscard]]
int getGold()
const;
104 [[maybe_unused]] [[nodiscard]]
int getStone()
const;
107 [[maybe_unused]] [[nodiscard]]
int getLumber()
const;
109 [[nodiscard]]
virtual
113 [[maybe_unused]] [[nodiscard]]
int getUnitCount()
const;
125 [[nodiscard]]
const std::string &
getName()
const;
int num_footman
Definition: Player.h:181
Unit & spawnUnit(Unit &unit, Tile &tile, int select)
Definition: Player.cpp:52
int num_barrack
Definition: Player.h:184
int stone
Definition: Player.h:172
int sDamageTaken
Definition: Player.h:195
void reset()
Reset the player state.
Definition: Player.cpp:64
const Config & config
Definition: Player.h:60
bool canPlace(Unit &builder, Unit &unit, Tile &tile)
TODO move these to Unit.h?
Definition: Player.cpp:227
int gold
Definition: Player.h:173
std::vector< int > unitIndexes
List of all unit Ids belonging to this player. The object itself is located in Game class units list.
Definition: Player.h:64
int foodConsumption
Definition: Player.h:175
void removeStone(int n)
Remove N oil from the player.
Definition: Player.cpp:264
int lumber
Definition: Player.h:174
void setTargetedUnitID(int targetedUnitID)
Select a unit.
Definition: Player.cpp:493
Game & getGame() const
Get the game instance.
Definition: Player.cpp:481
int num_peasant
Definition: Player.h:180
int num_archer
Counters for buildings.
Definition: Player.h:179
const std::string & getName() const
Get the player name.
Definition: Player.cpp:485
Unit * getTargetedUnit()
Get the targeted unit (Returns null if none)
Definition: Player.cpp:344
int getUnitCount() const
Get the unit count for this player.
Definition: Player.cpp:148
Unit & addUnit(Constants::Unit unitType)
Add a unit to the player.
Definition: Player.cpp:247
Player(Game &game, int id)
Constructor.
Definition: Player.cpp:13
int getId() const
Get Player's ID.
Definition: Player.cpp:152
bool canAfford(Unit &unit) const
Definition: Player.cpp:242
int getTargetedUnitID() const
Get the targeted unit ID (-1 if none)
Definition: Player.cpp:489
void spawnUnitNearSpawnPoint(Constants::Unit unitType)
Definition: Player.cpp:114
void addGold(int n)
Add N gold to the player.
Definition: Player.cpp:156
int food
Definition: Player.h:176
int sGatheredGold
Definition: Player.h:191
int sGatheredLumber
Definition: Player.h:192
Unit & spawn(Tile &spawnPoint)
Spawns a unit on a tile.
Definition: Player.cpp:31
int getFood() const
Get Max Food.
Definition: Player.cpp:132
void setName(std::string name)
Set the name of the player.
Definition: Player.cpp:276
int getFoodConsumption() const
Get the food consumption.
Definition: Player.cpp:128
virtual Constants::PlayerState playerState()
Check if player is defeated.
Definition: Player.cpp:208
int sGatheredStone
Definition: Player.h:193
void addLumber(int n)
Add N lumber to the player.
Definition: Player.cpp:160
void removeGold(int n)
Remove N gold from the player.
Definition: Player.cpp:272
void leftClick(int x, int y)
Definition: Player.cpp:352
int num_farm
Definition: Player.h:183
virtual int getScore() const
Get the score.
Definition: Player.cpp:168
void addStone(int n)
Add N oil to the player.
Definition: Player.cpp:164
int getLumber() const
Get the lumber resource.
Definition: Player.cpp:144
void do_action(int actionID)
Definition: Player.cpp:389
void do_manual_action(int manual_action_id, int x, int y)
Definition: Player.cpp:376
int sDamageDone
Definition: Player.h:194
int getStone() const
Get the oil resource.
Definition: Player.cpp:140
int sUnitsCreated
Definition: Player.h:196
void removeUnit(Unit &unit)
Removes a unit from the player.
Definition: Player.cpp:188
void rightClick(int x, int y)
Definition: Player.cpp:363
void removeLumber(int n)
Remove N lumber from the player.
Definition: Player.cpp:268
int num_town_hall
Definition: Player.h:182
int getGold() const
Get the gold resource.
Definition: Player.cpp:136
PlayerState
Definition: Constants.h:39
Unit
Definition: Constants.h:20