From 576a2d597f1e05a823a960bc12b461768bf73937 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Sun, 12 Jul 2020 18:15:25 -0400 Subject: [PATCH] Make prey spill out when the pred dies --- src/game/entity.ts | 12 +++++++++++- src/game/vore.ts | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/game/entity.ts b/src/game/entity.ts index 0d1528e..98bce6f 100644 --- a/src/game/entity.ts +++ b/src/game/entity.ts @@ -19,9 +19,10 @@ export interface Mortal extends Entity { takeDamage: (damage: Damage) => void; stats: Stats; status: string; + destroy: () => void; } -export class Creature implements Mortal, Vore, Vore, Combatant { +export class Creature extends Vore implements Combatant { vigors = { [Vigor.Health]: 100, [Vigor.Stamina]: 100, @@ -52,6 +53,7 @@ export class Creature implements Mortal, Vore, Vore, Combatant { containedIn: Container|null = null; constructor (public name: Noun, public pronouns: Pronoun, public stats: Stats, public preyPrefs: Set, public predPrefs: Set, bulk: number) { + super() this.baseBulk = bulk } @@ -68,6 +70,10 @@ export class Creature implements Mortal, Vore, Vore, Combatant { this.vigors[instance.target] -= instance.amount } }) + + if (this.vigors.Health <= -100) { + this.destroy() + } } get status (): string { @@ -106,4 +112,8 @@ export class Creature implements Mortal, Vore, Vore, Combatant { return action.allowed(this, target) }) } + + destroy (): void { + super.destroy() + } } diff --git a/src/game/vore.ts b/src/game/vore.ts index 17ff778..ac87946 100644 --- a/src/game/vore.ts +++ b/src/game/vore.ts @@ -1,7 +1,7 @@ import { Entity, Mortal, POV, Creature } from './entity' -import { Damage, Actionable, Action, DevourAction, FeedAction, DigestAction, ReleaseAction, StruggleAction, Vigor } from './combat' +import { Damage, DamageType, Stats, Actionable, Action, DevourAction, FeedAction, DigestAction, ReleaseAction, StruggleAction, Vigor } from './combat' import { LogLines, LogEntry, CompositeLog, LogLine } from './interface' -import { Noun, POVPair, POVPairArgs, ImproperNoun } from './language' +import { Noun, Pronoun, POVPair, POVPairArgs, ImproperNoun } from './language' export enum VoreType { Oral = "Oral Vore", @@ -10,12 +10,32 @@ export enum VoreType { Unbirth = "Unbirthing" } -export interface Vore extends Mortal { - preyPrefs: Set; - bulk: number; - containedIn: Container | null; - predPrefs: Set; - containers: Array; +export abstract class Vore implements Mortal { + abstract name: Noun; + abstract pronouns: Pronoun; + abstract perspective: POV; + abstract vigors: {[key in Vigor]: number}; + abstract maxVigors: {[key in Vigor]: number}; + abstract disabled: boolean; + abstract resistances: Map; + abstract takeDamage (damage: Damage): void; + abstract stats: Stats; + abstract status: string; + abstract preyPrefs: Set; + abstract bulk: number; + abstract containedIn: Container | null; + abstract predPrefs: Set; + abstract containers: Array; + destroy (): void { + this.containers.map(container => { + container.contents.map(prey => { + prey.containedIn = this.containedIn + if (this.containedIn !== null) { + this.containedIn.contents.push(prey) + } + }) + }) + } } export interface Container extends Actionable {