|
|
|
@@ -1,8 +1,9 @@ |
|
|
|
import { Damage, DamageType, Actionable, Action, Vigor, DamageInstance, DamageFormula, ConstantDamageFormula } from '@/game/combat' |
|
|
|
import { LogLines, LogEntry, LogLine, nilLog, RandomEntry } from '@/game/interface' |
|
|
|
import { LogLines, LogEntry, LogLine, nilLog, RandomEntry, FormatEntry, FormatOpt } from '@/game/interface' |
|
|
|
import { Noun, ImproperNoun, Verb, RandomWord, Word, Preposition, ToBe, Adjective } from '@/game/language' |
|
|
|
import { RubAction, DevourAction, ReleaseAction, StruggleAction, TransferAction, StruggleMoveAction } from '@/game/combat/actions' |
|
|
|
import * as Words from '@/game/words' |
|
|
|
import * as Onomatopoeia from '@/game/onomatopoeia' |
|
|
|
import { Creature } from '@/game/creature' |
|
|
|
import { VoreRelay } from '@/game/events' |
|
|
|
|
|
|
|
@@ -87,8 +88,13 @@ export interface Container extends Actionable { |
|
|
|
strugglePreposition: Preposition; |
|
|
|
|
|
|
|
canTake (prey: Creature): boolean; |
|
|
|
|
|
|
|
consume (prey: Creature): LogEntry; |
|
|
|
release (prey: Creature): LogEntry; |
|
|
|
|
|
|
|
enter (prey: Creature): LogEntry; |
|
|
|
exit (prey: Creature): LogEntry; |
|
|
|
|
|
|
|
struggle (prey: Creature): LogEntry; |
|
|
|
|
|
|
|
tick (dt: number, victims?: Array<Creature>): LogEntry; |
|
|
|
@@ -189,29 +195,57 @@ export abstract class DefaultContainer implements Container { |
|
|
|
} |
|
|
|
|
|
|
|
consume (prey: Creature): LogEntry { |
|
|
|
const results: Array<LogEntry> = [ |
|
|
|
this.enter(prey), |
|
|
|
this.voreRelay.dispatch("onEaten", this, { prey: prey }), |
|
|
|
prey.voreRelay.dispatch("onEaten", this, { prey: prey }), |
|
|
|
this.consumeLine(this.owner, prey) |
|
|
|
] |
|
|
|
|
|
|
|
this.owner.effects.forEach(effect => results.push(effect.postConsume(this.owner, prey, this))) |
|
|
|
|
|
|
|
return new LogLines(...results) |
|
|
|
} |
|
|
|
|
|
|
|
release (prey: Creature): LogEntry { |
|
|
|
const results = [ |
|
|
|
this.exit(prey), |
|
|
|
this.releaseLine(this.owner, prey), |
|
|
|
this.voreRelay.dispatch("onReleased", this, { prey: prey }), |
|
|
|
prey.voreRelay.dispatch("onReleased", this, { prey: prey }) |
|
|
|
] |
|
|
|
return new LogLines(...results) |
|
|
|
} |
|
|
|
|
|
|
|
enter (prey: Creature): LogEntry { |
|
|
|
if (prey.containedIn !== null) { |
|
|
|
prey.containedIn.contents = prey.containedIn.contents.filter(item => prey !== item) |
|
|
|
} |
|
|
|
this.contents.push(prey) |
|
|
|
prey.containedIn = this |
|
|
|
|
|
|
|
const results: Array<LogEntry> = [] |
|
|
|
this.owner.effects.forEach(effect => results.push(effect.postConsume(this.owner, prey, this))) |
|
|
|
const relayResults = this.voreRelay.dispatch("onEaten", this, { prey: prey }) |
|
|
|
const preyRelayResults = prey.voreRelay.dispatch("onEaten", this, { prey: prey }) |
|
|
|
const consumeLineResult: LogEntry = this.consumeLine(this.owner, prey) |
|
|
|
const results = [ |
|
|
|
this.voreRelay.dispatch("onEntered", this, { prey: prey }), |
|
|
|
prey.voreRelay.dispatch("onEntered", this, { prey: prey }) |
|
|
|
] |
|
|
|
|
|
|
|
return new LogLines(...[consumeLineResult].concat(results).concat(relayResults).concat(preyRelayResults)) |
|
|
|
return new LogLines(...results) |
|
|
|
} |
|
|
|
|
|
|
|
release (prey: Creature): LogEntry { |
|
|
|
exit (prey: Creature): LogEntry { |
|
|
|
prey.containedIn = this.owner.containedIn |
|
|
|
this.contents = this.contents.filter(victim => victim !== prey) |
|
|
|
|
|
|
|
if (this.owner.containedIn !== null) { |
|
|
|
this.owner.containedIn.contents.push(prey) |
|
|
|
} |
|
|
|
return new LogLines(this.releaseLine(this.owner, prey), this.voreRelay.dispatch("onReleased", this, { prey: prey })) |
|
|
|
|
|
|
|
const results = [ |
|
|
|
this.voreRelay.dispatch("onExited", this, { prey: prey }), |
|
|
|
prey.voreRelay.dispatch("onExited", this, { prey: prey }) |
|
|
|
] |
|
|
|
|
|
|
|
return new LogLines(...results) |
|
|
|
} |
|
|
|
|
|
|
|
struggle (prey: Creature): LogEntry { |
|
|
|
@@ -268,7 +302,15 @@ export abstract class DefaultContainer implements Container { |
|
|
|
options.push(new LogLine(`${this.fluid.name.capital} ${this.fluid.sloshVerb.singular} and ${this.fluid.sound.singular} as ${this.owner.name.possessive} ${this.name} steadily ${Words.Digest.singular} ${target.name.objective}.`)) |
|
|
|
} |
|
|
|
|
|
|
|
return new RandomEntry(...options) |
|
|
|
const result: Array<LogEntry> = [ |
|
|
|
new RandomEntry(...options) |
|
|
|
] |
|
|
|
|
|
|
|
if (Math.random() < 0.3) { |
|
|
|
result.push(new FormatEntry(new LogLine(`${Onomatopoeia.Gurgle}`), FormatOpt.Onomatopoeia)) |
|
|
|
} |
|
|
|
|
|
|
|
return new LogLines(...result) |
|
|
|
} |
|
|
|
|
|
|
|
digestLine (user: Creature, target: Creature): LogEntry { |
|
|
|
@@ -390,6 +432,10 @@ export class Stomach extends DefaultContainer { |
|
|
|
ContainerCapability.Absorb |
|
|
|
])) |
|
|
|
|
|
|
|
this.voreRelay.subscribe("onEntered", (sender: Container, args: { prey: Creature }) => { |
|
|
|
return new FormatEntry(new LogLine(`${Onomatopoeia.Glunk}`), FormatOpt.Onomatopoeia) |
|
|
|
}) |
|
|
|
|
|
|
|
this.damage = damage |
|
|
|
} |
|
|
|
} |
|
|
|
@@ -418,11 +464,15 @@ export class Throat extends DefaultContainer { |
|
|
|
ContainerCapability.Consume, |
|
|
|
ContainerCapability.Release |
|
|
|
])) |
|
|
|
|
|
|
|
this.voreRelay.subscribe("onEaten", (sender: Container, args: { prey: Creature }) => { |
|
|
|
return new FormatEntry(new LogLine(`${Onomatopoeia.Swallow}`), FormatOpt.Onomatopoeia) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
export function transferDescription (verb: Word, preposition: Preposition): ((from: Container, to: Container, prey: Creature) => LogEntry) { |
|
|
|
return (from: Container, to: Container, prey: Creature) => { |
|
|
|
return new LogLine(`${from.owner.name.capital} ${verb.singular} ${prey.name.objective} ${preposition} ${to.consumePreposition} ${from.owner.pronouns.possessive} ${to.name}.`) |
|
|
|
return new LogLine(`${from.owner.name.capital} ${from.owner.name.conjugate(verb.singular)} ${prey.name.objective} ${preposition} ${to.consumePreposition} ${from.owner.pronouns.possessive} ${to.name}.`) |
|
|
|
} |
|
|
|
} |