Skip to content

Passing results on

tilttek/score-sheets

ScoreKeeper::close() returns a MatchResult: neutral data that a play log, a rating or a leaderboard reads without the library depending on any of them.

FieldMeaning
matchThe match
gameThe key of the game
revision1 for the first result, 2 and more for a correction after the sheet was reopened
participantsA Placement by participant, in rank order: identifier, rank, total
teamsA Placement by team, in rank order: identifier, rank, total, members
completeWhether every value was entered
$result = $keeper->close($match, $version);

$bus->dispatch($result->message());   // Message\MatchResultRecorded: the match and the revision only

Message\MatchResultRecorded carries identifiers only; its handler reads the sheet from the store and computes the result again with MatchResult::of($sheet, $scorer->score($sheet->sheet, $sheet->entries)). A handler that receives a revision it has already recorded, or an older one, ignores it; a newer revision replaces the result it recorded.

A rating takes the places as a suggestion: the ranks say who finished where, and the rating decides what it does with ties, incomplete sheets and teams.