Player12
An open source football management simulator
Loading...
Searching...
No Matches
MatchChanges::SubstitutionPlan Class Reference

Substitutions queued by the manager and made together, so they share one stoppage and one window. More...

#include <match_changes.h>

Public Member Functions

Refusal check (const MatchEngine &engine, bool home, std::span< const Player *const > bench, PlayerID out, PlayerID in) const
 Whether out can be replaced by in given the rules and the changes already planned (nothing is added).
 
Refusal add (const MatchEngine &engine, bool home, std::span< const Player *const > bench, PlayerID out, PlayerID in)
 check() and, when allowed, appends the change.
 
bool remove (std::size_t index)
 Drops one planned change (false for a bad index).
 
void clear ()
 Drops every planned change and the confirmation.
 
std::span< const PlannedSubstitution > entries () const
 
bool empty () const
 
bool involves (PlayerID player) const
 The player is leaving or coming on in a planned change.
 
PlayerID replacementFor (PlayerID out) const
 Planned replacement of an outgoing player (0 when none).
 
void confirm ()
 Hands the plan to the referee: made at the next stoppage.
 
bool isConfirmed () const
 
std::vector< SubstitutionOutcome > apply (MatchEngine &engine, bool home, std::span< const Player *const > bench)
 Makes every planned change now, in order, without advancing the engine in between (so they count as one window), then clears the plan. Changes the engine refuses carry the reason.
 
std::vector< SubstitutionOutcome > applyIfDue (MatchEngine &engine, bool home, std::span< const Player *const > bench)
 apply() once the plan is confirmed and play has stopped; nothing (an empty result) otherwise.
 

Private Attributes

std::vector< PlannedSubstitution > planned
 
bool confirmed = false
 

Detailed Description

Substitutions queued by the manager and made together, so they share one stoppage and one window.

Member Function Documentation

◆ add()

Refusal MatchChanges::SubstitutionPlan::add ( const MatchEngine &  engine,
bool  home,
std::span< const Player *const >  bench,
PlayerID  out,
PlayerID  in 
)

check() and, when allowed, appends the change.

◆ apply()

std::vector< SubstitutionOutcome > MatchChanges::SubstitutionPlan::apply ( MatchEngine &  engine,
bool  home,
std::span< const Player *const >  bench 
)

Makes every planned change now, in order, without advancing the engine in between (so they count as one window), then clears the plan. Changes the engine refuses carry the reason.

◆ applyIfDue()

std::vector< SubstitutionOutcome > MatchChanges::SubstitutionPlan::applyIfDue ( MatchEngine &  engine,
bool  home,
std::span< const Player *const >  bench 
)

apply() once the plan is confirmed and play has stopped; nothing (an empty result) otherwise.

◆ check()

Refusal MatchChanges::SubstitutionPlan::check ( const MatchEngine &  engine,
bool  home,
std::span< const Player *const >  bench,
PlayerID  out,
PlayerID  in 
) const

Whether out can be replaced by in given the rules and the changes already planned (nothing is added).

Parameters
benchThe side's substitutes (the matchday squad's reserves).

◆ clear()

void MatchChanges::SubstitutionPlan::clear ( )

Drops every planned change and the confirmation.

◆ confirm()

void MatchChanges::SubstitutionPlan::confirm ( )
inline

Hands the plan to the referee: made at the next stoppage.

◆ empty()

bool MatchChanges::SubstitutionPlan::empty ( ) const
inline

◆ entries()

std::span< const PlannedSubstitution > MatchChanges::SubstitutionPlan::entries ( ) const
inline

◆ involves()

bool MatchChanges::SubstitutionPlan::involves ( PlayerID  player) const

The player is leaving or coming on in a planned change.

◆ isConfirmed()

bool MatchChanges::SubstitutionPlan::isConfirmed ( ) const
inline

◆ remove()

bool MatchChanges::SubstitutionPlan::remove ( std::size_t  index)

Drops one planned change (false for a bad index).

◆ replacementFor()

PlayerID MatchChanges::SubstitutionPlan::replacementFor ( PlayerID  out) const

Planned replacement of an outgoing player (0 when none).

Member Data Documentation

◆ confirmed

bool MatchChanges::SubstitutionPlan::confirmed = false
private

◆ planned

std::vector<PlannedSubstitution> MatchChanges::SubstitutionPlan::planned
private

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