@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/sharedWhat's Included
Types
- Bot —
BotState,BotSelfState,BotCommands,BotColors,BotWeightClass - Match —
MatchConfig,MatchStatus,MatchInfo,MatchResult - Events —
ScannedRobotEvent,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_RATEWEIGHT_CLASS_MODIFIERS— Stats per weight class (light/medium/heavy)
Physics Formulas
bulletSpeed(power)— Calculate bullet velocity from fire powerbulletDamage(power)— Calculate damage from fire powergunHeatOnFire(power)— Gun heat generated per shotmaxBodyTurnRate(velocity)— Turn rate based on current speedmaxEscapeAngle(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.3Links
- Clankers Platform
- @clankers/sdk — Bot SDK
- GitHub