C++ Joueur Client
 All Classes Namespaces Functions Variables
unit.hpp
1 #ifndef GAMES_PIRATES_UNIT_H
2 #define GAMES_PIRATES_UNIT_H
3 
4 // Unit
5 // A unit group in the game. This may consist of a ship and any number of crew.
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/pirates_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 pirates
32 {
33 
37 class Unit : public Game_object
38 {
39 public:
40 
44  const bool& acted;
45 
49  const int& crew;
50 
54  const int& crew_health;
55 
59  const int& gold;
60 
64  const int& moves;
65 
69  const Player& owner;
70 
74  const std::vector<Tile>& path;
75 
79  const int& ship_health;
80 
84  const int& stun_turns;
85 
89  const Port& target_port;
90 
94  const Tile& tile;
95 
96  // <<-- Creer-Merge: member variables -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.
97  // You can add additional member variables here. None of them will be tracked or updated by the server.
98  // <<-- /Creer-Merge: member variables -->>
99 
100 
106  bool attack(const Tile& tile, const std::string& target);
107 
112  bool bury(int amount);
113 
118  bool deposit(int amount = 0);
119 
124  bool dig(int amount = 0);
125 
130  bool move(const Tile& tile);
131 
135  bool rest();
136 
143  bool split(const Tile& tile, int amount = 1, int gold = 0);
144 
149  bool withdraw(int amount = 0);
150 
151 
152  // <<-- Creer-Merge: methods -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.
153  // You can add additional methods here.
154  // <<-- /Creer-Merge: methods -->>
155 
156  ~Unit_();
157 
158  // ####################
159  // Don't edit these!
160  // ####################
162  Unit_(std::initializer_list<std::pair<std::string, Any&&>> init);
163  Unit_() : Unit_({}){}
164  virtual void resize(const std::string& name, std::size_t size) override;
165  virtual void change_vec_values(const std::string& name, std::vector<std::pair<std::size_t, Any>>& values) override;
166  virtual void remove_key(const std::string& name, Any& key) override;
167  virtual std::unique_ptr<Any> add_key_value(const std::string& name, Any& key, Any& value) override;
168  virtual bool is_map(const std::string& name) override;
169  virtual void rebind_by_name(Any* to_change, const std::string& member, std::shared_ptr<Base_object> ref) override;
171  // ####################
172  // Don't edit these!
173  // ####################
174 };
175 
176 } // pirates
177 
178 } // cpp_client
179 
180 #endif // GAMES_PIRATES_UNIT_H
const int & moves
How many more times this Unit may move this turn.
Definition: unit.hpp:64
const Player & owner
The Player that owns and can control this Unit, or null if the Unit is neutral.
Definition: unit.hpp:69
const int & gold
How much gold this Unit is carrying.
Definition: unit.hpp:59
const std::vector< Tile > & path
(Merchants only) The path this Unit will follow. The first element is the Tile this Unit will move to...
Definition: unit.hpp:74
const bool & acted
Whether this Unit has performed its action this turn.
Definition: unit.hpp:44
const int & ship_health
If a ship is on this Tile, how much health it has remaining. 0 for no ship.
Definition: unit.hpp:79
bool rest()
regenerates this _unit's health. _must be used in range of a port.
A Tile in the game that makes up the 2D map grid.
Definition: tile.hpp:37
bool deposit(int amount=0)
puts gold into an adjacent _port. _if that _port is the _player's port, the gold is added to that _pl...
bool bury(int amount)
buries gold on this _unit's _tile. _gold must be a certain distance away for it to get interest (_gam...
const Port & target_port
(Merchants only) The Port this Unit is moving to.
Definition: unit.hpp:89
const int & crew
How many crew are on this Tile. This number will always be <= crewHealth.
Definition: unit.hpp:49
bool withdraw(int amount=0)
takes gold from the _player. _you can only withdraw from your own _port.
const int & stun_turns
(Merchants only) The number of turns this merchant ship won't be able to move. They will still attack...
Definition: unit.hpp:84
bool dig(int amount=0)
digs up gold on this _unit's _tile.
A unit group in the game. This may consist of a ship and any number of crew.
Definition: unit.hpp:37
bool attack(const Tile &tile, const std::string &target)
attacks either the 'crew' or 'ship' on a _tile in range.
A port on a Tile.
Definition: port.hpp:37
const int & crew_health
How much total health the crew on this Tile have.
Definition: unit.hpp:54
bool move(const Tile &tile)
moves this _unit from its current _tile to an adjacent _tile. _if this _unit merges with another one...
bool split(const Tile &tile, int amount=1, int gold=0)
moves a number of crew from this _unit to the given _tile. _this will consume a move from those crew...
An object in the game. The most basic class that all game classes should inherit from automatically...
Definition: game_object.hpp:37
const Tile & tile
The Tile this Unit is on.
Definition: unit.hpp:94
A player in this game. Every AI controls one player.
Definition: player.hpp:37