From fde7ed19a46bcf676476b1f8473d02529920e1c3 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Fri, 17 Jun 2022 12:39:00 -0400 Subject: [PATCH] Add crunches to instant digestion This includes a new postEnter hook for status effects, so that they can distinguish between consumption and transfer --- src/game/combat.ts | 11 +++++++++++ src/game/combat/effects.ts | 9 +++++++-- src/game/onomatopoeia.ts | 36 +++++++++++++++++++++++++++++++++++- src/game/vore.ts | 3 +++ 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/src/game/combat.ts b/src/game/combat.ts index 3565927..47dae17 100644 --- a/src/game/combat.ts +++ b/src/game/combat.ts @@ -753,6 +753,17 @@ export class Effective { return nilLog } + /** + * Triggers after prey enters a container + */ + postEnter ( + predator: Creature, + prey: Creature, + container: Container + ): LogEntry { + return nilLog + } + /** * Affects a stat */ diff --git a/src/game/combat/effects.ts b/src/game/combat/effects.ts index 378131e..b736408 100644 --- a/src/game/combat/effects.ts +++ b/src/game/combat/effects.ts @@ -10,8 +10,9 @@ import { import { DynText, LiveText, ToBe, Verb } from "@/game/language" import { Creature } from "../creature" import { LogLine, LogEntry, LogLines, FAElem, nilLog } from "@/game/interface" -import { Container } from "@/game/vore" +import { Container, ContainerCapability } from "@/game/vore" import * as Words from "@/game/words" +import * as Onomatopoeia from "@/game/onomatopoeia" export class InstantKillEffect extends StatusEffect { constructor () { @@ -307,7 +308,10 @@ export class InstantDigestionEffect extends StatusEffect { ) } - postConsume (predator: Creature, prey: Creature, container: Container) { + postEnter (predator: Creature, prey: Creature, container: Container) { + if (!container.capabilities.has(ContainerCapability.Digest)) { + return nilLog + } prey.applyEffect(new InstantKillEffect()) predator.voreStats.Mass += prey.voreStats.Mass prey.voreStats.Mass = 0 @@ -316,6 +320,7 @@ export class InstantDigestionEffect extends StatusEffect { new ToBe() )} instantly digested! `, new FAElem("fas fa-skull"), + Onomatopoeia.makeOnomatopoeia(Onomatopoeia.Crunch), container.tick(0, [prey]) ) } diff --git a/src/game/onomatopoeia.ts b/src/game/onomatopoeia.ts index 891aaa6..13cc352 100644 --- a/src/game/onomatopoeia.ts +++ b/src/game/onomatopoeia.ts @@ -1,5 +1,9 @@ -import { Onomatopoeia, RandomWord } from "./language" +import { FormatEntry, FormatOpt, LogEntry, LogLine } from "./interface" +import { Onomatopoeia, RandomWord, Word } from "./language" +export function makeOnomatopoeia (word: Word): LogEntry { + return new FormatEntry(new LogLine(`${word}`), FormatOpt.Onomatopoeia) +} export const Swallow = new RandomWord([ new Onomatopoeia([ ["GL", 1, 1], @@ -56,3 +60,33 @@ export const Gurgle = new RandomWord([ ["e", 1, 1] ]) ]) + +export const MuffledScream = new RandomWord([ + new Onomatopoeia([ + ["m", 5, 9], + ["p", 2, 4], + ["h", 4, 8] + ]), + new Onomatopoeia([ + ["h", 4, 9], + ["m", 3, 8], + ["p", 1, 3], + ["h", 3, 5] + ]), + new Onomatopoeia([ + ["n", 4, 9], + ["g", 3, 5], + ["h", 5, 10] + ]) +]) + +export const Crunch = new RandomWord([ + new Onomatopoeia([ + ["C", 1, 1], + ["R", 4, 8], + ["U", 1, 3], + ["N", 2, 4], + ["CH", 1, 1], + ["!", 1, 1] + ]) +]) diff --git a/src/game/vore.ts b/src/game/vore.ts index 6f19184..98ec01c 100644 --- a/src/game/vore.ts +++ b/src/game/vore.ts @@ -214,6 +214,7 @@ export abstract class DefaultContainer implements Container { this.voreRelay.dispatch("onReleased", this, { prey: prey }), prey.voreRelay.dispatch("onReleased", this, { prey: prey }) ] + return new LogLines(...results) } @@ -229,6 +230,8 @@ export abstract class DefaultContainer implements Container { prey.voreRelay.dispatch("onEntered", this, { prey: prey }) ] + this.owner.effects.forEach(effect => results.push(effect.postEnter(this.owner, prey, this))) + return new LogLines(...results) }