Zappy Server
C++ game server: world, rules, scheduler, network
Loading...
Searching...
No Matches
IWorldObserver.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5
8
17 public:
18 virtual ~IWorldObserver() = default;
19
21 virtual void onPlayerAdded(int playerId, int x, int y, Orientation orientation, int level,
22 const std::string& teamName) = 0;
24 virtual void onPlayerMoved(int playerId, int nx, int ny, Orientation newOrientation) = 0;
26 virtual void onPlayerInventoryChanged(int playerId, int x, int y, Resources inventory) = 0;
28 virtual void onPlayerRemoved(int playerId) = 0;
30 virtual void onPlayerEjected(int playerId) = 0;
32 virtual void onBroadcast(int playerId, const std::string& message) = 0;
34 virtual void onResourceTaken(int playerId, ResourceType resourceType, int tileX, int tileY,
35 Resources resources) = 0;
37 virtual void onResourceDropped(int playerId, ResourceType resourceType, int tileX, int tileY,
38 Resources resources) = 0;
40 virtual void onEggLaid(int eggId, int playerId, int x, int y) = 0;
42 virtual void onInitialEggSpawned(int eggId, const std::string& teamName, int x, int y) = 0;
44 virtual void onEggHatched(int eggId) = 0;
46 virtual void onEggDied(int eggId) = 0;
48 virtual void onIncantationStart(int x, int y, int level,
49 const std::vector<int>& participantIds) = 0;
51 virtual void onIncantationEnd(int x, int y, bool success) = 0;
53 virtual void onPlayerLevelUp(int playerId, int newLevel) = 0;
55 virtual void onGameEnd(const std::string& winningTeam) = 0;
57 virtual void onTileChanged(int x, int y, Resources resources) = 0;
58};
Orientation
ResourceType
Enumerate the different types of resources in the game.
Definition Resources.hpp:12
Observer hooks for game-state changes (Observer pattern).
virtual void onEggLaid(int eggId, int playerId, int x, int y)=0
A player laid an egg via Fork. -> enw.
virtual void onEggHatched(int eggId)=0
An egg hatched into a connectable slot. -> ebo.
virtual void onPlayerAdded(int playerId, int x, int y, Orientation orientation, int level, const std::string &teamName)=0
Player spawned (egg hatched or initial connection). -> pnw.
virtual void onGameEnd(const std::string &winningTeam)=0
A team won (6 players at max level). -> seg.
virtual void onResourceDropped(int playerId, ResourceType resourceType, int tileX, int tileY, Resources resources)=0
Player dropped a resource onto the tile. -> pdr (+ bct/pin)
virtual void onEggDied(int eggId)=0
An egg was destroyed (e.g. crushed by an eject). -> edi.
virtual void onResourceTaken(int playerId, ResourceType resourceType, int tileX, int tileY, Resources resources)=0
Player picked a resource up off the tile. -> pgt (+ bct/pin)
virtual void onIncantationEnd(int x, int y, bool success)=0
Incantation finished, success = leveled up or not. -> pie.
virtual ~IWorldObserver()=default
virtual void onPlayerRemoved(int playerId)=0
Player left (death or disconnect). -> pdi.
virtual void onInitialEggSpawned(int eggId, const std::string &teamName, int x, int y)=0
An initial team egg placed at game start (custom). -> sse.
virtual void onPlayerLevelUp(int playerId, int newLevel)=0
Player reached a new level. -> plv.
virtual void onPlayerMoved(int playerId, int nx, int ny, Orientation newOrientation)=0
Player changed tile and/or facing. -> ppo.
virtual void onPlayerEjected(int playerId)=0
Player got pushed off its tile by an eject. -> pex.
virtual void onTileChanged(int x, int y, Resources resources)=0
A tile's resource contents changed (e.g. respawn). -> bct.
virtual void onPlayerInventoryChanged(int playerId, int x, int y, Resources inventory)=0
Player's carried resources changed. -> pin.
virtual void onIncantationStart(int x, int y, int level, const std::vector< int > &participantIds)=0
Incantation began on a tile. participantIds = players involved. -> pic.
virtual void onBroadcast(int playerId, const std::string &message)=0
Player shouted a broadcast message. -> pbc.
Represents the resources available in the game, including food and various minerals.
Definition Resources.hpp:17