Feast 2.0!
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 

133 рядки
4.3 KiB

  1. import { StatusEffect, Damage, DamageType, Action, Condition } from '../combat'
  2. import { DynText, LiveText, ToBe, Verb } from '../language'
  3. import { Creature } from "../creature"
  4. import { LogLine, LogEntry, LogLines, FAElem, nilLog } from '../interface'
  5. export class InstantKillEffect extends StatusEffect {
  6. constructor () {
  7. super('Instant Kill', 'Instant kill!', 'fas fa-skull')
  8. }
  9. onApply (creature: Creature) {
  10. creature.vigors.Health = 0
  11. creature.removeEffect(this)
  12. return new LogLines(
  13. new LogLine(
  14. `${creature.name.capital} ${creature.name.conjugate(new ToBe())} killed instantly! `,
  15. new FAElem('fas fa-skull')
  16. ),
  17. creature.takeDamage(new Damage())
  18. )
  19. }
  20. }
  21. export class StunEffect extends StatusEffect {
  22. constructor (private duration: number) {
  23. super('Stun', 'Cannot act!', 'fas fa-sun')
  24. this.desc = new DynText('Stunned for your next ', new LiveText(this, x => x.duration), ' actions!')
  25. }
  26. get topLeft () {
  27. return this.duration.toString()
  28. }
  29. onApply (creature: Creature) {
  30. return new LogLine(`${creature.name.capital} ${creature.name.conjugate(new ToBe())} is stunned!`)
  31. }
  32. onRemove (creature: Creature) {
  33. return new LogLine(`${creature.name.capital} ${creature.name.conjugate(new ToBe())} no longer stunned.`)
  34. }
  35. preTurn (creature: Creature): { prevented: boolean; log: LogEntry } {
  36. if (--this.duration <= 0) {
  37. return {
  38. prevented: true,
  39. log: new LogLines(
  40. `${creature.name.capital} ${creature.name.conjugate(new ToBe())} stunned! ${creature.pronouns.capital.subjective} can't move.`,
  41. creature.removeEffect(this)
  42. )
  43. }
  44. } else {
  45. return {
  46. prevented: true,
  47. log: new LogLines(
  48. `${creature.name.capital} ${creature.name.conjugate(new ToBe())} stunned! ${creature.pronouns.capital.subjective} can't move!`
  49. )
  50. }
  51. }
  52. }
  53. }
  54. export class ShieldEffect extends StatusEffect {
  55. constructor (private damageTypes: DamageType[], private amount: number) {
  56. super('Shield', 'Block a fraction of incoming damage', 'fas fa-shield-alt')
  57. }
  58. onApply (creature: Creature) {
  59. return new LogLine(`${creature.name.capital} ${creature.name.conjugate(new Verb('gain'))} a shield!`)
  60. }
  61. onRemove (creature: Creature) {
  62. return new LogLine(`${creature.name.capital} ${creature.name.conjugate(new Verb('lose'))} ${creature.pronouns.possessive} shield!`)
  63. }
  64. preDamage (creature: Creature, damage: Damage) {
  65. return damage.scale(this.amount)
  66. }
  67. }
  68. export class PredatorCounterEffect extends StatusEffect {
  69. constructor (private devour: Action, private chance: number) {
  70. super('Predatory Counter', 'Eat them back', 'fas fa-redo')
  71. this.desc = new DynText(new LiveText(this, x => (x.chance * 100).toFixed(0)), '% chance to devour your attackers')
  72. }
  73. preAttack (creature: Creature, attacker: Creature) {
  74. if (this.devour.allowed(creature, attacker) && Math.random() < this.chance) {
  75. return {
  76. prevented: true,
  77. log: new LogLines(
  78. `${creature.name.capital} ${creature.name.conjugate(new Verb('surprise'))} ${attacker.name.objective} and ${creature.name.conjugate(new Verb('try', 'tries'))} to devour ${attacker.pronouns.objective}!`,
  79. this.devour.execute(creature, attacker)
  80. )
  81. }
  82. } else {
  83. return { prevented: false, log: nilLog }
  84. }
  85. }
  86. }
  87. export class UntouchableEffect extends StatusEffect {
  88. constructor () {
  89. super('Untouchable', 'Cannot be attacked', 'fas fa-times')
  90. }
  91. preAttack (creature: Creature, attacker: Creature) {
  92. return {
  93. prevented: true,
  94. log: new LogLine(`${creature.name.capital} cannot be attacked.`)
  95. }
  96. }
  97. }
  98. export class DazzlingEffect extends StatusEffect {
  99. constructor (private conditions: Condition[]) {
  100. super('Dazzling', 'Stuns enemies who try to affect this creature', 'fas fa-spinner')
  101. }
  102. preReceiveAction (creature: Creature, attacker: Creature) {
  103. if (this.conditions.every(cond => cond.allowed(creature, attacker))) {
  104. attacker.applyEffect(new StunEffect(1))
  105. return {
  106. prevented: true,
  107. log: new LogLine(`${attacker.name.capital} can't act against ${creature.name.objective}!`)
  108. }
  109. } else {
  110. return {
  111. prevented: false,
  112. log: nilLog
  113. }
  114. }
  115. }
  116. }