C++ Joueur Client
 All Classes Namespaces Functions Variables
unit.hpp
1 #ifndef GAMES_NECROWAR_UNIT_H
2 #define GAMES_NECROWAR_UNIT_H
3 
4 // Unit
5 // A unit in the game. May be a worker, zombie, ghoul, hound, abomination, wraith or horseman.
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/necrowar_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 necrowar
32 {
33 
37 class Unit : public Game_object
38 {
39 public:
40 
44  const bool& acted;
45 
49  const int& health;
50 
54  const Unit_job& job;
55 
59  const int& moves;
60 
64  const Player& owner;
65 
69  const Tile& tile;
70 
71  // <<-- Creer-Merge: member variables -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.
72  // You can add additional member variables here. None of them will be tracked or updated by the server.
73  // <<-- /Creer-Merge: member variables -->>
74 
75 
80  bool attack(const Tile& tile);
81 
86  bool build(const std::string& title);
87 
92  bool fish(const Tile& tile);
93 
98  bool mine(const Tile& tile);
99 
104  bool move(const Tile& tile);
105 
106 
107  // <<-- Creer-Merge: methods -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.
108  // You can add additional methods here.
109  // <<-- /Creer-Merge: methods -->>
110 
111  ~Unit_();
112 
113  // ####################
114  // Don't edit these!
115  // ####################
117  Unit_(std::initializer_list<std::pair<std::string, Any&&>> init);
118  Unit_() : Unit_({}){}
119  virtual void resize(const std::string& name, std::size_t size) override;
120  virtual void change_vec_values(const std::string& name, std::vector<std::pair<std::size_t, Any>>& values) override;
121  virtual void remove_key(const std::string& name, Any& key) override;
122  virtual std::unique_ptr<Any> add_key_value(const std::string& name, Any& key, Any& value) override;
123  virtual bool is_map(const std::string& name) override;
124  virtual void rebind_by_name(Any* to_change, const std::string& member, std::shared_ptr<Base_object> ref) override;
126  // ####################
127  // Don't edit these!
128  // ####################
129 };
130 
131 } // necrowar
132 
133 } // cpp_client
134 
135 #endif // GAMES_NECROWAR_UNIT_H
bool build(const std::string &title)
unit, if it is a worker, builds a tower on the tile it is on, only workers can do this...
A Tile in the game that makes up the 2D map grid.
Definition: tile.hpp:37
const int & moves
The number of moves this unit has left this turn.
Definition: unit.hpp:59
An object in the game. The most basic class that all game classes should inherit from automatically...
Definition: game_object.hpp:37
bool attack(const Tile &tile)
attacks an enemy tower on an adjacent tile.
const int & health
The remaining health of a unit.
Definition: unit.hpp:49
bool move(const Tile &tile)
moves this _unit from its current _tile to an adjacent _tile.
A player in this game. Every AI controls one player.
Definition: player.hpp:37
const Player & owner
The Player that owns and can control this Unit.
Definition: unit.hpp:64
bool fish(const Tile &tile)
stops adjacent to a river tile and begins fishing for mana.
bool mine(const Tile &tile)
enters a mine and is put to work gathering resources.
A unit in the game. May be a worker, zombie, ghoul, hound, abomination, wraith or horseman...
Definition: unit.hpp:37
const Tile & tile
The Tile this Unit is on.
Definition: unit.hpp:69
Information about a unit's job/type.
Definition: unit_job.hpp:37
const bool & acted
Whether or not this Unit has performed its action this turn (attack or build).
Definition: unit.hpp:44
const Unit_job & job
The type of unit this is.
Definition: unit.hpp:54