Zappy Server
C++ game server: world, rules, scheduler, network
Loading...
Searching...
No Matches
GuiNotifier.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5
8
9class GuiNotifier : public IWorldObserver {
10 public:
11 explicit GuiNotifier(ClientManager& clients);
12
13 void addGui(int connectionId);
14 void removeGui(int connectionId);
15
16 void send(int connectionId, const std::string& msg);
17 void broadcast(const std::string& msg);
18
19 void onPlayerAdded(int playerId, int x, int y, Orientation orientation, int level,
20 const std::string& teamName) override;
21 void onPlayerMoved(int playerId, int nx, int ny, Orientation newOrientation) override;
22 void onPlayerInventoryChanged(int playerId, int x, int y, Resources inventory) override;
23 void onPlayerRemoved(int playerId) override;
24 void onPlayerEjected(int playerId) override;
25 void onBroadcast(int playerId, const std::string& message) override;
26 void onResourceTaken(int playerId, ResourceType resourceType, int tileX, int tileY,
27 Resources resources) override;
28 void onResourceDropped(int playerId, ResourceType resourceType, int tileX, int tileY,
29 Resources resources) override;
30 void onEggLaid(int eggId, int playerId, int x, int y) override;
31 void onInitialEggSpawned(int eggId, const std::string& teamName, int x, int y) override;
32 void onEggHatched(int eggId) override;
33 void onEggDied(int eggId) override;
34 void onIncantationStart(int x, int y, int level,
35 const std::vector<int>& participantIds) override;
36 void onIncantationEnd(int x, int y, bool success) override;
37 void onPlayerLevelUp(int playerId, int newLevel) override;
38 void onGameEnd(const std::string& winningTeam) override;
39 void onTileChanged(int x, int y, Resources resources) override;
40
41 private:
43 std::vector<int> _guiIds;
44};
Orientation
ResourceType
Enumerate the different types of resources in the game.
Definition Resources.hpp:12
Owns every client socket and runs the poll() loop.
void addGui(int connectionId)
ClientManager & _clients
void onIncantationStart(int x, int y, int level, const std::vector< int > &participantIds) override
Incantation began on a tile. participantIds = players involved. -> pic.
void onInitialEggSpawned(int eggId, const std::string &teamName, int x, int y) override
An initial team egg placed at game start (custom). -> sse.
void onPlayerAdded(int playerId, int x, int y, Orientation orientation, int level, const std::string &teamName) override
Player spawned (egg hatched or initial connection). -> pnw.
void broadcast(const std::string &msg)
std::vector< int > _guiIds
void onEggLaid(int eggId, int playerId, int x, int y) override
A player laid an egg via Fork. -> enw.
void onEggHatched(int eggId) override
An egg hatched into a connectable slot. -> ebo.
void onGameEnd(const std::string &winningTeam) override
A team won (6 players at max level). -> seg.
void onPlayerEjected(int playerId) override
Player got pushed off its tile by an eject. -> pex.
void onPlayerMoved(int playerId, int nx, int ny, Orientation newOrientation) override
Player changed tile and/or facing. -> ppo.
void onPlayerRemoved(int playerId) override
Player left (death or disconnect). -> pdi.
void onResourceTaken(int playerId, ResourceType resourceType, int tileX, int tileY, Resources resources) override
Player picked a resource up off the tile. -> pgt (+ bct/pin)
void onBroadcast(int playerId, const std::string &message) override
Player shouted a broadcast message. -> pbc.
void onResourceDropped(int playerId, ResourceType resourceType, int tileX, int tileY, Resources resources) override
Player dropped a resource onto the tile. -> pdr (+ bct/pin)
void onEggDied(int eggId) override
An egg was destroyed (e.g. crushed by an eject). -> edi.
void onPlayerLevelUp(int playerId, int newLevel) override
Player reached a new level. -> plv.
void onPlayerInventoryChanged(int playerId, int x, int y, Resources inventory) override
Player's carried resources changed. -> pin.
void onTileChanged(int x, int y, Resources resources) override
A tile's resource contents changed (e.g. respawn). -> bct.
void onIncantationEnd(int x, int y, bool success) override
Incantation finished, success = leveled up or not. -> pie.
void send(int connectionId, const std::string &msg)
void removeGui(int connectionId)
Observer hooks for game-state changes (Observer pattern).
Represents the resources available in the game, including food and various minerals.
Definition Resources.hpp:17