|  | import { TextLike, LiveText, DynText, Word, ImproperNoun, Verb } from './language'
import { Actionable, Action, DamageFormula, ConstantDamageFormula, Damage, DamageType, Vigor, StatDamageFormula, Stat } from './combat'
import { AttackAction } from './combat/actions'
export enum ItemKind {
  Key = "Key Item",
  Consumable = "Consumable",
  Equipment = "Equipment"
}
export const ItemKindIcons: {[key in ItemKind]: string} = {
  [ItemKind.Key]: "fas fa-key",
  [ItemKind.Consumable]: "fas fa-wine-bottle",
  [ItemKind.Equipment]: "fas fa-hammer"
}
export abstract class Item implements Actionable {
  abstract kind: ItemKind;
  abstract actions: Array<Action>;
  constructor (public name: Word, public desc: TextLike) {
  }
}
export enum EquipmentSlot {
  Head = "Head",
  Chest = "Chest",
  Legs = "Legs",
  Arms = "Arms",
  MainHand = "MainHand",
  OffHand = "OffHand",
  Feet = "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 (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 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')
    )
  }
}
 |