Files
roll20-character-sheets/TailsOfEquestria/sheet.html
T
2024-06-03 13:15:14 -04:00

1542 lines
71 KiB
HTML

<!--
@typedef {object} TabData
@property {string} id The ID used to identify the tab radio buttons and their
corresponding containers. The container's ID will be suffixed with
"Container".
@property {string} label The tab's label.
@property {string} include The path to the pug file defining the tab contents.
-->
<input type="hidden" name="attr_character_sheet" style="display: none;" value="TailsOfEquestria" spellcheck="false"/>
<input type="hidden" name="attr_debug" style="display: none;" value="" spellcheck="false"/>
<input type="checkbox" name="attr_useApiExplodingHoof" style="display: none;" spellcheck="false"/>
<div class="top"><img src="https://raw.githubusercontent.com/Roll20/roll20-character-sheets/master/TailsOfEquestria/banner.jpeg"/>
<div class="mask"></div>
<div class="version">Version 1.6</div>
</div>
<div class="tabs">
<!-- Labels-->
<input type="radio" name="attr_sheet_type" id="sheetTabPC" value="0" checked="checked" spellcheck="false"/>
<label for="sheetTabPC" title="Main sheet for Player Characters.">PC</label>
<input type="radio" name="attr_sheet_type" id="sheetTabNPC" value="1" spellcheck="false"/>
<label for="sheetTabNPC" title="Main sheet for Non-Player Characters.">NPC</label>
<input type="radio" name="attr_sheet_type" id="sheetTabVehicle" value="2" spellcheck="false"/>
<label for="sheetTabVehicle" title="Main sheet for Vehicles.">Vehicle</label>
<input type="radio" name="attr_sheet_type" id="sheetTabEquipment" value="3" spellcheck="false"/>
<label for="sheetTabEquipment" title="Keep track of your character's equipment here.">Equipment</label>
<input type="radio" name="attr_sheet_type" id="sheetTabNotes" value="4" spellcheck="false"/>
<label for="sheetTabNotes" title="Record additional notes about your character, the campaign world, or anything else here.">Campaign Notes</label>
<!-- Contents-->
<div class="tabContents">
<div class="tab" id="sheetTabPCContainer">
<div class="main-container">
<div class="tabSheet pcSheet">
<div>
<div class="bio">
<div class="labelledUnderlined">
<label>Character Name:</label>
<div class="inner">
<input type="text" name="attr_character_name" spellcheck="false"/>
</div>
</div>
<div class="labelledUnderlined">
<label>Player Name:</label>
<div class="inner">
<input type="text" name="attr_player_name" spellcheck="false"/>
</div>
</div>
<div class="labelledUnderlined">
<label>Character Race:</label>
<div class="inner">
<input type="text" name="attr_race" spellcheck="false"/>
</div>
</div>
<div class="labelledUnderlined">
<label>Level:</label>
<div class="inner">
<input type="number" name="attr_level" spellcheck="false"/>
</div>
</div>
<div class="labelledUnderlined">
<label>Element of Harmony:</label>
<div class="inner">
<select name="attr_elementOfHarmony">
<option value="generosity">generosity</option>
<option value="honesty">honesty</option>
<option value="kindness">kindness</option>
<option value="laughter">laughter</option>
<option value="loyalty">loyalty</option>
<option value="magic">magic</option>
<option value="other">other</option>
</select>
</div>
</div>
</div>
<div style="display: inline-block; width: 2.2in;">
<div class="friendshipTokens">
<h1><span>F</span><span>R</span><span>I</span><span>E</span><span>N</span><span>D</span><span>S</span><span>H</span><span>I</span><span>P</span></h1>
<input type="number" name="attr_friendshipTokens" value="0" spellcheck="false"/>
</div>
<div class="explodingHooves api">
<h1>Exploding Hoof Dice:</h1>
<div class="explodingHoof">
<button type="roll" value="!tailsOfEquestriaHelper_explodingHoof @{character_name} 4" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<button type="roll" value="!tailsOfEquestriaHelper_explodingHoof @{character_name} 6" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<button type="roll" value="!tailsOfEquestriaHelper_explodingHoof @{character_name} 8" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<button type="roll" value="!tailsOfEquestriaHelper_explodingHoof @{character_name} 10" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<button type="roll" value="!tailsOfEquestriaHelper_explodingHoof @{character_name} 12" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<button type="roll" value="!tailsOfEquestriaHelper_explodingHoof @{character_name} 20" title="Click to roll!"></button>
</div>
</div>
<div class="explodingHooves noApi">
<h1>Exploding Hoof Dice:</h1>
<div class="explodingHoof">
<input type="hidden" name="attr_exploding_hoof_d4" style="display: none;" value="{1d3, floor(1d4/4)*{{0} + 4, 1d5, floor(1d6/6)*{{0} + 6, 1d7, floor(1d8/8)*{{0} + 8, 1d9, floor(1d10/10)*{{0} + 10, 1d11, floor(1d12/12)*{{0} + 12, 1d20}k1}k1}k1}k1}k1}k1" spellcheck="false"/>
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=exploding_hoof_d4}} {{result=[[@{exploding_hoof_d4}]]}}" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<input type="hidden" name="attr_exploding_hoof_d6" style="display: none;" value="{1d5, floor(1d6/6)*{{0} + 6, 1d7, floor(1d8/8)*{{0} + 8, 1d9, floor(1d10/10)*{{0} + 10, 1d11, floor(1d12/12)*{{0} + 12, 1d20}k1}k1}k1}k1}k1" spellcheck="false"/>
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=exploding_hoof_d6}} {{result=[[@{exploding_hoof_d6}]]}}" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<input type="hidden" name="attr_exploding_hoof_d8" style="display: none;" value="{1d7, floor(1d8/8)*{{0} + 8, 1d9, floor(1d10/10)*{{0} + 10, 1d11, floor(1d12/12)*{{0} + 12, 1d20}k1}k1}k1}k1" spellcheck="false"/>
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=exploding_hoof_d8}} {{result=[[@{exploding_hoof_d8}]]}}" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<input type="hidden" name="attr_exploding_hoof_d10" style="display: none;" value="{1d9, floor(1d10/10)*{{0} + 10, 1d11, floor(1d12/12)*{{0} + 12, 1d20}k1}k1}k1" spellcheck="false"/>
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=exploding_hoof_d10}} {{result=[[@{exploding_hoof_d10}]]}}" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<input type="hidden" name="attr_exploding_hoof_d12" style="display: none;" value="{1d11, floor(1d12/12)*{{0} + 12, 1d20}k1}k1" spellcheck="false"/>
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=exploding_hoof_d12}} {{result=[[@{exploding_hoof_d12}]]}}" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<input type="hidden" name="attr_exploding_hoof_d20" style="display: none;" value="1d20" spellcheck="false"/>
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=exploding_hoof_d20}} {{result=[[@{exploding_hoof_d20}]]}}" title="Click to roll!"></button>
</div>
</div>
</div>
</div>
<div>
<div class="stamina">
<div>
<h1>Stamina:</h1>
<div class="fraction">
<input type="number" name="attr_stamina"/><span>/</span>
<input type="number" name="attr_stamina_max"/>
</div>
</div>
<div>
<div class="labelledUnderlined" style="font-size: 1.5em; max-width: 2in;">
<label>Damage Reduction:</label>
<div class="inner">
<input type="text" name="attr_damageReduction" style="width: 2.4in;" spellcheck="false"/>
</div>
</div>
</div>
</div>
<div class="traits">
<div class="trait body">
<label class="traitName">Body</label>
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=Body}} {{result=[[@{body_equation}]]}}{{updowngrade=@{body_updowngrade}}}{{updowngrade_note=@{body_updowngrade_note}}}" title="Click to roll!"></button>
<select name="attr_body">
<option value="null" selected="selected">Pick One</option>
<option value="D4">D4</option>
<option value="D6">D6</option>
<option value="D8">D8</option>
<option value="D10">D10</option>
<option value="D12">D12</option>
<option value="D20">D20</option>
<option value="{D20,D4}k1">D20+D4</option>
<option value="{D20,D6}k1">D20+D6</option>
<option value="{D20,D8}k1">D20+D8</option>
<option value="{D20,D10}k1">D20+D10</option>
<option value="{D20,D12}k1">D20+D12</option>
<option value="{D20,D20}k1">2D20</option>
<option value="{D20,D20,D4}k1">2D20+D4</option>
<option value="{D20,D20,D6}k1">2D20+D6</option>
<option value="{D20,D20,D8}k1">2D20+D8</option>
<option value="{D20,D20,D10}k1">2D20+D10</option>
<option value="{D20,D20,D12}k1">2D20+D12</option>
<option value="{D20,D20,D20}k1">3D20</option>
</select>
<div class="updowngrade" title="Adjust this to upgrade or downgrade your roll.">
<label>Upgrade/<br/>Downgrade</label><span class="arrows">
<div class="up">
<input type="checkbox" name="attr_body_tickup" value="1" title="Upgrade 1 step"/><span></span>
</div>
<div class="down">
<input type="checkbox" name="attr_body_tickdown" value="1" title="Downgrade 1 step"/><span></span>
</div></span><span>
<div class="labelledUnderlined" style="width: 0.3in;">
<label></label>
<div class="inner">
<input type="number" name="attr_body_updowngrade" spellcheck="false"/>
</div>
</div>
<input type="hidden" name="attr_body_updowngrade_note" spellcheck="false"/></span>
</div>
<input type="hidden" name="attr_body_equation" spellcheck="false"/>
</div>
<div class="trait mind">
<label class="traitName">Mind</label>
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=Mind}} {{result=[[@{mind_equation}]]}}{{updowngrade=@{mind_updowngrade}}}{{updowngrade_note=@{mind_updowngrade_note}}}" title="Click to roll!"></button>
<select name="attr_mind">
<option value="null" selected="selected">Pick One</option>
<option value="D4">D4</option>
<option value="D6">D6</option>
<option value="D8">D8</option>
<option value="D10">D10</option>
<option value="D12">D12</option>
<option value="D20">D20</option>
<option value="{D20,D4}k1">D20+D4</option>
<option value="{D20,D6}k1">D20+D6</option>
<option value="{D20,D8}k1">D20+D8</option>
<option value="{D20,D10}k1">D20+D10</option>
<option value="{D20,D12}k1">D20+D12</option>
<option value="{D20,D20}k1">2D20</option>
<option value="{D20,D20,D4}k1">2D20+D4</option>
<option value="{D20,D20,D6}k1">2D20+D6</option>
<option value="{D20,D20,D8}k1">2D20+D8</option>
<option value="{D20,D20,D10}k1">2D20+D10</option>
<option value="{D20,D20,D12}k1">2D20+D12</option>
<option value="{D20,D20,D20}k1">3D20</option>
</select>
<div class="updowngrade" title="Adjust this to upgrade or downgrade your roll.">
<label>Upgrade/<br/>Downgrade</label><span class="arrows">
<div class="up">
<input type="checkbox" name="attr_mind_tickup" value="1" title="Upgrade 1 step"/><span></span>
</div>
<div class="down">
<input type="checkbox" name="attr_mind_tickdown" value="1" title="Downgrade 1 step"/><span></span>
</div></span><span>
<div class="labelledUnderlined" style="width: 0.3in;">
<label></label>
<div class="inner">
<input type="number" name="attr_mind_updowngrade" spellcheck="false"/>
</div>
</div>
<input type="hidden" name="attr_mind_updowngrade_note" spellcheck="false"/></span>
</div>
<input type="hidden" name="attr_mind_equation" spellcheck="false"/>
</div>
<div class="trait charm">
<label class="traitName">Charm</label>
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=Charm}} {{result=[[@{charm_equation}]]}}{{updowngrade=@{charm_updowngrade}}}{{updowngrade_note=@{charm_updowngrade_note}}}" title="Click to roll!"></button>
<select name="attr_charm">
<option value="null" selected="selected">Pick One</option>
<option value="D4">D4</option>
<option value="D6">D6</option>
<option value="D8">D8</option>
<option value="D10">D10</option>
<option value="D12">D12</option>
<option value="D20">D20</option>
<option value="{D20,D4}k1">D20+D4</option>
<option value="{D20,D6}k1">D20+D6</option>
<option value="{D20,D8}k1">D20+D8</option>
<option value="{D20,D10}k1">D20+D10</option>
<option value="{D20,D12}k1">D20+D12</option>
<option value="{D20,D20}k1">2D20</option>
<option value="{D20,D20,D4}k1">2D20+D4</option>
<option value="{D20,D20,D6}k1">2D20+D6</option>
<option value="{D20,D20,D8}k1">2D20+D8</option>
<option value="{D20,D20,D10}k1">2D20+D10</option>
<option value="{D20,D20,D12}k1">2D20+D12</option>
<option value="{D20,D20,D20}k1">3D20</option>
</select>
<div class="updowngrade" title="Adjust this to upgrade or downgrade your roll.">
<label>Upgrade/<br/>Downgrade</label><span class="arrows">
<div class="up">
<input type="checkbox" name="attr_charm_tickup" value="1" title="Upgrade 1 step"/><span></span>
</div>
<div class="down">
<input type="checkbox" name="attr_charm_tickdown" value="1" title="Downgrade 1 step"/><span></span>
</div></span><span>
<div class="labelledUnderlined" style="width: 0.3in;">
<label></label>
<div class="inner">
<input type="number" name="attr_charm_updowngrade" spellcheck="false"/>
</div>
</div>
<input type="hidden" name="attr_charm_updowngrade_note" spellcheck="false"/></span>
</div>
<input type="hidden" name="attr_charm_equation" spellcheck="false"/>
</div>
</div>
</div>
<div>
<div class="talents">
<h1>Talents:</h1>
<fieldset class="repeating_talents">
<div class="talent">
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=@{name}}} {{result=[[@{equation}]]}}{{notes=@{notes}}}{{updowngrade=@{updowngrade}}}{{updowngrade_note=@{updowngrade_note}}}" title="Click to roll!"></button>
<div style="display: inline-block; vertical-align: top; width: 0.4in;">
<div class="talentIcon" style="font-size: 3em;"></div>
</div>
<div style="display: inline-block; width: 6.5in;">
<div class="labelledUnderlined" style="width: 2.5in;">
<label></label>
<div class="inner">
<input type="text" name="attr_name" placeholder="Talent Name" spellcheck="false"/>
</div>
</div>
<div class="labelledUnderlined">
<label>Source:</label>
<div class="inner">
<select name="attr_source">
<option value="null" selected="selected">Pick One</option>
<option value="Cutie Mark">Cutie Mark</option>
<option value="Race">Race</option>
<option value="Level Up">Level Up</option>
<option value="Item">Item</option>
<option value="Temporary">Temporary</option>
<option value="Training">Training</option>
<option value="Other">Other</option>
</select>
</div>
</div>
<div class="labelledUnderlined">
<label>Dice:</label>
<div class="inner">
<select name="attr_dice">
<option value="null" selected="selected">Pick One</option>
<option value="D4">D4</option>
<option value="D6">D6</option>
<option value="D8">D8</option>
<option value="D10">D10</option>
<option value="D12">D12</option>
<option value="D20">D20</option>
<option value="{D20,D4}k1">D20+D4</option>
<option value="{D20,D6}k1">D20+D6</option>
<option value="{D20,D8}k1">D20+D8</option>
<option value="{D20,D10}k1">D20+D10</option>
<option value="{D20,D12}k1">D20+D12</option>
<option value="{D20,D20}k1">2D20</option>
<option value="{D20,D20,D4}k1">2D20+D4</option>
<option value="{D20,D20,D6}k1">2D20+D6</option>
<option value="{D20,D20,D8}k1">2D20+D8</option>
<option value="{D20,D20,D10}k1">2D20+D10</option>
<option value="{D20,D20,D12}k1">2D20+D12</option>
<option value="{D20,D20,D20}k1">3D20</option>
</select>
</div>
</div>
<div class="labelledUnderlined">
<label>Trait</label>
<div class="inner">
<select name="attr_trait">
<option value="null" selected="selected">none</option>
<option value="body">body</option>
<option value="mind">mind</option>
<option value="charm">charm</option>
</select>
</div>
</div>
<div class="updowngrade" title="Adjust this to upgrade or downgrade your roll.">
<label>Upgrade/<br/>Downgrade</label><span class="arrows">
<div class="up">
<input type="checkbox" name="attr_tickup" value="1" title="Upgrade 1 step"/><span></span>
</div>
<div class="down">
<input type="checkbox" name="attr_tickdown" value="1" title="Downgrade 1 step"/><span></span>
</div></span><span>
<div class="labelledUnderlined" style="width: 0.3in;">
<label></label>
<div class="inner">
<input type="number" name="attr_updowngrade" spellcheck="false"/>
</div>
</div>
<input type="hidden" name="attr_updowngrade_note" spellcheck="false"/></span>
</div>
<div class="notes">
<div class="labelledUnderlined">
<label>Notes:</label>
<div class="inner">
<input type="text" name="attr_notes" spellcheck="false"/>
</div>
</div>
</div>
</div>
<input type="hidden" name="attr_equation" spellcheck="false"/>
</div>
</fieldset>
</div>
</div>
<div>
<div class="quirks">
<h1>Quirks:</h1>
<fieldset class="repeating_quirks">
<div class="quirk">
<div style="display: inline-block; vertical-align: top; width: 0.4in;">
<div class="quirkIcon" style="font-size: 2em;"></div>
</div>
<div style="display: inline-block; width: 6.5in;">
<div class="labelledUnderlined">
<label></label>
<div class="inner">
<input type="text" name="attr_name" placeholder="Quirk Name" spellcheck="false"/>
</div>
</div>
<div class="labelledUnderlined">
<label>Source:</label>
<div class="inner">
<select name="attr_source">
<option value="null" selected="selected">Pick One</option>
<option value="Main">Main</option>
<option value="Race">Race</option>
<option value="Item">Item</option>
<option value="Temporary">Temporary</option>
<option value="Other">Other</option>
</select>
</div>
</div>
<div class="labelledUnderlined">
<label>Notes</label>
<div class="inner">
<input type="text" name="attr_notes" spellcheck="false"/>
</div>
</div>
</div>
</div>
</fieldset>
</div>
</div>
<div>
<div class="reputations">
<h1>Reputation:</h1>
<fieldset class="repeating_reputations">
<div class="reputation">
<div class="reputationIcon" style="font-size: 2em;"></div>
<div class="labelledUnderlined">
<label>Faction/Individual</label>
<div class="inner">
<input type="text" name="attr_name" spellcheck="false"/>
</div>
</div>
<div class="labelledUnderlined">
<label>Level</label>
<div class="inner">
<select name="attr_level">
<option value="2">Esteemed (2x upgrade)</option>
<option value="1">Friendly (1x upgrade)</option>
<option value="Neutral" selected="selected">Neutral</option>
<option value="-1">Unfriendly (1x downgrade)</option>
<option value="-2">Hostile (2x downgrade)</option>
</select>
</div>
</div>
<div class="labelledUnderlined" style="width: 3in;">
<label>Notes</label>
<div class="inner">
<input type="text" name="attr_notes" spellcheck="false"/>
</div>
</div>
</div>
</fieldset>
</div>
</div>
<div>
<div class="inlineBlock" style="margin-right: 1em; vertical-align: top; width: 48%;">
<h1>Appearance:</h1>
<textarea name="attr_appearance" style="height: 2in;"></textarea>
</div>
<div class="inlineBlock" style="width: 48%;">
<h1>Background:</h1>
<textarea name="attr_background" style="height: 2in;"></textarea>
</div>
</div>
</div>
</div>
</div>
<div class="tab" id="sheetTabNPCContainer">
<div class="main-container">
<div class="tabSheet npcSheet">
<div>
<div class="bio">
<input type="text" name="attr_character_name" placeholder="NPC/Creature name" spellcheck="false"/>
<div class="checkbox">
<label>Unique?</label>
<div class="checkboxInner">
<input type="checkbox" name="attr_isUnique" value="1" spellcheck="false"/>
<div></div>
</div>
</div>
</div>
</div>
<div>
<div class="traits">
<div class="trait body">
<label class="traitName">Body</label>
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=Body}} {{result=[[@{body_equation}]]}}{{updowngrade=@{body_updowngrade}}}" title="Click to roll!"></button>
<select name="attr_body">
<option value="null" selected="selected">Pick One</option>
<option value="D4">D4</option>
<option value="D6">D6</option>
<option value="D8">D8</option>
<option value="D10">D10</option>
<option value="D12">D12</option>
<option value="D20">D20</option>
<option value="{D20,D4}k1">D20+D4</option>
<option value="{D20,D6}k1">D20+D6</option>
<option value="{D20,D8}k1">D20+D8</option>
<option value="{D20,D10}k1">D20+D10</option>
<option value="{D20,D12}k1">D20+D12</option>
<option value="{D20,D20}k1">2D20</option>
<option value="{D20,D20,D4}k1">2D20+D4</option>
<option value="{D20,D20,D6}k1">2D20+D6</option>
<option value="{D20,D20,D8}k1">2D20+D8</option>
<option value="{D20,D20,D10}k1">2D20+D10</option>
<option value="{D20,D20,D12}k1">2D20+D12</option>
<option value="{D20,D20,D20}k1">3D20</option>
</select>
<div class="updowngrade" title="Adjust this to upgrade or downgrade your roll.">
<label>Upgrade/<br/>Downgrade</label><span class="arrows">
<div class="up">
<input type="checkbox" name="attr_body_tickup" value="1" title="Upgrade 1 step"/><span></span>
</div>
<div class="down">
<input type="checkbox" name="attr_body_tickdown" value="1" title="Downgrade 1 step"/><span></span>
</div></span><span>
<div class="labelledUnderlined" style="width: 0.3in;">
<label></label>
<div class="inner">
<input type="number" name="attr_body_updowngrade" spellcheck="false"/>
</div>
</div>
<input type="hidden" name="attr_body_updowngrade_note" spellcheck="false"/></span>
</div>
<input type="hidden" name="attr_body_equation" spellcheck="false"/>
</div>
<div class="trait mind">
<label class="traitName">Mind</label>
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=Mind}} {{result=[[@{mind_equation}]]}}{{updowngrade=@{mind_updowngrade}}}" title="Click to roll!"></button>
<select name="attr_mind">
<option value="null" selected="selected">Pick One</option>
<option value="D4">D4</option>
<option value="D6">D6</option>
<option value="D8">D8</option>
<option value="D10">D10</option>
<option value="D12">D12</option>
<option value="D20">D20</option>
<option value="{D20,D4}k1">D20+D4</option>
<option value="{D20,D6}k1">D20+D6</option>
<option value="{D20,D8}k1">D20+D8</option>
<option value="{D20,D10}k1">D20+D10</option>
<option value="{D20,D12}k1">D20+D12</option>
<option value="{D20,D20}k1">2D20</option>
<option value="{D20,D20,D4}k1">2D20+D4</option>
<option value="{D20,D20,D6}k1">2D20+D6</option>
<option value="{D20,D20,D8}k1">2D20+D8</option>
<option value="{D20,D20,D10}k1">2D20+D10</option>
<option value="{D20,D20,D12}k1">2D20+D12</option>
<option value="{D20,D20,D20}k1">3D20</option>
</select>
<div class="updowngrade" title="Adjust this to upgrade or downgrade your roll.">
<label>Upgrade/<br/>Downgrade</label><span class="arrows">
<div class="up">
<input type="checkbox" name="attr_mind_tickup" value="1" title="Upgrade 1 step"/><span></span>
</div>
<div class="down">
<input type="checkbox" name="attr_mind_tickdown" value="1" title="Downgrade 1 step"/><span></span>
</div></span><span>
<div class="labelledUnderlined" style="width: 0.3in;">
<label></label>
<div class="inner">
<input type="number" name="attr_mind_updowngrade" spellcheck="false"/>
</div>
</div>
<input type="hidden" name="attr_mind_updowngrade_note" spellcheck="false"/></span>
</div>
<input type="hidden" name="attr_mind_equation" spellcheck="false"/>
</div>
<div class="trait charm">
<label class="traitName">Charm</label>
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=Charm}} {{result=[[@{charm_equation}]]}}{{updowngrade=@{charm_updowngrade}}}" title="Click to roll!"></button>
<select name="attr_charm">
<option value="null" selected="selected">Pick One</option>
<option value="D4">D4</option>
<option value="D6">D6</option>
<option value="D8">D8</option>
<option value="D10">D10</option>
<option value="D12">D12</option>
<option value="D20">D20</option>
<option value="{D20,D4}k1">D20+D4</option>
<option value="{D20,D6}k1">D20+D6</option>
<option value="{D20,D8}k1">D20+D8</option>
<option value="{D20,D10}k1">D20+D10</option>
<option value="{D20,D12}k1">D20+D12</option>
<option value="{D20,D20}k1">2D20</option>
<option value="{D20,D20,D4}k1">2D20+D4</option>
<option value="{D20,D20,D6}k1">2D20+D6</option>
<option value="{D20,D20,D8}k1">2D20+D8</option>
<option value="{D20,D20,D10}k1">2D20+D10</option>
<option value="{D20,D20,D12}k1">2D20+D12</option>
<option value="{D20,D20,D20}k1">3D20</option>
</select>
<div class="updowngrade" title="Adjust this to upgrade or downgrade your roll.">
<label>Upgrade/<br/>Downgrade</label><span class="arrows">
<div class="up">
<input type="checkbox" name="attr_charm_tickup" value="1" title="Upgrade 1 step"/><span></span>
</div>
<div class="down">
<input type="checkbox" name="attr_charm_tickdown" value="1" title="Downgrade 1 step"/><span></span>
</div></span><span>
<div class="labelledUnderlined" style="width: 0.3in;">
<label></label>
<div class="inner">
<input type="number" name="attr_charm_updowngrade" spellcheck="false"/>
</div>
</div>
<input type="hidden" name="attr_charm_updowngrade_note" spellcheck="false"/></span>
</div>
<input type="hidden" name="attr_charm_equation" spellcheck="false"/>
</div>
</div>
<div class="stamina">
<div class="staminaInner">
<label>Stamina:</label>
<div class="fraction">
<input type="number" name="attr_stamina"/><span>/</span>
<input type="number" name="attr_stamina_max"/>
</div>
</div>
<div class="damageModifiers">
<div class="labelledUnderlined">
<label>Damage Reduction:</label>
<div class="inner">
<input type="text" name="attr_damageReduction" spellcheck="false"/>
</div>
</div>
</div>
</div>
</div>
<div>
<div class="talents">
<label>Talents:</label>
<fieldset class="repeating_talents">
<div class="talent">
<input type="hidden" name="attr_equation" spellcheck="false"/>
<input type="hidden" name="attr_readOnlyView" spellcheck="false"/>
<input class="editCheckbox" type="checkbox" name="attr_editMode" title="Click to edit" spellcheck="false"/>
<div class="editIcon"></div>
<div class="viewMode">
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=@{name}}} {{result=[[@{equation}]]}}{{notes=@{notes}}}{{updowngrade=@{updowngrade}}}" title="Click to roll!"></button><span name="attr_readOnlyView">New talent</span>
</div>
<div class="editMode">
<div style="display: inline-block; width: 6.5in;">
<div class="labelledUnderlined" style="width: 2.5in;">
<label></label>
<div class="inner">
<input type="text" name="attr_name" spellcheck="false"/>
</div>
</div>
<div class="labelledUnderlined">
<label>Dice:</label>
<div class="inner">
<select name="attr_dice">
<option value="null" selected="selected">Pick One</option>
<option value="D4">D4</option>
<option value="D6">D6</option>
<option value="D8">D8</option>
<option value="D10">D10</option>
<option value="D12">D12</option>
<option value="D20">D20</option>
<option value="{D20,D4}k1">D20+D4</option>
<option value="{D20,D6}k1">D20+D6</option>
<option value="{D20,D8}k1">D20+D8</option>
<option value="{D20,D10}k1">D20+D10</option>
<option value="{D20,D12}k1">D20+D12</option>
<option value="{D20,D20}k1">2D20</option>
<option value="{D20,D20,D4}k1">2D20+D4</option>
<option value="{D20,D20,D6}k1">2D20+D6</option>
<option value="{D20,D20,D8}k1">2D20+D8</option>
<option value="{D20,D20,D10}k1">2D20+D10</option>
<option value="{D20,D20,D12}k1">2D20+D12</option>
<option value="{D20,D20,D20}k1">3D20</option>
</select>
</div>
</div>
<div class="labelledUnderlined">
<label>Trait</label>
<div class="inner">
<select name="attr_trait">
<option value="null" selected="selected">none</option>
<option value="body">body</option>
<option value="mind">mind</option>
<option value="charm">charm</option>
</select>
</div>
</div>
<div class="updowngrade" title="Adjust this to upgrade or downgrade your roll.">
<label>Upgrade/<br/>Downgrade</label><span class="arrows">
<div class="up">
<input type="checkbox" name="attr_tickup" value="1" title="Upgrade 1 step"/><span></span>
</div>
<div class="down">
<input type="checkbox" name="attr_tickdown" value="1" title="Downgrade 1 step"/><span></span>
</div></span><span>
<div class="labelledUnderlined" style="width: 0.3in;">
<label></label>
<div class="inner">
<input type="number" name="attr_updowngrade" spellcheck="false"/>
</div>
</div>
<input type="hidden" name="attr_updowngrade_note" spellcheck="false"/></span>
</div>
<div class="notes">
<div class="labelledUnderlined">
<label>Notes:</label>
<div class="inner">
<input type="text" name="attr_notes" spellcheck="false"/>
</div>
</div>
</div>
</div>
</div>
</div>
</fieldset>
</div>
</div>
<div>
<div class="quirks">
<label>Quirks:</label>
<fieldset class="repeating_quirks">
<div class="quirk">
<input class="editCheckbox" type="checkbox" name="attr_editMode" title="Click to edit" spellcheck="false"/>
<div class="editIcon"></div>
<div class="viewMode"><span name="attr_name">New quirk</span></div>
<div class="editMode">
<div class="labelledUnderlined">
<label></label>
<div class="inner">
<input type="text" name="attr_name" spellcheck="false"/>
</div>
</div>
<div class="labelledUnderlined">
<label>Notes</label>
<div class="inner">
<input type="text" name="attr_notes" spellcheck="false"/>
</div>
</div>
</div>
</div>
</fieldset>
</div>
</div>
<div>
<div class="explodingHooves api">
<h1>Exploding Hoof Dice:</h1>
<div class="explodingHoof">
<button type="roll" value="!tailsOfEquestriaHelper_explodingHoof @{character_name} 4" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<button type="roll" value="!tailsOfEquestriaHelper_explodingHoof @{character_name} 6" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<button type="roll" value="!tailsOfEquestriaHelper_explodingHoof @{character_name} 8" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<button type="roll" value="!tailsOfEquestriaHelper_explodingHoof @{character_name} 10" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<button type="roll" value="!tailsOfEquestriaHelper_explodingHoof @{character_name} 12" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<button type="roll" value="!tailsOfEquestriaHelper_explodingHoof @{character_name} 20" title="Click to roll!"></button>
</div>
</div>
<div class="explodingHooves noApi">
<h1>Exploding Hoof Dice:</h1>
<div class="explodingHoof">
<input type="hidden" name="attr_exploding_hoof_d4" style="display: none;" value="{1d3, floor(1d4/4)*{{0} + 4, 1d5, floor(1d6/6)*{{0} + 6, 1d7, floor(1d8/8)*{{0} + 8, 1d9, floor(1d10/10)*{{0} + 10, 1d11, floor(1d12/12)*{{0} + 12, 1d20}k1}k1}k1}k1}k1}k1" spellcheck="false"/>
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=exploding_hoof_d4}} {{result=[[@{exploding_hoof_d4}]]}}" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<input type="hidden" name="attr_exploding_hoof_d6" style="display: none;" value="{1d5, floor(1d6/6)*{{0} + 6, 1d7, floor(1d8/8)*{{0} + 8, 1d9, floor(1d10/10)*{{0} + 10, 1d11, floor(1d12/12)*{{0} + 12, 1d20}k1}k1}k1}k1}k1" spellcheck="false"/>
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=exploding_hoof_d6}} {{result=[[@{exploding_hoof_d6}]]}}" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<input type="hidden" name="attr_exploding_hoof_d8" style="display: none;" value="{1d7, floor(1d8/8)*{{0} + 8, 1d9, floor(1d10/10)*{{0} + 10, 1d11, floor(1d12/12)*{{0} + 12, 1d20}k1}k1}k1}k1" spellcheck="false"/>
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=exploding_hoof_d8}} {{result=[[@{exploding_hoof_d8}]]}}" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<input type="hidden" name="attr_exploding_hoof_d10" style="display: none;" value="{1d9, floor(1d10/10)*{{0} + 10, 1d11, floor(1d12/12)*{{0} + 12, 1d20}k1}k1}k1" spellcheck="false"/>
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=exploding_hoof_d10}} {{result=[[@{exploding_hoof_d10}]]}}" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<input type="hidden" name="attr_exploding_hoof_d12" style="display: none;" value="{1d11, floor(1d12/12)*{{0} + 12, 1d20}k1}k1" spellcheck="false"/>
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=exploding_hoof_d12}} {{result=[[@{exploding_hoof_d12}]]}}" title="Click to roll!"></button>
</div>
<div class="explodingHoof">
<input type="hidden" name="attr_exploding_hoof_d20" style="display: none;" value="1d20" spellcheck="false"/>
<button type="roll" value="&amp;{template:toe} {{charName=@{character_name}}} {{attr=exploding_hoof_d20}} {{result=[[@{exploding_hoof_d20}]]}}" title="Click to roll!"></button>
</div>
</div>
</div>
<div>
<div class="inlineBlock" style="margin-right: 1em; vertical-align: top; width: 48%;">
<h1>Description:</h1>
<textarea name="attr_appearance" style="height: 4in;"></textarea>
</div>
<div class="inlineBlock" style="width: 48%;">
<h1>Tactics:</h1>
<textarea name="attr_tactics" style="height: 4in;"></textarea>
</div>
</div>
</div>
</div>
</div>
<div class="tab" id="sheetTabVehicleContainer">
<div class="main-container">
<div class="tabSheet vehicleSheet">
<div class="bio">
<input type="text" name="attr_character_name" placeholder="Vehicle Name" spellcheck="false"/>
<div class="checkbox">
<label>Unique?</label>
<div class="checkboxInner">
<input type="checkbox" name="attr_isUnique" value="1" spellcheck="false"/>
<div></div>
</div>
</div>
</div>
<div>
<table class="vehicleStats">
<thead>
<tr>
<th>Type</th>
<th style="width: 0.5in;">Speed</th>
<th>Handling</th>
<th>Stability</th>
<th style="width: 0.5in;">Armor</th>
<th>Misc. Damage Modifiers</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<select name="attr_vehicleType">
<option value="Pick One">Pick One</option>
<option value="Land">Land</option>
<option value="Water">Water</option>
<option value="Air">Air</option>
<option value="Other">Other</option>
</select>
</td>
<td>
<input type="number" name="attr_vehicleSpeed" spellcheck="false"/>
</td>
<td>
<select name="attr_vehicleHandling">
<option value="Pick One">Pick One</option>
<option value="2x Downgrade">2x Downgrade</option>
<option value="1x Downgrade">1x Downgrade</option>
<option value="-">-</option>
<option value="1x Upgrade">1x Upgrade</option>
<option value="2x Upgrade">2x Upgrade</option>
</select>
</td>
<td>
<div class="fraction">
<input type="number" name="attr_vehicleStability"/><span>/</span>
<input type="number" name="attr_vehicleStability_max"/>
</div>
</td>
<td>
<input type="number" name="attr_vehicleArmor" spellcheck="false"/>
</td>
<td>
<input type="text" name="attr_vehicleDamageModifiers" spellcheck="false"/>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<div class="systems">
<label>Systems:</label>
<fieldset class="repeating_systems">
<div class="system">
<input class="editCheckbox" type="checkbox" name="attr_editMode" title="Click to edit" spellcheck="false"/>
<div class="editIcon"></div>
<div class="viewMode"><span name="attr_name">New system</span></div>
<div class="editMode">
<div class="labelledUnderlined">
<label></label>
<div class="inner">
<input type="text" name="attr_name" spellcheck="false"/>
</div>
</div>
<div class="labelledUnderlined">
<label>Notes</label>
<div class="inner">
<input type="text" name="attr_notes" spellcheck="false"/>
</div>
</div>
</div>
</div>
</fieldset>
</div>
</div>
<div>
<div class="inlineBlock" style="margin-right: 1em; vertical-align: top; width: 48%;">
<h1>Description:</h1>
<textarea name="attr_appearance" style="height: 4in;"></textarea>
</div>
<div class="inlineBlock" style="width: 48%;">
<h1>Crew:</h1>
<textarea name="attr_vehicleCrew" style="height: 4in;"></textarea>
</div>
</div>
</div>
</div>
</div>
<div class="tab" id="sheetTabEquipmentContainer">
<div class="main-container">
<div class="tabSheet equipmentSheet">
<div class="equipmentHeader"><span style="width: 2in;">Item Name</span><span style="width: 0.5in;">Qty.</span><span style="width: 4.5in;">Notes</span></div>
<div class="equipmentBody">
<fieldset class="repeating_equipment">
<div class="labelledUnderlined" style="width: 2in;">
<label></label>
<div class="inner">
<input type="text" name="attr_name" spellcheck="false"/>
</div>
</div>
<div class="labelledUnderlined" style="width: 0.5in;">
<label></label>
<div class="inner">
<input type="number" name="attr_quantity" spellcheck="false"/>
</div>
</div>
<div class="labelledUnderlined" style="width: 4.5in;">
<label></label>
<div class="inner">
<input type="text" name="attr_notes" spellcheck="false"/>
</div>
</div>
</fieldset>
</div>
</div>
</div>
</div>
<div class="tab" id="sheetTabNotesContainer">
<div class="main-container">
<div class="tabSheet notesSheet">
<div class="notes">
<textarea name="attr_campaignNotes"></textarea>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/worker">(() => {
'use strict';
// A list of the dice, in descending order.
let DICE_DESCENDING = ['D20', 'D12', 'D10', 'D8', 'D6', 'D4'];
// Constant for a normal upgrade/downgrade. No special rules apply.
let NORMAL_UPDOWNGRADE = 0;
// Constant for when a D20 is upgraded. The player can choose to reroll the
// D20 and use the new result.
let SUPER_UPGRADE = 1;
// Constant for when a D4 is downgraded. The player must reroll the D4 and
// use the worst result.
let SUPER_DOWNGRADE = 2;
// Map upgrade/downgrade type constants to an upgrade/downgrade note.
let UPDOWNGRADE_NOTES = {
[NORMAL_UPDOWNGRADE]: '',
[SUPER_UPGRADE]: 'Can choose to reroll D20. Must use new result.',
[SUPER_DOWNGRADE]: 'Must reroll D4 and use lowest result.'
};
/**
* Forces an update on a list of numerical fields, also making sure that
* any undefined fields are set to 0.
* @param {string[]} attrs
* @param {function} cb
*/
function forceUpdate(attrs, cb) {
parseAttrs(attrs, values => {
let tempValues = {};
_.each(attrs, attr => {
tempValues[attr] = -9999;
});
setAttrs(tempValues);
setAttrs(values);
});
}
function getRollDiceCount(roll) {
// Extract each die type used in the roll.
var regex = /{(.+?)}k1/;
var match = regex.exec(roll);
if(match)
roll = match[1];
var dice = roll.split(',');
// Count the number of each die type.
var diceCount = {
'D20': 0,
'D12': 0,
'D10': 0,
'D8': 0,
'D6': 0,
'D4': 0
};
_.each(dice, die => {
diceCount[die]++;
});
return diceCount;
}
/**
* Gets the view for some dice value.
* @param {string} roll
* @return {string}
*/
function getRollView(roll) {
var diceCount = getRollDiceCount(roll);
// Produce the appropriate view based on the dice counts.
var view = '';
_.each(DICE_DESCENDING, die => {
var count = diceCount[die];
if(view && count > 0)
view += '+';
if(count === 1)
view += die;
else if(count > 1)
view += `${count}${die}`;
});
return view;
}
/**
* @typedef {object} UpdownResult
* @property {string} roll
* The modified roll expression.
* @property {int} resultType
* One of SUPER_UPGRADE, SUPER_DOWNGRADE, or NORMAL_UPDOWNGRADE.
*/
/**
* Gets the upgraded/downgraded dice for a roll.
* @param {string} roll
* The roll expression.
* @param {int} steps
* Positive for upgrade, negative for downgrade.
* @return {string}
* The dice expression for the upgraded/downgraded roll.
*/
function getUpDowngradedRoll(roll, steps) {
if (steps === 0)
return roll;
// Map each die to the number of times it is normally rolled.
let diceCount = getRollDiceCount(roll);
// Apply the upgrade or downgrade a number of times equal to the
// unsigned steps. Stop early if we reach a rerollGood or rerollBad case.
let rerollGood = false;
let rerollBad = false;
_.find(_.range(Math.abs(steps)), () => {
// Determine the highest die in the roll.
let highestDie = _.find(DICE_DESCENDING, die => {
let count = diceCount[die];
if (count > 0)
return true;
}) || 'D4';
// Upgrade the highest die.
if (steps > 0) {
// If we're upgrading a D20, the player can choose to reroll.
if (highestDie === 'D20') {
rerollGood = true;
return true;
}
// Otherwise, decrement the highest die's count and increment the count
// for the die ranking above it.
else {
let nextIndex = DICE_DESCENDING.indexOf(highestDie) - 1;
let nextDie = DICE_DESCENDING[nextIndex];
diceCount[highestDie]--;
diceCount[nextDie]++;
}
}
// Downgrade the highest die.
else {
if (highestDie === 'D4') {
// Drop a D4 if we have more than 1.
if (diceCount['D4'] > 1)
diceCount['D4']--;
// If we're downgrading a lone D4, the player must reroll and use
// the lowest result.
else {
rerollBad = true;
return true;
}
}
// If the highest die is not a D4, decrement its count and increment
// the count of the die ranking below it.
else {
let nextIndex = DICE_DESCENDING.indexOf(highestDie) + 1;
let nextDie = DICE_DESCENDING[nextIndex];
diceCount[highestDie]--;
diceCount[nextDie]++;
}
}
});
// Compose a new roll based on the modified dice count.
let newDice = [];
_.each(DICE_DESCENDING, die => {
let count = diceCount[die];
if (count) {
_.each(_.range(count), () => {
newDice.push(die);
});
}
});
if (rerollGood)
return {
roll: `{${newDice.join(',')}}k1`,
type: SUPER_UPGRADE
};
else if (rerollBad)
return {
roll: `D4`,
type: SUPER_DOWNGRADE
};
else
return {
roll: `{${newDice.join(',')}}k1`,
type: NORMAL_UPDOWNGRADE
};
}
// Migrate sheet data from prior versions to the most recent version.
function migrateVersion(cb) {
_migrate1_5(cb);
}
/**
* Migrate from v1.5 to 1.6.
* @param {func} cb Callback
*/
function _migrate1_5(cb) {
_migrate1_5_hardcodedTalent('talent_cutieMark_', 'Cutie Mark', () => {
_migrate1_5_hardcodedTalent('talent_racial_', 'Race', () => {
_migrate1_5_mainQuirk(() => {
_migrate1_5_equipment(cb);
});
});
});
}
/**
* Migrate a hardcoded talent from v1.5 to repeating talents section.
* @param {string} prefix The attribute prefix for the talent.
* @param {string} source The new value for the talent's source property.
* @param {func} cb Callback.
*/
function _migrate1_5_hardcodedTalent(prefix, source, cb) {
let attrList = [prefix + 'name', prefix + 'dice', prefix + 'trait', prefix + 'updowngrade', prefix + 'equation', prefix + 'readOnlyView', prefix + 'notes'];
parseAttrs(attrList, values => {
if (values[prefix + 'name']) {
let nextRowID = generateRowID();
let repPrefix = `repeating_talents_${nextRowID}_`;
setAttrs({
// Void the hard-coded talent's name.
[prefix + 'name']: '',
// Copy the hard-coded talent's values to a new repeating talent.
[repPrefix + 'name']: values[prefix + 'name'],
[repPrefix + 'source']: source,
[repPrefix + 'dice']: values[prefix + 'dice'],
[repPrefix + 'trait']: values[prefix + 'trait'],
[repPrefix + 'updowngrade']: values[prefix + 'updowngrade'],
[repPrefix + 'equation']: values[prefix + 'equation'],
[repPrefix + 'readOnlyView']: values[prefix + 'readOnlyView'],
[repPrefix + 'notes']: values[prefix + 'notes']
}, { silent: true }, cb);
}
else
cb();
});
}
/**
* Migrate main quirk from v1.5 to repeating quirks section.
* @param {func} cb Callback.
*/
function _migrate1_5_mainQuirk(cb) {
let prefix = 'quirk_main_';
let attrList = [prefix + 'name', prefix + 'notes'];
parseAttrs(attrList, values => {
if (values[prefix + 'name']) {
let nextRowID = generateRowID();
let repPrefix = `repeating_quirks_${nextRowID}_`;
setAttrs({
// Void the hard-coded quirk.
[prefix + 'name']: '',
// Copy the hard-coded quirk's values to a new repeating quirk.
[repPrefix + 'name']: values[prefix + 'name'],
[repPrefix + 'notes']: values[prefix + 'notes']
}, { silent: true }, cb);
}
else
cb();
});
}
/**
* Migrate equipment from v1.5 to v1.6.
* @param {func} cb Callback.
*/
function _migrate1_5_equipment(cb) {
getAttrs(['equipment'], values => {
let equipmentRaw = values['equipment'] || '';
// Transfer equipment from the 1.5 textarea to the 1.6 repeating section.
if (equipmentRaw) {
let equipmentList = equipmentRaw.split('\n');
_.each(equipmentList, item => {
let nextRowID = generateRowID();
let repPrefix = `repeating_equipment_${nextRowID}_`;
setAttrs({
[repPrefix + 'name']: item,
'equipment': ''
}, { silent: true }, cb);
});
}
});
}
// Registers an event listener for attribute changes.
// @param {string[]} attrs A list of attribute names.
// @param {fn} cb Callback with one parameter for a received event.
function onChange(attrs, cb) {
attrs = _.map(attrs, attr => {
return 'change:' + attr;
}).join(' ');
on(attrs, cb);
}
// Registers an event listener for attribute changes, and parses them to more
// useful forms.
// @param {string[]} attrs A list of attribute names.
// @param {fn} cb Callback with one parameter for a mapping of
// attribute names to their parsed values.
function onChangeParse(attrs, cb) {
onChange(attrs, () => {
parseAttrs(attrs, cb);
});
}
/**
* Gets the specified attributes and parses them as an integer or 0.
*/
function parseAttrs(attrs, cb) {
try {
getAttrs(attrs, values => {
try {
_.each(attrs, attr => {
if(_.isUndefined(values[attr]))
values[attr] = 0;
else if(!isNaN(values[attr]))
values[attr] = parseInt(values[attr]);
});
cb(values);
}
catch (err) {
setAttrs({
"debug": `parseAttrs error: ${err.message}`
});
}
});
}
catch (err) {
setAttrs({
"debug": `parseAttrs error: ${err.message}`
});
}
}
// Update the equations and views for all talents.
function updateTalents(cb) {
cb = cb || _.noop;
getSectionIDs('repeating_talents', ids => {
// Create a semaphore that will invoke our callback once all the
// talents have been processed.
var idsLeft = ids.length;
var semaphore = () => {
idsLeft--;
if (!idsLeft)
cb();
};
// Process each talent in the repeating section.
_.each(ids, id => {
var prefix = 'repeating_talents_' + id;
_updateTalents(prefix, semaphore);
});
});
}
// Update the equations and views for all talents with the given prefix.
function _updateTalents(prefix, cb) {
cb = cb || _.noop;
// If we just up-ticked or down-ticked the up/downgrade, then quit early
// after handling that.
if(_tickDowngrade(prefix) || _tickUpgrade(prefix)) {
cb();
return;
}
parseAttrs([prefix + '_name', prefix + '_dice', prefix + '_trait', prefix + '_updowngrade', 'body_equation', 'mind_equation', 'charm_equation'], values => {
var talentName = values[prefix + '_name'];
var talentDice = values[prefix + '_dice'];
var talentDiceView = getRollView(talentDice);
var trait = values[prefix + '_trait'];
var traitDice = values[trait + '_equation'] || 'D0';
// Apply upgrades/downgrades to talent dice.
var updown = parseInt(values[prefix + '_updowngrade']) || 0;
var talentDiceModified = talentDice;
var updowngrade_note = '';
if(talentDice && updown) {
let {roll, type} = getUpDowngradedRoll(talentDice, updown, 'talent');
talentDiceModified = roll;
updowngrade_note = UPDOWNGRADE_NOTES[type];
}
// Update the attributes.
if(talentDiceModified === 'null')
setAttrs({
[prefix + '_equation']: 0,
[prefix + '_readOnlyView']: `${talentName}(n/a)`,
[prefix + '_updowngrade_note']: ''
}, {}, cb);
else {
//var traitDice = values[trait];
setAttrs({
[prefix + '_equation']: `{${talentDiceModified} [talent],${traitDice} [trait]}k1`,
[prefix + '_readOnlyView']: `${talentName}(${talentDiceView})`,
[prefix + '_updowngrade_note']: updowngrade_note
}, {}, cb);
}
});
}
// Update the equation values for all traits.
function updateTraits(cb) {
_updateTrait('body', () => {
_updateTrait('mind', () => {
_updateTrait('charm', cb);
});
});
}
// Updates the equation value for a single trait.
function _updateTrait(trait, cb) {
parseAttrs([trait, trait + '_updowngrade'], values => {
var traitDice = values[trait];
var updowngrade_note = '';
if(traitDice === 'null')
setAttrs({
[trait + '_equation']: 0,
[trait + '_updowngrade_note']: ''
}, {}, cb);
else {
// Apply upgrades/downgrades to the trait dice.
var updown = values[trait + '_updowngrade'] || 0;
if(updown) {
let {roll, type} = getUpDowngradedRoll(traitDice, updown, 'trait');
traitDice = roll;
updowngrade_note = UPDOWNGRADE_NOTES[type];
}
setAttrs({
[trait + '_equation']: traitDice,
[trait + '_updowngrade_note']: updowngrade_note
}, {}, cb);
}
});
}
// Process a downtick for an upgrade/downgrade field.
function _tickDowngrade(prefix) {
parseAttrs([prefix + '_tickdown', prefix + '_updowngrade'], values => {
let checked = !!values[prefix + '_tickdown'];
if(checked) {
var updown = parseInt(values[prefix + '_updowngrade']) || 0;
setAttrs({
[prefix + '_updowngrade']: updown - 1,
[prefix + '_tickdown']: 0
});
return true;
}
return false;
});
}
// Process an uptick for an upgrade/downgrade field.
function _tickUpgrade(prefix) {
parseAttrs([prefix + '_tickup', prefix + '_updowngrade'], values => {
let checked = !!values[prefix + '_tickup'];
if(checked) {
var updown = parseInt(values[prefix + '_updowngrade']) || 0;
setAttrs({
[prefix + '_updowngrade']: updown + 1,
[prefix + '_tickup']: 0
});
return true;
}
return false;
});
}
// Change events
on('change:repeating_talents', evt => {
updateTalents();
});
onChange(['body_equation', 'mind_equation', 'charm_equation'], () => {
updateTalents();
});
on('sheet:opened', () => {
setAttrs({
"debug": "Opening sheet"
});
setAttrs({
character_sheet: 'TailsOfEquestria v1.6'
});
// Migrate from v1.5 to 1.6
migrateVersion(() => {
setAttrs({
"debug": "Migration SUCCESS"
});
updateTraits(() => {
setAttrs({
"debug": "Update traits SUCCESS"
});
updateTalents(() => {
setAttrs({
"debug": "Update talents SUCCESS"
});
});
});
});
});
// Up/downgrade tick events
onChange(['body_tickup'], () => {
_tickUpgrade('body');
});
onChange(['body_tickdown'], () => {
_tickDowngrade('body');
});
onChange(['body', 'body_updowngrade'], () => {
_updateTrait('body');
});
onChange(['mind_tickup'], () => {
_tickUpgrade('mind');
});
onChange(['mind_tickdown'], () => {
_tickDowngrade('mind');
});
onChange(['mind', 'mind_updowngrade'], () => {
_updateTrait('mind');
});
onChange(['charm_tickup'], () => {
_tickUpgrade('charm');
});
onChange(['charm_tickdown'], () => {
_tickDowngrade('charm');
});
onChange(['charm', 'charm_updowngrade'], () => {
_updateTrait('charm');
});
})();
</script>
<rolltemplate class="sheet-rolltemplate-toe">
<table>
<thead>
<tr>
<th>{{charName}} &#x21D2; {{attr}}</th>
</tr>
</thead>
<tbody>
<tr>
<td>Result {{result}}</td>
</tr>{{#updowngrade}}
<tr>
<td class="updowngrade">
<p><span>Up/Downgrade:</span><span>{{updowngrade}}</span></p>
<p>{{updowngrade_note}}</p>
</td>
</tr>
{{/updowngrade}}
{{#notes}}
<tr>
<td class="notes">
<div>Notes:</div>
<div>{{notes}}</div>
</td>
</tr>{{/notes}}
</tbody>
</table>
</rolltemplate>