<input type="checkbox" class="sheet-block-switch" name="attr_npcsheet" value="1"><span> NPC? (DO NOT CLICK)</span><br/><br/>
<div class="main">
    <div class="header section">
        <div class="header-grid">
            <div class="header-field-grid">
                <span>Name</span>
                <input class="line-input" name="attr_character_name">
            </div>
            <div>
                <h2>Adventurer Conqueror King</h2>
            </div>
            <div class="header-field-grid">
                <span>Title</span>
                <input class="line-input" type="text" name="attr_classtitle" value="the Unknown">
                
                <span>Class</span>
                <select name="attr_class">
                    <option>Fighter</option>
                    <option>Mage</option>
                    <option>Cleric</option>
                    <option>Thief</option>
                    <option>Assassin</option>
                    <option>Bard</option>
                    <option>Bladedancer</option>
                    <option>Explorer</option>
                </select>
            </div>
            <div class="header-field-grid">
                <span>Alignment</span>
                <input class="line-input" type="text" name="attr_align" value="">
            
                <span>Level</span>
                <input class="line-input" type="text" name="attr_level" value="0">
            </div>
        </div>
    </div>
    <div class="attributes section">
        <div class="grid-container-2col">
            <div class="stat-grid">
                <div class="sheet-stat-title">
                    <h3>Attributes</h3>
                </div>
                
                <span>Value</span><span></span><span>Modifier</span><span></span>
                <!-- Strength -->
                <input class="sheet-stat-input" type="text" name="attr_str" value="10">
                <span class="sheet-stat-span">Str</span>
                <input class="sheet-stat-input" type="text" name="attr_str_mod" value="0">
                <button class="sheet-roll-button" type='roll' value='&{template:acks} {{name=Strength Throw}} {{character=@{character_name}}} {{roll=[[1d20 + @{str_mod}]]}}' name='roll_StrengthCheck'></button>

                <!-- Intelligence -->
                <input class="sheet-stat-input" type="text" name="attr_int" value="10">
                <span class="sheet-stat-span">Int</span>
                <input class="sheet-stat-input" type="text" name="attr_int_mod" value="0">
                <button class="sheet-roll-button" type='roll' value='&{template:acks} {{name=Intelligence Throw}} {{character=@{character_name}}} {{roll=[[1d20 + @{int_mod}]]}}' name='roll_IntelligenceCheck'></button>
            
                <!-- Wisdom -->
                <input class="sheet-stat-input" type="text" name="attr_wis" value="10">
                <span class="sheet-stat-span">Wis</span>
                <input class="sheet-stat-input" type="text" name="attr_wis_mod" value="0">
                <button class="sheet-roll-button" type='roll' value='&{template:acks} {{name=Wisdom Throw}} {{character=@{character_name}}} {{roll=[[1d20 + @{wis_mod}]]}}' name='roll_WisdomCheck'></button>
            
                <!-- Dexterity -->
                <input class="sheet-stat-input" type="text" name="attr_dex" value="10">
                <span class="sheet-stat-span">Dex</span>
                <input class="sheet-stat-input" type="text" name="attr_dex_mod" value="0">
                <button class="sheet-roll-button" type='roll' value='&{template:acks} {{name=Dexterity Throw}} {{character=@{character_name}}} {{roll=[[1d20 + @{dex_mod}]]}}' name='roll_DexterityCheck'></button>
            
                <!-- Constitution -->
                <input class="sheet-stat-input" type="text" name="attr_con" value="10">
                <span class="sheet-stat-span">Con</span>
                <input class="sheet-stat-input" type="text" name="attr_con_mod" value="0">
                <button class="sheet-roll-button" type='roll' value='&{template:acks} {{name=Constitution Throw}} {{character=@{character_name}}} {{roll=[[1d20 + @{con_mod}]]}}' name='roll_ConstitutionCheck'></button>
            
                <!-- Charisma -->
                <input class="sheet-stat-input" type="text" name="attr_chr" value="10">
                <span class="sheet-stat-span">Chr</span>
                <input class="sheet-stat-input" type="text" name="attr_chr_mod" value="0">
                <button class="sheet-roll-button" type='roll' value='&{template:acks} {{name=Charisma Throw}} {{character=@{character_name}}} {{roll=[[1d20 + @{chr_mod}]]}}' name='roll_CharismaCheck'></button>
            </div>
            <div class="stat2-grid">
                <!-- Hit Points -->
                <span class="sheet-hp-span">HP</span>
                <span class="sheet-text-center">Current</span><span class="sheet-text-center">Maximum</span>
                <div><input class="sheet-stat-input sheet-hp-input" type="text" name="attr_hp"></div>
                <div><input class="sheet-stat-input sheet-hp-mod-input" type="text" name="attr_hp_max"></div>

                <!-- Hit Points -->
                <span class="sheet-hp-span">AC</span>
                <div class="sheet-ac-wrapper"><input class="sheet-stat-input sheet-ac-input" type="text" name="attr_ac" value="0"></div>
            </div>
        </div>
    </div>
    <div class="saves section">
        <div class="grid-container-2col">
            <div class="movement-grid">
                <div class="sheet-movement-title">
                    <h3>Movement</h3>
                </div>
                
                <span class="sheet-save-span">Base</span>
                <input class="sheet-stat-input sheet-input-big" type="text" name="attr_base_movement" value="120">
                
                <span class="sheet-save-span">Combat</span>
                <input class="sheet-stat-input sheet-input-big" type="text" name="attr_combat_movement" value="floor(@{base_movement} / 3)" disabled="true">
                
                <span class="sheet-save-span">Chrg/Run</span>
                <input class="sheet-stat-input sheet-input-big" type="text" name="attr_charge_movement" value="@{base_movement}" disabled="true">
                
                <span class="sheet-save-span">Climb</span>
                <input class="sheet-stat-input sheet-input-big" type="text" name="attr_climb_movement" value="floor(@{combat_movement} / 4)" disabled="true">
                
                <span class="sheet-save-span">Stealth</span>
                <input class="sheet-stat-input sheet-input-big" type="text" name="attr_stealth_movement" value="floor(@{base_movement} / 2)" disabled="true">
                
                <span class="sheet-save-span">Daily</span>
                <input class="sheet-stat-input sheet-input-big" type="text" name="attr_daily_movement" value="floor(@{base_movement} * 2 / 10)" disabled="true">
            </div>
            <div class="saves-grid">
                <div class="sheet-saves-title">
                    <h3>Saving Throws</h3>
                </div>
                
                <span></span><span>Throw</span><span>Modifier</span><span></span>
                
                <span class="sheet-save-span">Petrif. & Paral.</span>
                <div><input class="sheet-stat-input" type="text" name="attr_save_pp"></div>
                <div><input class="sheet-stat-input" type="text" name="attr_save_pp_mod" value="0"></div>
                <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=Saving Throw}} {{subheader=Petrification & Paralysis}} {{character=@{character_name}}} {{roll=[[1d20 + @{save_pp_mod}]]}} {{target=[[@{save_pp}]]}}" name="roll_PPSave"></button></div>
                
                <span class="sheet-save-span">Poison & Death</span>
                <div><input class="sheet-stat-input" type="text" name="attr_save_pd"></div>
                <div><input class="sheet-stat-input" type="text" name="attr_save_pd_mod" value="0"></div>
                <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=Saving Throw}} {{subheader=Poison & Death}} {{character=@{character_name}}} {{roll=[[1d20 + @{save_pd_mod}]]}} {{target=[[@{save_pd}]]}}" name="roll_PDSave"></button></div>
                
                <span class="sheet-save-span">Blast & Breath</span>
                <div><input class="sheet-stat-input" type="text" name="attr_save_bb"></div>
                <div><input class="sheet-stat-input" type="text" name="attr_save_bb_mod" value="0"></div>
                <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=Saving Throw}} {{subheader=Blast & Breath}} {{character=@{character_name}}} {{roll=[[1d20 + @{save_bb_mod}]]}} {{target=[[@{save_bb}]]}}" name="roll_BBSave"></button></div>
                
                <span class="sheet-save-span">Staffs & Wands</span>
                <div><input class="sheet-stat-input" type="text" name="attr_save_sw"></div>
                <div><input class="sheet-stat-input" type="text" name="attr_save_sw_mod" value="0"></div>
                <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=Saving Throw}} {{subheader=Staffs & Wands}} {{character=@{character_name}}} {{roll=[[1d20 + @{save_sw_mod}]]}} {{target=[[@{save_sw}]]}}" name="roll_SWSave"></button></div>
                
                <span class="sheet-save-span">Spells</span>
                <div><input class="sheet-stat-input" type="text" name="attr_save_sp"></div>
                <div><input class="sheet-stat-input" type="text" name="attr_save_sp_mod" value="0"></div>
                <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=Saving Throw}} {{subheader=Spells}} {{character=@{character_name}}} {{roll=[[1d20 + @{save_sp_mod}]]}} {{target=[[@{save_sp}]]}}" name="roll_SPSave"></button></div>
            </div>
        </div>
    </div>
    
    <div class="lactions section">
        <div class="attacks-grid">
            <!-- Initiative -->
            <span class="sheet-initiative-span">Initiative</span>
            <div><input class="sheet-stat-input" type="text" name="attr_initiative_mod" value="0"></div>
            <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=Initiative Roll}} {{character=@{character_name}}} {{roll=[[1d6 + @{initiative_mod} &{tracker}]]}}" name="roll_Initiative"></button></div> 
        
            <span class="sheet-initiative-span">Attack Throw</span>
            <div><input class="sheet-stat-input" type="text" name="attr_attack_throw_vis" value="@{attack_throw}" disabled="true"></div>
            <div><input class="sheet-stat-input sheet-hidden" type="text" name="attr_attack_throw"></div>
        </div>
        <div class="attacks-grid">
            <div class="sheet-attack-title">
                <h3>Weapons & Attacks</h3>
            </div>
            <span>Attack Name</span><span>Th. Mod</span><span>Damage</span><span></span>
        </div>
        <fieldset class="repeating_attacks">
            <div class="attacks-grid">
                <input class="sheet-name-input" type="text" name="attr_attack_name">
                <div><input class="sheet-stat-input" type="text" name="attr_attack_throw_mod"></div>
                <div><input class="sheet-stat-input" type="text" name="attr_attack_dmg"></div>
                <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=@{attack_name} Attack}} {{character=@{character_name}}} {{roll=[[1d20 + @{attack_throw_mod}]]}} {{target=[[@{attack_throw}]]}} {{damage=[[@{attack_dmg}]]}}" name="roll_Attack"></button></div>
            </div>
        </fieldset>

        <div class="proficiencies-grid">
            <div class="sheet-proficiency-title">
                <h3>Proficiencies</h3>
            </div>
            <span>Proficiency</span><span>Desc</span><span></span>
        </div>
        <fieldset class="repeating_proficiencies">
            <div class="proficiencies-grid">
                <input class="sheet-name-input" type="text" name="attr_proficiency_name">
                <div><input class="sheet-stat-input" type="text" name="attr_proficiency_desc"></div>
                <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=@{proficiency_name}}} {{character=@{character_name}}} {{subheader=Proficiency}} {{desc=@{proficiency_desc}}}" name="roll_Proficiency"></button></div>
            </div>
        </fieldset>
    </div>
    <div class="ractions section">
        <div class="proficiencies-grid">
            <div class="sheet-proficiency-title">
                <h3>Class & Race Abilities</h3>
            </div>
            <span>Ability Name</span><span>Throw</span><span></span>
        </div>
        <fieldset class="repeating_abilities">
            <div class="proficiencies-grid">
                <input class="sheet-name-input" type="text" name="attr_ability_name">
                <div><input class="sheet-stat-input" type="text" name="attr_ability_throw"></div>
                <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=@{ability_name}}} {{@subheader=Class/Race Ability}} {{character=@{character_name}}} {{roll=[[1d20]]}} {{target=@{ability_throw}}}" name="roll_Ability"></button></div>
            </div>
        </fieldset>

        <div class="proficiencies-grid">
            <div class="sheet-proficiency-title">
                <h3>Actions</h3>
            </div>
            <span>Action Name</span><span>Throw</span><span></span>
        </div>
        <div class="proficiencies-grid">
            <input class="sheet-name-input" type="text" name="attr_opendoor_name" value="Open Door" title="A stuck door can be forced open with brute strength. Forcing open a door requires a proficiency throw of 18+. Doors of unusual material or size may impose a penalty on this proficiency throw. In addition, for each point of Strength adjustment, modify the result of the die roll by +/- 4. (A character with Strength 18 thus opens doors with a proficiency throw of 6+). If two characters cooperate to force open a door, use the stronger character’s Strength adjustment +4. A roll of 1 always fails to open a door. It takes only one combat round to force open a door, and characters may try again if they fail." disabled>
            <div><input class="sheet-stat-input" type="text" name="attr_opendoor_throw"></div>
            <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=Open Door}} {{@subheader=Action}} {{character=@{character_name}}} {{roll=[[1d20]]}} {{target=@{opendoor_throw}}}" name="roll_OpenDoor"></button></div>
        </div>
        <div class="proficiencies-grid">
            <input class="sheet-name-input" type="text" name="attr_detectdoor_name" value="Detect Secret Door" title="Some doors are somehow concealed or hidden - these are secret doors. Common secret doors are sliding panels in a wall, trap-doors under rugs, and so on. Secret doors can only be spotted if characters are specifically looking for them. When a player declares that his character is looking for secret door, the Judge should make a proficiency throw on behalf of the character. All characters except elves will spot a secret door if one is present on a throw of 18+ on 1d20. Elves have keen eyes that allow them to detect hidden and secret doors with a proficiency throw of 8+ on 1d20 when actively searching, or 14+ on casual inspection. It takes 1 turn for a character to search a 10’ x 10’ area. Since the Judge rolls the dice, the player never know if the roll failed or if there simply is no door in the area searched. Each character has only one chance to find each secret door." disabled>
            <div><input class="sheet-stat-input" type="text" name="attr_detectdoor_throw"></div>
            <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=Detect Secret Door}} {{@subheader=Action}} {{character=@{character_name}}} {{roll=[[1d20]]}} {{target=@{detectdoor_throw}}}" name="roll_DetectDoor"></button></div>
        </div>
        <div class="proficiencies-grid">
            <input class="sheet-name-input" type="text" name="attr_hearnoise_name" value="Hear Noise" title="Players will sometimes want their character to listen at a door or intersection to hear any noises beyond. Again, the Judge should make a proficiency throw on behalf of the character. A throw of 18+ on 1d20 succeeds. Dwarves and elves only need to throw 14+ due to their keen hearing. A thief has specially trained for this task, and has a different chance of success (refer to the Thief Skills table). This attempt may only be made one time at any door or intersection by a character. Note that some creatures, such as undead, do not make noise." disabled>
            <div><input class="sheet-stat-input" type="text" name="attr_hearnoise_throw"></div>
            <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=Hear Noise}} {{@subheader=Action}} {{character=@{character_name}}} {{roll=[[1d20]]}} {{target=@{hearnoise_throw}}}" name="roll_HearNoise"></button></div>
        </div>
        <div class="proficiencies-grid">
            <input class="sheet-name-input" type="text" name="attr_findtraps_name" value="Find Traps" title="While thieves have a special skill to detect traps, characters of all classes can search for non-magical traps with time and caution. All characters except dwarves succeed in spotting a trap with a proficiency throw of 18+ on 1d20. Dwarves succeed with a proficiency throw of 14+. Players must declare that their characters are actively looking for traps, and they must be looking in the right place. This roll may only be made once per character in a particular location, and it takes 1 turn per 10’ x 10’ area searched." disabled>
            <div><input class="sheet-stat-input" type="text" name="attr_findtraps_throw"></div>
            <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=Find Traps}} {{@subheader=Action}} {{character=@{character_name}}} {{roll=[[1d20]]}} {{target=@{findtraps_throw}}}" name="roll_FindTraps"></button></div>
        </div>
        <fieldset class="repeating_actions">
            <div class="proficiencies-grid">
                <input class="sheet-name-input" type="text" name="attr_action_name">
                <div><input class="sheet-stat-input" type="text" name="attr_action_throw"></div>
                <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=@{action_name}}} {{@subheader=Action}} {{character=@{character_name}}} {{roll=[[1d20]]}} {{target=@{action_throw}}}" name="roll_Action"></button></div>
            </div>
        </fieldset>
    </div>
    
    <div class="equipment section">
        <div class="equipment-grid">
            <div class="sheet-equipment-title">
                <h3>Equipment & Magic Items</h3>
            </div>
            
            <div class="total-encumb-display">
                <span>Total Encumbrance:</span>
                <span name="attr_encumbrance_total"></span>
            </div>

            <span>Item Name</span><span title="Stone Fractions to Decimal:
            1/6 = 0.167
            2/6 (1/3) = 0.333
            3/6 (1/2) = 0.5
            4/6 (2/3) = 0.667
            5/6 = 0.833">Encumb.</span>
        </div>
        <fieldset class="repeating_equipment">
            <div class="equipment-grid">
                <input class="sheet-name-input" type="text" name="attr_equipment_name">
                <div><input class="sheet-stat-input" type="text" name="attr_equipment_encumb"></div>
            </div>
        </fieldset>
    </div>
    <div class="loot section">
        <div class="currency-grid">            
            <div class="sheet-exp-title">
                <h3>Experience</h3>
            </div>
            <span>Current</span><span></span><span>Needed</span><span></span><span>Bonus</span>
            <div class="sheet-exp-current"><input type="text" name="attr_exp_current"></div>
            <div class="sheet-exp-needed"><input type="text" name="attr_exp_needed"></div>
            <div><input class="sheet-currency-input" type="text" name="attr_exp_bonus"></div>
            
            
            <div class="sheet-currency-title">
                <h3>Loot</h3>
            </div>
            <span>Copper</span><span>Silver</span><span>Electrum</span><span>Gold</span><span>Platinum</span>
            <input class="currency-input" type="text" name="attr_cp">
            <input class="currency-input" type="text" name="attr_sp">
            <input class="currency-input" type="text" name="attr_ep">
            <input class="currency-input" type="text" name="attr_gp">
            <input class="currency-input" type="text" name="attr_pp">

            <div class="sheet-lootbox"><textarea class="sheet-textarea" wrap="off" name="attr_loot"></textarea></div>
        </div>
    </div>
    <div class="spells section">
        <div class="spells-grid spells-grid-daily">
            <div class="sheet-spells-title">
                <h3>Spells Per Day</h3>
            </div>
            <span></span><span>One</span><span>Two</span><span>Three</span><span>Four</span><span>Five</span><span>Six</span><span></span><span></span>
            <span>Used</span>
            <input class="spells-input" type="text" name="attr_spells_l1">
            <input class="spells-input" type="text" name="attr_spells_l2">
            <input class="spells-input" type="text" name="attr_spells_l3">
            <input class="spells-input" type="text" name="attr_spells_l4">
            <input class="spells-input" type="text" name="attr_spells_l5">
            <input class="spells-input" type="text" name="attr_spells_l6">
            <span></span><span></span>
            
            <span>Total</span>
            <input class="spells-input" type="text" name="attr_spells_l1_max">
            <input class="spells-input" type="text" name="attr_spells_l2_max">
            <input class="spells-input" type="text" name="attr_spells_l3_max">
            <input class="spells-input" type="text" name="attr_spells_l4_max">
            <input class="spells-input" type="text" name="attr_spells_l5_max">
            <input class="spells-input" type="text" name="attr_spells_l6_max">
            <span></span><span></span>
        </div>
        <div class="spells-grid">
            <div class="sheet-spells-title sheet-margin-top">
                <h3>Spellbook</h3>
            </div>
            <span class="grid-span-1-2">Spell Name</span><span>Level</span><span class="grid-span-4-2">Effect</span><span>Range</span><span>Roll</span><span></span><span></span><span></span><span></span>
        </div>
        <fieldset class="repeating_spells">
            <div class="spells-grid">
                <input class="sheet-name-input grid-span-1-2" type="text" name="attr_spell_name">
                <div><input class="sheet-stat-input" type="text" name="attr_spell_level"></div>
                <div class="grid-span-4-2"><textarea class="sheet-stat-input sheet-txtarea" name="attr_spell_effect" ></textarea></div>
                <div><input class="sheet-stat-input" type="text" name="attr_spell_range"></div>
                <div><input class="sheet-stat-input" type="text" name="attr_spell_roll" value="0"></div>
                <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=@{spell_name}}} {{subheader=Level @{spell_level} @{spell_school} Spell}} {{desc=@{spell_effect}}} {{character=@{character_name}}} {{roll=[[@{spell_roll}]]}} {{range=@{spell_range}}}" name="roll_Spell"></button></div>
                <div class="sheet-hidden"><input type="text" name="attr_spell_school"></div>
            </div>
        </fieldset>
    </div>   

    </div>
</div>
<div class="npc">
    <div class="npc-header sheet-grid-span-1-2 sheet-text-center">
        <h2>Adventurer Conqueror King System</h2>
        <h4>NPC/Monster Stat Block</h4>
        <br><br><br>
    </div>
    <div class="npc-lsection">
        <div class="attacks-grid">
            <span class="sheet-initiative-span">Attack Throw</span>
            <div><input class="sheet-stat-input" type="text" name="attr_npc_attack_throw_vis" value="@{npc_attack_throw}" disabled="true"></div>
            <div><input class="sheet-stat-input sheet-hidden" type="text" name="attr_npc_attack_throw"></div>
            
            <span class="sheet-initiative-span">Armour Class</span>
            <div><input class="sheet-stat-input" type="text" name="attr_ac" value="0"></div>
            <div></div>
            
            <!-- Initiative -->
            <span class="sheet-initiative-span">Initiative</span>
            <div><input class="sheet-stat-input" type="text" name="attr_initiative_mod" value="0"></div>
            <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=Initiative Roll}} {{character=@{character_name}}} {{roll=[[1d6 + @{initiative_mod} &{tracker}]]}}" name="roll_Initiative"></button></div> 
        </div>
        <div class="attacks-grid">
            <div class="sheet-attack-title">
                <h3>Weapons & Attacks</h3>
            </div>
            <span>Attack Name</span><span>Th. Mod</span><span>Damage</span><span></span>
        </div>
        <fieldset class="repeating_attacks">
            <div class="attacks-grid">
                <input class="sheet-name-input" type="text" name="attr_attack_name">
                <div><input class="sheet-stat-input" type="text" name="attr_attack_throw_mod"></div>
                <div><input class="sheet-stat-input" type="text" name="attr_attack_dmg"></div>
                <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=@{attack_name} Attack}} {{character=@{character_name}}} {{roll=[[1d20 + @{attack_throw_mod}]]}} {{target=[[@{npc_attack_throw}]]}} {{damage=[[@{attack_dmg}]]}}" name="roll_Attack"></button></div>
            </div>
        </fieldset>

        <div class="proficiencies-grid">
            <div class="sheet-proficiency-title">
                <h3>Proficiencies</h3>
            </div>
            <span>Proficiency</span><span>Desc</span><span></span>
        </div>
        <fieldset class="repeating_proficiencies">
            <div class="proficiencies-grid">
                <input class="sheet-name-input" type="text" name="attr_proficiency_name">
                <div><input class="sheet-stat-input" type="text" name="attr_proficiency_desc"></div>
                <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=@{proficiency_name} Proficency}} {{desc=@{proficiency_desc}}}" name="roll_Proficiency"></button></div>
            </div>
        </fieldset>
    </div>
    <div class="npc-rsection">
        <div class="hitdie-grid">
            <span class="sheet-title-line">Hit Dice</span>
            <span>
                <input type="checkbox" name="attr_npc_hda_1" class="hd-checkbox">
                <input type="checkbox" name="attr_npc_hda_2" class="hd-checkbox">
                <input type="checkbox" name="attr_npc_hda_3" class="hd-checkbox">
            </span>
            <input class="sheet-stat-input" type="text" name="attr_npc_hitdice" value="d8">
            <div><button class="sheet-roll-button" type="roll" value="/w gm &{template:acks}{{name=Hit Dice}}{{character=@{character_name}}} {{roll=[[@{npc_hitdice}]]}}" name="roll_NPCHitDice"></button></div>
            
            
            <span class="sheet-title-line">Hit Points/Max</span><input class="sheet-stat-input" type="text" name="attr_hp"><input class="sheet-stat-input" type="text" name="attr_hp_max"><span></span>
        
            <span class="sheet-title-line">Class</span><span></span><span class="sheet-title-line">Level</span><span></span>
            
            <select name="attr_class">
                <option>Fighter</option>
                <option>Mage</option>
                <option>Cleric</option>
                <option>Thief</option>
                <option>Assassin</option>
                <option>Bard</option>
                <option>Bladedancer</option>
                <option>Explorer</option>
            </select>
            <span></span>
            <input class="sheet-stat-input" type="text" name="attr_level">
            <span></span>
        </div>
        <div class="saves-grid">
            <div class="sheet-saves-title">
                <h3>Saving Throws</h3>
            </div>
            
            <span></span><span>Throw</span><span>Modifier</span><span></span>
            
            <span class="sheet-save-span">Petrif. & Paral.</span>
            <div><input class="sheet-stat-input" type="text" name="attr_save_pp"></div>
            <div><input class="sheet-stat-input" type="text" name="attr_save_pp_mod" value="0"></div>
            <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=Saving Throw}} {{subheader=Petrification & Paralysis}} {{character=@{character_name}}} {{roll=[[1d20 + @{save_pp_mod}]]}} {{target=[[@{save_pp}]]}}" name="roll_PPSave"></button></div>
            
            <span class="sheet-save-span">Poison & Death</span>
            <div><input class="sheet-stat-input" type="text" name="attr_save_pd"></div>
            <div><input class="sheet-stat-input" type="text" name="attr_save_pd_mod" value="0"></div>
            <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=Saving Throw}} {{subheader=Poison & Death}} {{character=@{character_name}}} {{roll=[[1d20 + @{save_pd_mod}]]}} {{target=[[@{save_pd}]]}}" name="roll_PDSave"></button></div>
            
            <span class="sheet-save-span">Blast & Breath</span>
            <div><input class="sheet-stat-input" type="text" name="attr_save_bb"></div>
            <div><input class="sheet-stat-input" type="text" name="attr_save_bb_mod" value="0"></div>
            <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=Saving Throw}} {{subheader=Blast & Breath}} {{character=@{character_name}}} {{roll=[[1d20 + @{save_bb_mod}]]}} {{target=[[@{save_bb}]]}}" name="roll_BBSave"></button></div>
            
            <span class="sheet-save-span">Staffs & Wands</span>
            <div><input class="sheet-stat-input" type="text" name="attr_save_sw"></div>
            <div><input class="sheet-stat-input" type="text" name="attr_save_sw_mod" value="0"></div>
            <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=Saving Throw}} {{subheader=Staffs & Wands}} {{character=@{character_name}}} {{roll=[[1d20 + @{save_sw_mod}]]}} {{target=[[@{save_sw}]]}}" name="roll_SWSave"></button></div>
            
            <span class="sheet-save-span">Spells</span>
            <div><input class="sheet-stat-input" type="text" name="attr_save_sp"></div>
            <div><input class="sheet-stat-input" type="text" name="attr_save_sp_mod" value="0"></div>
            <div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=Saving Throw}} {{subheader=Spells}} {{character=@{character_name}}} {{roll=[[1d20 + @{save_sp_mod}]]}} {{target=[[@{save_sp}]]}}" name="roll_SPSave"></button></div>
        </div>
    </div>
</div>


<!-- Roll Templates -->
<rolltemplate class="sheet-rolltemplate-acks">
    <div class="sheet-acks-container">
	    {{#character}}
	    <div class="sheet-acks-charname">{{character}}</div>
	    {{/character}}
	    
        <div class="sheet-acks-header">{{name}}</div>
        
        {{#subheader}}
            <div class="sheet-acks-subheader sheet-acks-row">{{subheader}}</div>
        {{/subheader}}
        
        {{#target}}
            <div class="sheet-acks-row"><strong>Target</strong> <span class="sheet-acks-target-value">{{target}}+</span></div>
        {{/target}}
        
        {{#range}}
            <div class="sheet-acks-row"><strong>Range</strong> <span class="sheet-acks-target-value">{{range}}</span></div>
        {{/range}}
        
        {{#roll}}
            <div class="sheet-acks-row"><strong>Roll</strong> {{roll}}</div>
        {{/roll}}
        
        {{#damage}}
            <div class="sheet-acks-row"><strong>Damage</strong> {{damage}}</div>
        {{/damage}}
        
        {{#desc}}
            <div class="sheet-acks-row sheet-acks-desc">{{desc}}</div>
        {{/desc}}
        
        {{#allprops() character subheader target range roll damage desc}}
            <div class="sheet-acks-row"><strong>{{key}}</strong> {{value}}</div>
        {{/allprops() character subheader target range roll damage desc}}
    </div>
</rolltemplate>


<!-- Sheet Workers -->
<script type="text/worker">
/*** Equipment Encumbrance Totaling ***/
on('change:repeating_equipment:equipment_encumb remove:repeating_equipment', function() {
    console.log('calculating equipment encumbrance');
	repeatingSum("encumbrance_total","equipment","equipment_encumb", "round: 3");
});
const repeatingSum = (destinations, section, fields, ...extras) => {
    const isNumber = value => parseFloat(value).toString() === value.toString();
    const isOption = value => [...checks.valid, ...checks.roundtypes].includes(value);
    const isRounding = value => checks.roundtypes.includes(value);
    const isFraction = value => value.includes('/') && !(value.includes(',') || value.includes('|'));
    const getTrimmed = value => value.toLowerCase().replace(/\s/g, '');
    const getRounded = (type, value, pow) => (Math[type](value * Math.pow(10, pow)) / Math.pow(10, pow)).toFixed(Math.max(0, pow));
    const getFraction = (value) => /*{ console.log(`value: ${value}`); */
        parseInt(value.split('/')[0]) / parseInt(value.split('/')[1]);
    const getMultiplier = (value, rounding = 1) => 'undefined' === typeof value ? (rounding ? 0: 1) : (
        isNumber(value) ? parseFloat(value) : (isFraction(value) ? getFraction(value) : value));
    if (!Array.isArray(destinations)) destinations = [getTrimmed(destinations)];
    if (!Array.isArray(fields)) fields = [getTrimmed(fields)];
    const fields_trimmed = fields.map(field => getTrimmed(field).split(':')[0]);
    const subfields = fields_trimmed.slice(0,destinations.length);
    const checks = { valid: ['multiplier'], roundtypes: ['ceil', 'round', 'floor'] };
    let properties = {attributes: {}, options: {}};
    extras.forEach(extra => {
        const [prop, v] = getTrimmed(extra).split(':');
        const multiplier_maybe = getMultiplier(v, isRounding(prop));
        const obj = isNumber(multiplier_maybe) ? subfields.reduce((obj,field) => {
            obj[field] = multiplier_maybe;
            return obj;
        },{}) : multiplier_maybe.split(',').reduce((obj, item) => {
            const [stat, value] = item.split('|');
            const multiplier = getMultiplier(value, isRounding(prop));
            obj[stat] = multiplier;
            return obj;
        }, {});
        properties[isOption(prop) ? 'options' : 'attributes'][prop] = obj;
    });
    getSectionIDs(`repeating_${section}`, idArray => {
        const attrArray = idArray.reduce((m, id) => [...m, ...(fields_trimmed.map(field => `repeating_${section}_${id}_${field}`))], []);
        getAttrs([...attrArray, ...Object.keys(properties.attributes)], v => {
            const getValue = (section, id, field) => v[`repeating_${section}_${id}_${field}`] === 'on' ? 1 : parseFloat(v[`repeating_${section}_${id}_${field}`]) || 0;
            const commonMultipliers = (fields.length <= destinations.length) ? [] : fields.splice(destinations.length, fields.length - destinations.length);
            const output = destinations.reduce((obj, destination, index) => {
                let sumTotal = idArray.reduce((total, id) => total + getValue(section, id, fields_trimmed[index]) * commonMultipliers.reduce((subtotal, mult) => subtotal * ((!mult.includes(':') || mult.split(':')[1].split(',').includes(fields_trimmed[index])) ? getValue(section, id, mult.split(':')[0]) : 1), 1), 0);
                sumTotal *= (properties.options.hasOwnProperty('multiplier') && Object.keys(properties.options.multiplier).includes(fields_trimmed[index])) ? (parseFloat(properties.options.multiplier[fields_trimmed[index]]) || 0): 1;
                sumTotal += Object.entries(properties.attributes).reduce((total, [key, value]) => 
                    total += (value.hasOwnProperty(fields_trimmed[index]) ? parseFloat(v[key] || 0) * (parseFloat(value[fields_trimmed[index]]) || 1): 0) , 0);
                checks.roundtypes.forEach(type => {
                    if (properties.options.hasOwnProperty(type)) {
                        if (Object.keys(properties.options[type]).includes(fields_trimmed[index])) {
                            sumTotal = getRounded(type, sumTotal, (+properties.options[type][fields_trimmed[index]] || 0));
                        } else if (properties.options[type] == '0' || !isNaN(+properties.options[type] || 'x') ) {
                            sumTotal = getRounded(type, sumTotal, +properties.options[type]);
                        } 
                    } 
                });
                obj[destination] = sumTotal;
                return obj;
            }, {});
            setAttrs(output);
        }); 
    }); 
};
</script>
<script type="text/worker">
/*** ATTRIBUTE RELATED WORKERS ***/
    const calculateAttrMod = function(attr) {
        // Calculate the modifier for a given attribute value
        let atr = parseInt(attr);
        let mod = 0;
        
        if(atr <= 3) mod = -3;
        if(atr >= 4 && atr <= 5) mod = -2;
        if(atr >= 6 && atr <= 8) mod = -1;
        if(atr >= 9 && atr <= 12) mod = 0;
        if(atr >= 13 && atr <= 15) mod = 1;
        if(atr >= 16 && atr <= 17) mod = 2;
        if(atr >= 18) mod = 3;
        
        return mod;
    };
    
    /** Calculate Modifiers when an Attribute value changes **/
    on("change:str", function(e) {
        console.log('calculate mod for str');
        setAttrs({str_mod: calculateAttrMod(e.newValue)});
    });
    on("change:int", function(e) {
        console.log('calculate mod for int');
        setAttrs({int_mod: calculateAttrMod(e.newValue)});
    });
    on("change:wis", function(e) {
        console.log('calculate mod for wis');
        setAttrs({wis_mod: calculateAttrMod(e.newValue)});
    });
    on("change:dex", function(e) {
        console.log('calculate mod for dex');
        setAttrs({dex_mod: calculateAttrMod(e.newValue)});
    });
    on("change:con", function(e) {
        console.log('calculate mod for con');
        setAttrs({con_mod: calculateAttrMod(e.newValue)});
    });
    on("change:chr", function(e) {
        console.log('calculate mod for chr');
        setAttrs({chr_mod: calculateAttrMod(e.newValue)});
    });
</script>
<script type="text/worker">
/*** SAVES/THROWS RELATED WORKERS ***/
    const calculateSavesThrows = function(level, clas) {
        level = parseInt(level);
        var saves = [0, 0, 0, 0, 0, 0];
        switch(clas) {
            case 'Fighter':
            case 'Assassin':
            case 'Explorer':
                switch(level) {
                    case 0:
                        saves = [16, 15, 17, 17, 18];
                        break;
                    case 1: 
                        saves = [15, 14, 16, 16, 17, 10]; 
                        break;
                    case 2:
                    case 3:
                        saves = [14, 13, 15, 15, 16, 9];
                        break;
                    case 4:
                        saves = [13, 12, 14, 14, 15, 8];
                        break;
                    case 5:
                    case 6:
                        saves = [12, 11, 13, 13, 14, 7];
                        break;
                    case 7:
                        saves = [11, 10, 12, 12, 13, 6];
                        break;
                    case 8:
                    case 9:
                        saves = [10, 9, 11, 11, 12, 5];
                        break;
                    case 10:
                        saves = [9, 8, 10, 10, 11, 4];
                        break;
                    case 11:
                    case 12:
                        saves = [8, 7, 9, 9, 10, 3];
                        break;
                    case 13:
                        saves = [7, 6, 8, 8, 9, 2];
                        break;
                    case 14:
                        saves = [6, 5, 7, 7, 8, 1];
                        break;
                }
                break;
            case 'Mage':
                switch(level) {
                    case 1: 
                    case 2:
                    case 3:
                        saves = [13, 13, 15, 11, 12, 10]; 
                        break;
                    case 4:
                    case 5:
                    case 6:
                        saves = [12, 12, 14, 10, 11, 9];
                        break;
                    case 7:
                    case 8:
                    case 9:
                        saves = [11, 11, 13, 9, 10, 8];
                        break;
                    case 10:
                    case 11:
                    case 12:
                        saves = [10, 10, 12, 8, 9, 7];
                        break;
                    case 13:
                    case 14:
                        saves = [9, 9, 11, 7, 8, 6];
                        break;
                }
                break;
            case 'Cleric':
            case 'Bladedancer':
                switch(level) {
                    case 1:
                    case 2:
                        saves = [13, 10, 16, 13, 15, 10];
                        break;
                    case 3:
                    case 4:
                        saves = [12, 9, 15, 12, 14, 9];
                        break;
                    case 5:
                    case 6:
                        saves = [11, 8, 14, 11, 13, 8];
                        break;
                    case 7:
                    case 8:
                        saves = [10, 7, 13, 10, 12, 7];
                        break;
                    case 9:
                    case 10:
                        saves = [9, 6, 12, 9, 11, 6];
                        break;
                    case 11:
                    case 12:
                        saves = [8, 5, 11, 8, 10, 5];
                        break;
                    case 13:
                    case 14:
                        saves = [7, 4, 10, 7, 9, 4];
                        break;
                }
                break;
            case 'Thief':
            case 'Bard':
                switch(level) {
                    case 1:
                    case 2:
                        saves = [13, 13, 16, 14, 15, 10];
                        break;
                    case 3:
                    case 4:
                        saves = [12, 12, 15, 13, 14, 9];
                        break;
                    case 5:
                    case 6:
                        saves = [11, 11, 14, 12, 13, 8];
                        break;
                    case 7:
                    case 8:
                        saves = [10, 10, 13, 11, 12, 7];
                        break;
                    case 9:
                    case 10:
                        saves = [9, 9, 12, 10, 11, 6];
                        break;
                    case 11:
                    case 12:
                        saves = [8, 8, 11, 9, 10, 5];
                        break;
                    case 13:
                    case 14:
                        saves = [7, 7, 10, 8, 9, 4];
                        break;
                }
                break;
        }
        
        return saves;
    };
    
    on("change:level change:class", function(e) {
        console.log('calculate saves and throws for class/level');
        getAttrs(["level", "class"], function(v) {
            let saves = calculateSavesThrows(v.level, v.class);
            setAttrs({
                save_pp: saves[0],
                save_pd: saves[1],
                save_bb: saves[2],
                save_sw: saves[3],
                save_sp: saves[4],
                attack_throw: saves[5]
            });

            let title = getClassLevelTitle(v.level, v.class);
            setAttr({classtitle: title});
        });
    });

    /* PC Class Default Titles */
    const class_titles = {
        // 1,2,3,4,5,6,7,8,9,10,11,12,13,14
        'Fighter': ["Man-at-Arms", "Warrior", "Swordmaster", "Hero", "Exemplar", "Myrmidon", "Champion", "Epic Hero", "Warlord", "Warlord", "Warlord", "Warlord", "Warlord", "Overlord"],
        'Assassin': ["Thug", "Enforcer", "Torturer", "Slayer", "Destroyer", "Executioner", "Blackguard", "Assassin", "Master Assassin", "Master Assassin", "Master Assassin", "Master Assassin", "Master Assassin", "Grandfather of Assassins"],
        'Explorer': ["Scout", "Outrider", "Forester", "Explorer", "Guide", "Tracker", "Pathfinder", "Ranger", "Warden", "Warden", "Warden", "Warden", "Warden", "Lord Warden"],
        'Mage': ["Arcanist", "Seer", "Theurgist", "Magician", "Thaumaturge", "Enchanter", "Sorcerer", "Mage", "Wizard", "Wizard", "Wizard", "Wizard", "Wizard", "Archmage"],
        'Cleric': ["Catechist", "Acolyte", "Priest", "Curate", "Vicar", "Rector", "Prelate", "Bishop", "Patriarch", "Patriarch", "Patriarch", "Patriarch", "Patriarch", "Theocrat"],
        'Bladedancer': ["Blade-Initiate", "Blade-Daughter", "Blade-Singer", "Blade-Weaver", "Blade-Sister", "Blade-Adept", "Blade-Dancer", "Blade-Priestess", "Blade-Mistress", "Blade-Mistress", "Blade-Mistress", "Blade-Mistress", "Blade-Mistress", "Mistress of All Blades"],
        'Thief': ["Footpad", "Hood", "Robber", "Burglar", "Rogue", 'Scoundrel", "Pilferer", "Thief", "Master Thief", "Master Thief", "Master Thief", "Master Thief", "Master Thief", "Prince of Thieves"],
        'Bard': ["Reciter", "Versifier", "Archivist", "Annalist", "Chronicler", "Panegyrist", "Skald", "Rhapsodist", "Bard", "Bard", "Bard", "Bard", "Bard", "Master Bard"],
    };
    
    const getClassLevelTitle = function(level, class_name) {
        return class_titles[class_name][level - 1] || "the Unknown";
    };
    
    /* NPC Attack Throw */
    const calculateNpcHit = function(hd) {
        switch(hd.toString().replace(/(d\d+[+\-0-9]*)/, '')) {
            case '1':
                return 10;
            case '2':
                return 9;
            case '3':
                return 8;
            case '4':
                return 7;
            case '5':
                return 6;
            case '6':
                return 5;
            case '7':
                return 4;
            case '8':
            case '9':
                return 3;
            case '10':
            case '11':
                return 2;
            case '12':
            case '13':
                return 1;
            case '14':
            case '15':
                return 0;
            case '16':
            case '17':
                return -1;
            case '18':
            case '19':
                return -2;
            case '20':
            case '21':
                return -3;
            default:
                return -4;
        }
    };
    on("change:npc_hitdice", function(e) {
       getAttrs(["npc_hitdice"], function(v) {
           let thrw = calculateNpcHit(v.npc_hitdice);
           setAttrs({npc_attack_throw: thrw});
       }); 
    });
</script>
