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.
 
 
 
 
 

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