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

#include <GuiNotifier.hpp>

+ Inheritance diagram for GuiNotifier:
+ Collaboration diagram for GuiNotifier:

Public Member Functions

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

Private Attributes

ClientManager_clients
 
std::vector< int > _guiIds
 

Detailed Description

Definition at line 9 of file GuiNotifier.hpp.

Constructor & Destructor Documentation

◆ GuiNotifier()

GuiNotifier::GuiNotifier ( ClientManager clients)
explicit

Definition at line 7 of file GuiNotifier.cpp.

Member Function Documentation

◆ addGui()

void GuiNotifier::addGui ( int  connectionId)

Definition at line 9 of file GuiNotifier.cpp.

References _guiIds.

Referenced by HandshakeHandler::_promoteToGui().

+ Here is the caller graph for this function:

◆ broadcast()

void GuiNotifier::broadcast ( const std::string &  msg)

Definition at line 21 of file GuiNotifier.cpp.

References _clients, _guiIds, and ClientManager::send().

Referenced by Server::_handleGameOver(), CommandDispatcher::_handleSst(), onBroadcast(), onEggDied(), onEggHatched(), onEggLaid(), onGameEnd(), onIncantationEnd(), onIncantationStart(), onInitialEggSpawned(), onPlayerAdded(), onPlayerEjected(), onPlayerInventoryChanged(), onPlayerLevelUp(), onPlayerMoved(), onPlayerRemoved(), onResourceDropped(), onResourceTaken(), and onTileChanged().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ onBroadcast()

void GuiNotifier::onBroadcast ( int  playerId,
const std::string &  message 
)
overridevirtual

Player shouted a broadcast message. -> pbc.

Implements IWorldObserver.

Definition at line 46 of file GuiNotifier.cpp.

References broadcast(), and Serializer::pbc().

+ Here is the call graph for this function:

◆ onEggDied()

void GuiNotifier::onEggDied ( int  eggId)
overridevirtual

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

Implements IWorldObserver.

Definition at line 78 of file GuiNotifier.cpp.

References broadcast(), and Serializer::edi().

+ Here is the call graph for this function:

◆ onEggHatched()

void GuiNotifier::onEggHatched ( int  eggId)
overridevirtual

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

Implements IWorldObserver.

Definition at line 76 of file GuiNotifier.cpp.

References broadcast(), and Serializer::ebo().

+ Here is the call graph for this function:

◆ onEggLaid()

void GuiNotifier::onEggLaid ( int  eggId,
int  playerId,
int  x,
int  y 
)
overridevirtual

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

Implements IWorldObserver.

Definition at line 65 of file GuiNotifier.cpp.

References broadcast(), Serializer::enw(), and Serializer::pfk().

+ Here is the call graph for this function:

◆ onGameEnd()

void GuiNotifier::onGameEnd ( const std::string &  winningTeam)
overridevirtual

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

Implements IWorldObserver.

Definition at line 96 of file GuiNotifier.cpp.

References broadcast(), and Serializer::seg().

+ Here is the call graph for this function:

◆ onIncantationEnd()

void GuiNotifier::onIncantationEnd ( int  x,
int  y,
bool  success 
)
overridevirtual

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

Implements IWorldObserver.

Definition at line 86 of file GuiNotifier.cpp.

References broadcast(), and Serializer::pie().

+ Here is the call graph for this function:

◆ onIncantationStart()

void GuiNotifier::onIncantationStart ( int  x,
int  y,
int  level,
const std::vector< int > &  participantIds 
)
overridevirtual

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

Implements IWorldObserver.

Definition at line 80 of file GuiNotifier.cpp.

References broadcast(), and Serializer::pic().

+ Here is the call graph for this function:

◆ onInitialEggSpawned()

void GuiNotifier::onInitialEggSpawned ( int  eggId,
const std::string &  teamName,
int  x,
int  y 
)
overridevirtual

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

Implements IWorldObserver.

Definition at line 71 of file GuiNotifier.cpp.

References broadcast(), and Serializer::sse().

+ Here is the call graph for this function:

◆ onPlayerAdded()

void GuiNotifier::onPlayerAdded ( int  playerId,
int  x,
int  y,
Orientation  orientation,
int  level,
const std::string &  teamName 
)
overridevirtual

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

Implements IWorldObserver.

Definition at line 26 of file GuiNotifier.cpp.

References broadcast(), and Serializer::pnw().

+ Here is the call graph for this function:

◆ onPlayerEjected()

void GuiNotifier::onPlayerEjected ( int  playerId)
overridevirtual

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

Implements IWorldObserver.

Definition at line 44 of file GuiNotifier.cpp.

References broadcast(), and Serializer::pex().

+ Here is the call graph for this function:

◆ onPlayerInventoryChanged()

void GuiNotifier::onPlayerInventoryChanged ( int  playerId,
int  x,
int  y,
Resources  inventory 
)
overridevirtual

Player's carried resources changed. -> pin.

Implements IWorldObserver.

Definition at line 37 of file GuiNotifier.cpp.

References broadcast(), and Serializer::pin().

+ Here is the call graph for this function:

◆ onPlayerLevelUp()

void GuiNotifier::onPlayerLevelUp ( int  playerId,
int  newLevel 
)
overridevirtual

Player reached a new level. -> plv.

Implements IWorldObserver.

Definition at line 91 of file GuiNotifier.cpp.

References broadcast(), and Serializer::plv().

+ Here is the call graph for this function:

◆ onPlayerMoved()

void GuiNotifier::onPlayerMoved ( int  playerId,
int  nx,
int  ny,
Orientation  newOrientation 
)
overridevirtual

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

Implements IWorldObserver.

Definition at line 32 of file GuiNotifier.cpp.

References broadcast(), and Serializer::ppo().

+ Here is the call graph for this function:

◆ onPlayerRemoved()

void GuiNotifier::onPlayerRemoved ( int  playerId)
overridevirtual

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

Implements IWorldObserver.

Definition at line 42 of file GuiNotifier.cpp.

References broadcast(), and Serializer::pdi().

+ Here is the call graph for this function:

◆ onResourceDropped()

void GuiNotifier::onResourceDropped ( int  playerId,
ResourceType  resourceType,
int  tileX,
int  tileY,
Resources  resources 
)
overridevirtual

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

Implements IWorldObserver.

Definition at line 58 of file GuiNotifier.cpp.

References Serializer::bct(), broadcast(), and Serializer::pdr().

+ Here is the call graph for this function:

◆ onResourceTaken()

void GuiNotifier::onResourceTaken ( int  playerId,
ResourceType  resourceType,
int  tileX,
int  tileY,
Resources  resources 
)
overridevirtual

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

Implements IWorldObserver.

Definition at line 51 of file GuiNotifier.cpp.

References Serializer::bct(), broadcast(), and Serializer::pgt().

+ Here is the call graph for this function:

◆ onTileChanged()

void GuiNotifier::onTileChanged ( int  x,
int  y,
Resources  resources 
)
overridevirtual

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

Implements IWorldObserver.

Definition at line 101 of file GuiNotifier.cpp.

References Serializer::bct(), and broadcast().

+ Here is the call graph for this function:

◆ removeGui()

void GuiNotifier::removeGui ( int  connectionId)

Definition at line 11 of file GuiNotifier.cpp.

References _guiIds.

Referenced by CommandDispatcher::onDisconnect().

+ Here is the caller graph for this function:

◆ send()

void GuiNotifier::send ( int  connectionId,
const std::string &  msg 
)

Definition at line 16 of file GuiNotifier.cpp.

References _clients, and ClientManager::send().

Referenced by HandshakeHandler::_promoteToGui().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ _clients

ClientManager& GuiNotifier::_clients
private

Definition at line 42 of file GuiNotifier.hpp.

Referenced by broadcast(), and send().

◆ _guiIds

std::vector<int> GuiNotifier::_guiIds
private

Definition at line 43 of file GuiNotifier.hpp.

Referenced by addGui(), broadcast(), and removeGui().


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