From 9a2d49df3571d3665e8e9e9cdf94e7b17f6271fa Mon Sep 17 00:00:00 2001 From: raeleus Date: Sat, 12 Oct 2024 11:39:08 -0700 Subject: [PATCH] Replace "character" in encounter text. --- Library.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Library.js b/Library.js index f9ee5d4..a517880 100644 --- a/Library.js +++ b/Library.js @@ -851,8 +851,7 @@ function createEncounter(listName) { case "easy": if (encounter.cr == null) encounter.cr = 1 multiplier = 1 + (encounter.cr - 1) / 10 - // switch (getRandomInteger(0, 99)) { - switch (95) { + switch (getRandomInteger(0, 99)) { case 0: encounter.text = "There is a curious contraption encasing what appears to be a small treasure chest." break @@ -1366,6 +1365,14 @@ function createEncounter(listName) { break } + var characterName = toTitleCase(state.characters[getRandomInteger(0, state.characters.length-1)].name) + var characterNameAdjustedCase = characterName == "You" ? "you" : characterName + var possessiveName = getPossessiveName(characterName) + encounter.text = encounter.text.replaceAll("Character", characterName) + encounter.text = encounter.text.replaceAll("character", characterNameAdjustedCase) + encounter.text = encounter.text.replaceAll("character's", possessiveName) + encounter.text = encounter.text.replaceAll("Character's", toTitleCase(possessiveName)) + for (var enemy of encounter.enemies) { enemy.health = Math.floor(enemy.health * multiplier) enemy.ac = Math.floor(enemy.ac * multiplier)