Quellcode durchsuchen

Get rid of the Vore class and fold it into Creature

vintage
Fen Dweller vor 5 Jahren
Ursprung
Commit
049fa0938f
8 geänderte Dateien mit 146 neuen und 174 gelöschten Zeilen
  1. +3
    -3
      src/components/ContainerView.vue
  2. +1
    -1
      src/components/ItemView.vue
  3. +1
    -1
      src/components/WalletView.vue
  4. +78
    -14
      src/game/creature.ts
  5. +3
    -3
      src/game/creatures/goldeneye.ts
  6. +3
    -3
      src/game/creatures/shingo.ts
  7. +3
    -3
      src/game/creatures/withers.ts
  8. +54
    -146
      src/game/vore.ts

+ 3
- 3
src/components/ContainerView.vue Datei anzeigen

@@ -15,7 +15,7 @@ import { Component, Prop, Vue, Watch, Emit } from 'vue-property-decorator'
import { Creature } from '@/game/creature'
import { POV } from '@/game/language'
import { Stats, Stat } from '@/game/combat'
import { Container, VoreContainer, Vore } from '@/game/vore'
import { Container, VoreContainer } from '@/game/vore'

function wiggle (contents: HTMLElement) {
setTimeout(() => wiggle(contents), 3000)
@@ -43,8 +43,8 @@ function draw (delta: number, dt: number, total: number, parent: HTMLElement, ca
canvas.height = parent.clientHeight
ctx.fillStyle = container.fluidColor
const fraction = container.fullness / container.capacity
const livingFraction = container.contents.reduce((total: number, prey: Vore) => total + prey.voreStats.Bulk, 0) / container.capacity
const deadFraction = container.digested.reduce((total: number, prey: Vore) => total + prey.voreStats.Bulk, 0) / container.capacity
const livingFraction = container.contents.reduce((total: number, prey: Creature) => total + prey.voreStats.Bulk, 0) / container.capacity
const deadFraction = container.digested.reduce((total: number, prey: Creature) => total + prey.voreStats.Bulk, 0) / container.capacity
const liveliness = livingFraction + deadFraction * 0.5

smoothedFraction = smoothedFraction * 0.995 + fraction * 0.005


+ 1
- 1
src/components/ItemView.vue Datei anzeigen

@@ -15,7 +15,7 @@ import { Component, Prop, Vue, Watch, Emit } from 'vue-property-decorator'
import { Creature } from '@/game/creature'
import { POV } from '@/game/language'
import { Stats, Stat } from '@/game/combat'
import { Container, VoreContainer, Vore } from '@/game/vore'
import { Container, VoreContainer } from '@/game/vore'
import { Item, ItemKindIcons, ItemKind } from '@/game/items'

@Component({


+ 1
- 1
src/components/WalletView.vue Datei anzeigen

@@ -9,7 +9,7 @@ import { Component, Prop, Vue, Watch, Emit } from 'vue-property-decorator'
import { Creature } from '@/game/creature'
import { POV } from '@/game/language'
import { Stats, Stat } from '@/game/combat'
import { Container, VoreContainer, Vore } from '@/game/vore'
import { Container, VoreContainer } from '@/game/vore'
import { Item, ItemKindIcons, ItemKind, Currency, CurrencyData } from '@/game/items'

@Component({


+ 78
- 14
src/game/creature.ts Datei anzeigen

@@ -1,14 +1,21 @@
import { Damage, Combatant, Stats, Action, Vigor, Side, GroupAction, VisibleStatus, ImplicitStatus, StatusEffect, DamageType, Effective, VoreStat } from './combat'
import { Noun, Pronoun } from './language'
import { LogEntry, LogLines } from './interface'
import { Vore, VoreContainer, VoreType } from './vore'
import { Damage, Combatant, Stats, Action, Vigor, Side, GroupAction, VisibleStatus, ImplicitStatus, StatusEffect, DamageType, Effective, VoreStat, VoreStats } from './combat'
import { Noun, Pronoun, SoloLine, Verb } from './language'
import { LogEntry, LogLines, LogLine } from './interface'
import { VoreContainer, VoreType, Container } from './vore'
import { Item, EquipmentSlot, Equipment, ItemKind, Currency } from './items'
import { PassAction } from './combat/actions'
import { AI, NoAI } from './ai'
import { Mortal } from './entity'

export class Creature extends Mortal {
containers: Array<VoreContainer> = []
otherContainers: Array<Container> = []

containedIn: Container | null = null

voreStats: VoreStats

export class Creature extends Vore implements Combatant {
actions: Array<Action> = [];
containedIn: VoreContainer | null = null;
desc = "Some creature";

get effects (): Array<Effective> {
@@ -29,30 +36,53 @@ export class Creature extends Vore implements Combatant {
equipment: {[key in EquipmentSlot]?: Equipment } = {}
ai: AI = new NoAI()

constructor (name: Noun, kind: Noun, pronouns: Pronoun, stats: Stats, preyPrefs: Set<VoreType>, predPrefs: Set<VoreType>, mass: number) {
super(name, kind, pronouns, stats, preyPrefs, predPrefs, mass)
constructor (name: Noun, kind: Noun, pronouns: Pronoun, stats: Stats, public preyPrefs: Set<VoreType>, public predPrefs: Set<VoreType>, private baseMass: number) {
super(name, kind, pronouns, stats)

this.actions.push(new PassAction())
this.side = Side.Heroes

const baseVoreStats = this.voreStats
/* eslint-disable-next-line */
const self = this

this.voreStats = {
get [VoreStat.Bulk] () {
return baseVoreStats.Bulk
return self.containers.reduce(
(total: number, container: VoreContainer) => {
return total + container.contents.reduce(
(total: number, prey: Creature) => {
return total + prey.voreStats.Bulk
},
0
) + container.digested.reduce(
(total: number, prey: Creature) => {
return total + prey.voreStats.Bulk
},
0
)
},
self.voreStats.Mass
)
},
get [VoreStat.Mass] () {
const base = baseVoreStats.Mass
const base = self.baseMass
const adjusted = self.effects.reduce((scale: number, effect: Effective) => effect.scale(scale), base)
return adjusted
},
set [VoreStat.Mass] (mass: number) {
baseVoreStats.Mass = mass
self.baseMass = mass
},
get [VoreStat.PreyCount] () {
return baseVoreStats["Prey Count"]
return self.containers.reduce(
(total: number, container: VoreContainer) => {
return total + container.contents.concat(container.digested).reduce(
(total: number, prey: Creature) => {
return total + 1 + prey.voreStats[VoreStat.PreyCount]
},
0
)
},
0
)
}
}
}
@@ -160,4 +190,38 @@ export class Creature extends Vore implements Combatant {
return targets.some(target => action.allowed(this, target))
})
}

destroy (): LogEntry {
const line: SoloLine<Creature> = (victim) => new LogLine(
`${victim.name.capital} ${victim.name.conjugate(new Verb('die'))}`
)

const released: Array<Creature> = this.containers.flatMap(container => {
return container.contents.map(prey => {
prey.containedIn = this.containedIn
if (this.containedIn !== null) {
this.containedIn.contents.push(prey)
}
return prey
})
})

const names = released.reduce((list: Array<string>, prey: Creature) => list.concat([prey.name.toString()]), []).joinGeneral(", ", " and ").join("")

if (released.length > 0) {
if (this.containedIn === null) {
return new LogLines(
line(this),
new LogLine(names + ` spill out!`)
)
} else {
return new LogLines(
line(this),
new LogLine(names + ` spill out into ${this.containedIn.owner.name}'s ${this.containedIn.name}!`)
)
}
} else {
return line(this)
}
}
}

+ 3
- 3
src/game/creatures/goldeneye.ts Datei anzeigen

@@ -1,7 +1,7 @@
import { Creature } from "../creature"
import { Damage, DamageType, ConstantDamageFormula, Vigor, Side, GroupAction, FractionDamageFormula, DamageFormula, UniformRandomDamageFormula, CompositionAction, StatusEffect, CompositeDamageFormula } from '../combat'
import { MalePronouns, ImproperNoun, Verb, ProperNoun, ToBe, SoloLineArgs } from '../language'
import { VoreType, NormalContainer, Vore, InnerVoreContainer, Container } from '../vore'
import { VoreType, NormalContainer, InnerVoreContainer, Container } from '../vore'
import { TransferAction } from '../combat/actions'
import { LogEntry, LogLine, LogLines } from '../interface'
import { ContainerFullCondition, CapableCondition, EnemyCondition, TogetherCondition } from '../combat/conditions'
@@ -13,7 +13,7 @@ class GoldeneyeCrop extends NormalContainer {
releaseVerb: Verb = new Verb('free')
struggleVerb: Verb = new Verb('struggle', 'struggles', 'struggling', 'struggled')

constructor (owner: Vore) {
constructor (owner: Creature) {
super(
new ImproperNoun('crop').all,
owner,
@@ -103,7 +103,7 @@ class GoldeneyeStomach extends InnerVoreContainer {
releaseVerb: Verb = new Verb('free')
struggleVerb: Verb = new Verb('struggle', 'struggles', 'struggling', 'struggled')

constructor (owner: Vore, crop: GoldeneyeCrop) {
constructor (owner: Creature, crop: GoldeneyeCrop) {
super(
new ImproperNoun('stomach').all,
owner,


+ 3
- 3
src/game/creatures/shingo.ts Datei anzeigen

@@ -1,7 +1,7 @@
import { Creature } from "../creature"
import { Damage, DamageType, ConstantDamageFormula, Vigor, Side, StatDamageFormula, Stat, Action, DamageFormula, Condition, FractionDamageFormula } from '../combat'
import { ImproperNoun, ProperNoun, FemalePronouns, MalePronouns, Verb, PairLineArgs, PairLine, TextLike } from '../language'
import { VoreType, Stomach, Bowels, NormalContainer, InnerContainer, VoreContainer, Container, Vore } from '../vore'
import { VoreType, Stomach, Bowels, NormalContainer, InnerContainer, VoreContainer, Container } from '../vore'
import { AttackAction, TransferAction, FeedAction, StruggleAction, DamageAction } from '../combat/actions'
import { LogLine, LogEntry, LogLines } from '../interface'
import { ContainsCondition, CapableCondition, EnemyCondition, TargetDrainedVigorCondition } from '../combat/conditions'
@@ -50,7 +50,7 @@ class Hand extends NormalContainer {
))
}

consumeLine: PairLineArgs<Vore, { container: Container }> = (user, target, args) => {
consumeLine: PairLineArgs<Creature, { container: Container }> = (user, target, args) => {
return new LogLine(`${user.name.capital} ${user.name.conjugate(this.consumeVerb)} ${target.name.objective} up in ${user.pronouns.possessive} ${args.container.name}, giving ${target.pronouns.objective} a firm squeeze in ${user.pronouns.possessive} fingers.`)
}
}
@@ -100,7 +100,7 @@ class Paw extends NormalContainer {
))
}

consumeLine: PairLineArgs<Vore, { container: Container }> = (user, target, args) => {
consumeLine: PairLineArgs<Creature, { container: Container }> = (user, target, args) => {
return new LogLine(`${user.name.capital} ${user.name.conjugate(this.consumeVerb)} ${target.name.objective} beneath ${user.pronouns.possessive} ${args.container.name}.`)
}
}


+ 3
- 3
src/game/creatures/withers.ts Datei anzeigen

@@ -2,7 +2,7 @@ import { Creature } from "../creature"
import { Damage, DamageType, ConstantDamageFormula, Vigor, Side, GroupAction, CombatTest, Stat, DamageFormula, UniformRandomDamageFormula, Action, DamageInstance, StatDamageFormula, VoreStat } from '../combat'
import { ImproperNoun, ProperNoun, FemalePronouns, RandomWord, Adjective, Verb, PairLine } from '../language'
import { LogLine, LogLines, LogEntry, Newline } from '../interface'
import { VoreType, Stomach, VoreContainer, Vore, NormalContainer, Container } from '../vore'
import { VoreType, Stomach, VoreContainer, NormalContainer, Container } from '../vore'
import { AttackAction, FeedAction, TransferAction } from '../combat/actions'
import { TogetherCondition, ContainsCondition, EnemyCondition, AllyCondition, PairCondition, CapableCondition } from '../combat/conditions'
import { InstantKillEffect, DamageTypeResistanceEffect } from '../combat/effects'
@@ -83,7 +83,7 @@ class MawContainer extends NormalContainer {
releaseVerb = new Verb('release')
struggleVerb = new Verb('struggle', 'struggles', 'struggling', 'struggled')

constructor (owner: Vore, stomach: VoreContainer) {
constructor (owner: Creature, stomach: VoreContainer) {
super(new ImproperNoun('maw'), owner, new Set([VoreType.Oral]), 0.05)

const transfer = new TransferAction(this, stomach)
@@ -121,7 +121,7 @@ class BootContainer extends NormalContainer {
releaseVerb = new Verb('dump')
struggleVerb = new Verb('struggle', 'struggles', 'struggling', 'struggled')

constructor (owner: Vore) {
constructor (owner: Creature) {
super(new ImproperNoun('boot'), owner, new Set(), 0.05)

const flex = new FlexToesAction(


+ 54
- 146
src/game/vore.ts Datei anzeigen

@@ -4,6 +4,7 @@ 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'
import * as Words from './words'
import { Creature } from './creature'

export enum VoreType {
Oral = "Oral Vore",
@@ -19,133 +20,40 @@ export const anyVore = new Set([
VoreType.Unbirth
])

export abstract class Vore extends Mortal {
containers: Array<VoreContainer> = []
otherContainers: Array<Container> = []

containedIn: Container | null = null

voreStats: VoreStats

constructor (name: Noun, kind: Noun, pronouns: Pronoun, baseStats: Stats, public preyPrefs: Set<VoreType>, public predPrefs: Set<VoreType>, private baseMass: number) {
super(name, kind, pronouns, baseStats)

const containers = this.containers

// we can't use arrow notation for getters, so we gotta do this
// eslint-disable-next-line
const self = this

this.voreStats = {
get [VoreStat.Bulk] () {
return containers.reduce(
(total: number, container: VoreContainer) => {
return total + container.contents.reduce(
(total: number, prey: Vore) => {
return total + prey.voreStats.Bulk
},
0
) + container.digested.reduce(
(total: number, prey: Vore) => {
return total + prey.voreStats.Bulk
},
0
)
},
self.voreStats.Mass
)
},
get [VoreStat.Mass] () {
return self.baseMass
},
set [VoreStat.Mass] (mass: number) {
self.baseMass = mass
},
get [VoreStat.PreyCount] () {
return containers.reduce(
(total: number, container: VoreContainer) => {
return total + container.contents.concat(container.digested).reduce(
(total: number, prey: Vore) => {
return total + 1 + prey.voreStats[VoreStat.PreyCount]
},
0
)
},
0
)
}
}
}

destroy (): LogEntry {
const line: SoloLine<Vore> = (victim) => new LogLine(
`${victim.name.capital} ${victim.name.conjugate(new Verb('die'))}`
)

const released: Array<Vore> = this.containers.flatMap(container => {
return container.contents.map(prey => {
prey.containedIn = this.containedIn
if (this.containedIn !== null) {
this.containedIn.contents.push(prey)
}
return prey
})
})

const names = released.reduce((list: Array<string>, prey: Vore) => list.concat([prey.name.toString()]), []).joinGeneral(", ", " and ").join("")

if (released.length > 0) {
if (this.containedIn === null) {
return new LogLines(
line(this),
new LogLine(names + ` spill out!`)
)
} else {
return new LogLines(
line(this),
new LogLine(names + ` spill out into ${this.containedIn.owner.name}'s ${this.containedIn.name}!`)
)
}
} else {
return line(this)
}
}
}

export interface Container extends Actionable {
name: Noun;
owner: Vore;
owner: Creature;
voreTypes: Set<VoreType>;

capacity: number;
fullness: number;

contents: Array<Vore>;
contents: Array<Creature>;
describe: () => LogEntry;

canTake: (prey: Vore) => boolean;
consume: (prey: Vore) => LogEntry;
release: (prey: Vore) => LogEntry;
struggle: (prey: Vore) => LogEntry;
canTake: (prey: Creature) => boolean;
consume: (prey: Creature) => LogEntry;
release: (prey: Creature) => LogEntry;
struggle: (prey: Creature) => LogEntry;

consumeVerb: Verb;
releaseVerb: Verb;
struggleVerb: Verb;

consumeLine: PairLineArgs<Vore, { container: Container }>;
consumeLine: PairLineArgs<Creature, { container: Container }>;

}

export abstract class NormalContainer implements Container {
public name: Noun
contents: Array<Vore> = []
contents: Array<Creature> = []
actions: Array<Action> = []

consumeVerb = new Verb('trap')
releaseVerb = new Verb('release', 'releases', 'releasing', 'released')
struggleVerb = new Verb('struggle', 'struggles', 'struggling', 'struggled')

constructor (name: Noun, public owner: Vore, public voreTypes: Set<VoreType>, public capacityFactor: number) {
constructor (name: Noun, public owner: Creature, public voreTypes: Set<VoreType>, public capacityFactor: number) {
this.name = name.all
this.actions.push(new DevourAction(this))
this.actions.push(new ReleaseAction(this))
@@ -156,23 +64,23 @@ export abstract class NormalContainer implements Container {
return this.capacityFactor * this.owner.voreStats.Mass
}

consumeLine: PairLineArgs<Vore, { container: Container }> = (user, target, args) => {
consumeLine: PairLineArgs<Creature, { container: Container }> = (user, target, args) => {
return new LogLine(`${user.name.capital} ${user.name.conjugate(this.consumeVerb)} ${target.name.objective} in ${user.pronouns.possessive} ${args.container.name}.`)
}

releaseLine: PairLineArgs<Vore, { container: Container }> = (user, target, args) => {
releaseLine: PairLineArgs<Creature, { container: Container }> = (user, target, args) => {
return new LogLine(`${user.name.capital} ${user.name.conjugate(this.releaseVerb)} ${target.name.objective} up from ${user.pronouns.possessive} ${args.container.name}.`)
}

struggleLine: PairLineArgs<Vore, { container: Container }> = (user, target, args) => {
struggleLine: PairLineArgs<Creature, { container: Container }> = (user, target, args) => {
return new LogLine(`${user.name.capital} ${user.name.conjugate(this.struggleVerb)} within ${target.name.possessive} ${args.container.name}.`)
}

get fullness (): number {
return Array.from(this.contents.values()).reduce((total: number, prey: Vore) => total + prey.voreStats.Bulk, 0)
return Array.from(this.contents.values()).reduce((total: number, prey: Creature) => total + prey.voreStats.Bulk, 0)
}

canTake (prey: Vore): boolean {
canTake (prey: Creature): boolean {
const fits = this.capacity - this.fullness >= prey.voreStats.Bulk

const permitted = Array.from(this.voreTypes).every(voreType => {
@@ -182,7 +90,7 @@ export abstract class NormalContainer implements Container {
return fits && permitted
}

consume (prey: Vore): LogEntry {
consume (prey: Creature): LogEntry {
if (prey.containedIn !== null) {
prey.containedIn.contents = prey.containedIn.contents.filter(item => prey !== item)
}
@@ -191,7 +99,7 @@ export abstract class NormalContainer implements Container {
return this.consumeLine(this.owner, prey, { container: this })
}

release (prey: Vore): LogEntry {
release (prey: Creature): LogEntry {
prey.containedIn = this.owner.containedIn
this.contents = this.contents.filter(victim => victim !== prey)

@@ -201,7 +109,7 @@ export abstract class NormalContainer implements Container {
return this.releaseLine(this.owner, prey, { container: this })
}

struggle (prey: Vore): LogEntry {
struggle (prey: Creature): LogEntry {
return this.struggleLine(prey, this.owner, { container: this })
}

@@ -218,7 +126,7 @@ export abstract class NormalContainer implements Container {

export class Hand extends NormalContainer {
consumeVerb = new Verb("grab")
constructor (owner: Vore, capacity: number) {
constructor (owner: Creature, capacity: number) {
super(
new ImproperNoun('hand'),
owner,
@@ -229,7 +137,7 @@ export class Hand extends NormalContainer {
}

export abstract class InnerContainer extends NormalContainer {
constructor (name: Noun, owner: Vore, voreTypes: Set<VoreType>, capacity: number, private escape: Container) {
constructor (name: Noun, owner: Creature, voreTypes: Set<VoreType>, capacity: number, private escape: Container) {
super(name, owner, voreTypes, capacity)

this.actions = []
@@ -237,7 +145,7 @@ export abstract class InnerContainer extends NormalContainer {
this.actions.push(new StruggleAction(this))
}

release (prey: Vore): LogEntry {
release (prey: Creature): LogEntry {
prey.containedIn = this.escape
this.contents = this.contents.filter(victim => victim !== prey)
return this.releaseLine(this.owner, prey, { container: this })
@@ -245,14 +153,14 @@ export abstract class InnerContainer extends NormalContainer {
}

export interface VoreContainer extends Container {
digested: Array<Vore>;
digested: Array<Creature>;
tick: (dt: number) => LogEntry;
digest: (preys: Vore[]) => LogEntry;
absorb: (preys: Vore[]) => LogEntry;
digest: (preys: Creature[]) => LogEntry;
absorb: (preys: Creature[]) => LogEntry;
fluidColor: string;

onDigest: (prey: Vore) => LogEntry;
onAbsorb: (prey: Vore) => LogEntry;
onDigest: (prey: Creature) => LogEntry;
onAbsorb: (prey: Creature) => LogEntry;
}

export abstract class NormalVoreContainer extends NormalContainer implements VoreContainer {
@@ -261,10 +169,10 @@ export abstract class NormalVoreContainer extends NormalContainer implements Vor
struggleVerb = new Verb('struggle', 'struggles', 'struggling', 'struggled')
fluidColor = "#00ff0088"

digested: Array<Vore> = []
absorbed: Array<Vore> = []
digested: Array<Creature> = []
absorbed: Array<Creature> = []

constructor (name: Noun, owner: Vore, voreTypes: Set<VoreType>, capacity: number, private damage: Damage) {
constructor (name: Noun, owner: Creature, voreTypes: Set<VoreType>, capacity: number, private damage: Damage) {
super(name, owner, voreTypes, capacity)

this.name = name
@@ -273,28 +181,28 @@ export abstract class NormalVoreContainer extends NormalContainer implements Vor
}

get fullness (): number {
return Array.from(this.contents.concat(this.digested, this.absorbed).values()).reduce((total: number, prey: Vore) => total + prey.voreStats.Bulk, 0)
return Array.from(this.contents.concat(this.digested, this.absorbed).values()).reduce((total: number, prey: Creature) => total + prey.voreStats.Bulk, 0)
}

consumeLine: PairLineArgs<Vore, { container: Container }> = (user, target, args) => {
consumeLine: PairLineArgs<Creature, { container: Container }> = (user, target, args) => {
return new LogLine(`${user.name.capital} ${user.name.conjugate(this.consumeVerb)} ${target.name.objective}, forcing ${target.pronouns.objective} into ${user.pronouns.possessive} ${args.container.name}.`)
}

tickLine: PairLineArgs<Vore, { container: VoreContainer; damage: Damage }> = (user, target, args) => {
tickLine: PairLineArgs<Creature, { container: VoreContainer; damage: Damage }> = (user, target, args) => {
return new LogLine(`${user.name.capital} ${user.name.conjugate(Words.Churns)} ${target.name.objective} in ${user.pronouns.possessive} ${args.container.name}.`)
}

digestLine: PairLineArgs<Vore, { container: VoreContainer }> = (user, target, args) => {
digestLine: PairLineArgs<Creature, { container: VoreContainer }> = (user, target, args) => {
return new LogLine(`${user.name.capital.possessive} ${args.container.name} ${args.container.name.conjugate(new Verb('finish', 'finishes'))} ${Words.Digests.present} ${target.name.objective} down, ${target.pronouns.possessive} ${Words.Struggles.singular} fading away.`)
}

absorbLine: PairLineArgs<Vore, { container: VoreContainer }> = (user, target, args) => {
absorbLine: PairLineArgs<Creature, { container: VoreContainer }> = (user, target, args) => {
return new LogLine(`${user.name.capital.possessive} ${args.container.name} ${args.container.name.conjugate(new Verb('finish', 'finishes'))} ${Words.Absorbs.present} ${target.name.objective}, fully claiming ${target.pronouns.objective}.`)
}

tick (dt: number): LogEntry {
const justDigested: Array<Vore> = []
const justAbsorbed: Array<Vore> = []
const justDigested: Array<Creature> = []
const justAbsorbed: Array<Creature> = []

const scaled = this.damage.scale(dt / 60)

@@ -345,25 +253,25 @@ export abstract class NormalVoreContainer extends NormalContainer implements Vor
return new LogLines(tickedEntries, new LogLines(...damageResults), digestedEntries, absorbedEntries)
}

absorb (preys: Vore[]): LogEntry {
absorb (preys: Creature[]): LogEntry {
return new LogLines(...preys.map(prey => this.absorbLine(this.owner, prey, { container: this })))
}

digest (preys: Vore[]): LogEntry {
digest (preys: Creature[]): LogEntry {
return new LogLines(...preys.map(prey => this.digestLine(this.owner, prey, { container: this })))
}

onAbsorb (prey: Vore): LogEntry {
onAbsorb (prey: Creature): LogEntry {
return nilLog
}

onDigest (prey: Vore): LogEntry {
onDigest (prey: Creature): LogEntry {
return nilLog
}
}

export abstract class InnerVoreContainer extends NormalVoreContainer {
constructor (name: Noun, owner: Vore, voreTypes: Set<VoreType>, capacity: number, damage: Damage, private escape: Container) {
constructor (name: Noun, owner: Creature, voreTypes: Set<VoreType>, capacity: number, damage: Damage, private escape: Container) {
super(name, owner, voreTypes, capacity, damage)

this.actions = []
@@ -372,7 +280,7 @@ export abstract class InnerVoreContainer extends NormalVoreContainer {
this.actions.push(new StruggleAction(this))
}

release (prey: Vore): LogEntry {
release (prey: Creature): LogEntry {
prey.containedIn = this.escape
this.contents = this.contents.filter(victim => victim !== prey)
this.escape.consume(prey)
@@ -381,18 +289,18 @@ export abstract class InnerVoreContainer extends NormalVoreContainer {
}

export class Stomach extends NormalVoreContainer {
constructor (owner: Vore, capacity: number, damage: Damage) {
constructor (owner: Creature, capacity: number, damage: Damage) {
super(new ImproperNoun('stomach', 'stomachs').all, owner, new Set([VoreType.Oral]), capacity, damage)
}

digest (preys: Vore[]): LogEntry {
digest (preys: Creature[]): LogEntry {
if (preys.length === 0) {
return super.digest(preys)
}

const heal = new Damage(
{
amount: preys.reduce((total: number, next: Vore) => total + next.maxVigors.Health / 5, 0),
amount: preys.reduce((total: number, next: Creature) => total + next.maxVigors.Health / 5, 0),
type: DamageType.Heal,
target: Vigor.Health
}
@@ -408,17 +316,17 @@ export class Stomach extends NormalVoreContainer {
export class InnerStomach extends InnerVoreContainer {
consumeVerb = new Verb('swallow')
releaseVerb = new Verb('hork')
constructor (owner: Vore, capacity: number, damage: Damage, escape: VoreContainer) {
constructor (owner: Creature, capacity: number, damage: Damage, 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: Vore, capacity: number, damage: Damage) {
constructor (owner: Creature, capacity: number, damage: Damage) {
super(new ImproperNoun('bowel', 'bowels').plural.all, owner, new Set([VoreType.Anal]), capacity, damage)
}

tickLine: PairLineArgs<Vore, { container: VoreContainer; damage: Damage }> = (user, target, args) => {
tickLine: PairLineArgs<Creature, { container: VoreContainer; damage: Damage }> = (user, target, args) => {
return new LogLine(`${user.name.capital} ${user.name.conjugate(
new RandomWord([
new Verb('crush', 'crushes'),
@@ -431,7 +339,7 @@ export class Bowels extends NormalVoreContainer {
export class Cock extends NormalVoreContainer {
fluidColor = "#eeeeee66";

constructor (owner: Vore, capacity: number, damage: Damage) {
constructor (owner: Creature, capacity: number, damage: Damage) {
super(
new ImproperNoun('cock').all,
owner,
@@ -441,7 +349,7 @@ export class Cock extends NormalVoreContainer {
)
}

tickLine: PairLineArgs<Vore, { container: VoreContainer; damage: Damage }> = (user, target, args) => {
tickLine: PairLineArgs<Creature, { container: VoreContainer; damage: Damage }> = (user, target, args) => {
return new LogLine(`${user.name.capital} ${user.name.conjugate(
new RandomWord([
new Verb('crush', 'crushes'),
@@ -454,7 +362,7 @@ export class Cock extends NormalVoreContainer {
export class Balls extends InnerVoreContainer {
fluidColor = "#eeeeeecc";

constructor (owner: Vore, capacity: number, damage: Damage, escape: Container) {
constructor (owner: Creature, capacity: number, damage: Damage, escape: Container) {
super(
new ImproperNoun('ball', 'balls').all.plural,
owner,
@@ -469,7 +377,7 @@ export class Balls extends InnerVoreContainer {
export class Slit extends NormalVoreContainer {
fluidColor = "#cccccc99";

constructor (owner: Vore, capacity: number, damage: Damage) {
constructor (owner: Creature, capacity: number, damage: Damage) {
super(
new ImproperNoun('slit').all,
owner,
@@ -483,7 +391,7 @@ export class Slit extends NormalVoreContainer {
export class Womb extends InnerVoreContainer {
fluidColor = "#ddddddbb";

constructor (owner: Vore, capacity: number, damage: Damage, escape: Container) {
constructor (owner: Creature, capacity: number, damage: Damage, escape: Container) {
super(
new ImproperNoun('womb').all,
owner,
@@ -496,7 +404,7 @@ export class Womb extends InnerVoreContainer {
}

export function biconnectContainers (outer: VoreContainer, inner: VoreContainer): void {
outer.onDigest = (prey: Vore) => {
outer.onDigest = (prey: Creature) => {
outer.digested = outer.digested.filter(victim => victim !== prey)
inner.digested.push(prey)
return inner.consumeLine(inner.owner, prey, { container: inner })


Laden…
Abbrechen
Speichern