Skip to content

Commit

Permalink
make properties available in tracery
Browse files Browse the repository at this point in the history
  • Loading branch information
aparrish committed Oct 3, 2018
1 parent 0cec7a3 commit 82a3589
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions seaduck.js
Expand Up @@ -199,9 +199,20 @@ class Narrative {
JSON.stringify(this.narrative.traceryDiscourse));
if (ev.a) {
discourseCopy["nounA"] = ev.a.name;
// copy properties as nounA_<propertyname>
for (let k in ev.a.properties) {
if (ev.a.properties.hasOwnProperty(k)) {
discourseCopy["nounA_"+k] = ev.a.properties[k];
}
}
}
if (ev.b) {
discourseCopy["nounB"] = ev.b.name;
for (let k in ev.b.properties) {
if (ev.b.properties.hasOwnProperty(k)) {
discourseCopy["nounB_"+k] = ev.b.properties[k];
}
}
}
let grammar = tracery.createGrammar(discourseCopy);
grammar.addModifiers(tracery.baseEngModifiers);
Expand Down

0 comments on commit 82a3589

Please sign in to comment.