bwmodel
A modeling environment for Minecraft Bedwars
Loading...
Searching...
No Matches
Public Member Functions | List of all members
bwmodel::Game Class Reference

#include <game.h>

Public Member Functions

 Game (std::unique_ptr< Map > map, PlayerColor me)
 
const Mapmap () const
 
uint64_t time () const
 
PlayerColor me () const
 
const std::set< PlayerColor > & players_left () const
 
bool player_has_bed (PlayerColor color)
 
void attach (std::shared_ptr< GameDelegate > delegate)
 
void notify_start ()
 
void notify_end ()
 
bool should_end () const
 
void cycle ()
 
void notify_player_kill (PlayerColor victor, PlayerColor loser)
 
void notify_break_bed (PlayerColor breaker, PlayerColor bed)
 

Detailed Description

Models a bedwars game.

Modeling Instructions

When a player player (bwmodel::PlayerColor) enters a bedwars game on a map (as a std::unique_ptr to bwmodel::Map), the game Game(map, player) will model that game until it ends.

Before beginning the game lifecycle (see next section), you may attach delegates via Game::attach. In fact, you may do this at any point, but it likely you wish to do this at the start.

Game Lifecycle
  1. Call Game::notify_start once when the game begins.
  2. Call Game::cycle as often as possible. In addition:
  3. Call Game::notify_end when the game ends (Game::should_end).

Constructor & Destructor Documentation

◆ Game()

bwmodel::Game::Game ( std::unique_ptr< Map > map,
PlayerColor me )

Constructs a new game from map, taking ownership of it. See Game::me() for information about me.

Member Function Documentation

◆ attach()

void bwmodel::Game::attach ( std::shared_ptr< GameDelegate > delegate)

Attaches the given delegate to notify for game events.

◆ cycle()

void bwmodel::Game::cycle ( )

Cycle the game.

◆ map()

const Map & bwmodel::Game::map ( ) const
Returns
The game map.

◆ me()

PlayerColor bwmodel::Game::me ( ) const

The player whose perspective this game is played from.

◆ notify_break_bed()

void bwmodel::Game::notify_break_bed ( PlayerColor breaker,
PlayerColor bed )

Player breaker breaks the bed for player whose color is given by bed.

◆ notify_end()

void bwmodel::Game::notify_end ( )

Ends the game.

◆ notify_player_kill()

void bwmodel::Game::notify_player_kill ( PlayerColor victor,
PlayerColor loser )

Player victor kills player loser.

◆ notify_start()

void bwmodel::Game::notify_start ( )

Begins the game.

◆ player_has_bed()

bool bwmodel::Game::player_has_bed ( PlayerColor color)

Whether the player whose color is color currently has a bed.

◆ players_left()

const std::set< PlayerColor > & bwmodel::Game::players_left ( ) const

A list of remaining players.

◆ should_end()

bool bwmodel::Game::should_end ( ) const

Whether the game should be ended.

◆ time()

uint64_t bwmodel::Game::time ( ) const

The time in milliseconds since the game started.


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