@clankers/shared

v0.2.0

Published

Shared types and constants for the Clankers platform

Readme

@clankers/shared

Shared types, constants, and physics formulas for the Clankers platform.

Installation

npm install @clankers/shared

What's Included

Types

  • BotBotState, BotSelfState, BotCommands, BotColors, BotWeightClass
  • MatchMatchConfig, MatchStatus, MatchInfo, MatchResult
  • EventsScannedRobotEvent, BulletHitEvent, HitByBulletEvent, and more
  • Protocol — WebSocket message types (TickMessage, CommandsMessage, etc.)
  • API — Request/response types for the REST API

Constants

  • MAX_VELOCITY, BOT_SIZE, SCAN_RANGE, GUN_TURN_RATE
  • WEIGHT_CLASS_MODIFIERS — Stats per weight class (light/medium/heavy)

Physics Formulas

  • bulletSpeed(power) — Calculate bullet velocity from fire power
  • bulletDamage(power) — Calculate damage from fire power
  • gunHeatOnFire(power) — Gun heat generated per shot
  • maxBodyTurnRate(velocity) — Turn rate based on current speed
  • maxEscapeAngle(power) — Maximum dodge angle for a bullet

Usage

import { MAX_VELOCITY, bulletDamage, WEIGHT_CLASS_MODIFIERS } from '@clankers/shared';
import type { BotCommands, ScannedRobotEvent } from '@clankers/shared';

// Calculate damage for a power-3 shot
const damage = bulletDamage(3); // 12

// Get heavy class modifiers
const heavy = WEIGHT_CLASS_MODIFIERS.heavy;
console.log(heavy.damageMultiplier); // 1.3

Links