From 3bc3609ffa3ec374bb2ba33522ca067bc5c3c77c Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Sat, 25 Jul 2020 16:34:16 -0400 Subject: [PATCH] Start replacing old language code Instead of picking between several options, we simply have one line that gets filled based on perspective. --- src/game/creatures/kenzie.ts | 2 +- src/game/creatures/withers.ts | 30 +---- src/game/language.ts | 7 +- src/game/vore.ts | 231 ++++++++-------------------------- 4 files changed, 65 insertions(+), 205 deletions(-) diff --git a/src/game/creatures/kenzie.ts b/src/game/creatures/kenzie.ts index e2fa86a..638585c 100644 --- a/src/game/creatures/kenzie.ts +++ b/src/game/creatures/kenzie.ts @@ -1,5 +1,5 @@ import { Creature, POV } from '../entity' -import { ProperNoun, ImproperNoun, FemalePronouns, POVPairArgs, POVPair, Verb } from '../language' +import { ProperNoun, ImproperNoun, FemalePronouns, Verb } from '../language' import { VoreType, Stomach, Vore } from '../vore' import { Side, Damage, DamageType, Vigor, UniformRandomDamageFormula, ConstantDamageFormula, StatDamageFormula, Stat, VoreStat } from '../combat' import { LogLine } from '../interface' diff --git a/src/game/creatures/withers.ts b/src/game/creatures/withers.ts index 02ddfa2..81e70a9 100644 --- a/src/game/creatures/withers.ts +++ b/src/game/creatures/withers.ts @@ -1,6 +1,6 @@ import { Creature, POV } from '../entity' import { Damage, DamageType, ConstantDamageFormula, Vigor, Side, GroupAction, CombatTest, Stat, DamageFormula, UniformRandomDamageFormula, Action, DamageInstance, StatDamageFormula, VoreStat } from '../combat' -import { ImproperNoun, POVPair, ProperNoun, FemalePronouns, RandomWord, Adjective, POVPairArgs, Verb } from '../language' +import { ImproperNoun, POVPair, POVPairArgs, ProperNoun, FemalePronouns, RandomWord, Adjective, Verb } from '../language' import { LogLine, LogLines, LogEntry, Newline } from '../interface' import { VoreType, Stomach, VoreContainer, Vore, NormalContainer, Container } from '../vore' import { AttackAction, FeedAction, TransferAction, EatenAction } from '../combat/actions' @@ -109,11 +109,7 @@ class MawContainer extends NormalContainer { } class FlexToesAction extends GroupAction { - lines = new POVPairArgs([ - [[POV.Second, POV.Third], (user, target, args) => new LogLine(`Your toes crush ${target.name} for `, args.damage.renderShort(), ` damage!`)], - [[POV.Third, POV.Second], (user, target, args) => new LogLine(`${user.name.capital}'s toes crush you for `, args.damage.renderShort(), ` damage!`)], - [[POV.Third, POV.Third], (user, target, args) => new LogLine(`${user.name.capital}'s toes crush ${target.name} for `, args.damage.renderShort(), ` damage!`)] - ]) + line = (user: Creature, target: Creature, args: { damage: Damage }) => new LogLine(`${user.name.capital.possessive} toes crush ${target.name.objective} for `, args.damage.renderShort(), ` damage!`) describeGroup (user: Creature, targets: Creature[]): LogEntry { return new LogLine(`Flex your toes. `, this.damage.explain(user)) @@ -121,7 +117,7 @@ class FlexToesAction extends GroupAction { execute (user: Creature, target: Creature): LogEntry { const damage = this.damage.calc(user, target) - return new LogLines(target.takeDamage(damage), this.lines.run(user, target, { damage: damage })) + return new LogLines(target.takeDamage(damage), this.line(user, target, { damage: damage })) } describe (user: Creature, target: Creature): LogEntry { @@ -197,11 +193,7 @@ class BiteAction extends AttackAction { } class ChewAction extends GroupAction { - lines: POVPairArgs = new POVPairArgs([ - [[POV.Second, POV.Third], (user, target, args: { damage: Damage }) => new LogLine(`You chew on ${target.name} for `, args.damage.renderShort(), `!`)], - [[POV.Third, POV.Second], (user, target, args: { damage: Damage }) => new LogLine(`${user.name.capital} chews on you for `, args.damage.renderShort(), `!`)], - [[POV.Third, POV.Third], (user, target, args: { damage: Damage }) => new LogLine(`${user.name.capital} chews on ${target.name} for `, args.damage.renderShort(), `!`)] - ]) + line = (user: Creature, target: Creature, args: { damage: Damage }) => new LogLine(`${user.name.capital} chews on ${target.name.objective} for `, args.damage.renderShort(), `!`) describeGroup (user: Creature, targets: Creature[]): LogEntry { return new LogLine('Crunch \'em all. ', this.damage.explain(user)) @@ -210,7 +202,7 @@ class ChewAction extends GroupAction { execute (user: Creature, target: Creature): LogEntry { const damage = this.damage.calc(user, target) const results: Array = [] - results.push(this.lines.run(user, target, { damage: damage })) + results.push(this.line(user, target, { damage: damage })) results.push(new LogLine(' ')) results.push(target.takeDamage(damage)) @@ -368,18 +360,6 @@ export class Withers extends Creature { { amount: 200, type: DamageType.Dominance, target: Vigor.Resolve } )) - stomach.tickLines = new POVPairArgs([ - [[POV.Second, POV.Third], (user, target, args) => new LogLine(`Your stomach ${Words.Churns.singular} ${target.name} for `, args.damage.renderShort())], - [[POV.Third, POV.Second], (user, target, args) => new LogLine(`${user.name.capital}'s stomach ${Words.Churns.singular} you for `, args.damage.renderShort())], - [[POV.Third, POV.Third], (user, target, args) => new LogLine(`${user.name.capital} ${Words.Churns.singular} ${target.name} for `, args.damage.renderShort())] - ]) - - stomach.digestLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`Your stomach ${Words.Digests.singular} ${target.name}`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital}'s stomach ${Words.Digests.singular} you`)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${target.name.capital}'s ${Words.Struggles.present} fades as the ${target.kind.all} is ${Words.Digests.past} by the ${user.kind.all}'s ${stomach.name}.`)] - ]) - this.containers.push(stomach) this.otherActions.push(new FeedAction(stomach)) diff --git a/src/game/language.ts b/src/game/language.ts index d82a563..27e627e 100644 --- a/src/game/language.ts +++ b/src/game/language.ts @@ -1,5 +1,10 @@ import { Entity, POV } from './entity' -import { LogEntry, LogLines, LogLine } from './interface' +import { LogEntry, LogLine } from './interface' + +export type SoloLine = (user: T) => LogEntry +export type SoloLineArgs = (user: T, args: V) => LogEntry +export type PairLine = (user: T, target: T) => LogEntry +export type PairLineArgs = (user: T, target: T, args: V) => LogEntry export class POVPair { run (user: K, target: V): LogEntry { diff --git a/src/game/vore.ts b/src/game/vore.ts index 1fda727..39e3bd5 100644 --- a/src/game/vore.ts +++ b/src/game/vore.ts @@ -1,7 +1,7 @@ import { Entity, Mortal, POV, Creature } from './entity' import { Damage, DamageType, Stats, Actionable, Action, Vigor, VoreStats } from './combat' import { LogLines, LogEntry, CompositeLog, LogLine } from './interface' -import { Noun, Pronoun, POVPair, POVPairArgs, ImproperNoun, POVSolo, TextLike, Verb, SecondPersonPronouns, PronounAsNoun, FirstPersonPronouns } from './language' +import { Noun, Pronoun, POVPair, POVPairArgs, ImproperNoun, POVSolo, TextLike, Verb, SecondPersonPronouns, PronounAsNoun, FirstPersonPronouns, PairLine, PairLineArgs } from './language' import { DigestAction, DevourAction, ReleaseAction, StruggleAction } from './combat/actions' import * as Words from './words' @@ -117,9 +117,17 @@ export abstract class NormalContainer implements Container { contents: Array = [] actions: Array = [] - abstract consumeLines: POVPair - abstract releaseLines: POVPair - abstract struggleLines: POVPair + consumeLine: PairLineArgs = (user, target, args) => { + return new LogLine(`${user.name.capital} ${user.name.conjugate(new Verb('trap'))} ${target.name.objective} in ${user.pronouns.possessive} ${args.container.name}.`) + } + + releaseLine: PairLineArgs = (user, target, args) => { + return new LogLine(`${user.name.capital} ${user.name.conjugate(new Verb('hork'))} ${target.name.objective} up from ${user.pronouns.possessive} ${args.container.name}.`) + } + + struggleLine: PairLineArgs = (user, target, args) => { + return new LogLine(`struggle`) + } abstract consumeVerb: Verb abstract releaseVerb: Verb @@ -145,7 +153,7 @@ export abstract class NormalContainer implements Container { } this.contents.push(prey) prey.containedIn = this - return this.consumeLines.run(this.owner, prey) + return this.consumeLine(this.owner, prey, { container: this }) } release (prey: Vore): LogEntry { @@ -155,11 +163,11 @@ export abstract class NormalContainer implements Container { if (this.owner.containedIn !== null) { this.owner.containedIn.contents.push(prey) } - return this.releaseLines.run(this.owner, prey) + return this.releaseLine(this.owner, prey, { container: this }) } struggle (prey: Vore): LogEntry { - return this.struggleLines.run(prey, this.owner) + return this.struggleLine(prey, this.owner, { container: this }) } describe (): LogEntry { @@ -184,76 +192,69 @@ export interface VoreContainer extends Container { digested: Array; tick: (dt: number) => LogEntry; digest: (preys: Vore[]) => LogEntry; - absorb: (preys: Vore[]) => LogEntry; - dispose: (preys: Vore[]) => LogEntry; } export abstract class NormalVoreContainer extends NormalContainer implements VoreContainer { - digested: Array = [] - - abstract tickLines: POVPairArgs - abstract digestLines: POVPair - abstract absorbLines: POVPair - abstract disposeLines: POVPair + digested: Array = [] - consumeVerb = new Verb('devour') - releaseVerb = new Verb('release', 'releases', 'releasing', 'released') - struggleVerb = new Verb('struggle', 'struggles', 'struggling', 'struggled') + tickLine: PairLineArgs = (user, target, args) => { + return new LogLine(`${user.name.capital} ${user.name.conjugate(Words.Churns)} ${target.name.objective} in ${user.pronouns.possessive} ${args.container.name}.`) + } - tick (dt: number): LogEntry { - const justDigested: Array = [] + digestLine: PairLineArgs = (user, target, args) => { + return new LogLine(`${user.name.capital.possessive} ${args.container.name} finishes ${Words.Digests.present} ${target.name.objective} down, ${target.pronouns.possessive} ${Words.Struggles.singular} fading away.`) + } - const scaled = this.damage.scale(dt / 60) + consumeVerb = new Verb('devour') + releaseVerb = new Verb('release', 'releases', 'releasing', 'released') + struggleVerb = new Verb('struggle', 'struggles', 'struggling', 'struggled') - const damageResults: Array = [] + tick (dt: number): LogEntry { + const justDigested: Array = [] - const tickedEntries = new LogLines(...this.contents.map(prey => this.tickLines.run(this.owner, prey, { damage: scaled }))) + const scaled = this.damage.scale(dt / 60) - this.contents.forEach(prey => { - damageResults.push(prey.takeDamage(scaled)) + const damageResults: Array = [] - if (prey.vigors[Vigor.Health] <= 0) { - prey.destroyed = true - this.digested.push(prey) - justDigested.push(prey) - } - }) + const tickedEntries = new LogLines(...this.contents.map(prey => this.tickLine(this.owner, prey, { container: this, damage: scaled }))) - const digestedEntries = this.digest(justDigested) + this.contents.forEach(prey => { + damageResults.push(prey.takeDamage(scaled)) - this.contents = this.contents.filter(prey => { - return prey.vigors[Vigor.Health] > 0 - }) + if (prey.vigors[Vigor.Health] <= 0) { + prey.destroyed = true + this.digested.push(prey) + justDigested.push(prey) + } + }) - return new LogLines(tickedEntries, new LogLines(...damageResults), digestedEntries) - } + const digestedEntries = this.digest(justDigested) - digest (preys: Vore[]): LogEntry { - return new LogLines(...preys.map(prey => this.digestLines.run(this.owner, prey))) - } + this.contents = this.contents.filter(prey => { + return prey.vigors[Vigor.Health] > 0 + }) - absorb (preys: Vore[]): LogEntry { - return new LogLines(...preys.map(prey => this.absorbLines.run(this.owner, prey))) - } + return new LogLines(tickedEntries, new LogLines(...damageResults), digestedEntries) + } - dispose (preys: Vore[]): LogEntry { - return new LogLines(...preys.map(prey => this.disposeLines.run(this.owner, prey))) - } + digest (preys: Vore[]): LogEntry { + return new LogLines(...preys.map(prey => this.digestLine(this.owner, prey, { container: this }))) + } - constructor (name: Noun, owner: Vore, voreTypes: Set, capacity: number, private damage: Damage) { - super(name, owner, voreTypes, capacity) + constructor (name: Noun, owner: Vore, voreTypes: Set, capacity: number, private damage: Damage) { + super(name, owner, voreTypes, capacity) - this.name = name + this.name = name - this.actions.push(new DigestAction(this)) - } + this.actions.push(new DigestAction(this)) + } } abstract class InnerContainer extends NormalVoreContainer { release (prey: Vore): LogEntry { prey.containedIn = this.escape this.contents = this.contents.filter(victim => victim !== prey) - return this.releaseLines.run(this.owner, prey) + return this.releaseLine(this.owner, prey, { container: this }) } constructor (name: Noun, owner: Vore, voreTypes: Set, capacity: number, damage: Damage, private escape: VoreContainer) { @@ -271,48 +272,6 @@ export class Stomach extends NormalVoreContainer { super(new ImproperNoun('stomach', 'stomachs').all, owner, new Set([VoreType.Oral]), capacity, damage) } - consumeLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`You devour ${target.name}`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital} munches you`)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} munches ${target.name}`)] - ]) - - releaseLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`You hork up ${target.name}`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital} horks you up`)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} horks up ${target.name}`)] - ]) - - struggleLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`You claw your way out of ${target.name}`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital} forces ${user.pronouns.possessive} way up your throat!`)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} escapes from the gut of ${target.name}`)] - ]) - - tickLines = new POVPairArgs([ - [[POV.Second, POV.Third], (user, target, args) => new LogLine(`Your stomach ${Words.Churns.singular} ${target.name} for `, args.damage.renderShort())], - [[POV.Third, POV.Second], (user, target, args) => new LogLine(`${user.name.capital}'s stomach ${Words.Churns.singular} you for `, args.damage.renderShort())], - [[POV.Third, POV.Third], (user, target, args) => new LogLine(`${user.name.capital} ${Words.Churns.singular} ${target.name} for `, args.damage.renderShort())] - ]) - - digestLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`Your stomach ${Words.Digests.singular} ${target.name}`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital}'s stomach ${Words.Digests.singular} you`)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${target.name.capital}'s ${Words.Struggles.present} fades as the ${target.kind.all} is ${Words.Digests.past} by the ${user.kind.all}'s ${this.name}.`)] - ]) - - absorbLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`Your guts completely absorb ${target.name}`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital}'s guts soak you up like water in a sponge`)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} finishes absorbing the remains of ${target.name}`)] - ]) - - disposeLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`Your guts completely absorb ${target.name}`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital}'s guts soak you up like water in a sponge`)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} finishes absorbing the remains of ${target.name}`)] - ]) - digest (preys: Vore[]): LogEntry { if (preys.length === 0) { return super.digest(preys) @@ -337,94 +296,10 @@ export class InnerStomach extends InnerContainer { constructor (owner: Vore, capacity: number, damage: Damage, escape: VoreContainer) { super(new ImproperNoun('inner stomach', 'inner stomachs').all, owner, new Set([VoreType.Oral]), capacity, damage, escape) } - - consumeLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`You devour ${target.name}`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital} munches you`)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} munches ${target.name.capital}`)] - ]) - - releaseLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`You hork up ${target.name}`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital} horks you up`)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} horks up ${target.name.capital}`)] - ]) - - struggleLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`You claw your way out of ${target.name}`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital} forces ${user.pronouns.possessive} way up your throat!`)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} escapes from the gut of ${target.name}`)] - ]) - - tickLines = new POVPairArgs([ - [[POV.Second, POV.Third], (user, target, args) => new LogLine(`Your stomach gurgles ${target.name} for `, args.damage.renderShort())], - [[POV.Third, POV.Second], (user, target, args) => new LogLine(`${user.name.capital}'s stomach churns you for `, args.damage.renderShort())], - [[POV.Third, POV.Third], (user, target, args) => new LogLine(`${user.name.capital} churns ${target.name} for `, args.damage.renderShort())] - ]) - - digestLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`Your stomach overwhelms ${target.name}`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital}'s stomach finishes you off`)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${target.name.capital}'s squirms fade, overwhelmed by the stomach of ${user.name}`)] - ]) - - absorbLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`Your guts completely absorb ${target.name}`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital}'s guts soak you up like water in a sponge`)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} finishes absorbing the remains of ${target.name}`)] - ]) - - disposeLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`Your guts completely absorb ${target.name}`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital}'s guts soak you up like water in a sponge`)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} finishes absorbing the remains of ${target.name}`)] - ]) } export class Bowels extends NormalVoreContainer { constructor (owner: Vore, capacity: number, damage: Damage) { super(new ImproperNoun('bowel', 'bowels').plural, owner, new Set([VoreType.Anal]), capacity, damage) } - - consumeLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`You force ${target.name} into your bowels`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital} works you into ${user.pronouns.possessive} ass`)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} anal-vores ${target.name.capital}`)] - ]) - - releaseLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`You let out ${target.name}`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital} lets you out `)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} lets out ${target.name.capital}`)] - ]) - - struggleLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`You claw your way out of ${target.name}`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital} forces ${user.pronouns.possessive} way out your rump!`)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} escapes from the bowels of ${target.name}`)] - ]) - - tickLines = new POVPairArgs([ - [[POV.Second, POV.Third], (user, target, args) => new LogLine(`Your bowels gurgle ${target.name} for `, args.damage.renderShort())], - [[POV.Third, POV.Second], (user, target, args) => new LogLine(`${user.name.capital}'s bowels churn you for `, args.damage.renderShort())], - [[POV.Third, POV.Third], (user, target, args) => new LogLine(`${target.name.capital} churns ${user.name} for `, args.damage.renderShort())] - ]) - - digestLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`Your bowels overwhelm ${target.name}`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital}'s bowels finish you off`)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${target.name.capital}'s squirms fade, overwhelmed by the bowels of ${user.name}`)] - ]) - - absorbLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`Your guts completely absorb ${target.name}`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital}'s guts soak you up like water in a sponge`)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} finishes absorbing the remains of ${target.name}`)] - ]) - - disposeLines = new POVPair([ - [[POV.Second, POV.Third], (user, target) => new LogLine(`Your guts completely absorb ${target.name}`)], - [[POV.Third, POV.Second], (user, target) => new LogLine(`${user.name.capital}'s guts soak you up like water in a sponge`)], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} finishes absorbing the remains of ${target.name}`)] - ]) }