diff --git a/assets/sampledata.html b/assets/sampledata.html index 60f48cd..3085941 100644 --- a/assets/sampledata.html +++ b/assets/sampledata.html @@ -50,6 +50,10 @@ Your VIGOUR increases by 10. + But at a small cost to your Chi. + + Your PSI reduces by 1. + Turn to 203. Or, [[return to the beginning->Start]]. diff --git a/src/plugins/attributephraseplugin.js b/src/plugins/attributephraseplugin.js index acd2cca..0c1b2d1 100644 --- a/src/plugins/attributephraseplugin.js +++ b/src/plugins/attributephraseplugin.js @@ -9,7 +9,7 @@ import '../core/types' // This matches a sentence by itself in a paragraph. const deadPhraseRegex = /\nYou are dead.\n/g // This matches a sentence that ends a paragraph. -const phraseRegex = /Your (VIGOUR|AGILITY|PSI) ((?:is restored)|(?:increases by)|(?:decreases by))( \d{1,2})?\.\n/g +const phraseRegex = /Your (VIGOUR|AGILITY|PSI) ((?:is restored)|(?:increases by)|(?:decreases by)|(?:reduces by))( \d{1,2})?\.\n/g export class AttributePhrasePlugin extends BBScannerPlugin { /** @type {CharacterSheetPlugin} */ @@ -61,7 +61,7 @@ export class AttributePhrasePlugin extends BBScannerPlugin { const amount = action === 'is restored' ? 1000 // a high amount restores the attribute : phraseMatch[3] - ? parseInt(phraseMatch[3].trimStart()) * (action === 'decreases by' ? -1 : 1) + ? parseInt(phraseMatch[3].trimStart()) * (action === 'decreases by' || action === 'reduces by' ? -1 : 1) : 0 this.#charactersheet[attribute] += amount diff --git a/src/plugins/charactersheetplugin.js b/src/plugins/charactersheetplugin.js index 5048fdc..29248a9 100644 --- a/src/plugins/charactersheetplugin.js +++ b/src/plugins/charactersheetplugin.js @@ -134,6 +134,10 @@ export class CharacterSheetPlugin extends BBGlobalStatePlugin { this.#vigourlabel.textContent = value this.setCurrentState({ sheet: structuredClone(this.#currentSheet) }) + // Handle the death case + if (value === 0 ) { + this.player.preventNavigation() + } } /** diff --git a/src/plugins/combatplugin.js b/src/plugins/combatplugin.js index ccc1f99..dd97a5d 100644 --- a/src/plugins/combatplugin.js +++ b/src/plugins/combatplugin.js @@ -35,13 +35,6 @@ export class CombatPlugin extends BBScannerPlugin { init (player) { super.init(player) - // This should move to renderer interface - // const element = document.querySelector('div.combat') - - // this.#foenamelabel = element.querySelector('label.foename') - // this.#foevigourlabel = element.querySelector('label.foevigour') - // this.#element = element - this.#diceboard = player.getPlugin('diceboard') if (!this.#diceboard) { throw new Error('Combat plugin requires the Dice Board plugin') @@ -79,12 +72,10 @@ export class CombatPlugin extends BBScannerPlugin { ) { if (rule.action === 'loses') { combat.foeVigour = combat.foeVigour - rule.turnAmount; - // this.#foevigourlabel.textContent = combat.foeVigour updateFightArea(`You hit ${combat.foe} for ${rule.turnAmount} points.`) if (combat.foeVigour <= 0) { this.#won = true this.#lost = false - // this.#foenamelabel.textContent = 'DEFEATED!' replaceFightArea('You won!') this.#diceboard.hide('combat') this.setCurrentState({ defeated: true }) @@ -168,7 +159,6 @@ export class CombatPlugin extends BBScannerPlugin { // Player had won earlier this.#won = true this.#lost = false - // this.#element.classList.add('hidden') this.player.allowNavigation() return true } else if (state?.playerdefeated) { @@ -232,12 +222,8 @@ export class CombatPlugin extends BBScannerPlugin { this.#combat = combat - // this.#foenamelabel.textContent = combat.foe - // this.#foevigourlabel.textContent = combat.foeVigour - this.#diceboard.setDice(combat.numberOfDice) this.#diceboard.show('combat') - // this.#element.classList.remove('hidden') this.player.preventNavigation() console.log('Combat detected:') @@ -248,13 +234,12 @@ export class CombatPlugin extends BBScannerPlugin { } this.#diceboard.hide('combat') - // this.#element.classList.add('hidden') this.player.allowNavigation() return false } } -const combatTemplate = '