From c7cdb8396fa68078cc93894c2e6881dc6f4a0c74 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Mon, 27 Jul 2020 13:20:31 -0400 Subject: [PATCH] Allow status effects to display numbers --- src/components/Statblock.vue | 20 ++++++++++++++++++++ src/game/combat.ts | 21 +++++++++++++++++---- src/game/creatures/kenzie.ts | 2 +- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/components/Statblock.vue b/src/components/Statblock.vue index d9d76dc..e14c165 100644 --- a/src/components/Statblock.vue +++ b/src/components/Statblock.vue @@ -15,6 +15,8 @@
+
{{ status.topLeft }}
+
{{ status.bottomRight }}
{{ status.name }}
{{ status.desc }}
@@ -301,6 +303,24 @@ a { .statblock-status-icons > i { font-size: 16pt; + position: relative; +} + +.statblock-status-icon-topleft, +.statblock-status-icon-bottomright { + position: absolute; + font-family: sans-serif; + font-weight: 300; + color: #999; +} + +.statblock-status-icon-topleft { + top: -12pt; +} + +.statblock-status-icon-bottomright { + top: 4pt; + right: -12pt; } diff --git a/src/game/combat.ts b/src/game/combat.ts index 9f5b52b..7adf216 100644 --- a/src/game/combat.ts +++ b/src/game/combat.ts @@ -1,5 +1,5 @@ import { Creature } from './entity' -import { TextLike, DynText, ToBe } from './language' +import { TextLike, DynText, ToBe, LiveText } from './language' import { LogEntry, LogLines, FAElem, LogLine, FormatEntry, FormatOpt, PropElem, nilLog } from './interface' export enum DamageType { @@ -333,6 +333,8 @@ export interface VisibleStatus { name: TextLike; desc: TextLike; icon: TextLike; + topLeft: string; + bottomRight: string; } /** @@ -343,6 +345,9 @@ export class ImplicitStatus implements VisibleStatus { constructor (public name: TextLike, public desc: TextLike, public icon: string) { } + + topLeft = '' + bottomRight = '' } /** @@ -357,6 +362,9 @@ export abstract class StatusEffect implements VisibleStatus { } + get topLeft () { return '' } + get bottomRight () { return '' } + onApply (creature: Creature): LogEntry { return nilLog } onRemove (creature: Creature): LogEntry { return nilLog } preAction (creature: Creature): { prevented: boolean; log: LogEntry } { @@ -368,8 +376,13 @@ export abstract class StatusEffect implements VisibleStatus { } export class StunEffect extends StatusEffect { - constructor () { - super('Stun', 'Stunned!', 'fas fa-sun') + constructor (private duration: number) { + super('Stun', 'Cannot act!', 'fas fa-sun') + this.desc = new DynText('Stunned for your next ', new LiveText(this, x => x.duration), ' actions!') + } + + get topLeft () { + return this.duration.toString() } onApply (creature: Creature) { @@ -381,7 +394,7 @@ export class StunEffect extends StatusEffect { } preAction (creature: Creature): { prevented: boolean; log: LogEntry } { - if (Math.random() < 0.3) { + if (--this.duration <= 0) { return { prevented: true, log: new LogLines( diff --git a/src/game/creatures/kenzie.ts b/src/game/creatures/kenzie.ts index f818964..5572c9d 100644 --- a/src/game/creatures/kenzie.ts +++ b/src/game/creatures/kenzie.ts @@ -12,7 +12,7 @@ class StompAttack extends AttackAction { const damage = this.damage.calc(user, target) const targetResult = target.takeDamage(damage) const ownResult = this.successLine(user, target, { damage: damage }) - const effResult = target.applyEffect(new StunEffect()) + const effResult = target.applyEffect(new StunEffect(3)) console.log(target.effects) return new LogLines(ownResult, targetResult, effResult) } else {