ソースを参照

Start replacing old language code

Instead of picking between several options, we simply have one line that gets filled
based on perspective.
master
Fen Dweller 5年前
コミット
3bc3609ffa
4個のファイルの変更65行の追加205行の削除
  1. +1
    -1
      src/game/creatures/kenzie.ts
  2. +5
    -25
      src/game/creatures/withers.ts
  3. +6
    -1
      src/game/language.ts
  4. +53
    -178
      src/game/vore.ts

+ 1
- 1
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'


+ 5
- 25
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<Creature, Creature, { damage: Damage }>([
[[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<Creature, Creature, { damage: Damage }> = 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<LogEntry> = []
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<Vore, Vore, { damage: Damage }>([
[[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<Vore, Vore>([
[[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))



+ 6
- 1
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<T> = (user: T) => LogEntry
export type SoloLineArgs<T, V> = (user: T, args: V) => LogEntry
export type PairLine<T> = (user: T, target: T) => LogEntry
export type PairLineArgs<T, V> = (user: T, target: T, args: V) => LogEntry

export class POVPair<K extends Entity, V extends Entity> {
run (user: K, target: V): LogEntry {


+ 53
- 178
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<Vore> = []
actions: Array<Action> = []

abstract consumeLines: POVPair<Vore, Vore>
abstract releaseLines: POVPair<Vore, Vore>
abstract struggleLines: POVPair<Vore, Vore>
consumeLine: PairLineArgs<Vore, { container: Container }> = (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<Vore, { container: Container }> = (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<Vore, { container: Container }> = (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<Vore>;
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<Vore> = []

abstract tickLines: POVPairArgs<Vore, Vore, { damage: Damage }>
abstract digestLines: POVPair<Vore, Vore>
abstract absorbLines: POVPair<Vore, Vore>
abstract disposeLines: POVPair<Vore, Vore>
digested: Array<Vore> = []

consumeVerb = new Verb('devour')
releaseVerb = new Verb('release', 'releases', 'releasing', 'released')
struggleVerb = new Verb('struggle', 'struggles', 'struggling', 'struggled')
tickLine: PairLineArgs<Vore, { 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}.`)
}

tick (dt: number): LogEntry {
const justDigested: Array<Vore> = []
digestLine: PairLineArgs<Vore, { container: VoreContainer }> = (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<LogEntry> = []
tick (dt: number): LogEntry {
const justDigested: Array<Vore> = []

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<LogEntry> = []

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<VoreType>, capacity: number, private damage: Damage) {
super(name, owner, voreTypes, capacity)
constructor (name: Noun, owner: Vore, voreTypes: Set<VoreType>, 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<VoreType>, 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<Vore, Vore>([
[[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<Vore, Vore>([
[[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<Vore, Vore>([
[[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<Vore, Vore, { damage: Damage }>([
[[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<Vore, Vore>([
[[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<Vore, Vore>([
[[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<Vore, Vore>([
[[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<Vore, Vore, { damage: Damage }>([
[[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<Vore, Vore, { damage: Damage }>([
[[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}`)]
])
}

読み込み中…
キャンセル
保存