Botball Game State
A game stared library for Botball, it helps model the table and different phases of the competition.
Loading...
Searching...
No Matches
Phase Class Reference

#include <Phase.h>

Public Member Functions

 Phase (const std::string &phase_id, const json &data)
const std::string get_id () const
int get_time_to_completion () const
const std::string & get_allowed_agent () const
const std::unordered_map< std::string, std::any > & get_conditions () const
const std::unordered_map< std::string, std::any > & get_completion () const
bool get_done () const
int get_points () const
PhaseStatus get_status () const
void set_status (PhaseStatus status)
void set_status (PhaseStatus status, const Socket &so)
void execute (TableState &table, const std::function< void()> &action, const Socket &so)
std::string to_string () const

Detailed Description

An Object representing a task on the Botball Game Table

Member Function Documentation

◆ execute()

void Phase::execute ( TableState & table,
const std::function< void()> & action,
const Socket & so )

Executes the phase action, mutates the table state to reflect the changes made by the action and sets the PhaseStatus to DONE

Parameters
tablea reference to the table state so that it may be changed on commpletion
actiona void(void) function that will be executed by the phase
sosocket to pass to table state for sending updates over the network

◆ get_allowed_agent()

const std::string & Phase::get_allowed_agent ( ) const
nodiscard
Returns
the agent ("bot_a" or "bot_b") that may complete the phase

◆ get_completion()

const std::unordered_map< std::string, std::any > & Phase::get_completion ( ) const
nodiscard
Returns
an unordered map of strings -> primitive datatypes representing the conditions that will be set in the table state after the successful execution of the phase

◆ get_conditions()

const std::unordered_map< std::string, std::any > & Phase::get_conditions ( ) const
nodiscard
Returns
an unordered map of strings -> primitive dataypes representing the conditions that have to be met before the phase may be executed

◆ get_done()

bool Phase::get_done ( ) const
nodiscard
Returns
true if the phase was executed

◆ get_id()

const std::string Phase::get_id ( ) const
nodiscard
Returns
the phase id

◆ get_points()

int Phase::get_points ( ) const
nodiscard
Returns
the amount of points to be earned by the phase

◆ get_status()

PhaseStatus Phase::get_status ( ) const
nodiscard
Returns
the PhaseStatus of a phase

◆ get_time_to_completion()

int Phase::get_time_to_completion ( ) const
nodiscard
Returns
the amount of time it takes to complete the phase as an int

◆ set_status() [1/2]

void Phase::set_status ( PhaseStatus status)

Sets the PhaseStatus of a phase

Parameters
statusthe phase should be in

◆ set_status() [2/2]

void Phase::set_status ( PhaseStatus status,
const Socket & so )

Sets the PhaseStatus of a phase and sends it to the peer bot

Parameters
statusthe phase should be in
soused to send a request to the peer bot

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