Zappy Server
C++ game server: world, rules, scheduler, network
Loading...
Searching...
No Matches
IWorldObserver Class Referenceabstract

Observer hooks for game-state changes (Observer pattern). More...

#include <IWorldObserver.hpp>

+ Inheritance diagram for IWorldObserver:
+ Collaboration diagram for IWorldObserver:

Public Member Functions

virtual ~IWorldObserver ()=default
 
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 onPlayerMoved (int playerId, int nx, int ny, Orientation newOrientation)=0
 Player changed tile and/or facing. -> ppo.
 
virtual void onPlayerInventoryChanged (int playerId, int x, int y, Resources inventory)=0
 Player's carried resources changed. -> pin.
 
virtual void onPlayerRemoved (int playerId)=0
 Player left (death or disconnect). -> pdi.
 
virtual void onPlayerEjected (int playerId)=0
 Player got pushed off its tile by an eject. -> pex.
 
virtual void onBroadcast (int playerId, const std::string &message)=0
 Player shouted a broadcast message. -> pbc.
 
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 onResourceDropped (int playerId, ResourceType resourceType, int tileX, int tileY, Resources resources)=0
 Player dropped a resource onto the tile. -> pdr (+ bct/pin)
 
virtual void onEggLaid (int eggId, int playerId, int x, int y)=0
 A player laid an egg via Fork. -> enw.
 
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 onEggHatched (int eggId)=0
 An egg hatched into a connectable slot. -> ebo.
 
virtual void onEggDied (int eggId)=0
 An egg was destroyed (e.g. crushed by an eject). -> edi.
 
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 onIncantationEnd (int x, int y, bool success)=0
 Incantation finished, success = leveled up or not. -> pie.
 
virtual void onPlayerLevelUp (int playerId, int newLevel)=0
 Player reached a new level. -> plv.
 
virtual void onGameEnd (const std::string &winningTeam)=0
 A team won (6 players at max level). -> seg.
 
virtual void onTileChanged (int x, int y, Resources resources)=0
 A tile's resource contents changed (e.g. respawn). -> bct.
 

Detailed Description

Observer hooks for game-state changes (Observer pattern).

World fires one of these whenever something happens (a player moves, a resource is taken, an incantation ends...). Observers react without World depending on them. Each hook maps to one GUI message, noted as "-> xxx".

Definition at line 16 of file IWorldObserver.hpp.

Constructor & Destructor Documentation

◆ ~IWorldObserver()

virtual IWorldObserver::~IWorldObserver ( )
virtualdefault

Member Function Documentation

◆ onBroadcast()

virtual void IWorldObserver::onBroadcast ( int  playerId,
const std::string &  message 
)
pure virtual

Player shouted a broadcast message. -> pbc.

Implemented in GuiNotifier, and LogObserver.

◆ onEggDied()

virtual void IWorldObserver::onEggDied ( int  eggId)
pure virtual

An egg was destroyed (e.g. crushed by an eject). -> edi.

Implemented in GuiNotifier, and LogObserver.

◆ onEggHatched()

virtual void IWorldObserver::onEggHatched ( int  eggId)
pure virtual

An egg hatched into a connectable slot. -> ebo.

Implemented in GuiNotifier, and LogObserver.

◆ onEggLaid()

virtual void IWorldObserver::onEggLaid ( int  eggId,
int  playerId,
int  x,
int  y 
)
pure virtual

A player laid an egg via Fork. -> enw.

Implemented in GuiNotifier, and LogObserver.

◆ onGameEnd()

virtual void IWorldObserver::onGameEnd ( const std::string &  winningTeam)
pure virtual

A team won (6 players at max level). -> seg.

Implemented in GuiNotifier, and LogObserver.

◆ onIncantationEnd()

virtual void IWorldObserver::onIncantationEnd ( int  x,
int  y,
bool  success 
)
pure virtual

Incantation finished, success = leveled up or not. -> pie.

Implemented in GuiNotifier, and LogObserver.

◆ onIncantationStart()

virtual void IWorldObserver::onIncantationStart ( int  x,
int  y,
int  level,
const std::vector< int > &  participantIds 
)
pure virtual

Incantation began on a tile. participantIds = players involved. -> pic.

Implemented in GuiNotifier, and LogObserver.

◆ onInitialEggSpawned()

virtual void IWorldObserver::onInitialEggSpawned ( int  eggId,
const std::string &  teamName,
int  x,
int  y 
)
pure virtual

An initial team egg placed at game start (custom). -> sse.

Implemented in GuiNotifier, and LogObserver.

◆ onPlayerAdded()

virtual void IWorldObserver::onPlayerAdded ( int  playerId,
int  x,
int  y,
Orientation  orientation,
int  level,
const std::string &  teamName 
)
pure virtual

Player spawned (egg hatched or initial connection). -> pnw.

Implemented in GuiNotifier, and LogObserver.

◆ onPlayerEjected()

virtual void IWorldObserver::onPlayerEjected ( int  playerId)
pure virtual

Player got pushed off its tile by an eject. -> pex.

Implemented in GuiNotifier, and LogObserver.

◆ onPlayerInventoryChanged()

virtual void IWorldObserver::onPlayerInventoryChanged ( int  playerId,
int  x,
int  y,
Resources  inventory 
)
pure virtual

Player's carried resources changed. -> pin.

Implemented in GuiNotifier, and LogObserver.

◆ onPlayerLevelUp()

virtual void IWorldObserver::onPlayerLevelUp ( int  playerId,
int  newLevel 
)
pure virtual

Player reached a new level. -> plv.

Implemented in GuiNotifier, and LogObserver.

◆ onPlayerMoved()

virtual void IWorldObserver::onPlayerMoved ( int  playerId,
int  nx,
int  ny,
Orientation  newOrientation 
)
pure virtual

Player changed tile and/or facing. -> ppo.

Implemented in GuiNotifier, and LogObserver.

◆ onPlayerRemoved()

virtual void IWorldObserver::onPlayerRemoved ( int  playerId)
pure virtual

Player left (death or disconnect). -> pdi.

Implemented in GuiNotifier, and LogObserver.

◆ onResourceDropped()

virtual void IWorldObserver::onResourceDropped ( int  playerId,
ResourceType  resourceType,
int  tileX,
int  tileY,
Resources  resources 
)
pure virtual

Player dropped a resource onto the tile. -> pdr (+ bct/pin)

Implemented in GuiNotifier, and LogObserver.

◆ onResourceTaken()

virtual void IWorldObserver::onResourceTaken ( int  playerId,
ResourceType  resourceType,
int  tileX,
int  tileY,
Resources  resources 
)
pure virtual

Player picked a resource up off the tile. -> pgt (+ bct/pin)

Implemented in GuiNotifier, and LogObserver.

◆ onTileChanged()

virtual void IWorldObserver::onTileChanged ( int  x,
int  y,
Resources  resources 
)
pure virtual

A tile's resource contents changed (e.g. respawn). -> bct.

Implemented in GuiNotifier, and LogObserver.


The documentation for this class was generated from the following file: