He has his reason I have my reason - jackdarker/TwineTest GitHub Wiki
A problem with description
I have this outfit-system and the plan was to check the worn equipment and display a textual description of the character.
"You wear an ugly hat and dense fur overs your body."
The hat-outfit and also the fur-outfit will produce the substrings that then need to be glued together.
- you wear an ugly hat
- dense fur covers your body
But those outfits can also be used by NPC and I want to be able to create the description with the same operations.
But they need to be modified: - he wears a ugly hat
- dense fur covers his body
Note that we also have to be gender specific.
My current solution:
- the desription in the outfits is always written in singular pronoun; I wear...
- a function detects the gender of the character and resolves it to I,he,she,it
- a function parses the outfits description; this requires the sensitive parts to be encased in brackets: $[I]$ $[wear]$ an ugly...
- the sensitive parts together with the pronoun are fed into a lookup function that returns the matching phrase
- the original text is reassembled with the matched phrases
This requires a lookup-table with objects defining phrases replacements.
f.e. list['my'] = {def:'my',i:'my',you:'your',he:'his',she:'her', it:'its'};
See window.gm.util.descFixer and window.gm.util.wordlist.