Loading...
Searching...
No Matches
CScoreboard Class Reference

Scoreboard used to score complex code battles. More...

`#include <src/level/scoreboard.h>`

## Classes

struct | Score
| Struct containing score of individual team and additional variables to allow sorting teams through different criteria. More...
class | CScoreboardRule
| Base class for scoreboard rules. More...
class | CScoreboardKillRule
| Scoreboard rule for destroying other objects. More...
class | CScoreboardObjectRule
| Scoreboard rule for counting objects. More...
class | CScoreboardEndTakeRule
| Scoreboard rule for EndMissionTake rewards. More...

## Public Types

enum class | SortType { SORT_ID , SORT_POINTS }
| Enum defining the scoreboard sorting criteria. More...

## Public Member Functions

| CScoreboard ()
| ~CScoreboard ()
| Destroys the scoreboard.
void | AddKillRule (std::unique_ptr< CScoreboardKillRule > rule)
| Add ScoreboardKillRule.
void | AddObjectRule (std::unique_ptr< CScoreboardObjectRule > rule)
| Add ScoreboardObjectRule.
void | AddEndTakeRule (std::unique_ptr< CScoreboardEndTakeRule > rule)
| Add ScoreboardEndTakeRule.
void | ProcessKill (CObject *target, CObject *killer=nullptr)
void | UpdateObjectCount ()
| Updates the object count rules.
void | ProcessEndTake (int team)
| Called after EndTake contition has been met, used to handle ScoreboardEndTakeRule.
void | AddPoints (int team, int points)
Score | GetScore (int team)
void | SetScore (int team, int points)
SortType | GetSortType ()
void | SetSortType (SortType type)
std::vector< std::pair< int, Score > > | GetSortedScores ()

## Detailed Description

Scoreboard used to score complex code battles.

Todo
  This is pretty much a work-in-progress hack for Diversity. Be wary of possible API changes.

Todo
  Proper documentation

See also
  CRobotMain::GetScoreboard()

# Usage example

Scoreboard enable=true // enable the scoreboard
ScoreboardSortType sort=Name // sort teams alphabetically, another option is sort=Points, sorting teams in order of points
ScoreboardKillRule type=WheeledShooter team=1 score=500 // destruction of team 1's WheeledShooter gives 100 points to the team that destroyed it
ScoreboardKillRule type=TargetBot score=100 // destruction of TargetBot (any team) gives 100 points
ScoreboardObjectRule pos=0.0;0.5 dist=5.0 type=Titanium winTeam=1 score=5 // each Titanium within 5 meters of 0;0 gives team 1 5 points, losing Titanium gives -5
ScoreboardEndTakeRule score=1000 // completion of EndMissionTake objectives for any team results in 1000 points for that team

## Member Enumeration Documentation

## SortType

enum class CScoreboard::SortType

strong

Enum defining the scoreboard sorting criteria.

Enumerator
SORT_ID | Sort by team ID.
SORT_POINTS | Sort by points.

## Constructor & Destructor Documentation

## CScoreboard()

CScoreboard::CScoreboard | ( |  | ) |

inline

Creates the scoreboard The scoreboard exists only if enabled in level file

## ~CScoreboard()

CScoreboard::~CScoreboard | ( |  | ) |

inline

Destroys the scoreboard.

## Member Function Documentation

## AddKillRule()

void CScoreboard::AddKillRule | ( | std::unique_ptr< CScoreboardKillRule > | rule | ) |

Add ScoreboardKillRule.

## AddObjectRule()

void CScoreboard::AddObjectRule | ( | std::unique_ptr< CScoreboardObjectRule > | rule | ) |

Add ScoreboardObjectRule.

## AddEndTakeRule()

void CScoreboard::AddEndTakeRule | ( | std::unique_ptr< CScoreboardEndTakeRule > | rule | ) |

Add ScoreboardEndTakeRule.

## ProcessKill()

void CScoreboard::ProcessKill | ( | CObject * | target,
|  | CObject * | killer = nullptr )

Called after an object is destroyed by another object

Parameters

  target | The object that has just been destroyed
  killer | The object that caused the destruction, can be null

## UpdateObjectCount()

void CScoreboard::UpdateObjectCount | ( |  | ) |

Updates the object count rules.

## ProcessEndTake()

void CScoreboard::ProcessEndTake | ( | int | team | ) |

Called after EndTake contition has been met, used to handle ScoreboardEndTakeRule.

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

- src/level/scoreboard.h
- src/level/scoreboard.cpp