From b59f185bf8dd445c07ed3fa26c79082dfcd6ca0d Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Wed, 18 Nov 2020 16:33:13 -0500 Subject: [PATCH] Add optional words --- src/game/combat/actions.ts | 2 +- src/game/creatures/characters/inazuma.ts | 20 ++++++++++++++- src/game/language.ts | 32 ++++++++++++++++++++++++ src/game/vore.ts | 2 +- src/game/words.ts | 19 ++++++++------ 5 files changed, 65 insertions(+), 10 deletions(-) diff --git a/src/game/combat/actions.ts b/src/game/combat/actions.ts index 43961be..90e2c24 100644 --- a/src/game/combat/actions.ts +++ b/src/game/combat/actions.ts @@ -187,7 +187,7 @@ export class StruggleAction extends Action { new CompositionTest( [ new OpposedStatScorer( - { Power: 100, Agility: 1, Bulk: 0.05 }, + { Power: 1, Agility: 1, Bulk: 0.05 }, { Toughness: 1, Reflexes: 1, Mass: 0.05 } ) ], diff --git a/src/game/creatures/characters/inazuma.ts b/src/game/creatures/characters/inazuma.ts index 40b3288..b1acb34 100644 --- a/src/game/creatures/characters/inazuma.ts +++ b/src/game/creatures/characters/inazuma.ts @@ -4,8 +4,9 @@ import { PairCondition, TogetherCondition } from '@/game/combat/conditions' import { ConsumeConsequence, DamageConsequence, DrainConsequence, StatusConsequence } from '@/game/combat/consequences' import { LogGroupConsequence } from '@/game/combat/groupConsequences' import { PreyTargeter, SideTargeter, SoloTargeter } from '@/game/combat/targeters' +import { CompositionTest, OpposedStatScorer, TestCategory } from '@/game/combat/tests' import { Creature } from '@/game/creature' -import { LogLine } from '@/game/interface' +import { LogLine, nilLog } from '@/game/interface' import { ImproperNoun, MalePronouns, ProperNoun } from '@/game/language' import { anyVore, Stomach } from '@/game/vore' @@ -48,6 +49,23 @@ export default class Inazuma extends Creature { conditions: [new PairCondition(), new TogetherCondition()], targeters: [new SideTargeter()], consequences: [new ConsumeConsequence(stomach)], + tests: [new CompositionTest( + [ + new OpposedStatScorer( + { + Power: 0.5, + Agility: 0.75 + }, + { + Power: 0.5, + Reflexes: 0.75 + } + ) + ], + () => nilLog, + TestCategory.Vore, + 0 + )], groupConsequences: [new LogGroupConsequence( (user, targets) => new LogLine(`With a mighty GULP!, all ${targets.length} of ${user.name.possessive} prey are swallowed down.`) )] diff --git a/src/game/language.ts b/src/game/language.ts index 8ff1ec8..e48b28e 100644 --- a/src/game/language.ts +++ b/src/game/language.ts @@ -210,6 +210,24 @@ export abstract class Word { } } +export class OptionalWord extends Word { + constructor (public word: Word, private chance = 0.5, private suffix = " ") { + super(word.opt) + } + + configure (opts: WordOptions): Word { + return new OptionalWord(this.word.configure(opts), this.chance, this.suffix) + } + + toString (): string { + if (Math.random() < this.chance) { + return this.word + this.suffix + } else { + return "" + } + } +} + export class RandomWord extends Word { private history: { last: number } constructor (public choices: Array, opt: WordOptions = emptyConfig, history: { last: number } = { last: -1 }) { @@ -329,6 +347,20 @@ export class Adjective extends Word { } } +export class Adverb extends Word { + constructor (private adverb: string, opt: WordOptions = emptyConfig) { + super(opt) + } + + configure (opt: WordOptions): Word { + return new Adverb(this.adverb, opt) + } + + toString (): string { + return this.adverb + } +} + export class Verb extends Word { constructor (private _root: string, private _singular: string = _root + "s", private _present: string = _root + "ing", private _past: string = _root + "ed", private _pastParticiple: string = _past, public opt: WordOptions = emptyConfig) { super(opt) diff --git a/src/game/vore.ts b/src/game/vore.ts index 90293a8..c841c7d 100644 --- a/src/game/vore.ts +++ b/src/game/vore.ts @@ -211,7 +211,7 @@ export abstract class NormalVoreContainer extends NormalContainer implements Vor consumeLine (user: Creature, target: Creature) { return new RandomEntry( - new LogLine(`${user.name.capital} ${user.name.conjugate(this.consumeVerb)} ${target.name.objective}, forcing ${target.pronouns.objective} ${this.consumePreposition} ${user.pronouns.possessive} ${this.name}.`), + new LogLine(`${user.name.capital} ${user.name.conjugate(this.consumeVerb)} ${target.name.objective}, ${Words.Force.present} ${target.pronouns.objective} ${this.consumePreposition} ${user.pronouns.possessive} ${this.name}.`), new LogLine(`${user.name.capital} ${user.name.conjugate(new Verb("pounce"))} on ${target.name.objective} and ${user.name.conjugate(this.consumeVerb)} ${target.pronouns.objective}, ${Words.Force.present} ${target.pronouns.objective} ${this.consumePreposition} ${user.pronouns.possessive} ${this.name}.`) ) } diff --git a/src/game/words.ts b/src/game/words.ts index bd98e4f..3ffba23 100644 --- a/src/game/words.ts +++ b/src/game/words.ts @@ -1,4 +1,4 @@ -import { RandomWord, ImproperNoun, Adjective, Verb } from '@/game/language' +import { RandomWord, ImproperNoun, Adjective, Verb, Adverb } from '@/game/language' export const Have = new Verb( "have", @@ -74,12 +74,12 @@ export const Bulge = new RandomWord([ ]) export const Brutally = new RandomWord([ - new Adjective('brutally'), - new Adjective('viciously'), - new Adjective('callously'), - new Adjective('savagely'), - new Adjective('ruthlessly'), - new Adjective('mercilessly') + new Adverb('brutally'), + new Adverb('viciously'), + new Adverb('callously'), + new Adverb('savagely'), + new Adverb('ruthlessly'), + new Adverb('mercilessly') ]) export const Fatal = new RandomWord([ @@ -115,3 +115,8 @@ export const Flaunt = new RandomWord([ new Verb("flaunt"), new Verb("show off", "shows off", "showing off", "shown off") ]) + +export const Sloppily = new RandomWord([ + new Adverb("sloppily"), + new Adverb("messily") +])