Skip to content

Commit

Permalink
Added "You are dead" attribute phrase.
Browse files Browse the repository at this point in the history
  • Loading branch information
rajch committed Aug 17, 2024
1 parent f08a674 commit 5fc5f84
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/plugins/attributephraseplugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { BBScannerPlugin } from '../core/plugin'

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

Expand Down Expand Up @@ -43,6 +45,15 @@ export class AttributePhrasePlugin extends BBScannerPlugin {
const passageBody = passage.body
let result = false

// First check for death. All else is secondary.
if (passageBody.match(deadPhraseRegex)) {
this.#charactersheet.psi = 0
this.#charactersheet.agility = 0
this.#charactersheet.vigour = 0

return true
}

let phraseMatch
while ((phraseMatch = phraseRegex.exec(passageBody)) !== null) {
const attribute = phraseMatch[1].toLowerCase()
Expand Down

0 comments on commit 5fc5f84

Please sign in to comment.