mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-27 21:42:25 +00:00
Record player deaths (#2102)
## Description: Record player death ticks and "conquests" (when a player has < 100 tiles). Tournaments would be easier to manage with those information. Related infra PR: https://github.com/openfrontio/infra/pull/196 Tested locally with docker/infra repo ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: IngloriousTom
This commit is contained in:
@@ -93,4 +93,7 @@ export interface Stats {
|
||||
|
||||
// Player loses a unit of type
|
||||
unitLose(player: Player, type: OtherUnitType): void;
|
||||
|
||||
// player was killed (0 tiles)
|
||||
playerKilled(player: Player, tick: number): void;
|
||||
}
|
||||
|
||||
@@ -133,6 +133,22 @@ export class StatsImpl implements Stats {
|
||||
p.units[type][index] += _bigint(value);
|
||||
}
|
||||
|
||||
private _addConquest(player: Player) {
|
||||
const p = this._makePlayerStats(player);
|
||||
if (p === undefined) return;
|
||||
if (p.conquests === undefined) {
|
||||
p.conquests = _bigint(1);
|
||||
} else {
|
||||
p.conquests += _bigint(1);
|
||||
}
|
||||
}
|
||||
|
||||
private _addPlayerKilled(player: Player, tick: number) {
|
||||
const p = this._makePlayerStats(player);
|
||||
if (p === undefined) return;
|
||||
p.killedAt = _bigint(tick);
|
||||
}
|
||||
|
||||
attack(
|
||||
player: Player,
|
||||
target: Player | TerraNullius,
|
||||
@@ -225,6 +241,7 @@ export class StatsImpl implements Stats {
|
||||
|
||||
goldWar(player: Player, captured: Player, gold: BigIntLike): void {
|
||||
this._addGold(player, GOLD_INDEX_WAR, gold);
|
||||
this._addConquest(player);
|
||||
}
|
||||
|
||||
unitBuild(player: Player, type: OtherUnitType): void {
|
||||
@@ -246,4 +263,8 @@ export class StatsImpl implements Stats {
|
||||
unitLose(player: Player, type: OtherUnitType): void {
|
||||
this._addOtherUnit(player, type, OTHER_INDEX_LOST, 1);
|
||||
}
|
||||
|
||||
playerKilled(player: Player, tick: number): void {
|
||||
this._addPlayerKilled(player, tick);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user