Add round stages, respawn protection and match highlights
This commit is contained in:
1 parent
b87a3770a1
commit
d1c42a36b8
28 files changed
+753
-45
No files matched your search
@@ -0,0 +1,40 @@
|
||||
--!strict
|
||||
export type Row = {userId: number, stats: {[string]: number}}
|
||||
local Stats = {}
|
||||
local byPlayer: {[Player]: {[string]: number}} = {}
|
||||
|
||||
function Stats.reset()
|
||||
table.clear(byPlayer)
|
||||
end
|
||||
|
||||
function Stats.add(player: Player, key: string, amount: number)
|
||||
local record = byPlayer[player]
|
||||
if not record then
|
||||
record = {}
|
||||
byPlayer[player] = record
|
||||
end
|
||||
record[key] = (record[key] or 0) + amount
|
||||
end
|
||||
|
||||
function Stats.get(player: Player): {[string]: number}
|
||||
return table.clone(byPlayer[player] or {})
|
||||
end
|
||||
|
||||
function Stats.remove(player: Player)
|
||||
byPlayer[player] = nil
|
||||
end
|
||||
|
||||
function Stats.mvp(rows: {Row}, weights: {[string]: number}): number?
|
||||
local best: number? = nil
|
||||
local bestScore = -math.huge
|
||||
for _, row in rows do
|
||||
local score = 0
|
||||
for key, weight in weights do score += (row.stats[key] or 0) * weight end
|
||||
if score > bestScore or (score == bestScore and best ~= nil and row.userId < best) then
|
||||
best, bestScore = row.userId, score
|
||||
end
|
||||
end
|
||||
return best
|
||||
end
|
||||
|
||||
return Stats
|
||||
Reference in new issue
Block a user