mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 11:50:42 +00:00
6e892839e8
**Add approved & assigned issue number here:** Resolves #4349 ## Description: The infra related PR is linked to this one and would need to be pushed first (376) Two changes for organized/tournament matches: 1. **Final standings.** `setWinner` snapshots each player's tiles owned at game end into `PlayerStats` (`finalTiles`). It's a deterministic integer captured in the sim, so it's replay-safe and rides into the existing game record. This lets standings be derived directly (winner, then surviving players by territory, then eliminated players by when they died) without re-simulating, which matters because a domination win ends with many players still alive. 2. **Per-kill log**. Records, per player, which humans they eliminated and at what tick (kills on PlayerStats). This lets standings attribute each kill to the victim's final placement, and gives a deterministic kill graph for integrity review. Hooked once in conquerPlayer (the single elimination funnel), humans only. Additive optional field that rides the existing game record, no archive or wire changes. These are off by default with no effect on normal play. ## Please complete the following: - [x] I have added screenshots for all UI updates (no UI changes in this PR) - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file (no new user-facing text) - [x] I have added relevant tests to the test directory ## Please put your Discord username so you can be contacted if a bug or regression is found: zixer._
117 lines
3.4 KiB
TypeScript
117 lines
3.4 KiB
TypeScript
import { AllPlayersStats } from "../Schemas";
|
|
import { NukeType, OtherUnitType, PlayerStats } from "../StatsSchemas";
|
|
import { Player, TerraNullius } from "./Game";
|
|
|
|
export interface Stats {
|
|
getPlayerStats(player: Player): PlayerStats | null;
|
|
stats(): AllPlayersStats;
|
|
|
|
numMirvsLaunched(): bigint;
|
|
|
|
// Player attacks target
|
|
attack(
|
|
player: Player,
|
|
target: Player | TerraNullius,
|
|
troops: number | bigint,
|
|
): void;
|
|
|
|
// Player cancels attack on target
|
|
attackCancel(
|
|
player: Player,
|
|
target: Player | TerraNullius,
|
|
troops: number | bigint,
|
|
): void;
|
|
|
|
// Player betrays another player
|
|
betray(player: Player): void;
|
|
|
|
// Time between lobby creation and game start (ms)
|
|
lobbyFillTime(fillTimeMs: number): void;
|
|
|
|
// Player sends a trade ship to target
|
|
boatSendTrade(player: Player, target: Player): void;
|
|
|
|
// Player's trade ship arrives at target, both players earn gold
|
|
boatArriveTrade(player: Player, target: Player, gold: number | bigint): void;
|
|
|
|
// Player's trade ship, captured from target, arrives. Player earns gold.
|
|
boatCapturedTrade(
|
|
player: Player,
|
|
target: Player,
|
|
gold: number | bigint,
|
|
): void;
|
|
|
|
// Player destroys target's trade ship
|
|
boatDestroyTrade(player: Player, target: Player): void;
|
|
|
|
// Player sends a transport ship to target with troops
|
|
boatSendTroops(
|
|
player: Player,
|
|
target: Player | TerraNullius,
|
|
troops: number | bigint,
|
|
): void;
|
|
|
|
// Player's transport ship arrives at target with troops
|
|
boatArriveTroops(
|
|
player: Player,
|
|
target: Player | TerraNullius,
|
|
troops: number | bigint,
|
|
): void;
|
|
|
|
// Player destroys target's transport ship with troops
|
|
boatDestroyTroops(
|
|
player: Player,
|
|
target: Player,
|
|
troops: number | bigint,
|
|
): void;
|
|
|
|
// Player launches bomb at target
|
|
bombLaunch(
|
|
player: Player,
|
|
target: Player | TerraNullius,
|
|
type: NukeType,
|
|
): void;
|
|
|
|
// Player's bomb lands at target
|
|
bombLand(player: Player, target: Player | TerraNullius, type: NukeType): void;
|
|
|
|
// Player's SAM intercepts a bomb from attacker
|
|
bombIntercept(player: Player, type: NukeType, count: number | bigint): void;
|
|
|
|
// Player earns gold from conquering tiles or trade ships from captured
|
|
goldWar(player: Player, captured: Player, gold: number | bigint): void;
|
|
|
|
// Player earns gold from workers
|
|
goldWork(player: Player, gold: number | bigint): void;
|
|
|
|
// Player builds a unit of type
|
|
unitBuild(player: Player, type: OtherUnitType): void;
|
|
|
|
// Player captures a unit of type
|
|
unitCapture(player: Player, type: OtherUnitType): void;
|
|
|
|
// Player upgrades a unit of type
|
|
unitUpgrade(player: Player, type: OtherUnitType): void;
|
|
|
|
// Player destroys a unit of type
|
|
unitDestroy(player: Player, type: OtherUnitType): void;
|
|
|
|
// Player loses a unit of type
|
|
unitLose(player: Player, type: OtherUnitType): void;
|
|
|
|
// player was killed (0 tiles)
|
|
playerKilled(player: Player, tick: number): void;
|
|
|
|
// Record tiles owned at game end (final standings).
|
|
recordFinalTiles(player: Player, tiles: number | bigint): void;
|
|
|
|
// Record that player eliminated human victim at tick (OFM kill scoring).
|
|
recordKill(player: Player, victim: Player, tick: number | bigint): void;
|
|
|
|
// Player's train arrives at any station, generating gold
|
|
trainSelfTrade(player: Player, gold: number | bigint): void;
|
|
|
|
// Another player's train arrives at own station
|
|
trainExternalTrade(player: Player, goldPlayer: number | bigint): void;
|
|
}
|