Add failure flavor for spells

This commit is contained in:
James Fleming
2022-02-20 22:20:04 -05:00
parent c2f87ae6e7
commit ec514b8815
+25 -10
View File
@@ -315,9 +315,13 @@
<input type=text class=sheet-tiny-input name=attr_iqrequired>
</div>
<div>
<span title="Text that displays when the spell succeeds, optional.">Flavor Text:</span>
<span title="Text that displays when the spell succeeds, optional.">Success Flavor Text:</span>
<input type=text name="attr_successflavor" style='display: block; width:100%' placeholder="A giant wolf appears.">
</div>
<div>
<span title="Text that displays when the spell fails, optional.">Failure Flavor Text:</span>
<input type=text name="attr_failureflavor" style='display: block; width:100%' placeholder="A whisker falls to the ground.">
</div>
<div title="Description that shows when you click the Describe button.">Description:</div>
<textarea class=sheet-text-area spellcheck="false" name="attr_description"></textarea>
</div>
@@ -612,12 +616,12 @@
{{/roll1}}
<!-- Success -->
{{#rollGreater() computed::success 0}}
{{#flavor}}
<div class=flavor-success>{{flavor}}</div>
{{/flavor}}
{{^flavor}}
{{#successflavor}}
<div class=flavor-success>{{successflavor}}</div>
{{/successflavor}}
{{^successflavor}}
<div class=success>Success!</div>
{{/flavor}}
{{/successflavor}}
{{#damage}}
<div class=keyvalue><span>Damage: </span><span>{{damage}}</span></div>
{{/damage}}
@@ -633,7 +637,12 @@
{{/rollGreater() computed::success 0}}
<!-- Failure -->
{{#rollLess() computed::success 0}}
<div class=failure>Failure!</div>
{{#failureflavor}}
<div class=flavor-failure>{{failureflavor}}</div>
{{/failureflavor}}
{{^failureflavor}}
<div class=failure>Failure!</div>
{{/failureflavor}}
{{#rollTotal() computed::success -4}}
<div class=failure>Critical: Staff breaks!</div>
{{/rollTotal() computed::success -4}}
@@ -1223,6 +1232,10 @@
// Do the Attack roll with success level.
const doAttackRoll = function(macro) {
// @TEST remove me!
console.log(macro);
macro += ' {{character_name=@{cname}}}';
macro += rollTemplateValue('success', 0, true); // level of success, crits, etc.
startRoll(macro, (results) => {
@@ -1322,8 +1335,9 @@
}
else if (type == 'spell') {
let damageName = repeatingPropertyName('spells', id, 'spelldamage');
let flavorName = repeatingPropertyName('spells', id, 'successflavor');
let attrNames = [flavorName, damageName, 'defending'];
let successFlavorName = repeatingPropertyName('spells', id, 'successflavor');
let failureFlavorName = repeatingPropertyName('spells', id, 'failureflavor');
let attrNames = [successFlavorName, failureFlavorName, damageName, 'defending'];
let spellToHitName = repeatingPropertyName('spells', id, 'tohit');
if (toHitCharacter != 'a') {
attrNames.push(spellToHitName);
@@ -1362,7 +1376,8 @@
mstring += toHitString;
}
mstring += rollTemplateProperty('damage', damageName, v, true);
mstring += rollTemplateProperty('flavor', flavorName, v);
mstring += rollTemplateProperty('successflavor', successFlavorName, v);
mstring += rollTemplateProperty('failureflavor', failureFlavorName, v);
doAttackRoll(mstring);
});
}