Match.js

claude-of-duty · game-rules, score-tracking, respawn-logic, kill-feed, match-summary, realtime

Team-deathmatch rules: score, clock, respawns, kill feed events and the end-of-match summary. Kept free of rendering and input so the whole match can be simulated headlessly in a test. /

/**
 * Team-deathmatch rules: score, clock, respawns, kill feed events and the
 * end-of-match summary. Kept free of rendering and input so the whole match can
 * be simulated headlessly in a test.
 */

const CALLSIGNS_A = ['HAWK', 'VIPER', 'ATLAS', 'RONIN', 'CIPHER', 'ORACLE', 'BISHOP', 'NOMAD'];
const CALLSIGNS_B = ['JACKAL', 'SPECTRE', 'KILO', 'ONYX', 'HAVOC', 'WRAITH', 'TALON', 'ZEALOT'];

export class Match {
  constructor({ scoreLimit = 40, timeLimit = 600, respawnDelay = 3.0 } = {}) {
    this.scoreLimit = scoreLimit;
    this.timeLimit = timeLimit;
    this.respawnDelay = respawnDelay;
    this.reset();
    this.onEnd = null;
    this.onKill = null;
  }

  reset() {
    this.scores = { A: 0, B: 0 };
    this.timeLeft = this.timeLimit;
    this.running = false;
    this.ended = fals

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key