Feast 2.0!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

102 lines
2.7 KiB

  1. import { TextLike, LiveText, DynText, Word, ImproperNoun, Verb } from './language'
  2. import { Actionable, Action, DamageFormula, ConstantDamageFormula, Damage, DamageType, Vigor, StatDamageFormula, Stat } from './combat'
  3. import { AttackAction } from './combat/actions'
  4. export enum ItemKind {
  5. Key,
  6. Consumable,
  7. Equipment
  8. }
  9. export abstract class Item implements Actionable {
  10. abstract kind: ItemKind;
  11. abstract actions: Array<Action>;
  12. constructor (public name: Word, public desc: TextLike) {
  13. }
  14. }
  15. export enum EquipmentSlot {
  16. Head,
  17. Chest,
  18. Legs,
  19. Arms,
  20. MainHand,
  21. OffHand,
  22. Feet
  23. }
  24. export abstract class Equipment extends Item {
  25. kind = ItemKind.Equipment
  26. abstract slot: EquipmentSlot
  27. }
  28. export abstract class Weapon extends Equipment {
  29. actions: Array<Action> = []
  30. slot = EquipmentSlot.MainHand
  31. constructor (name: Word, desc: TextLike, damageFormula: DamageFormula, verb: Verb) {
  32. super(name, desc)
  33. const attack = new AttackAction(damageFormula, verb)
  34. attack.desc = new DynText(`Attack with your `, this.name.all)
  35. this.actions.push(attack)
  36. }
  37. }
  38. export class Sword extends Weapon {
  39. constructor () {
  40. super(
  41. new ImproperNoun('sword', 'swords'),
  42. 'An arming sword',
  43. new StatDamageFormula([
  44. { fraction: 0.35, stat: Stat.Power, target: Vigor.Health, type: DamageType.Slash },
  45. { fraction: 0.25, stat: Stat.Power, target: Vigor.Health, type: DamageType.Pierce }
  46. ]),
  47. new Verb('slash', 'slashes')
  48. )
  49. }
  50. }
  51. export class Dagger extends Weapon {
  52. constructor () {
  53. super(
  54. new ImproperNoun('dagger', 'daggers'),
  55. 'A pointy dagger',
  56. new StatDamageFormula([
  57. { fraction: 0.50, stat: Stat.Speed, target: Vigor.Health, type: DamageType.Pierce },
  58. { fraction: 0.05, stat: Stat.Speed, target: Vigor.Health, type: DamageType.Slash }
  59. ]),
  60. new Verb('stab', 'stabs', 'stabbing', 'stabbed')
  61. )
  62. }
  63. }
  64. export class Wand extends Weapon {
  65. constructor () {
  66. super(
  67. new ImproperNoun('wand', 'wands'),
  68. 'A magical wand',
  69. new StatDamageFormula([
  70. { fraction: 0.25, stat: Stat.Charm, target: Vigor.Health, type: DamageType.Crush },
  71. { fraction: 0.25, stat: Stat.Willpower, target: Vigor.Health, type: DamageType.Crush }
  72. ]),
  73. new Verb('zap', 'zaps', 'zapping', 'zapped')
  74. )
  75. }
  76. }
  77. export class Mace extends Weapon {
  78. constructor () {
  79. super(
  80. new ImproperNoun('mace', 'maces'),
  81. 'A heavy mace',
  82. new StatDamageFormula([
  83. { fraction: 0.4, stat: Stat.Power, target: Vigor.Health, type: DamageType.Crush },
  84. { fraction: 0.2, stat: Stat.Power, target: Vigor.Health, type: DamageType.Pierce }
  85. ]),
  86. new Verb('bash', 'bashes', 'bashing', 'bashed')
  87. )
  88. }
  89. }