diff --git a/The Fantasy Trip/TFT.html b/The Fantasy Trip/TFT.html index 2a208d0d81..45d01e7036 100644 --- a/The Fantasy Trip/TFT.html +++ b/The Fantasy Trip/TFT.html @@ -172,20 +172,21 @@ - + - - + + - + - - Defend + + + 4d6 @@ -438,28 +439,33 @@ {{#defending}}

Opponent is defending/dodging

{{/defending}} + {{^roll1}} +

Automatic Hit

+ {{/roll1}}
-
+ {{#roll1}}
- {{computed::roll1}} - = {{roll1}} vs - {{#simpletohit}} - {{tohit}} +
+ {{computed::roll1}} + = {{roll1}} vs + {{#simpletohit}} + {{tohit}} + {{/simpletohit}} +
+ {{^simpletohit}} +
+ {{dx}} + {{#weaponadj}} + + {{weaponadj}} + {{/weaponadj}} + {{#tohitadj}} + + {{tohitadj}} + {{/tohitadj}} + = {{tohit}} +
{{/simpletohit}}
- {{^simpletohit}} -
- {{dx}} - {{#weaponadj}} - + {{weaponadj}} - {{/weaponadj}} - {{#tohitadj}} - + {{tohitadj}} - {{/tohitadj}} - = {{tohit}} -
- {{/simpletohit}} -
+ {{/roll1}} {{#rollGreater() computed::success 0}} {{#successflavor}} @@ -504,28 +510,33 @@ {{#defending}}

Opponent is defending/dodging

{{/defending}} + {{^roll1}} +

Automatic Success

+ {{/roll1}}
-
+ {{#roll1}}
- {{computed::roll1}} - = {{roll1}} vs - {{#simpletohit}} - {{tohit}} +
+ {{computed::roll1}} + = {{roll1}} vs + {{#simpletohit}} + {{tohit}} + {{/simpletohit}} +
+ {{^simpletohit}} +
+ {{dx}} + {{#spelladj}} + + {{spelladj}} + {{/spelladj}} + {{#tohitadj}} + + {{tohitadj}} + {{/tohitadj}} + = {{tohit}} +
{{/simpletohit}}
- {{^simpletohit}} -
- {{dx}} - {{#spelladj}} - + {{spelladj}} - {{/spelladj}} - {{#tohitadj}} - + {{tohitadj}} - {{/tohitadj}} - = {{tohit}} -
- {{/simpletohit}} -
+ {{/roll1}} {{#rollGreater() computed::success 0}} {{#flavor}} @@ -1064,7 +1075,8 @@ /* WEAPON HANDLERS */ // Weapon Attack Buttons. - on('clicked:attack-5' + on('clicked:attack-6' + + ' clicked:attack-5' + ' clicked:attack-4' + ' clicked:attack-3' + ' clicked:attack-2' @@ -1074,13 +1086,20 @@ + ' clicked:attack2' + ' clicked:attack3' + ' clicked:attack4' - + ' clicked:attack5', (info) => { - let toHit = parseInt(info.triggerName.substring(14))||0; + + ' clicked:attack5' + + ' clicked:attack6' + + ' clicked:attacka', (info) => { + let toHitCharacter = info.triggerName.substring(14); + let toHit = parseInt(toHitCharacter)||0; onSelectedWeaponOrSpell(function(id, selectedIds, type) { // return the string depending on whether we are defending or not. - const defendingProperties = function (attrs) { + const diceProperties = function (attrs, toHitName) { + // if no to hit, then no nothing. + if (!(toHitName in attrs)) { + return ''; // nothing, automatic hit. + } // we are defending, so need 4d6, arg. if (attrs.defending == 'on') { return rollTemplateValue('defending', '1') + rollTemplateValue('roll1', '4d6', true); @@ -1092,9 +1111,13 @@ // returns success level. positive is success. // negative is failure. const successLevel = function(results) { + + // if no roll, normal success. + if (!('roll1' in results)) { + return 1; + } let roll = results.roll1.result; let tohit = results.tohit.result; - // Check all the crits first. if (results.roll1.dice.length == 3) { // 3d6 @@ -1134,27 +1157,30 @@ macro += rollTemplateValue('success', 0, true); // level of success, crits, etc. startRoll(macro, (results) => { let level = successLevel(results.results); - let diceString = diceArrayToString(results.results.roll1.dice); - finishRoll( results.rollId, { - 'roll1': diceString, - 'success': level - }); + let computed = {'success': level}; + if ('roll1' in results.results) { + computed['roll1'] = diceArrayToString(results.results.roll1.dice); + } + finishRoll( results.rollId, computed ); }); } if (type == 'weapon') { let attackFlavorName = repeatingPropertyName('weapons', id, 'attackflavor'); let successFlavorName = repeatingPropertyName('weapons', id, 'successflavor'); - let weaponToHitName = repeatingPropertyName('weapons', id, 'tohit'); let weaponDamageName = repeatingPropertyName('weapons', id, 'weapondamage'); - getAttrs(['gender', attackFlavorName, successFlavorName, weaponToHitName, weaponDamageName, 'defending'], function(v) { + let attrNames = ['gender', attackFlavorName, successFlavorName, weaponDamageName, 'defending']; + let weaponToHitName = repeatingPropertyName('weapons', id, 'tohit'); + if (toHitCharacter != 'a') { + attrNames.push(weaponToHitName); + } + getAttrs(attrNames, function(v) { let mstring = `&{template:attack}` + rollTemplateProperty('weaponname', repeatingPropertyName('weapons', id, 'weaponname')) - + defendingProperties(v); + + diceProperties(v, weaponToHitName); - // short description means no toHit or Weapon bonuses, can all be on one line or with no summation and = - { // compute total and separate to hits. - let simpleToHit = true; + // append total and separate to hits, if present. + if (weaponToHitName in v) { let dxAdj = `@{DX}[DEX]`; let toHitString = ` {{tohit=[[${dxAdj}`; let oldHitLength = toHitString.length; @@ -1172,11 +1198,9 @@ toHitString += ` + ${toHitAdj}`; mstring += rollTemplateValue('tohitadj', toHitAdj, true); } - if (oldHitLength == toHitString.length) { mstring += rollTemplateValue('simpletohit', '1'); } - // and finish. toHitString += ']]}}'; mstring += toHitString; @@ -1200,21 +1224,26 @@ else if (type == 'spell') { let damageName = repeatingPropertyName('spells', id, 'spelldamage'); let flavorName = repeatingPropertyName('spells', id, 'successflavor'); - let toHitName = repeatingPropertyName('spells', id, 'tohit'); - getAttrs([flavorName, toHitName, damageName, 'defending'], function(v) { + let attrNames = [flavorName, damageName, 'defending']; + let spellToHitName = repeatingPropertyName('spells', id, 'tohit'); + if (toHitCharacter != 'a') { + attrNames.push(spellToHitName); + } + getAttrs(attrNames, function(v) { let mstring = `&{template:cast-spell}` + rollTemplateProperty('spellname', repeatingPropertyName('spells', id, 'spellname')) - + defendingProperties(v); + + diceProperties(v, spellToHitName); - { // compute to hit + // append to hit values if present. + if (spellToHitName in v) { let dxAdj = `@{DX}[DEX]`; let toHitString = ` {{tohit=[[${dxAdj}`; let oldHitLength = toHitString.length; mstring += rollTemplateValue('dx', dxAdj, true); // provisionally add spell toHit. - if (parseInt(v[toHitName])||0) { - let spellAdj = `@{${toHitName}}[SPELL_ADJ]`; + if (parseInt(v[spellToHitName])||0) { + let spellAdj = `@{${spellToHitName}}[SPELL_ADJ]`; toHitString += ` + ${spellAdj}`; mstring += rollTemplateValue('spelladj', spellAdj, true); }