浏览代码

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'
vintage
Fen Dweller 5 年前
父节点
当前提交
cc10c6e0bf
共有 2 个文件被更改,包括 14 次插入28 次删除
  1. +5
    -12
      src/game/creatures/withers.ts
  2. +9
    -16
      src/game/language.ts

+ 5
- 12
src/game/creatures/withers.ts 查看文件

@@ -1,6 +1,6 @@
import { Creature, POV } from '../entity' import { Creature, POV } from '../entity'
import { Damage, DamageType, ConstantDamageFormula, Vigor, Side, GroupAction, CombatTest, Stat, DamageFormula, UniformRandomDamageFormula, Action, DamageInstance, StatDamageFormula, VoreStat } from '../combat' 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 { LogLine, LogLines, LogEntry, Newline } from '../interface'
import { VoreType, Stomach, VoreContainer, Vore, NormalContainer, Container } from '../vore' import { VoreType, Stomach, VoreContainer, Vore, NormalContainer, Container } from '../vore'
import { AttackAction, FeedAction, TransferAction, EatenAction } from '../combat/actions' import { AttackAction, FeedAction, TransferAction, EatenAction } from '../combat/actions'
@@ -304,20 +304,13 @@ class StompAllyAction extends Action {
} }


class DevourAllAction extends GroupAction { 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 { execute (user: Creature, target: Creature): LogEntry {
this.container.consume(target) 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 { 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( return new LogLines(...targets.filter(target => this.test.test(user, target)).map(target => this.execute(user, target)).concat(
[ [
new Newline(), new Newline(),
this.groupLines.run(user, { count: targets.length })
this.groupLine(user, { count: targets.length })
] ]
)) ))
} }


+ 9
- 16
src/game/language.ts 查看文件

@@ -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 { enum NounKind {
Specific, Specific,
Nonspecific, Nonspecific,
@@ -326,6 +310,14 @@ export class Noun extends Word {


return result return result
} }

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


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


configure (opts: WordOptions): Word { configure (opts: WordOptions): Word {


正在加载...
取消
保存