|
|
|
@@ -2,57 +2,100 @@ import { TextLike, LiveText, DynText, Word, ImproperNoun, Verb } from './languag |
|
|
|
import { Actionable, Action, DamageFormula, ConstantDamageFormula, Damage, DamageType, Vigor, StatDamageFormula, Stat } from './combat' |
|
|
|
import { AttackAction } from './combat/actions' |
|
|
|
|
|
|
|
export interface Item extends Actionable { |
|
|
|
name: Word; |
|
|
|
desc: TextLike; |
|
|
|
export enum ItemKind { |
|
|
|
Key, |
|
|
|
Consumable, |
|
|
|
Equipment |
|
|
|
} |
|
|
|
|
|
|
|
export class Weapon implements Actionable { |
|
|
|
export abstract class Item implements Actionable { |
|
|
|
abstract kind: ItemKind; |
|
|
|
abstract actions: Array<Action>; |
|
|
|
|
|
|
|
constructor (public name: Word, public desc: TextLike) { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
export enum EquipmentSlot { |
|
|
|
Head, |
|
|
|
Chest, |
|
|
|
Legs, |
|
|
|
Arms, |
|
|
|
MainHand, |
|
|
|
OffHand, |
|
|
|
Feet |
|
|
|
} |
|
|
|
|
|
|
|
export abstract class Equipment extends Item { |
|
|
|
kind = ItemKind.Equipment |
|
|
|
abstract slot: EquipmentSlot |
|
|
|
} |
|
|
|
|
|
|
|
export abstract class Weapon extends Equipment { |
|
|
|
actions: Array<Action> = [] |
|
|
|
slot = EquipmentSlot.MainHand |
|
|
|
|
|
|
|
constructor (public name: Word, public desc: TextLike, damageFormula: DamageFormula, verb: Verb) { |
|
|
|
constructor (name: Word, desc: TextLike, damageFormula: DamageFormula, verb: Verb) { |
|
|
|
super(name, desc) |
|
|
|
const attack = new AttackAction(damageFormula, verb) |
|
|
|
attack.desc = new DynText(`Attack with your `, this.name.all) |
|
|
|
this.actions.push(attack) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
export const Sword = new Weapon( |
|
|
|
new ImproperNoun('sword', 'swords'), |
|
|
|
'An arming sword', |
|
|
|
new StatDamageFormula([ |
|
|
|
{ fraction: 0.35, stat: Stat.Power, target: Vigor.Health, type: DamageType.Slash }, |
|
|
|
{ fraction: 0.25, stat: Stat.Power, target: Vigor.Health, type: DamageType.Pierce } |
|
|
|
]), |
|
|
|
new Verb('slash', 'slashes') |
|
|
|
) |
|
|
|
|
|
|
|
export const Dagger = new Weapon( |
|
|
|
new ImproperNoun('dagger', 'daggers'), |
|
|
|
'A pointy dagger', |
|
|
|
new StatDamageFormula([ |
|
|
|
{ fraction: 0.50, stat: Stat.Speed, target: Vigor.Health, type: DamageType.Pierce }, |
|
|
|
{ fraction: 0.05, stat: Stat.Speed, target: Vigor.Health, type: DamageType.Slash } |
|
|
|
]), |
|
|
|
new Verb('stab', 'stabs', 'stabbing', 'stabbed') |
|
|
|
) |
|
|
|
|
|
|
|
export const Wand = new Weapon( |
|
|
|
new ImproperNoun('wand', 'wands'), |
|
|
|
'A magical wand', |
|
|
|
new StatDamageFormula([ |
|
|
|
{ fraction: 0.25, stat: Stat.Charm, target: Vigor.Health, type: DamageType.Crush }, |
|
|
|
{ fraction: 0.25, stat: Stat.Willpower, target: Vigor.Health, type: DamageType.Crush } |
|
|
|
]), |
|
|
|
new Verb('zap', 'zaps', 'zapping', 'zapped') |
|
|
|
) |
|
|
|
|
|
|
|
export const Mace = new Weapon( |
|
|
|
new ImproperNoun('mace', 'maces'), |
|
|
|
'A heavy mace', |
|
|
|
new StatDamageFormula([ |
|
|
|
{ fraction: 0.4, stat: Stat.Power, target: Vigor.Health, type: DamageType.Crush }, |
|
|
|
{ fraction: 0.2, stat: Stat.Power, target: Vigor.Health, type: DamageType.Pierce } |
|
|
|
]), |
|
|
|
new Verb('bash', 'bashes', 'bashing', 'bashed') |
|
|
|
) |
|
|
|
export class Sword extends Weapon { |
|
|
|
constructor () { |
|
|
|
super( |
|
|
|
new ImproperNoun('sword', 'swords'), |
|
|
|
'An arming sword', |
|
|
|
new StatDamageFormula([ |
|
|
|
{ fraction: 0.35, stat: Stat.Power, target: Vigor.Health, type: DamageType.Slash }, |
|
|
|
{ fraction: 0.25, stat: Stat.Power, target: Vigor.Health, type: DamageType.Pierce } |
|
|
|
]), |
|
|
|
new Verb('slash', 'slashes') |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
export class Dagger extends Weapon { |
|
|
|
constructor () { |
|
|
|
super( |
|
|
|
new ImproperNoun('dagger', 'daggers'), |
|
|
|
'A pointy dagger', |
|
|
|
new StatDamageFormula([ |
|
|
|
{ fraction: 0.50, stat: Stat.Speed, target: Vigor.Health, type: DamageType.Pierce }, |
|
|
|
{ fraction: 0.05, stat: Stat.Speed, target: Vigor.Health, type: DamageType.Slash } |
|
|
|
]), |
|
|
|
new Verb('stab', 'stabs', 'stabbing', 'stabbed') |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
export class Wand extends Weapon { |
|
|
|
constructor () { |
|
|
|
super( |
|
|
|
new ImproperNoun('wand', 'wands'), |
|
|
|
'A magical wand', |
|
|
|
new StatDamageFormula([ |
|
|
|
{ fraction: 0.25, stat: Stat.Charm, target: Vigor.Health, type: DamageType.Crush }, |
|
|
|
{ fraction: 0.25, stat: Stat.Willpower, target: Vigor.Health, type: DamageType.Crush } |
|
|
|
]), |
|
|
|
new Verb('zap', 'zaps', 'zapping', 'zapped') |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
export class Mace extends Weapon { |
|
|
|
constructor () { |
|
|
|
super( |
|
|
|
new ImproperNoun('mace', 'maces'), |
|
|
|
'A heavy mace', |
|
|
|
new StatDamageFormula([ |
|
|
|
{ fraction: 0.4, stat: Stat.Power, target: Vigor.Health, type: DamageType.Crush }, |
|
|
|
{ fraction: 0.2, stat: Stat.Power, target: Vigor.Health, type: DamageType.Pierce } |
|
|
|
]), |
|
|
|
new Verb('bash', 'bashes', 'bashing', 'bashed') |
|
|
|
) |
|
|
|
} |
|
|
|
} |