Bläddra i källkod

Allow nouns to conjugate verbs

This is necessary to move away from the POVPair/etc. classes; verbs need to be
conjugated correctly for the subject they refer to. For example, 'You gulp' vs
'She gulps'
master
Fen Dweller 5 år sedan
förälder
incheckning
cc10c6e0bf
2 ändrade filer med 14 tillägg och 28 borttagningar
  1. +5
    -12
      src/game/creatures/withers.ts
  2. +9
    -16
      src/game/language.ts

+ 5
- 12
src/game/creatures/withers.ts Visa fil

@@ -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, POVSoloArgs, Verb } from '../language'
import { ImproperNoun, POVPair, ProperNoun, FemalePronouns, RandomWord, Adjective, POVPairArgs, 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'
@@ -304,20 +304,13 @@ class StompAllyAction extends Action {
}

class DevourAllAction extends GroupAction {
lines: POVPair<Creature, Creature> = new POVPair([
[[POV.First, POV.Third], (user: Creature, target: Creature) => new LogLine(`You scoop up ${target.name}!`)],
[[POV.Third, POV.First], (user: Creature) => new LogLine(`${user.name.capital} scoops you up!`)],
[[POV.Third, POV.Third], (user: Creature, target: Creature) => new LogLine(`${user.name.capital} scoops ${target.name} up!`)]
])
line = (user: Creature, target: Creature) => new LogLine(`${user.name.capital} ${user.name.conjugate(new Verb('scoop'))} ${target.name} up!`)

groupLines = new POVSoloArgs<Creature, { count: number }>([
[[POV.First], (user, args) => new LogLine(`${Words.SwallowSound.allCaps}! All ${args.count} of your prey pour down your ${Words.Slick} throat. They're just ${user.kind.all} chow now`)],
[[POV.Third], (user, args) => new LogLine(`${Words.SwallowSound.allCaps}! All ${args.count} of ${user.pronouns.possessive} prey pour down ${user.name}'s ${Words.Slick} gullet as ${user.pronouns.subjective} ${Words.Swallows.singular}; they're just ${user.kind.all} chow now`)]
])
groupLine = (user: Creature, args: { count: number }) => new LogLine(`${Words.SwallowSound.allCaps}! All ${args.count} of ${user.pronouns.possessive} prey pour down ${user.name.possessive} ${Words.Slick} gullet as ${user.pronouns.subjective} ${user.name.conjugate(Words.Swallows)}; they're just ${user.kind.all} chow now`)

execute (user: Creature, target: Creature): LogEntry {
this.container.consume(target)
return new LogLines(this.lines.run(user, target))
return new LogLines(this.line(user, target))
}

describe (user: Creature, target: Creature): LogEntry {
@@ -328,7 +321,7 @@ class DevourAllAction extends GroupAction {
return new LogLines(...targets.filter(target => this.test.test(user, target)).map(target => this.execute(user, target)).concat(
[
new Newline(),
this.groupLines.run(user, { count: targets.length })
this.groupLine(user, { count: targets.length })
]
))
}


+ 9
- 16
src/game/language.ts Visa fil

@@ -48,22 +48,6 @@ export class POVSolo<K extends Entity> {
}
}

export class POVSoloArgs<K extends Entity, U> {
run (user: K, args: U): LogEntry {
const choice = this.options.find(element => element[0][0] === user.perspective)

if (choice === undefined) {
return new LogLine("Fen didn't write any text for this...")
} else {
return choice[1](user, args)
}
}

constructor (private options: Array<[[POV], (user: K, args: U) => LogEntry]>) {

}
}

enum NounKind {
Specific,
Nonspecific,
@@ -326,6 +310,14 @@ export class Noun extends Word {

return result
}

conjugate (verb: Word): Word {
if (this.opt.plural) {
return verb.root
} else {
return verb.singular
}
}
}

export class ImproperNoun extends Noun {
@@ -437,6 +429,7 @@ export class PronounAsNoun extends Noun {
constructor (private pronouns: Pronoun, opt: WordOptions = emptyConfig) {
super(pronouns.subjective, pronouns.subjective, pronouns.possessive, opt)
this.options.nounKind = NounKind.All
this.options.plural = true
}

configure (opts: WordOptions): Word {


Laddar…
Avbryt
Spara