From 4a04be11ffd78f12946af6e0ba6e0bccd2c34f44 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Tue, 13 Oct 2020 16:14:13 -0400 Subject: [PATCH] Require at least 1 prey to use Flaunt --- src/game/combat/conditions.ts | 34 ++++++++++++++++++++++++++++++++-- src/game/combat/perks.ts | 19 ++++++++++++++++--- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/src/game/combat/conditions.ts b/src/game/combat/conditions.ts index d99ad92..f168389 100644 --- a/src/game/combat/conditions.ts +++ b/src/game/combat/conditions.ts @@ -1,7 +1,7 @@ -import { Condition, Vigor } from "../combat" +import { Condition, Stat, Vigor, VoreStat } from "../combat" import { Creature } from "../creature" import { Container } from '../vore' -import { LogEntry, LogLine, PropElem } from '../interface' +import { FAElem, LogEntry, LogLine, PropElem } from '../interface' import { ToBe, Verb } from '../language' import * as Words from '../words' @@ -275,3 +275,33 @@ export class MassRatioCondition implements Condition { } } } + +export class StatCondition implements Condition { + constructor (private stat: Stat | VoreStat, private amount: number) { + + } + + allowed (user: Creature, target: Creature): boolean { + if (this.stat in Stat) { + return user.stats[this.stat as Stat] >= this.amount + } else if (this.stat in VoreStat) { + return user.voreStats[this.stat as VoreStat] >= this.amount + } else { + return false + } + } + + explain (user: Creature, target: Creature): LogEntry { + if (this.allowed(user, target)) { + return new LogLine( + `${user.name.capital} ${user.name.conjugate(Words.Have)} at least ${this.amount} `, + new PropElem(this.stat) + ) + } else { + return new LogLine( + `${user.name.capital} must ${user.name.conjugate(Words.Have)} at least ${this.amount} `, + new PropElem(this.stat) + ) + } + } +} diff --git a/src/game/combat/perks.ts b/src/game/combat/perks.ts index 834b7e2..0637eb1 100644 --- a/src/game/combat/perks.ts +++ b/src/game/combat/perks.ts @@ -1,8 +1,8 @@ import { Effective, Damage, DamageType, CompositionAction, StatDamageFormula, Action, Stat, Vigor, VoreStat } from '../combat' import { TextLike } from '../language' import { Creature } from '../creature' -import { TestCategory } from './tests' -import { EnemyCondition, PairCondition, TogetherCondition } from './conditions' +import { CompositionTest, OpposedStatScorer, TestCategory } from './tests' +import { EnemyCondition, PairCondition, StatCondition, TogetherCondition } from './conditions' import { DamageConsequence, LogConsequence } from './consequences' import { LogLine } from '../interface' import * as Words from '../words' @@ -93,7 +93,8 @@ export class FlauntPerk extends Perk { conditions: [ new PairCondition(), new EnemyCondition(), - new TogetherCondition() + new TogetherCondition(), + new StatCondition(VoreStat.Prey, 1) ], consequences: [ new LogConsequence( @@ -106,6 +107,18 @@ export class FlauntPerk extends Perk { ] ) ) + ], + tests: [ + new CompositionTest( + [ + new OpposedStatScorer( + { Charm: 1, Bulk: 0.01 }, + { Willpower: 1 } + ) + ], + (user, target) => new LogLine(`${user.name.capital.possessive} predatory advances aren't enough to intimidate ${target.name.objective}.`), + TestCategory.Vore + ) ] } )]