Procházet zdrojové kódy

Add a way to check if a noun/pronoun is plural

vintage
Fen Dweller před 5 roky
rodič
revize
95b45510f9
2 změnil soubory, kde provedl 15 přidání a 7 odebrání
  1. +2
    -2
      src/game/creatures/cafat.ts
  2. +13
    -5
      src/game/language.ts

+ 2
- 2
src/game/creatures/cafat.ts Zobrazit soubor

@@ -56,8 +56,8 @@ class BelchAction extends AttackAction {
class CrushAction extends EatenAction { class CrushAction extends EatenAction {
lines: POVPair<Entity, Entity> = new POVPair([ lines: POVPair<Entity, Entity> = new POVPair([
[[POV.First, POV.Third], (user, target) => new LogLine(`You crush ${target.name} `, new FAElem('fas fa-skull'))], [[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( private damage: Damage = new Damage(


+ 13
- 5
src/game/language.ts Zobrazit soubor

@@ -60,6 +60,10 @@ enum VowelSound {
NonVowel NonVowel
} }


export interface Pluralizable {
isPlural: boolean;
}

interface WordOptions { interface WordOptions {
plural: boolean; plural: boolean;
capital: boolean; capital: boolean;
@@ -92,7 +96,7 @@ export class DynText {
return (this.parts.map(part => part.toString())).join('') 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 }) { 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) return new Noun(this.singularNoun, this.pluralNoun, opts)
} }


get isPlural (): boolean {
return this.options.plural
}

toString (): string { toString (): string {
let result: string let result: string


@@ -207,8 +215,8 @@ interface PronounDict {
reflexive: string; 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', objective: 'them',
possessive: 'their', possessive: 'their',
reflexive: 'themself' reflexive: 'themself'
})
}, false, true)


export const TheyPluralPronouns = new Pronoun({ export const TheyPluralPronouns = new Pronoun({
subjective: 'they', subjective: 'they',
objective: 'them', objective: 'them',
possessive: 'their', possessive: 'their',
reflexive: 'themselves' reflexive: 'themselves'
})
}, false, true)


export const ObjectPronouns = new Pronoun({ export const ObjectPronouns = new Pronoun({
subjective: 'it', subjective: 'it',


Načítá se…
Zrušit
Uložit