Player12
An open source football management simulator
Loading...
Searching...
No Matches
Strategy Class Reference

Represents the tactical setup of a team for a match. More...

#include <strategy.h>

Public Member Functions

 Strategy ()
 Default constructor, initializes global sliders and default weights.
 
float getAttackWeight (int roleIndex, int gridPosition) const
 Get weights of a player at a specific grid cell.
 
float getDefenseWeight (int roleIndex, int gridPosition) const
 Get defense weight of a player at a specific grid cell.
 
void setPressing (float value)
 Sets the pressing slider value.
 
void setRiskTaking (float value)
 Sets the risk taking slider value.
 
void setOffensiveBias (float value)
 Sets the offensive bias slider value.
 
void setWidthUsage (float value)
 Sets the width usage slider value.
 
void setCompactness (float value)
 Sets the compactness slider value.
 
void setOutfieldWeights (int playerIndex, float attack, float defense, int radius)
 Sets the role weights for a specific outfield player.
 
RoleWeights & getRole (int roleIndex)
 Gets the role weights for a specific player (non-const).
 
const RoleWeights & getRole (int roleIndex) const
 Gets the role weights for a specific player (const).
 
void setAllSliders (const StrategySliders &newSliders)
 Sets all sliders at once.
 
StrategySliders getSliders () const
 Retrieves the current slider state.
 
void setAllOutfieldWeights (float attack, float defense, int radius)
 Applies the same weights to all outfield players.
 
const std::vector< SlotInstruction > & getSlotInstructions () const
 
void setSlotInstructions (std::vector< SlotInstruction > instructions)
 
const SlotInstruction * findSlot (Vector2F anchor) const
 
void setSlot (const SlotInstruction &instruction)
 
TacticalRole getKeeperRole () const
 
void setKeeperRole (TacticalRole role)
 
const std::vector< PlayerInstruction > & getOppositionOrders () const
 
void setOppositionOrders (std::vector< PlayerInstruction > orders)
 

Private Attributes

StrategySliders sliders
 
RoleWeights goalkeeper = {0.0f, 1.0f, 1}
 
RoleWeights outfield [10]
 
std::vector< SlotInstruction > slots
 
TacticalRole keeper_role = TacticalRole::Standard
 
std::vector< PlayerInstruction > opposition_orders
 

Detailed Description

Represents the tactical setup of a team for a match.

Stores team sliders, tactical slot/keeper roles, possession offsets and opposition orders. The engine copies a Strategy and resolves its role profiles; changing a club's Strategy alone does not update a running match.

Constructor & Destructor Documentation

◆ Strategy()

Strategy::Strategy ( )

Default constructor, initializes global sliders and default weights.

Member Function Documentation

◆ findSlot()

const SlotInstruction * Strategy::findSlot ( Vector2F  anchor) const

Instruction of the slot at anchor (lineup coordinates): the nearest stored one within TacticsTuning::SLOT_MATCH_DISTANCE, else nullptr.

◆ getAttackWeight()

float Strategy::getAttackWeight ( int  roleIndex,
int  gridPosition 
) const

Get weights of a player at a specific grid cell.

  • roleIndex: 0 = goalkeeper, 1-10 = outfield players
  • gridPosition: grid position to evaluate
Parameters
roleIndexThe index of the player's role.
gridPositionThe grid position to evaluate.
Returns
The attack weight at the given position, 0 if outside movement area.

◆ getDefenseWeight()

float Strategy::getDefenseWeight ( int  roleIndex,
int  gridPosition 
) const

Get defense weight of a player at a specific grid cell.

Parameters
roleIndexThe index of the player's role.
gridPositionThe grid position to evaluate.
Returns
The defense weight at the given position, 0 if outside movement area.

◆ getKeeperRole()

TacticalRole Strategy::getKeeperRole ( ) const
inline

◆ getOppositionOrders()

const std::vector< PlayerInstruction > & Strategy::getOppositionOrders ( ) const
inline

Instructions against players of the next opponent. Not saved with the tactic: the club's opposition plan is the saved copy and refreshes them.

◆ getRole() [1/2]

RoleWeights & Strategy::getRole ( int  roleIndex)

Gets the role weights for a specific player (non-const).

Parameters
roleIndexThe index of the player.
Returns
Reference to the RoleWeights struct.

◆ getRole() [2/2]

const RoleWeights & Strategy::getRole ( int  roleIndex) const

Gets the role weights for a specific player (const).

Parameters
roleIndexThe index of the player.
Returns
Const reference to the RoleWeights struct.

◆ getSliders()

StrategySliders Strategy::getSliders ( ) const

Retrieves the current slider state.

Returns
The current StrategySliders.

◆ getSlotInstructions()

const std::vector< SlotInstruction > & Strategy::getSlotInstructions ( ) const
inline

Every stored slot instruction (all formations used so far).

◆ setAllOutfieldWeights()

void Strategy::setAllOutfieldWeights ( float  attack,
float  defense,
int  radius 
)

Applies the same weights to all outfield players.

Parameters
attackThe attack weight to set.
defenseThe defense weight to set.
radiusThe movement radius to set.

◆ setAllSliders()

void Strategy::setAllSliders ( const StrategySliders &  newSliders)

Sets all sliders at once.

Parameters
newSlidersThe new StrategySliders to apply.

◆ setCompactness()

void Strategy::setCompactness ( float  value)
inline

Sets the compactness slider value.

◆ setKeeperRole()

void Strategy::setKeeperRole ( TacticalRole  role)

◆ setOffensiveBias()

void Strategy::setOffensiveBias ( float  value)
inline

Sets the offensive bias slider value.

◆ setOppositionOrders()

void Strategy::setOppositionOrders ( std::vector< PlayerInstruction >  orders)

◆ setOutfieldWeights()

void Strategy::setOutfieldWeights ( int  playerIndex,
float  attack,
float  defense,
int  radius 
)

Sets the role weights for a specific outfield player.

Parameters
playerIndexThe zero-based outfield index (0-9).
attackThe attack weight to set.
defenseThe defense weight to set.
radiusThe movement radius to set.

◆ setPressing()

void Strategy::setPressing ( float  value)
inline

Sets the pressing slider value.

◆ setRiskTaking()

void Strategy::setRiskTaking ( float  value)
inline

Sets the risk taking slider value.

◆ setSlot()

void Strategy::setSlot ( const SlotInstruction &  instruction)

Stores the instruction of the slot at its anchor (replacing it).

◆ setSlotInstructions()

void Strategy::setSlotInstructions ( std::vector< SlotInstruction >  instructions)

Replaces the slot instructions (persistence).

◆ setWidthUsage()

void Strategy::setWidthUsage ( float  value)
inline

Sets the width usage slider value.

Member Data Documentation

◆ goalkeeper

RoleWeights Strategy::goalkeeper = {0.0f, 1.0f, 1}
private

◆ keeper_role

TacticalRole Strategy::keeper_role = TacticalRole::Standard
private

◆ opposition_orders

std::vector<PlayerInstruction> Strategy::opposition_orders
private

◆ outfield

RoleWeights Strategy::outfield[10]
private

◆ sliders

StrategySliders Strategy::sliders
private

◆ slots

std::vector<SlotInstruction> Strategy::slots
private

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