From ee4440a71af5a47a613bea0df4b40e9667c24c63 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Sun, 19 Jul 2020 16:46:30 -0400 Subject: [PATCH] Add a chew action for Withers --- src/App.vue | 2 +- src/components/ActionButton.vue | 1 + src/components/Combat.vue | 4 +-- src/game/combat/actions.ts | 2 +- src/game/combat/conditions.ts | 11 +++++++ src/game/creatures/withers.ts | 58 ++++++++++++++++++++++++++++++--- src/game/entity.ts | 3 +- 7 files changed, 71 insertions(+), 10 deletions(-) diff --git a/src/App.vue b/src/App.vue index dc6dec8..e98f9b1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -108,7 +108,7 @@ body, html { } *::-webkit-scrollbar { - height: 2px; + height: 12px; } *::-webkit-scrollbar-button { width: 0px; diff --git a/src/components/ActionButton.vue b/src/components/ActionButton.vue index 33dd78a..721343e 100644 --- a/src/components/ActionButton.vue +++ b/src/components/ActionButton.vue @@ -57,6 +57,7 @@ export default class ActionButton extends Vue { background: #333; border-color: #666; border-style: outset; + user-select: none; } .action-button:hover { diff --git a/src/components/Combat.vue b/src/components/Combat.vue index 3999ec5..b86b826 100644 --- a/src/components/Combat.vue +++ b/src/components/Combat.vue @@ -287,13 +287,13 @@ div.right-move { div.left-move { text-align: start; margin-right: 25%; - margin-left: 5%; + margin-left: 2%; } div.right-move { text-align: end; margin-left: 25%; - margin-right: 5%; + margin-right: 2%; } #log img { diff --git a/src/game/combat/actions.ts b/src/game/combat/actions.ts index 56c0108..7cd83a5 100644 --- a/src/game/combat/actions.ts +++ b/src/game/combat/actions.ts @@ -176,7 +176,7 @@ export abstract class EatenAction extends PairAction { } } - constructor (public container: VoreContainer, name: TextLike, desc: string) { + constructor (public container: Container, name: TextLike, desc: string) { super(new DynText(name, ' (', new LiveText(container, x => x.name.all), ')'), desc, [new CapableCondition()]) } } diff --git a/src/game/combat/conditions.ts b/src/game/combat/conditions.ts index 2aef981..6a28c51 100644 --- a/src/game/combat/conditions.ts +++ b/src/game/combat/conditions.ts @@ -1,5 +1,6 @@ import { Condition, Vigor } from "../combat" import { Creature } from "../entity" +import { Container } from '../vore' export class InverseCondition implements Condition { allowed (user: Creature, target: Creature): boolean { @@ -31,3 +32,13 @@ export class TogetherCondition implements Condition { return user.containedIn === target.containedIn } } + +export class ContainerCondition implements Condition { + allowed (user: Creature, target: Creature): boolean { + return target.containedIn === this.container + } + + constructor (private container: Container) { + + } +} diff --git a/src/game/creatures/withers.ts b/src/game/creatures/withers.ts index ab9569b..448eb07 100644 --- a/src/game/creatures/withers.ts +++ b/src/game/creatures/withers.ts @@ -1,12 +1,13 @@ import { Creature, POV } from '../entity' -import { Damage, DamageType, ConstantDamageFormula, Vigor, Side, GroupAction } from '../combat' +import { Damage, DamageType, ConstantDamageFormula, Vigor, Side, GroupAction, CombatTest, Stat, Action } from '../combat' import { ImproperNoun, POVPair, ProperNoun, FemalePronouns, RandomWord, Adjective, POVPairArgs, POVSoloArgs, Verb } from '../language' import { LogLine, LogLines, LogEntry, Newline } from '../interface' -import { VoreType, Stomach, VoreContainer, Vore, NormalContainer } from '../vore' -import { AttackAction, FeedAction, TransferAction } from '../combat/actions' -import { TogetherCondition } from '../combat/conditions' +import { VoreType, Stomach, VoreContainer, Vore, NormalContainer, Container } from '../vore' +import { AttackAction, FeedAction, TransferAction, EatenAction } from '../combat/actions' +import { TogetherCondition, ContainerCondition } from '../combat/conditions' import { InstantKill } from '../combat/effects' import * as Words from '../words' +import { StatVigorTest } from '../combat/tests' class MawContainer extends NormalContainer { consumeVerb = new Verb('grab', 'grabs', 'grabbing', 'grabbed') @@ -54,6 +55,44 @@ class BiteAction extends AttackAction { } } +class ChewAction extends GroupAction { + lines: POVPairArgs = new POVPairArgs([ + [[POV.First, POV.Third], (user, target, args: { damage: Damage }) => new LogLine(`You chew on ${target.name} for `, args.damage.renderShort(), `!`)], + [[POV.Third, POV.First], (user, target, args: { damage: Damage }) => new LogLine(`${user.name.capital} chews on you for `, args.damage.renderShort(), `!`)], + [[POV.Third, POV.Third], (user, target, args: { damage: Damage }) => new LogLine(`${user.name.capital} chews on ${target.name} for `, args.damage.renderShort(), `!`)] + ]) + + describeGroup (user: Creature, targets: Creature[]): LogEntry { + return new LogLine('CRUNCH') + } + + execute (user: Creature, target: Creature): LogEntry { + const results: Array = [] + results.push(this.lines.run(user, target, { damage: this.damage })) + results.push(new LogLine(' ')) + results.push(target.takeDamage(this.damage)) + + if (target.vigors.Health <= 0) { + if (this.killAction.allowed(user, target)) { + results.push(new Newline()) + results.push(this.killAction.execute(user, target)) + } + } + + return new LogLine(...results) + } + + describe (user: Creature, target: Creature): LogEntry { + return new LogLine('Do the crunch') + } + + constructor (private damage: Damage, container: Container, private killAction: Action) { + super('Chew', 'Give them the big chew', [ + new ContainerCondition(container) + ]) + } +} + class StompAction extends GroupAction { lines: POVPair = new POVPair([ [[POV.First, POV.Third], (user: Creature, target: Creature) => new LogLine(`You flatten ${target.name} under your foot!`)], @@ -102,7 +141,7 @@ class DevourAllAction extends GroupAction { } executeGroup (user: Creature, targets: Array): LogEntry { - return new LogLines(...targets.map(target => this.execute(user, target)).concat( + return new LogLines(...targets.filter(target => this.test.test(user, target)).map(target => this.execute(user, target)).concat( [ new Newline(), this.groupLines.run(user, { count: targets.length }) @@ -114,10 +153,13 @@ class DevourAllAction extends GroupAction { return new LogLine('Eat all ', targets.length.toString(), ' of \'em!') } + private test: CombatTest + constructor (private container: VoreContainer) { super('Devour All', 'GULP!', [ new TogetherCondition() ]) + this.test = new StatVigorTest(Stat.Power) } } @@ -163,5 +205,11 @@ export class Withers extends Creature { const grapple = new MawContainer(this, stomach) this.otherContainers.push(grapple) + + this.actions.push(new ChewAction(new Damage( + { target: Vigor.Health, type: DamageType.Crush, amount: 10000 } + ), + grapple, + new TransferAction(grapple, stomach))) } } diff --git a/src/game/entity.ts b/src/game/entity.ts index e524e84..ee97cc1 100644 --- a/src/game/entity.ts +++ b/src/game/entity.ts @@ -106,6 +106,7 @@ export class Creature extends Vore implements Combatant { } takeDamage (damage: Damage): LogEntry { + const startHealth = this.vigors.Health damage.damages.forEach(instance => { const resistance: number|undefined = this.resistances.get(instance.type) if (resistance !== undefined) { @@ -123,7 +124,7 @@ export class Creature extends Vore implements Combatant { } }) - if (this.vigors.Health <= 0) { + if (this.vigors.Health <= 0 && startHealth > 0) { return this.destroy() } else { return new LogLine()