C++ Joueur Client
 All Classes Namespaces Functions Variables
unit.hpp
1 #ifndef GAMES_CATASTROPHE_UNIT_H
2 #define GAMES_CATASTROPHE_UNIT_H
3 
4 // Unit
5 // A unit in the game.
6 
7 // DO NOT MODIFY THIS FILE
8 // Never try to directly create an instance of this class, or modify its member variables.
9 // Instead, you should only be reading its variables and calling its functions.
10 
11 #include <vector>
12 #include <queue>
13 #include <deque>
14 #include <unordered_map>
15 #include <string>
16 #include <initializer_list>
17 
18 #include "../../joueur/src/any.hpp"
19 
20 #include "game_object.hpp"
21 
22 #include "impl/catastrophe_fwd.hpp"
23 
24 // <<-- Creer-Merge: includes -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.
25 // you can add additional #includes here
26 // <<-- /Creer-Merge: includes -->>
27 
28 namespace cpp_client
29 {
30 
31 namespace catastrophe
32 {
33 
37 class Unit : public Game_object
38 {
39 public:
40 
44  const bool& acted;
45 
49  const double& energy;
50 
54  const int& food;
55 
59  const Job& job;
60 
64  const int& materials;
65 
70 
74  const int& moves;
75 
79  const Player& owner;
80 
84  const std::vector<Unit>& squad;
85 
89  const bool& starving;
90 
94  const Tile& tile;
95 
99  const int& turns_to_die;
100 
101  // <<-- Creer-Merge: member variables -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.
102  // You can add additional member variables here. None of them will be tracked or updated by the server.
103  // <<-- /Creer-Merge: member variables -->>
104 
105 
110  bool attack(const Tile& tile);
111 
116  bool change_job(const std::string& job);
117 
123  bool construct(const Tile& tile, const std::string& type);
124 
129  bool convert(const Tile& tile);
130 
135  bool deconstruct(const Tile& tile);
136 
143  bool drop(const Tile& tile, const std::string& resource, int amount = 0);
144 
149  bool harvest(const Tile& tile);
150 
155  bool move(const Tile& tile);
156 
163  bool pickup(const Tile& tile, const std::string& resource, int amount = 0);
164 
168  bool rest();
169 
170 
171  // <<-- Creer-Merge: methods -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.
172  // You can add additional methods here.
173  // <<-- /Creer-Merge: methods -->>
174 
175  ~Unit_();
176 
177  // ####################
178  // Don't edit these!
179  // ####################
181  Unit_(std::initializer_list<std::pair<std::string, Any&&>> init);
182  Unit_() : Unit_({}){}
183  virtual void resize(const std::string& name, std::size_t size) override;
184  virtual void change_vec_values(const std::string& name, std::vector<std::pair<std::size_t, Any>>& values) override;
185  virtual void remove_key(const std::string& name, Any& key) override;
186  virtual std::unique_ptr<Any> add_key_value(const std::string& name, Any& key, Any& value) override;
187  virtual bool is_map(const std::string& name) override;
188  virtual void rebind_by_name(Any* to_change, const std::string& member, std::shared_ptr<Base_object> ref) override;
190  // ####################
191  // Don't edit these!
192  // ####################
193 };
194 
195 } // catastrophe
196 
197 } // cpp_client
198 
199 #endif // GAMES_CATASTROPHE_UNIT_H
const int & moves
How many moves this Unit has left this turn.
Definition: unit.hpp:74
const bool & starving
Whether this Unit is starving. Starving Units regenerate energy at half the rate they normally would ...
Definition: unit.hpp:89
bool construct(const Tile &tile, const std::string &type)
constructs a _structure on an adjacent _tile.
A Tile in the game that makes up the 2D map grid.
Definition: tile.hpp:37
An object in the game. The most basic class that all game classes should inherit from automatically...
Definition: game_object.hpp:37
bool move(const Tile &tile)
moves this _unit from its current _tile to an adjacent _tile.
bool attack(const Tile &tile)
attacks an adjacent _tile. _costs an action for each _unit in this _unit's squad. _units in the squad...
const Job & job
The Job this Unit was recruited to do.
Definition: unit.hpp:59
Information about a Unit's job.
Definition: job.hpp:37
bool change_job(const std::string &job)
changes this _unit's _job. _must be at max energy (100) to change _jobs.
const Tile & movement_target
The tile this Unit is moving to. This only applies to neutral fresh humans spawned on the road...
Definition: unit.hpp:69
bool rest()
regenerates energy. _must be in range of a friendly shelter to rest. _costs an action. _units cannot move after resting.
const Player & owner
The Player that owns and can control this Unit, or null if the Unit is neutral.
Definition: unit.hpp:79
const std::vector< Unit > & squad
The Units in the same squad as this Unit. Units in the same squad attack and defend together...
Definition: unit.hpp:84
const Tile & tile
The Tile this Unit is on.
Definition: unit.hpp:94
bool pickup(const Tile &tile, const std::string &resource, int amount=0)
picks up some materials or food on or adjacent to the _unit's _tile. _does not count as an action...
const int & food
The amount of food this Unit is holding.
Definition: unit.hpp:54
const double & energy
The amount of energy this Unit has (from 0.0 to 100.0).
Definition: unit.hpp:49
bool deconstruct(const Tile &tile)
removes materials from an adjacent _tile's _structure. _you cannot deconstruct friendly structures (s...
bool harvest(const Tile &tile)
harvests the food on an adjacent _tile.
const int & materials
The amount of materials this Unit is holding.
Definition: unit.hpp:64
const bool & acted
Whether this Unit has performed its action this turn.
Definition: unit.hpp:44
bool convert(const Tile &tile)
converts an adjacent _unit to your side.
A unit in the game.
Definition: unit.hpp:37
const int & turns_to_die
The number of turns before this Unit dies. This only applies to neutral fresh humans created from com...
Definition: unit.hpp:99
A player in this game. Every AI controls one player.
Definition: player.hpp:37
bool drop(const Tile &tile, const std::string &resource, int amount=0)
drops some of the given resource on or adjacent to the _unit's _tile. _does not count as an action...