diff --git a/src/game/combat/actions.ts b/src/game/combat/actions.ts index 38f37ce..e0a9e11 100644 --- a/src/game/combat/actions.ts +++ b/src/game/combat/actions.ts @@ -4,7 +4,7 @@ import { Entity, POV, Creature } from '../entity' import { Damage, DamageFormula, Stat, Vigor, Action } from '../combat' import { LogLine, LogLines, LogEntry, CompositeLog } from '../interface' import { VoreContainer, Container } from '../vore' -import { CapableCondition, UserDrainedVigorCondition, TogetherCondition, EnemyCondition, SoloCondition, PairCondition } from './conditions' +import { CapableCondition, UserDrainedVigorCondition, TogetherCondition, EnemyCondition, SoloCondition, PairCondition, ContainsCondition, ContainedCondition } from './conditions' export class AttackAction extends Action { protected test: StatTest @@ -147,19 +147,11 @@ export class StruggleAction extends Action { [[POV.Third, POV.Third], (user, target) => new LogLine(`${user.name.capital} unsuccessfully struggles against ${target.name}`)] ]) - allowed (user: Creature, target: Creature) { - if (user.containedIn === this.container && this.container.owner === target) { - return super.allowed(user, target) - } else { - return false - } - } - constructor (public container: Container) { super( new DynText('Struggle (', new LiveText(container, x => x.name.all), ')'), 'Try to escape from your foe', - [new CapableCondition(), new PairCondition()] + [new CapableCondition(), new PairCondition(), new ContainedCondition(container)] ) this.test = new StatVigorTest(Stat.Power) } @@ -243,7 +235,7 @@ export class ReleaseAction extends Action { super( new DynText('Release (', new LiveText(container, x => x.name.all), ')'), 'Release one of your prey', - [new CapableCondition(), new PairCondition()] + [new CapableCondition(), new PairCondition(), new ContainsCondition(container)] ) } diff --git a/src/game/combat/conditions.ts b/src/game/combat/conditions.ts index 00cb724..1e8ed50 100644 --- a/src/game/combat/conditions.ts +++ b/src/game/combat/conditions.ts @@ -56,7 +56,17 @@ export class TogetherCondition implements Condition { } } -export class ContainerCondition implements Condition { +export class ContainedCondition implements Condition { + allowed (user: Creature, target: Creature): boolean { + return user.containedIn === this.container + } + + constructor (private container: Container) { + + } +} + +export class ContainsCondition implements Condition { allowed (user: Creature, target: Creature): boolean { return target.containedIn === this.container } diff --git a/src/game/creatures/withers.ts b/src/game/creatures/withers.ts index 76d24ab..39b04d8 100644 --- a/src/game/creatures/withers.ts +++ b/src/game/creatures/withers.ts @@ -4,11 +4,55 @@ import { ImproperNoun, POVPair, ProperNoun, FemalePronouns, RandomWord, Adjectiv import { LogLine, LogLines, LogEntry, Newline } from '../interface' import { VoreType, Stomach, VoreContainer, Vore, NormalContainer, Container } from '../vore' import { AttackAction, FeedAction, TransferAction, EatenAction } from '../combat/actions' -import { TogetherCondition, ContainerCondition, EnemyCondition, AllyCondition, PairCondition, CapableCondition } from '../combat/conditions' +import { TogetherCondition, ContainsCondition, EnemyCondition, AllyCondition, PairCondition, CapableCondition } from '../combat/conditions' import { InstantKill } from '../combat/effects' import * as Words from '../words' import { StatVigorTest } from '../combat/tests' +class LevelDrain extends Action { + lines = new POVPairArgs([ + [[POV.First, POV.Third], (user, target, args) => new LogLine(`Your ${args.container.name} drains power from ${target.name}, siphoning `, args.damage.renderShort(), ` from ${target.pronouns.possessive} body!`)], + [[POV.Third, POV.First], (user, target, args) => new LogLine(`${user.name.capital}'s ${args.container.name} drains power from you, siphoning `, args.damage.renderShort(), ` from your body!`)], + [[POV.Third, POV.Third], (user, target, args) => new LogLine(`${user.name.capital}'s ${args.container.name} drains power from ${target.name}, siphoning `, args.damage.renderShort(), ` from ${target.pronouns.possessive} body!`)] + ]) + + execute (user: Creature, target: Creature): LogEntry { + const damage: Damage = new Damage(...Object.keys(Stat).map(stat => { + return { + type: DamageType.Acid, + target: stat as Stat, + amount: target.baseStats[stat as Stat] / 5 + } + })) + const heal: Damage = new Damage(...Object.keys(Stat).map(stat => { + return { + type: DamageType.Heal, + target: stat as Stat, + amount: target.baseStats[stat as Stat] / 5 + } + })) + + user.takeDamage(heal) + const targetResult = target.takeDamage(damage) + + return new LogLines(this.lines.run(user, target, { damage: damage, container: this.container }), targetResult) + } + + describe (user: Creature, target: Creature): LogEntry { + return new LogLine(`Drain energy from ${target.name}`) + } + + constructor (private container: Container) { + super( + 'Level Drain', + 'Drain energy from your prey', + [ + new ContainsCondition(container), + new CapableCondition() + ] + ) + } +} class HypnotizeAction extends Action { lines = new POVPair([ [[POV.First, POV.Third], (user, target) => new LogLine(`Your hypnotic gaze enthralls ${target.name}, putting ${target.pronouns.objective} under your control!`)], @@ -89,7 +133,7 @@ class FlexToesAction extends GroupAction { constructor (private damage: DamageFormula, container: Container) { super('Flex Toes', 'Flex your toes!', [ - new ContainerCondition(container), + new ContainsCondition(container), new PairCondition() ]) } @@ -189,7 +233,7 @@ class ChewAction extends GroupAction { constructor (private damage: DamageFormula, container: Container, private killAction: Action) { super('Chew', 'Give them the big chew', [ - new ContainerCondition(container) + new ContainsCondition(container) ]) } } @@ -378,5 +422,6 @@ export class Withers extends Creature { ) this.actions.push(new HypnotizeAction()) + this.actions.push(new LevelDrain(stomach)) } }