Feast 2.0!
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

122 строки
3.1 KiB

  1. import { Consequence, DamageFormula, Condition, StatusEffect } from '../combat'
  2. import { Creature } from '../creature'
  3. import { LogEntry, LogLines, LogLine, nilLog } from '../interface'
  4. import { Verb, PairLine } from '../language'
  5. import { Container } from '../vore'
  6. /**
  7. * Takes a function, and thus can do anything.
  8. */
  9. export class ArbitraryConsequence extends Consequence {
  10. constructor (
  11. public apply: (user: Creature, target: Creature) => LogEntry,
  12. public describe: (user: Creature, target: Creature) => LogEntry,
  13. conditions: Condition[] = []
  14. ) {
  15. super(conditions)
  16. }
  17. }
  18. /**
  19. * Renders some text.
  20. */
  21. export class LogConsequence extends Consequence {
  22. constructor (private line: PairLine<Creature>, conditions: Condition[] = []) {
  23. super(conditions)
  24. }
  25. apply (user: Creature, target: Creature): LogEntry {
  26. return this.line(user, target)
  27. }
  28. describe (user: Creature, target: Creature): LogEntry {
  29. return nilLog
  30. }
  31. }
  32. /**
  33. * Deals damage.
  34. */
  35. export class DamageConsequence extends Consequence {
  36. constructor (private damageFormula: DamageFormula, conditions: Condition[] = []) {
  37. super(conditions)
  38. }
  39. apply (user: Creature, target: Creature): LogEntry {
  40. const damage = this.damageFormula.calc(user, target)
  41. return new LogLines(
  42. new LogLine(`${target.name.capital} ${target.name.conjugate(new Verb('take'))} `, damage.renderShort(), ` damage!`),
  43. target.takeDamage(damage)
  44. )
  45. }
  46. describe (user: Creature, target: Creature): LogEntry {
  47. return new LogLine(
  48. this.damageFormula.describe(user, target)
  49. )
  50. }
  51. }
  52. /**
  53. * Same as [[DamageConsequence]], but it has healing text
  54. */
  55. export class HealingConsequence extends Consequence {
  56. constructor (private damageFormula: DamageFormula, conditions: Condition[] = []) {
  57. super(conditions)
  58. }
  59. apply (user: Creature, target: Creature): LogEntry {
  60. const damage = this.damageFormula.calc(user, target)
  61. return new LogLines(
  62. new LogLine(`${target.name.capital} ${target.name.conjugate(new Verb('heal'))} `, damage.renderShort(), `!`),
  63. target.takeDamage(damage)
  64. )
  65. }
  66. describe (user: Creature, target: Creature): LogEntry {
  67. return new LogLine(
  68. `Heals for `,
  69. this.damageFormula.describe(user, target)
  70. )
  71. }
  72. }
  73. /**
  74. * Applies a status effect
  75. */
  76. export class StatusConsequence extends Consequence {
  77. constructor (public statusMaker: (user: Creature, target: Creature) => StatusEffect, conditions: Condition[] = []) {
  78. super(conditions)
  79. }
  80. apply (user: Creature, target: Creature): LogEntry {
  81. return target.applyEffect(this.statusMaker(user, target))
  82. }
  83. describe (user: Creature, target: Creature): LogEntry {
  84. return new LogLine(
  85. `Applies a ${this.statusMaker(user, target)} effect.`
  86. )
  87. }
  88. }
  89. /**
  90. * Consumes the target
  91. */
  92. export class ConsumeConsequence extends Consequence {
  93. constructor (public container: Container, conditions: Condition[] = []) {
  94. super(conditions)
  95. }
  96. apply (user: Creature, target: Creature): LogEntry {
  97. return this.container.consume(target)
  98. }
  99. describe (user: Creature, target: Creature): LogEntry {
  100. return new LogLine(
  101. `Devours the target.`
  102. )
  103. }
  104. }