-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGameLogic.hpp
More file actions
75 lines (66 loc) · 2.14 KB
/
Copy pathGameLogic.hpp
File metadata and controls
75 lines (66 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#pragma once
#include <memory>
#include <vector>
#if !defined(__APPLE__)
#include <chrono>
#endif
#include "Game/Player.hpp"
#include "Map.hpp"
#include "Team.hpp"
namespace game {
class GameLogic {
private:
std::vector<std::unique_ptr<Team>> _teams;
int _mapX;
int _mapY;
int _freq;
int _nbClientMax;
int _nextId;
Map _map;
std::chrono::steady_clock::time_point _lastLifeTime;
std::chrono::steady_clock::time_point _lastRessourceTime;
public:
// getter and constructor
GameLogic(int x, int y, int freq, int nbClientMax,
std::vector<std::string> teamnames);
const std::vector<std::unique_ptr<Team>> &getTeams() const { return _teams; }
int getMapX() const { return _mapX; }
int getMapY() const { return _mapY; }
int getFreq() const { return _freq; }
void setFreq(int freq) { _freq = freq; }
int getClientMax() const { return _nbClientMax; }
int getNextId() const { return _nextId; }
Map &getMap() { return _map; }
// main loop
void initRessources();
void initEggs();
void initTeams(const std::vector<std::string> teamnames);
bool poll();
void lifeUpdate();
void ressourcesUpdate();
bool checkWinCond();
// commands
void broadcastPpo(Player &player);
void playerForward(Player &player);
void playerTurnRight(Player &player);
void playerTurnLeft(Player &player);
void playerInventory(Player &player);
void playerBroadcast(Player &player, const std::string &text);
void playerConnectNbr(Player &player);
void playerEject(Player &player);
void playerTakeRessources(Player &player, std::string &toTake);
void playerDropRessources(Player &player, std::string &toDrop);
void playerFork(Player &player);
void playerLook(Player &player);
bool playerIncantationStart(Player &player);
void playerIncantationEnd(Player &player);
// utils
void newPlayer(Client &client, const std::string &teamname);
void sendGuiWelcome(Client &client);
int getDir(game::Player &player, game::Player &other, int width, int heigth);
int getIndexByName(std::string &toTake);
std::shared_ptr<Player> getPlayerById(int id) const;
std::string formatBct(int x, int y);
void Debug();
};
} // namespace game