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.
 
 
 
 
 

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