Buffs now display who and what they were applied by.
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
</template>
|
||||
|
||||
<template name="buffDetails">
|
||||
<div>
|
||||
{{appliedBy}}
|
||||
</div>
|
||||
{{#if description}}
|
||||
<hr style="margin: 16px 0 16px 0;">
|
||||
<div>{{#markdown}}{{evaluateString charId description}}{{/markdown}}</div>
|
||||
|
||||
@@ -9,4 +9,40 @@ Template.buffDialog.events({
|
||||
Buffs.remove(instance.data.buffId);
|
||||
popDialogStack();
|
||||
},
|
||||
});
|
||||
|
||||
const typeDict = {
|
||||
"Features": "feature",
|
||||
"Items": "item",
|
||||
"Spells": "spell",
|
||||
}; //really, we should only need these three
|
||||
|
||||
Template.buffDetails.helpers({
|
||||
appliedBy: function() {
|
||||
if (this.type == "inate") {
|
||||
return "Innate.";
|
||||
} else {
|
||||
var myName = Characters.findOne(this.charId).name;
|
||||
var applierCharacter = Characters.findOne(this.appliedBy) || {name: "???"}
|
||||
// "???" indicates that either we do not have read access to the buff-giver, or that the buff-giver does not exist.
|
||||
|
||||
if (applierCharacter.name === myName) {
|
||||
var charName = "your "
|
||||
} else {
|
||||
if (applierCharacter.charName[applierCharacter.charName.length -1] === 's') {
|
||||
var charName = applierCharacter.charName + "' ";
|
||||
} else {
|
||||
var charName = applierCharacter.charName + "'s ";
|
||||
}
|
||||
}
|
||||
|
||||
var type = typeDict[this.appliedByDetails.collection] || "";
|
||||
var applierThing = global[this.appliedByDetails.collection]
|
||||
&& global[this.appliedByDetails.collection].findOne(this.appliedByDetails.id)
|
||||
&& global[this.appliedByDetails.collection].findOne(this.appliedByDetails.id).name
|
||||
|| "unknown ability";
|
||||
|
||||
return "Applied by " + charName + type + applierThing + ".";
|
||||
}
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user