From 95b45510f930d7c0289c9565173af1c117c22040 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Sun, 12 Jul 2020 19:21:39 -0400 Subject: [PATCH] Add a way to check if a noun/pronoun is plural --- src/game/creatures/cafat.ts | 4 ++-- src/game/language.ts | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/game/creatures/cafat.ts b/src/game/creatures/cafat.ts index 00b8247..a0ab123 100644 --- a/src/game/creatures/cafat.ts +++ b/src/game/creatures/cafat.ts @@ -56,8 +56,8 @@ class BelchAction extends AttackAction { class CrushAction extends EatenAction { lines: POVPair = new POVPair([ [[POV.First, POV.Third], (user, target) => new LogLine(`You crush ${target.name} `, new FAElem('fas fa-skull'))], - [[POV.Third, POV.First], (user, target) => new CompositeLog(new LogLine(`${user.name.capital} crushes you; ${user.pronouns.subjective} belches as ${user.pronouns.possessive} gut lets out a fatal CRUNCH `, new FAElem('fas fa-skull')), new ImgElem('./media/cafat/images/crunch.webp'))], - [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} crushes ${target.name}; ${user.pronouns.subjective} belches as ${user.pronouns.possessive} gut lets out a fatal CRUNCH `, new FAElem('fas fa-skull'))] + [[POV.Third, POV.First], (user, target) => new CompositeLog(new LogLine(`${user.name.capital} crushes you; ${user.pronouns.subjective} ${user.pronouns.isPlural ? 'belch' : 'belches'} as ${user.pronouns.possessive} gut lets out a fatal CRUNCH `, new FAElem('fas fa-skull')), new ImgElem('./media/cafat/images/crunch.webp'))], + [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} crushes ${target.name}; ${user.pronouns.subjective} ${user.pronouns.isPlural ? 'belch' : 'belches'} as ${user.pronouns.possessive} gut lets out a fatal CRUNCH `, new FAElem('fas fa-skull'))] ]) private damage: Damage = new Damage( diff --git a/src/game/language.ts b/src/game/language.ts index af64d99..7638121 100644 --- a/src/game/language.ts +++ b/src/game/language.ts @@ -60,6 +60,10 @@ enum VowelSound { NonVowel } +export interface Pluralizable { + isPlural: boolean; +} + interface WordOptions { plural: boolean; capital: boolean; @@ -92,7 +96,7 @@ export class DynText { return (this.parts.map(part => part.toString())).join('') } } -export class Noun { +export class Noun implements Pluralizable { constructor (private singularNoun: string, private pluralNoun: string|null = null, private options: WordOptions = { plural: false, capital: false, proper: false, kind: NounKind.Specific, vowel: VowelSound.Default, count: true }) { } @@ -145,6 +149,10 @@ export class Noun { return new Noun(this.singularNoun, this.pluralNoun, opts) } + get isPlural (): boolean { + return this.options.plural + } + toString (): string { let result: string @@ -207,8 +215,8 @@ interface PronounDict { reflexive: string; } -export class Pronoun { - constructor (private pronouns: PronounDict, private capitalize: boolean = false) { +export class Pronoun implements Pluralizable { + constructor (private pronouns: PronounDict, private capitalize: boolean = false, public isPlural: boolean = false) { } @@ -260,14 +268,14 @@ export const TheyPronouns = new Pronoun({ objective: 'them', possessive: 'their', reflexive: 'themself' -}) +}, false, true) export const TheyPluralPronouns = new Pronoun({ subjective: 'they', objective: 'them', possessive: 'their', reflexive: 'themselves' -}) +}, false, true) export const ObjectPronouns = new Pronoun({ subjective: 'it',