Log inGet started
World

Podium Points: Championship Points, Standings and Tie-breaks Kit

Branchmain
Branchesmain
Commitf2b4f040d8

README.md

championshipKit

Points tables and standings across rounds for any game played over several rounds: race cups, party game nights, tournaments, leagues. Record each round's finish order and read back the table: places, place changes, points, points gained this round, points and places per round, wins and who has been eliminated. Ties are settled sensibly, and the whole table fits in one synced field for multiplayer.

It draws nothing and needs nothing else installed. grandPrixKit uses it for kart racing cups; anything with rounds can.

First example

Install championshipKit from ZeroMind (search "championshipKit" or "points table standings across rounds"), then run this anywhere (the editor's run box, a script, a component):

local Championship = require("championshipKit.api")
local cup = Championship.new({ points = "classicKart", rounds = 3 })

cup:recordRound({ { id = 1, name = "Ana" }, { id = 2, name = "Bo" }, { id = 3, name = "Cy" } })   -- finish order
cup:recordRound({ { id = 2 }, { id = 1 }, { id = 3 } })

for _, row in cup:rows() do
    print(row.place, row.name, row.points, "won", row.wins, "was", row.prevPlace)
end
-- 1 Bo 27 won 1 was 2   (Ana also has 27; Bo won the latest round, so Bo leads)
-- 2 Ana 27 won 1 was 1
-- 3 Cy 20 won 0 was 3

Change "classicKart" to "motorsport", "arcade" or "elimination" and run it again: the same finishes score differently, and in an elimination cup the last finisher of each round (bar the final) drops out.

Points systems (points)

idScoresTags
classicKart15, 12, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1kart, classic, arcade, every place scores
motorsport25, 18, 15, 12, 10, 8, 6, 4, 2, 1, plus 1 for the fastest lap inside the top ten (fastestLap = true on that finisher)realistic, motorsport, formula, top ten, fastest lap
motoGP25, 20, 16, 13, 11, then one fewer per place to 1 for fifteenthrealistic, motorsport, bikes, deep field
arcadefield size minus place plus one: last scores 1, first scores the field sizearcade, simple, casual
podium5, 3, 1simple, podium, casual
winnerTakesAll1 per win onlyhardcore, wins, simple
eliminationclassicKart points; the last finisher of each round drops out, never after the final round and never below two leftelimination, knockout, survival

Aliases work too (classic, kart, f1, formula, realistic, bikes, simple, wta, knockout), and so does your own table: Championship.new({ points = { 10, 6, 4, 3, 2, 1 } }). Championship.points("simple") lists the systems with a tag, Championship.tags() every tag, require("championshipKit.points").add({...}) registers a new system.

How ties are settled

  1. More points.
  2. More wins, then more second places, then more thirds, and so on (countback).
  3. The better place in the latest round both raced.
  4. Who joined first.

Eliminated entrants always rank below everyone still in; of two eliminated, the one who lasted longer ranks higher.

The table (rows())

Each row: id, name, meta (free text you keep with an entrant, e.g. their kart), place, prevPlace (before the latest round; 0 before the first), points, gained (this round), places (finish place per round, 0 = did not race), roundPoints (points per round), wins, fastestLaps, eliminated, eliminatedAt (the round they dropped out after).

recordRound(results) takes the round's finishers in finish order, each { id, name?, meta?, place?, dnf?, fastestLap? } (a dnf scores nothing; anyone not listed did not race it), and returns that round's scoring { { id, name, place, points } } plus the id eliminated this round, if any. Someone who joins after round one is added with 0 for the rounds they missed: cup:add(id, name, meta) or simply list them in a round.

Multiplayer

The kit is plain data. Keep the table on the machine in charge and publish it in one synced string field: field = cup:encode(), and every machine reads it back with Championship.decode(field). grandPrixKit's GrandPrix does exactly this.

API

require("championshipKit.api"): new(opts), decode(s, opts?), points(tag?), system(id), pointsFor(id, place, fieldSize), tags(), plus the Points and Standings modules. A championship: add, isIn, recordRound, rows, podium(n?), roundsPlayed, lastRoundResults, encode.

Version

1.0.0: first release: seven points systems, countback tie-breaks, elimination, per-round points and places, one-string sync encoding.