From f53413bc96669b30a47a7e88113a753bde913b70 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Wed, 12 Aug 2020 11:03:11 -0400 Subject: [PATCH] Change containers to use damage formulas, not a plain Damage object --- src/game/creatures/cafat.ts | 8 ++++---- src/game/creatures/dragon.ts | 8 ++++---- src/game/creatures/geta.ts | 16 ++++++++-------- src/game/creatures/goldeneye.ts | 6 ++++-- src/game/creatures/kenzie.ts | 6 +++--- src/game/creatures/kuro.ts | 16 ++++++++-------- src/game/creatures/player.ts | 4 ++-- src/game/creatures/shingo.ts | 4 ++-- src/game/creatures/withers.ts | 4 ++-- src/game/creatures/wolf.ts | 24 ++++++++++++------------ src/game/vore.ts | 30 +++++++++++++++++------------- 11 files changed, 66 insertions(+), 60 deletions(-) diff --git a/src/game/creatures/cafat.ts b/src/game/creatures/cafat.ts index 460b0b6..744141b 100644 --- a/src/game/creatures/cafat.ts +++ b/src/game/creatures/cafat.ts @@ -83,21 +83,21 @@ export class Cafat extends Creature { this.side = Side.Monsters - const stomach = new Stomach(this, 1, new Damage( + const stomach = new Stomach(this, 1, new ConstantDamageFormula(new Damage( { amount: 20, type: DamageType.Acid, target: Vigor.Health }, { amount: 10, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 10, type: DamageType.Dominance, target: Vigor.Resolve } - )) + ))) stomach.name = new ImproperNoun("upper stomach", "upper stomachs").all this.containers.push(stomach) - const lowerStomach = new InnerStomach(this, 1.5, new Damage( + const lowerStomach = new InnerStomach(this, 1.5, new ConstantDamageFormula(new Damage( { amount: 40, type: DamageType.Acid, target: Vigor.Health }, { amount: 20, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 20, type: DamageType.Dominance, target: Vigor.Resolve } - ), stomach) + )), stomach) lowerStomach.name = new ImproperNoun("lower stomach", "lower stomachs").all diff --git a/src/game/creatures/dragon.ts b/src/game/creatures/dragon.ts index 50ceeb5..ab6c2ed 100644 --- a/src/game/creatures/dragon.ts +++ b/src/game/creatures/dragon.ts @@ -20,19 +20,19 @@ export class Dragon extends Creature { this.side = Side.Monsters - const stomach = new Stomach(this, 0.5, new Damage( + const stomach = new Stomach(this, 0.5, new ConstantDamageFormula(new Damage( { amount: 40, type: DamageType.Acid, target: Vigor.Health }, { amount: 20, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 20, type: DamageType.Dominance, target: Vigor.Resolve } - )) + ))) this.containers.push(stomach) - const bowels = new Bowels(this, 0.5, new Damage( + const bowels = new Bowels(this, 0.5, new ConstantDamageFormula(new Damage( { amount: 10, type: DamageType.Crush, target: Vigor.Health }, { amount: 25, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 50, type: DamageType.Dominance, target: Vigor.Resolve } - )) + ))) this.containers.push(bowels) diff --git a/src/game/creatures/geta.ts b/src/game/creatures/geta.ts index 8604004..c770080 100644 --- a/src/game/creatures/geta.ts +++ b/src/game/creatures/geta.ts @@ -23,18 +23,18 @@ export class Geta extends Creature { this.side = Side.Monsters - const stomach = new Stomach(this, 0.25, new Damage( + const stomach = new Stomach(this, 0.25, new ConstantDamageFormula(new Damage( { amount: 100, type: DamageType.Acid, target: Vigor.Health }, { amount: 40, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 80, type: DamageType.Dominance, target: Vigor.Resolve } - )) + ))) this.containers.push(stomach) - const bowels = new Bowels(this, 0.25, new Damage( + const bowels = new Bowels(this, 0.25, new ConstantDamageFormula(new Damage( { amount: 30, type: DamageType.Crush, target: Vigor.Health }, { amount: 90, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 120, type: DamageType.Dominance, target: Vigor.Resolve } - )) + ))) this.containers.push(bowels) @@ -42,11 +42,11 @@ export class Geta extends Creature { this.otherActions.push(new FeedAction(stomach)) - const cock = new Cock(this, 0.25, new Damage( + const cock = new Cock(this, 0.25, new ConstantDamageFormula(new Damage( { amount: 10, type: DamageType.Crush, target: Vigor.Health }, { amount: 50, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 150, type: DamageType.Dominance, target: Vigor.Resolve } - )) + ))) cock.digestLine = (user, target, args) => { return new LogLine(`${user.name.capital.possessive} ${args.container.name} throbs as it abruptly absorbs ${target.name.objective}, transforming ${target.name.objective} into more of ${user.pronouns.possessive} meaty shaft.`) @@ -85,11 +85,11 @@ export class Geta extends Creature { ) ) - const balls = new Balls(this, 0.25, new Damage( + const balls = new Balls(this, 0.25, new ConstantDamageFormula(new Damage( { amount: 50, type: DamageType.Acid, target: Vigor.Health }, { amount: 25, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 50, type: DamageType.Dominance, target: Vigor.Resolve } - ), cock) + )), cock) this.containers.push(balls) this.containers.push(cock) diff --git a/src/game/creatures/goldeneye.ts b/src/game/creatures/goldeneye.ts index 03dce37..68b79aa 100644 --- a/src/game/creatures/goldeneye.ts +++ b/src/game/creatures/goldeneye.ts @@ -109,8 +109,10 @@ class GoldeneyeStomach extends InnerVoreContainer { owner, new Set([VoreType.Oral]), 900, - new Damage( - { amount: 1000, target: Vigor.Health, type: DamageType.Acid } + new ConstantDamageFormula( + new Damage( + { amount: 1000, target: Vigor.Health, type: DamageType.Acid } + ) ), crop ) diff --git a/src/game/creatures/kenzie.ts b/src/game/creatures/kenzie.ts index d616a33..814c03d 100644 --- a/src/game/creatures/kenzie.ts +++ b/src/game/creatures/kenzie.ts @@ -1,7 +1,7 @@ import { Creature } from "../creature" import { ProperNoun, ImproperNoun, FemalePronouns, Verb } from '../language' import { VoreType, Stomach } from '../vore' -import { Side, Damage, DamageType, Vigor, StatDamageFormula, Stat, VoreStat, DamageFormula } from '../combat' +import { Side, Damage, DamageType, Vigor, StatDamageFormula, Stat, VoreStat, DamageFormula, ConstantDamageFormula } from '../combat' import { AttackAction, DevourAction } from '../combat/actions' import { LogEntry, LogLines } from '../interface' import { StunEffect, PredatorCounterEffect } from '../combat/effects' @@ -39,11 +39,11 @@ export class Kenzie extends Creature { this.side = Side.Monsters - const stomach = new Stomach(this, 0.1, new Damage( + const stomach = new Stomach(this, 0.1, new ConstantDamageFormula(new Damage( { amount: 100, type: DamageType.Acid, target: Vigor.Health }, { amount: 100, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 100, type: DamageType.Dominance, target: Vigor.Resolve } - )) + ))) this.applyEffect(new PredatorCounterEffect(new DevourAction(stomach), 0.4)) diff --git a/src/game/creatures/kuro.ts b/src/game/creatures/kuro.ts index 4787504..e3da667 100644 --- a/src/game/creatures/kuro.ts +++ b/src/game/creatures/kuro.ts @@ -18,18 +18,18 @@ export class Kuro extends Creature { this.side = Side.Monsters - const stomach = new Stomach(this, 0.5, new Damage( + const stomach = new Stomach(this, 0.5, new ConstantDamageFormula(new Damage( { amount: 100, type: DamageType.Acid, target: Vigor.Health }, { amount: 40, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 80, type: DamageType.Dominance, target: Vigor.Resolve } - )) + ))) this.containers.push(stomach) - const bowels = new Bowels(this, 0.5, new Damage( + const bowels = new Bowels(this, 0.5, new ConstantDamageFormula(new Damage( { amount: 30, type: DamageType.Crush, target: Vigor.Health }, { amount: 90, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 120, type: DamageType.Dominance, target: Vigor.Resolve } - )) + ))) this.containers.push(bowels) @@ -37,17 +37,17 @@ export class Kuro extends Creature { this.otherActions.push(new FeedAction(stomach)) - const cock = new Cock(this, 0.5, new Damage( + const cock = new Cock(this, 0.5, new ConstantDamageFormula(new Damage( { amount: 10, type: DamageType.Crush, target: Vigor.Health }, { amount: 30, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 30, type: DamageType.Dominance, target: Vigor.Resolve } - )) + ))) - const balls = new Balls(this, 0.5, new Damage( + const balls = new Balls(this, 0.5, new ConstantDamageFormula(new Damage( { amount: 50, type: DamageType.Acid, target: Vigor.Health }, { amount: 25, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 150, type: DamageType.Dominance, target: Vigor.Resolve } - ), cock) + )), cock) this.containers.push(balls) this.containers.push(cock) diff --git a/src/game/creatures/player.ts b/src/game/creatures/player.ts index c16472a..a0b3f0e 100644 --- a/src/game/creatures/player.ts +++ b/src/game/creatures/player.ts @@ -18,10 +18,10 @@ export class Player extends Creature { this.actions.push(new AttackAction(new ConstantDamageFormula(new Damage({ type: DamageType.Pierce, amount: 20, target: Vigor.Health }, { type: DamageType.Pierce, amount: 20, target: Vigor.Stamina })))) - const stomach = new Stomach(this, 2, new Damage({ amount: 20, type: DamageType.Acid, target: Vigor.Health }, { amount: 10, type: DamageType.Crush, target: Vigor.Health })) + const stomach = new Stomach(this, 2, new ConstantDamageFormula(new Damage({ amount: 20, type: DamageType.Acid, target: Vigor.Health }, { amount: 10, type: DamageType.Crush, target: Vigor.Health }))) this.containers.push(stomach) - const bowels = new Bowels(this, 2, new Damage({ amount: 20, type: DamageType.Crush, target: Vigor.Health })) + const bowels = new Bowels(this, 2, new ConstantDamageFormula(new Damage({ amount: 20, type: DamageType.Crush, target: Vigor.Health }))) this.containers.push(bowels) this.perspective = POV.Second diff --git a/src/game/creatures/shingo.ts b/src/game/creatures/shingo.ts index 482ec58..e9cd6c4 100644 --- a/src/game/creatures/shingo.ts +++ b/src/game/creatures/shingo.ts @@ -158,11 +158,11 @@ export class Shingo extends Creature { this.side = Side.Monsters - const stomach = new Stomach(this, 0.1, new Damage( + const stomach = new Stomach(this, 0.1, new ConstantDamageFormula(new Damage( { amount: 200, type: DamageType.Acid, target: Vigor.Health }, { amount: 100, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 100, type: DamageType.Dominance, target: Vigor.Resolve } - )) + ))) this.containers.push(stomach) diff --git a/src/game/creatures/withers.ts b/src/game/creatures/withers.ts index 7d75429..f8fa65f 100644 --- a/src/game/creatures/withers.ts +++ b/src/game/creatures/withers.ts @@ -317,11 +317,11 @@ export class Withers extends Creature { this.side = Side.Monsters - const stomach = new Stomach(this, 0.1, new Damage( + const stomach = new Stomach(this, 0.1, new ConstantDamageFormula(new Damage( { amount: 300, type: DamageType.Acid, target: Vigor.Health }, { amount: 200, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 200, type: DamageType.Dominance, target: Vigor.Resolve } - )) + ))) this.containers.push(stomach) this.otherActions.push(new FeedAction(stomach)) diff --git a/src/game/creatures/wolf.ts b/src/game/creatures/wolf.ts index c2e7a69..75a9dc9 100644 --- a/src/game/creatures/wolf.ts +++ b/src/game/creatures/wolf.ts @@ -28,18 +28,18 @@ export class Wolf extends Creature { this.side = Side.Monsters - const stomach = new Stomach(this, 2, new Damage( + const stomach = new Stomach(this, 2, new ConstantDamageFormula(new Damage( { amount: 60, type: DamageType.Acid, target: Vigor.Health }, { amount: 30, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 30, type: DamageType.Dominance, target: Vigor.Resolve } - )) + ))) this.containers.push(stomach) - const bowels = new Bowels(this, 2, new Damage( + const bowels = new Bowels(this, 2, new ConstantDamageFormula(new Damage( { amount: 30, type: DamageType.Crush, target: Vigor.Health }, { amount: 60, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 60, type: DamageType.Dominance, target: Vigor.Resolve } - )) + ))) this.containers.push(bowels) @@ -47,29 +47,29 @@ export class Wolf extends Creature { this.otherActions.push(new FeedAction(stomach)) - const cock = new Cock(this, 2, new Damage( + const cock = new Cock(this, 2, new ConstantDamageFormula(new Damage( { amount: 30, type: DamageType.Crush, target: Vigor.Health }, { amount: 60, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 60, type: DamageType.Dominance, target: Vigor.Resolve } - )) + ))) - const balls = new Balls(this, 2, new Damage( + const balls = new Balls(this, 2, new ConstantDamageFormula(new Damage( { amount: 30, type: DamageType.Crush, target: Vigor.Health }, { amount: 60, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 60, type: DamageType.Dominance, target: Vigor.Resolve } - ), cock) + )), cock) - const slit = new Slit(this, 2, new Damage( + const slit = new Slit(this, 2, new ConstantDamageFormula(new Damage( { amount: 30, type: DamageType.Crush, target: Vigor.Health }, { amount: 60, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 60, type: DamageType.Dominance, target: Vigor.Resolve } - )) + ))) - const womb = new Womb(this, 2, new Damage( + const womb = new Womb(this, 2, new ConstantDamageFormula(new Damage( { amount: 30, type: DamageType.Crush, target: Vigor.Health }, { amount: 60, type: DamageType.Crush, target: Vigor.Stamina }, { amount: 60, type: DamageType.Dominance, target: Vigor.Resolve } - ), slit) + )), slit) this.containers.push(balls) this.containers.push(cock) diff --git a/src/game/vore.ts b/src/game/vore.ts index 8d306f0..5d72e36 100644 --- a/src/game/vore.ts +++ b/src/game/vore.ts @@ -1,5 +1,5 @@ import { Mortal } from './entity' -import { Damage, DamageType, Stats, Actionable, Action, Vigor, VoreStats, VisibleStatus, VoreStat, DamageInstance } from './combat' +import { Damage, DamageType, Stats, Actionable, Action, Vigor, VoreStats, VisibleStatus, VoreStat, DamageInstance, DamageFormula } from './combat' import { LogLines, LogEntry, LogLine, nilLog } from './interface' import { Noun, Pronoun, ImproperNoun, TextLike, Verb, SecondPersonPronouns, PronounAsNoun, FirstPersonPronouns, PairLineArgs, SoloLine, POV, RandomWord } from './language' import { DigestAction, DevourAction, ReleaseAction, StruggleAction, TransferAction } from './combat/actions' @@ -172,7 +172,7 @@ export abstract class NormalVoreContainer extends NormalContainer implements Vor digested: Array = [] absorbed: Array = [] - constructor (name: Noun, owner: Creature, voreTypes: Set, capacity: number, private damage: Damage) { + constructor (name: Noun, owner: Creature, voreTypes: Set, capacity: number, private damage: DamageFormula) { super(name, owner, voreTypes, capacity) this.name = name @@ -204,13 +204,14 @@ export abstract class NormalVoreContainer extends NormalContainer implements Vor const justDigested: Array = [] const justAbsorbed: Array = [] - const scaled = this.damage.scale(dt / 60) - const damageResults: Array = [] - const tickedEntries = new LogLines(...this.contents.map(prey => this.tickLine(this.owner, prey, { container: this, damage: scaled }))) + const tickedEntryList: LogEntry[] = [] this.contents.forEach(prey => { + const scaled = this.damage.calc(this.owner, prey).scale(dt / 60) + tickedEntryList.push(this.tickLine(this.owner, prey, { container: this, damage: scaled })) + damageResults.push(prey.takeDamage(scaled)) if (prey.vigors[Vigor.Health] <= 0) { @@ -221,7 +222,10 @@ export abstract class NormalVoreContainer extends NormalContainer implements Vor } }) + const tickedEntries = new LogLines(...tickedEntryList) + this.digested.forEach(prey => { + const scaled = this.damage.calc(this.owner, prey).scale(dt / 60) const damageTotal: number = prey.effectiveDamage(scaled).damages.filter(instance => instance.target === Vigor.Health).reduce( (total: number, instance: DamageInstance) => total + instance.amount, 0 @@ -271,7 +275,7 @@ export abstract class NormalVoreContainer extends NormalContainer implements Vor } export abstract class InnerVoreContainer extends NormalVoreContainer { - constructor (name: Noun, owner: Creature, voreTypes: Set, capacity: number, damage: Damage, private escape: Container) { + constructor (name: Noun, owner: Creature, voreTypes: Set, capacity: number, damage: DamageFormula, private escape: Container) { super(name, owner, voreTypes, capacity, damage) this.actions = [] @@ -289,7 +293,7 @@ export abstract class InnerVoreContainer extends NormalVoreContainer { } export class Stomach extends NormalVoreContainer { - constructor (owner: Creature, capacity: number, damage: Damage) { + constructor (owner: Creature, capacity: number, damage: DamageFormula) { super(new ImproperNoun('stomach', 'stomachs').all, owner, new Set([VoreType.Oral]), capacity, damage) } @@ -316,13 +320,13 @@ export class Stomach extends NormalVoreContainer { export class InnerStomach extends InnerVoreContainer { consumeVerb = new Verb('swallow') releaseVerb = new Verb('hork') - constructor (owner: Creature, capacity: number, damage: Damage, escape: VoreContainer) { + constructor (owner: Creature, capacity: number, damage: DamageFormula, escape: VoreContainer) { super(new ImproperNoun('inner stomach', 'inner stomachs').all, owner, new Set([VoreType.Oral]), capacity, damage, escape) } } export class Bowels extends NormalVoreContainer { - constructor (owner: Creature, capacity: number, damage: Damage) { + constructor (owner: Creature, capacity: number, damage: DamageFormula) { super(new ImproperNoun('bowel', 'bowels').plural.all, owner, new Set([VoreType.Anal]), capacity, damage) } @@ -339,7 +343,7 @@ export class Bowels extends NormalVoreContainer { export class Cock extends NormalVoreContainer { fluidColor = "#eeeeee66"; - constructor (owner: Creature, capacity: number, damage: Damage) { + constructor (owner: Creature, capacity: number, damage: DamageFormula) { super( new ImproperNoun('cock').all, owner, @@ -362,7 +366,7 @@ export class Cock extends NormalVoreContainer { export class Balls extends InnerVoreContainer { fluidColor = "#eeeeeecc"; - constructor (owner: Creature, capacity: number, damage: Damage, escape: Container) { + constructor (owner: Creature, capacity: number, damage: DamageFormula, escape: Container) { super( new ImproperNoun('ball', 'balls').all.plural, owner, @@ -377,7 +381,7 @@ export class Balls extends InnerVoreContainer { export class Slit extends NormalVoreContainer { fluidColor = "#cccccc99"; - constructor (owner: Creature, capacity: number, damage: Damage) { + constructor (owner: Creature, capacity: number, damage: DamageFormula) { super( new ImproperNoun('slit').all, owner, @@ -391,7 +395,7 @@ export class Slit extends NormalVoreContainer { export class Womb extends InnerVoreContainer { fluidColor = "#ddddddbb"; - constructor (owner: Creature, capacity: number, damage: Damage, escape: Container) { + constructor (owner: Creature, capacity: number, damage: DamageFormula, escape: Container) { super( new ImproperNoun('womb').all, owner,