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

338 строки
15 KiB

  1. import { Entity, Mortal, POV, Creature } from './entity'
  2. import { Damage, DamageType, Stats, Actionable, Action, Vigor, VoreStats } from './combat'
  3. import { LogLines, LogEntry, CompositeLog, LogLine } from './interface'
  4. import { Noun, Pronoun, POVPair, POVPairArgs, ImproperNoun, POVSolo } from './language'
  5. import { DigestAction, DevourAction, ReleaseAction, StruggleAction } from './combat/actions'
  6. export enum VoreType {
  7. Oral = "Oral Vore",
  8. Anal = "Anal Vore",
  9. Cock = "Cock Vore",
  10. Unbirth = "Unbirthing"
  11. }
  12. export abstract class Vore implements Mortal {
  13. abstract name: Noun;
  14. abstract pronouns: Pronoun;
  15. abstract perspective: POV;
  16. abstract vigors: {[key in Vigor]: number};
  17. abstract maxVigors: {[key in Vigor]: number};
  18. abstract disabled: boolean;
  19. abstract resistances: Map<DamageType, number>;
  20. abstract takeDamage (damage: Damage): LogEntry;
  21. abstract stats: Stats;
  22. abstract status: string;
  23. abstract preyPrefs: Set<VoreType>;
  24. abstract voreStats: VoreStats;
  25. abstract containedIn: Container | null;
  26. abstract predPrefs: Set<VoreType>;
  27. abstract containers: Array<Container>;
  28. destroy (): LogEntry {
  29. const lines = new POVSolo<Vore>([
  30. [[POV.First], (target: Vore) => new LogLine('You die!')],
  31. [[POV.Third], (target: Vore) => new LogLine(`${target.name.capital} dies!`)]
  32. ])
  33. this.containers.map(container => {
  34. container.contents.map(prey => {
  35. prey.containedIn = this.containedIn
  36. if (this.containedIn !== null) {
  37. this.containedIn.contents.push(prey)
  38. }
  39. })
  40. })
  41. return lines.run(this)
  42. }
  43. }
  44. export interface Container extends Actionable {
  45. name: Noun;
  46. owner: Vore;
  47. voreTypes: Set<VoreType>;
  48. contents: Array<Vore>;
  49. digested: Array<Vore>;
  50. capacity: number;
  51. fullness: number;
  52. canTake: (prey: Vore) => boolean;
  53. consume: (prey: Vore) => LogEntry;
  54. release: (prey: Vore) => LogEntry;
  55. struggle: (prey: Vore) => LogEntry;
  56. tick: (dt: number) => LogEntry;
  57. describe: () => LogEntry;
  58. digest: (prey: Vore) => LogEntry;
  59. absorb: (prey: Vore) => LogEntry;
  60. dispose: (preys: Vore[]) => LogEntry;
  61. actions: Array<Action>;
  62. }
  63. abstract class NormalContainer implements Container {
  64. contents: Array<Vore>
  65. digested: Array<Vore>
  66. abstract consumeLines: POVPair<Vore, Vore>
  67. abstract releaseLines: POVPair<Vore, Vore>
  68. abstract struggleLines: POVPair<Vore, Vore>
  69. abstract tickLines: POVPairArgs<Vore, Vore, { damage: Damage }>
  70. abstract digestLines: POVPair<Vore, Vore>
  71. abstract absorbLines: POVPair<Vore, Vore>
  72. abstract disposeLines: POVPair<Vore, Vore>
  73. get fullness (): number {
  74. return Array.from(this.contents.values()).reduce((total: number, prey: Vore) => total + prey.voreStats.Bulk, 0)
  75. }
  76. canTake (prey: Vore): boolean {
  77. const fits = this.capacity - this.fullness >= prey.voreStats.Bulk
  78. const permitted = Array.from(this.voreTypes).every(voreType => {
  79. return prey.preyPrefs.has(voreType)
  80. })
  81. return fits && permitted
  82. }
  83. consume (prey: Vore): LogEntry {
  84. this.contents.push(prey)
  85. prey.containedIn = this
  86. return this.consumeLines.run(this.owner, prey)
  87. }
  88. release (prey: Vore): LogEntry {
  89. prey.containedIn = this.owner.containedIn
  90. this.contents = this.contents.filter(victim => victim !== prey)
  91. if (this.owner.containedIn !== null) {
  92. this.owner.containedIn.contents.push(prey)
  93. }
  94. return this.releaseLines.run(this.owner, prey)
  95. }
  96. struggle (prey: Vore): LogEntry {
  97. return this.struggleLines.run(prey, this.owner)
  98. }
  99. tick (dt: number): LogEntry {
  100. const justDigested: Array<Vore> = []
  101. const scaled = this.damage.scale(dt / 60)
  102. const damageResults: Array<LogEntry> = []
  103. this.contents.forEach(prey => {
  104. damageResults.push(prey.takeDamage(scaled))
  105. if (prey.vigors[Vigor.Health] <= 0) {
  106. this.digested.push(prey)
  107. justDigested.push(prey)
  108. }
  109. })
  110. const tickedEntries = new LogLines(...this.contents.map(prey => this.tickLines.run(this.owner, prey, { damage: scaled })))
  111. const digestedEntries = new LogLines(...justDigested.map(prey => this.digest(prey)))
  112. this.contents = this.contents.filter(prey => {
  113. return prey.vigors[Vigor.Health] > 0
  114. })
  115. return new LogLines(tickedEntries, new LogLines(...damageResults), digestedEntries)
  116. }
  117. describe (): LogEntry {
  118. const lines: Array<string> = []
  119. this.contents.forEach(prey => {
  120. lines.push(prey.toString())
  121. })
  122. return new LogLine(...lines)
  123. }
  124. digest (prey: Vore): LogEntry {
  125. return this.digestLines.run(this.owner, prey)
  126. }
  127. absorb (prey: Vore): LogEntry {
  128. return this.absorbLines.run(this.owner, prey)
  129. }
  130. dispose (preys: Vore[]): LogEntry {
  131. return new CompositeLog(...preys.map(prey => this.disposeLines.run(this.owner, prey)))
  132. }
  133. actions: Array<Action>
  134. constructor (public name: Noun, public owner: Vore, public voreTypes: Set<VoreType>, public capacity: number, private damage: Damage) {
  135. this.contents = []
  136. this.digested = []
  137. this.actions = []
  138. this.name = name
  139. this.actions.push(new DevourAction(this))
  140. this.actions.push(new DigestAction(this))
  141. this.actions.push(new ReleaseAction(this))
  142. this.actions.push(new StruggleAction(this))
  143. }
  144. }
  145. abstract class InnerContainer extends NormalContainer {
  146. release (prey: Vore): LogEntry {
  147. prey.containedIn = this.escape
  148. this.contents = this.contents.filter(victim => victim !== prey)
  149. return this.releaseLines.run(this.owner, prey)
  150. }
  151. constructor (name: Noun, owner: Vore, voreTypes: Set<VoreType>, capacity: number, damage: Damage, private escape: Container) {
  152. super(name, owner, voreTypes, capacity, damage)
  153. this.actions = []
  154. this.actions.push(new DigestAction(this))
  155. this.actions.push(new StruggleAction(this))
  156. }
  157. }
  158. export class Stomach extends NormalContainer {
  159. constructor (owner: Vore, capacity: number, damage: Damage) {
  160. super(new ImproperNoun('stomach', 'stomachs').all, owner, new Set([VoreType.Oral]), capacity, damage)
  161. }
  162. consumeLines = new POVPair([
  163. [[POV.First, POV.Third], (user, target) => new LogLine(`You devour ${target.name}`)],
  164. [[POV.Third, POV.First], (user, target) => new LogLine(`${user.name.capital} munches you`)],
  165. [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} munches ${target.name}`)]
  166. ])
  167. releaseLines = new POVPair([
  168. [[POV.First, POV.Third], (user, target) => new LogLine(`You hork up ${target.name}`)],
  169. [[POV.Third, POV.First], (user, target) => new LogLine(`${user.name.capital} horks you up`)],
  170. [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} horks up ${target.name}`)]
  171. ])
  172. struggleLines = new POVPair([
  173. [[POV.First, POV.Third], (user, target) => new LogLine(`You claw your way out of ${target.name}`)],
  174. [[POV.Third, POV.First], (user, target) => new LogLine(`${user.name.capital} forces ${user.pronouns.possessive} way up your throat!`)],
  175. [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} escapes from the gut of ${target.name}`)]
  176. ])
  177. tickLines = new POVPairArgs<Vore, Vore, { damage: Damage }>([
  178. [[POV.First, POV.Third], (user, target, args) => new LogLine(`Your stomach gurgles ${target.name} for `, args.damage.renderShort())],
  179. [[POV.Third, POV.First], (user, target, args) => new LogLine(`${user.name.capital}'s stomach churns you for `, args.damage.renderShort())],
  180. [[POV.Third, POV.Third], (user, target, args) => new LogLine(`${user.name.capital} churns ${target.name} for `, args.damage.renderShort())]
  181. ])
  182. digestLines = new POVPair([
  183. [[POV.First, POV.Third], (user, target) => new LogLine(`Your stomach overwhelms ${target.name}`)],
  184. [[POV.Third, POV.First], (user, target) => new LogLine(`${user.name.capital}'s stomach finishes you off`)],
  185. [[POV.Third, POV.Third], (user, target) => new LogLine(`${target.name.capital}'s squirms fade, overwhelmed by the stomach of ${user.name}`)]
  186. ])
  187. absorbLines = new POVPair([
  188. [[POV.First, POV.Third], (user, target) => new LogLine(`Your guts completely absorb ${target.name}`)],
  189. [[POV.Third, POV.First], (user, target) => new LogLine(`${user.name.capital}'s guts soak you up like water in a sponge`)],
  190. [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} finishes absorbing the remains of ${target.name}`)]
  191. ])
  192. disposeLines = new POVPair([
  193. [[POV.First, POV.Third], (user, target) => new LogLine(`Your guts completely absorb ${target.name}`)],
  194. [[POV.Third, POV.First], (user, target) => new LogLine(`${user.name.capital}'s guts soak you up like water in a sponge`)],
  195. [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} finishes absorbing the remains of ${target.name}`)]
  196. ])
  197. }
  198. export class InnerStomach extends InnerContainer {
  199. constructor (owner: Vore, capacity: number, damage: Damage, escape: Container) {
  200. super(new ImproperNoun('inner stomach', 'inner stomachs').all, owner, new Set([VoreType.Oral]), capacity, damage, escape)
  201. }
  202. consumeLines = new POVPair([
  203. [[POV.First, POV.Third], (user, target) => new LogLine(`You devour ${target.name}`)],
  204. [[POV.Third, POV.First], (user, target) => new LogLine(`${user.name.capital} munches you`)],
  205. [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} munches ${target.name.capital}`)]
  206. ])
  207. releaseLines = new POVPair([
  208. [[POV.First, POV.Third], (user, target) => new LogLine(`You hork up ${target.name}`)],
  209. [[POV.Third, POV.First], (user, target) => new LogLine(`${user.name.capital} horks you up`)],
  210. [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} horks up ${target.name.capital}`)]
  211. ])
  212. struggleLines = new POVPair([
  213. [[POV.First, POV.Third], (user, target) => new LogLine(`You claw your way out of ${target.name}`)],
  214. [[POV.Third, POV.First], (user, target) => new LogLine(`${user.name.capital} forces ${user.pronouns.possessive} way up your throat!`)],
  215. [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} escapes from the gut of ${target.name}`)]
  216. ])
  217. tickLines = new POVPairArgs<Vore, Vore, { damage: Damage }>([
  218. [[POV.First, POV.Third], (user, target, args) => new LogLine(`Your stomach gurgles ${target.name} for `, args.damage.renderShort())],
  219. [[POV.Third, POV.First], (user, target, args) => new LogLine(`${user.name.capital}'s stomach churns you for `, args.damage.renderShort())],
  220. [[POV.Third, POV.Third], (user, target, args) => new LogLine(`${user.name.capital} churns ${target.name} for `, args.damage.renderShort())]
  221. ])
  222. digestLines = new POVPair([
  223. [[POV.First, POV.Third], (user, target) => new LogLine(`Your stomach overwhelms ${target.name}`)],
  224. [[POV.Third, POV.First], (user, target) => new LogLine(`${user.name.capital}'s stomach finishes you off`)],
  225. [[POV.Third, POV.Third], (user, target) => new LogLine(`${target.name.capital}'s squirms fade, overwhelmed by the stomach of ${user.name}`)]
  226. ])
  227. absorbLines = new POVPair([
  228. [[POV.First, POV.Third], (user, target) => new LogLine(`Your guts completely absorb ${target.name}`)],
  229. [[POV.Third, POV.First], (user, target) => new LogLine(`${user.name.capital}'s guts soak you up like water in a sponge`)],
  230. [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} finishes absorbing the remains of ${target.name}`)]
  231. ])
  232. disposeLines = new POVPair([
  233. [[POV.First, POV.Third], (user, target) => new LogLine(`Your guts completely absorb ${target.name}`)],
  234. [[POV.Third, POV.First], (user, target) => new LogLine(`${user.name.capital}'s guts soak you up like water in a sponge`)],
  235. [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} finishes absorbing the remains of ${target.name}`)]
  236. ])
  237. }
  238. export class Bowels extends NormalContainer {
  239. constructor (owner: Vore, capacity: number, damage: Damage) {
  240. super(new ImproperNoun('bowel', 'bowels').plural, owner, new Set([VoreType.Anal]), capacity, damage)
  241. }
  242. consumeLines = new POVPair([
  243. [[POV.First, POV.Third], (user, target) => new LogLine(`You force ${target.name} into your bowels`)],
  244. [[POV.Third, POV.First], (user, target) => new LogLine(`${user.name.capital} works you into ${user.pronouns.possessive} ass`)],
  245. [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} anal-vores ${target.name.capital}`)]
  246. ])
  247. releaseLines = new POVPair([
  248. [[POV.First, POV.Third], (user, target) => new LogLine(`You let out ${target.name}`)],
  249. [[POV.Third, POV.First], (user, target) => new LogLine(`${user.name.capital} lets you out `)],
  250. [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} lets out ${target.name.capital}`)]
  251. ])
  252. struggleLines = new POVPair([
  253. [[POV.First, POV.Third], (user, target) => new LogLine(`You claw your way out of ${target.name}`)],
  254. [[POV.Third, POV.First], (user, target) => new LogLine(`${user.name.capital} forces ${user.pronouns.possessive} way out your rump!`)],
  255. [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} escapes from the bowels of ${target.name}`)]
  256. ])
  257. tickLines = new POVPairArgs<Vore, Vore, { damage: Damage }>([
  258. [[POV.First, POV.Third], (user, target, args) => new LogLine(`Your bowels gurgle ${target.name} for `, args.damage.renderShort())],
  259. [[POV.Third, POV.First], (user, target, args) => new LogLine(`${user.name.capital}'s bowels churn you for `, args.damage.renderShort())],
  260. [[POV.Third, POV.Third], (user, target, args) => new LogLine(`${target.name.capital} churns ${user.name} for `, args.damage.renderShort())]
  261. ])
  262. digestLines = new POVPair([
  263. [[POV.First, POV.Third], (user, target) => new LogLine(`Your bowels overwhelm ${target.name}`)],
  264. [[POV.Third, POV.First], (user, target) => new LogLine(`${user.name.capital}'s bowels finish you off`)],
  265. [[POV.Third, POV.Third], (user, target) => new LogLine(`${target.name.capital}'s squirms fade, overwhelmed by the bowels of ${user.name}`)]
  266. ])
  267. absorbLines = new POVPair([
  268. [[POV.First, POV.Third], (user, target) => new LogLine(`Your guts completely absorb ${target.name}`)],
  269. [[POV.Third, POV.First], (user, target) => new LogLine(`${user.name.capital}'s guts soak you up like water in a sponge`)],
  270. [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} finishes absorbing the remains of ${target.name}`)]
  271. ])
  272. disposeLines = new POVPair([
  273. [[POV.First, POV.Third], (user, target) => new LogLine(`Your guts completely absorb ${target.name}`)],
  274. [[POV.Third, POV.First], (user, target) => new LogLine(`${user.name.capital}'s guts soak you up like water in a sponge`)],
  275. [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} finishes absorbing the remains of ${target.name}`)]
  276. ])
  277. }