Civilization
Rules.hpp
1 // Generated by dia2code
2 #ifndef SHARED__RULES__H
3 #define SHARED__RULES__H
4 
5 #include <array>
6 #include <vector>
7 #include <memory>
8 #include <variant>
9 
10 namespace shared {
11  class RuleArgsStruct;
12  class Map;
13  class Caravan;
14  class Player;
15 }
16 
17 #include "Map.hpp"
18 #include "Caravan.hpp"
19 #include "Player.hpp"
20 #include "CardsEnum.hpp"
21 #include "RuleArgsStruct.hpp"
22 
23 namespace shared {
24 
26  class Rules {
27  // Operations
28  public:
29  Rules ();
30  bool runTheRule (RuleArgsStruct & args);
31  std::vector<std::array<unsigned, 2>> getNeighbors (unsigned posX, unsigned posY, std::shared_ptr<Map> gameMap);
32  bool isThereACityAround (std::array<unsigned, 2> position, std::shared_ptr<Map> gameMap);
33  bool isThereACity (std::array<unsigned,2> position, std::shared_ptr<Map> gameMap);
34  bool isThereAControlPawn (std::array<unsigned, 2> position, std::shared_ptr<Map> gameMap);
35  bool isThereACaravan (std::array<unsigned,2> position, std::shared_ptr<Map> gameMap);
36  private:
37  bool moveCaravan (std::vector<std::shared_ptr<Caravan>> caravans, std::array<unsigned,2> pos1, std::array<unsigned,2> pos2, std::shared_ptr<Map> map, std::shared_ptr<Player> currentPlayer);
38  void exchangeRessourceWithOtherPlayer ();
39  void playAnotherCard ();
40  void reinforcePawn ();
41  bool playEconomyCard (RuleArgsStruct & args);
42  bool playScienceCard (RuleArgsStruct & args);
43  bool playMilitaryCard (RuleArgsStruct & args);
44  bool playCultureCard (RuleArgsStruct & args);
45  bool playIndustryCard (RuleArgsStruct & args);
46  bool verifyIfPathIsValid (std::vector<int[2]> caravanMovementPath, int maxLevelReachable);
47  std::vector<std::shared_ptr<std::variant<Caravan,Barbarian,BarbarianVillage,ControlPawn,City>>> checkIfBarbarianIsOnThePath (std::vector<std::array<unsigned,2>> caravanMovementPath, std::shared_ptr<Map> map);
48  bool checkIfWaterIsOnThePath (std::vector<std::array<unsigned,2>> caravanMovementPath, std::shared_ptr<Map> map);
49  void nuke (std::vector<std::array<unsigned, 2>> neighbors, std::shared_ptr<Map> gameMap, std::shared_ptr<Player> currentPlayer);
50  bool placeControlPawns (std::vector<std::array<unsigned, 2>> positions, std::shared_ptr<Map> gameMap, std::shared_ptr<Player> currentPlayer);
51  bool attack (RuleArgsStruct & args);
52  bool reinforce (RuleArgsStruct & args);
53  bool buildWonder (RuleArgsStruct & args);
54  bool buildCity (RuleArgsStruct & args);
55  bool verifyIfPathSizeIsCorrect (int pathSize, int maxSize);
56  void addCaravanAfterCardAmelioration (std::vector<std::shared_ptr<Caravan>> & caravans, std::shared_ptr<shared::Player> currentPlayer, int numberOfCaravans);
57  void roundCards (std::shared_ptr<Player> currentPlayer, CardsEnum cardPlayed);
58  void killControlPawn (std::shared_ptr<Map> gameMap, std::array<unsigned, 2> position, std::shared_ptr<Player> currentPlayer);
59  // Setters and Getters
60  };
61 
62 };
63 
64 #endif
class RuleArgsStruct -
Definition: RuleArgsStruct.hpp:25
class Rules -
Definition: Rules.hpp:26
Rules()
constructor of Rules, define the ruleId of created rule.
Definition: Rules.cpp:29
bool isThereACityAround(std::array< unsigned, 2 > position, std::shared_ptr< Map > gameMap)
This function aim to check if there is a city around a position.
Definition: Rules.cpp:551
bool runTheRule(RuleArgsStruct &args)
This function aim to run the rule of the card.
Definition: Rules.cpp:39