diff --git a/src/js/storyJS.js b/src/js/storyJS.js index 1d9a97fd8aa7fc8669e6a5ad71795452e355a843..eb172c1209d03e14dd89b6d7b3286db066625e0b 100644 --- a/src/js/storyJS.js +++ b/src/js/storyJS.js @@ -977,3 +977,84 @@ window.generateAssistantPronouns = function() { V.marketAssistantPronouns.noun = "girl"; } }; + +window.printTrinkets = function printTrinkets() { + function trinketPluralReplacer(desc) { + switch (desc) { + /* not supported + best in show ribbons + napkins + saPorn trinkets + wedding photos + */ + // should never have plurals + case "a collection of diplomas from expensive schools": + case "a framed low denomination piece of paper money from your native country": + case "a battered old assault rifle": + case "a framed picture of a slave with her sale price scrawled across the bottom": + case "an artist's impression of an early arcology design": + case "a framed copy of the first news story featuring yourself": + case "a miniature model of your first arcology": + case "a copy of the first porno you starred in": + case "a framed picture of your late Master": + case "your favorite handgun, whose sight has instilled fear in many": + case "a news clipping of your first successful live hack": + case "a damaged plate carrier bearing Daughters of Liberty insignia": + case "a Daughters of Liberty flag that once hung in their forward command post within your arcology": + case "a Daughters of Liberty brassard": + case "a shot-torn flag of the failed nation whose militants attacked the Free City": + return desc; + // manual replacement + case "a thank-you note from a MILF tourist whom you made feel welcome in the arcology": + return "several thank-you notes from MILF tourists whom you made feel welcome in the arcology"; + // replacement by groups + default: + let r = desc; + if (desc.endsWith("citizen")) { // will not reduce spam from different future societies + r = r.replace("message", "messages"); + r = r.replace("from a", "from"); + r = r.replace("a ", "several "); + r = r.replace("citizen", "citizens"); + r = r.replace("number", "numbers"); + r = r.replace("test", "tests"); + } else if (desc.endsWith("acquaintance")) { + r = r.replace("note", "notes"); + r = r.replace("from a", "from"); + r = r.replace("a ", "several "); + r = r.replace("owner", "owners"); + } + return r; + } + } + + if (State.variables.trinkets.length === 0) + return ''; + + const trinkets = weightedArray2HashMap(State.variables.trinkets); + let trinketString = []; + let plurals = false; + + for (let trinketDesc in trinkets) { + if (trinkets[trinketDesc] === 1) { + trinketString.push(trinketDesc); + } else if (trinkets[trinketDesc] > 1) { + trinketString.push(trinketPluralReplacer(trinketDesc)); + plurals = true; + } + } + + // depending on length of trinketString, add necessary conjunctions + if (trinketString.length === 1) { + if (plurals === false) { + trinketString = `a single item: ${trinketString[0]}`; + } else { + trinketString = trinketString[0]; + } + } else if (trinketString.length === 2 && plurals === false) { + trinketString = `a couple of items: ${trinketString[0]}, and ${trinketString[1]}`; + } else { + trinketString[trinketString.length - 1] = "and " + trinketString[trinketString.length - 1]; + trinketString = trinketString.join(", "); + } + return `There's a display case behind your desk, with ${trinketString}.`; +}; diff --git a/src/uncategorized/officeDescription.tw b/src/uncategorized/officeDescription.tw index 1ccfe6471e364b873b1339505976bf1430b3ad85..160f9ae27cdc35e6a923fc11f28c99c0592c0804 100644 --- a/src/uncategorized/officeDescription.tw +++ b/src/uncategorized/officeDescription.tw @@ -179,22 +179,7 @@ <</switch>> <</if>> <</if>> -<<if $trinkets.length > 0>> -There's a display case behind your desk, -<<if $trinkets.length > 2>> - with - <<for $i = 0; $i < $trinkets.length; $i++>> - <<if $i < $trinkets.length-1>> - $trinkets[$i], - <<else>> - and $trinkets[$i]. - <</if>> - <</for>> -<<elseif $trinkets.length > 1>> - with a couple of items: $trinkets[0], and $trinkets[1]. -<<else>> - with a single item: $trinkets[0]. -<</if>> +<<= printTrinkets()>> A small mirror resides on your desk, facing you. A $PC.visualAge year old<<if $PC.markings == "freckles">>, freckled<<elseif $PC.markings == "heavily freckled">>, densely freckled<</if>> $PC.faceShape face stares back at you. @@ -204,4 +189,3 @@ A $PC.visualAge year old<<if $PC.markings == "freckles">>, freckled<<elseif $PC. <<PlayerCrotch>> <<PlayerButt>> -<</if>>