Log inGet started
Package

rules.module

README.md

game.rules

BATTLEBOX's constants, rules and live match state, shared by every part of the game. require("game.rules").

  • Constants: TITLE, PLAYER ("HAVOC"), RIVAL ("RIPTIDE"), COLORS palette, MATCH_SECONDS (180), COUNTDOWN_SECONDS, KO_COUNT_SECONDS (10), IMMOBILE_SPEED, MAX_HEALTH (100), ARENA (16 x 16 m box, wall height, camera inset), STARTS (start squares, yaw), HAZARDS (every floor saw, kill-saw slot, the screw pit and the four pulverizers, with damage footprints), BOT_SPECS (size, mass, drive, weapon RPM and damage).
  • Rules: weaponDamage(attacker, rpm) = maxHitDamage x (rpm/maxRpm)^2, zero below 20% spin; weaponKnockback; hazardAt(x, z); decide() for the judges (more damage dealt wins, then more health, then RIPTIDE).
  • State (per peer, single-player vs the AI): state(), bot(name), opponent(name), isLive(); phases free / title / countdown / fight / ko / decision.
  • Mutations: registerBot, setPhase, applyDamage(victim, amount, cause, attacker?), reset().
  • Events: on(event, fn) returns an unsubscribe; emit(event, payload). Events: phase, hit, hazard, damage, destroyed, ko, decision, reset, weapon, pulverize.
  • Camera: kickCamera(0..1), setShot("chase" | "faceoff" | "orbit", focus?), read by game.ArenaCam.
  • formatClock(seconds) -> "2:14".

State lives in modules.state(), so it survives hot reloads. Owned by the plan step; slices read it and may ask for additions in design/spec.md.