UNPKG

programming-game

Version:

The client for programming game, an mmorpg that you interact with entirely through code.

187 lines (183 loc) 3.59 kB
import { BaseIntent, IntentType, StatusEffectMechanics, StatusEffectName, } from "./types"; import { UnitStats } from "./unit-stats"; export enum CastType { channel, instant, castTime, } export interface CastIntent extends BaseIntent { type: IntentType.cast; spell: Spells; target?: string; } type SpellDefinition<T> = ChannelSpell<T> | InstantSpell<T> | CastTimeSpell<T>; type BaseSpell<T> = { calories?: number; cost: number; damage?: number; heal?: number; id: T; target: SpellTarget; castType: CastType; range: number; statusEffect?: { name: StatusEffectName; stackable: boolean; duration: number; effects: { [StatusEffectMechanics: string]: number; }; stats?: Partial<UnitStats>; }; }; interface ChannelSpell<T> extends BaseSpell<T> { castType: CastType.channel; } interface InstantSpell<T> extends BaseSpell<T> { castType: CastType.instant; } interface CastTimeSpell<T> extends BaseSpell<T> { castType: CastType.castTime; minCastTime: number; } export type Spells = | "aid_digestion" | "heal" | "regen" | "fireball" | "ballOfIce" | "chill" | "icicle" | "flashFreeze" | "iceArmor"; export type SpellMap = Record<Spells, SpellDefinition<Spells>>; export type SpellTarget = "self" | "hostile" | "ally" | "player" | "any"; export const spellMap = { aid_digestion: { id: "aid_digestion", castType: CastType.channel, target: "any", cost: 5, range: 10, damage: 0, heal: 5, calories: 1, }, heal: { id: "heal", castType: CastType.castTime, target: "any", cost: 5, minCastTime: 1_500, range: 10, heal: 10, }, regen: { id: "regen", castType: CastType.instant, target: "any", cost: 3, range: 10, statusEffect: { name: "regen", duration: 12_000, stackable: false, effects: { [StatusEffectMechanics.hot]: 3, }, }, damage: 0, }, chill: { id: "chill", castType: CastType.instant, target: "any", cost: 3, range: 10, statusEffect: { name: "chill", duration: 5_000, stackable: false, effects: { [StatusEffectMechanics.slow]: 0.5, }, stats: { movementSpeed: -1, }, }, damage: 0, }, ballOfIce: { id: "ballOfIce", castType: CastType.castTime, target: "any", cost: 5, minCastTime: 3_000, range: 10, damage: 3, }, flashFreeze: { id: "flashFreeze", castType: CastType.instant, target: "any", cost: 5, range: 10, damage: 0, statusEffect: { name: "freeze", duration: 5_000, stackable: false, effects: { [StatusEffectMechanics.stun]: 1, }, }, }, icicle: { id: "icicle", castType: CastType.castTime, target: "any", cost: 5, minCastTime: 3_000, range: 10, damage: 5, }, iceArmor: { id: "iceArmor", castType: CastType.castTime, target: "self", cost: 5, minCastTime: 2_000, range: 10, damage: 0, statusEffect: { name: "iceArmor", duration: 60_000, stackable: false, effects: { [StatusEffectMechanics.shield]: 50, }, }, }, fireball: { id: "fireball", castType: CastType.castTime, target: "any", cost: 7, damage: 15, statusEffect: { name: "burn", duration: 5_000, stackable: false, effects: { [StatusEffectMechanics.dot]: 1, }, }, minCastTime: 3_000, range: 10, }, } satisfies SpellMap;