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

290 lines
12 KiB
HTML

<h1 data-i18n="title"></h1>
<!-- Personal information -->
<div class="grid-personal">
<label data-i18n="character-name" for="attr_character_name" ></label>
<input type="text" name="attr_character_name" id="attr_character_name" />
<label data-i18n="pronouns" for="attr_pronouns" ></label>
<input type="text" name="attr_pronouns" id="attr_pronouns" />
<label data-i18n="background" for="attr_background" ></label>
<input type="text" name="attr_background" id="attr_background" />
<label data-i18n="gp" for="attr_gold" ></label>
<input type="text" name="attr_gold" id="attr_gold" />
</div>
<!-- Saves -->
<div class="flex-container top content-row">
<div class="flex-container column">
<h2 data-i18n="saves"></h2>
<div class="grid-saves">
<label data-i18n="strength" ></label>
<div class="flex-container-stats">
<input class="stat-input" type="number" name="attr_ability_strength" id="attr_ability_strength" min="0" max="18" value="10"/>
<div class="stat-input-separator">&nbsp;</div>
<input class="stat-input" type="number" name="attr_ability_strength_max" id="attr_ability_strength_max" min="0" max="18" value="10"/>
</div>
<button class="custom-roll-button" type="roll"
value="&{template:test-under} {{rollname=Save - Strength}} {{result=[[1d20]]}} {{target=[[@{ability_strength}]]}}"
name="roll_strength"></button>
<label data-i18n="dexterity" ></label>
<div class="flex-container-stats">
<input class="stat-input" type="number" name="attr_ability_dexterity" id="attr_ability_dexterity" min="0" max="18" value="10"/>
<div class="stat-input-separator">&nbsp;</div>
<input class="stat-input" type="number" name="attr_ability_dexterity_max" id="attr_ability_dexterity_max" min="0" max="18" value="10"/>
</div>
<button class="custom-roll-button" type="roll"
value="&{template:test-under} {{rollname=Save - Dexterity}} {{result=[[1d20]]}} {{target=[[@{ability_dexterity}]]}}"
name="roll_dexterity"></button>
<label data-i18n="willpower" ></label>
<div class="flex-container-stats">
<input class="stat-input" type="number" name="attr_ability_willpower" id="attr_ability_willpower" min="0" max="18" value="10"/>
<div class="stat-input-separator">&nbsp;</div>
<input class="stat-input" type="number" name="attr_ability_willpower_max" id="attr_ability_willpower_max" min="0" max="18" value="10"/>
</div>
<button class="custom-roll-button" type="roll"
value="&{template:test-under} {{rollname=Save - Willpower}} {{result=[[1d20]]}} {{target=[[@{ability_willpower}]]}}"
name="roll_willpower"></button>
</div>
</div>
<div class="flex-container column">
<h2 data-i18n="defense"></h2>
<div class="grid-defense">
<label data-i18n="armor"></label>
<input class="stat-input" type="number" name="attr_armor" id="attr_armor" min="0" max="3" value="0"/>
<label data-i18n="hit-protection"></label>
<div class="flex-container-stats">
<input class="stat-input" type="number" name="attr_hit_protection" id="attr_hit_protection" min="0" value="0"/>
<div class="stat-input-separator">&nbsp;</div>
<input class="stat-input" type="number" name="attr_hit_protection_max" id="attr_hit_protection_max" min="0" value="0"/>
</div>
</div>
</div>
</div>
<div class="flex-container top content-row">
<!-- Combat and recovery -->
<div class="flex-container column">
<h2 data-i18n="offense"></h2>
<div class="grid-offense">
<label data-i18n="weapon"></label>
<label data-i18n="damage"></label>
<span></span>
<input type="text" name="attr_weapon_1" />
<select name="attr_weapon_1_dmg" id="attr_weapon_1_dmg">
<option value="4" selected>d4</option>
<option value="6">d6</option>
<option value="8">d8</option>
<option value="10">d10</option>
<option value="12">d12</option>
</select>
<button class="custom-roll-button" type="roll"
value="&{template:attack} {{rollname=@{weapon_1}}} {{result=[[1d@{weapon_1_dmg}]]}}"
name="roll_weapon_1"></button>
<input type="text" name="attr_weapon_2" />
<select name="attr_weapon_2_dmg" id="attr_weapon_2_dmg">
<option value="4" selected>d4</option>
<option value="6">d6</option>
<option value="8">d8</option>
<option value="10">d10</option>
<option value="12">d12</option>
</select>
<button class="custom-roll-button" type="roll"
value="&{template:attack} {{rollname=@{weapon_2}}} {{result=[[1d@{weapon_2_dmg}]]}}"
name="roll_weapon_2"></button>
</div>
<h2 data-i18n="conditions"></h2>
<div class="flex-container">
<label data-i18n="deprived"></label>
<input class="stat-input" type="checkbox" name="attr_deprived" id="attr_deprived"/>
</div>
</div>
<!-- Items -->
<div class="flex-container column">
<div class="flex-container bottom">
<h2 data-i18n="inventory"></h2>
<p class="push"><span name="attr_inventory_slots"></span>/10</p>
</div>
<div class="grid-inventory">
<label data-i18n="item"></label>
<label data-i18n="quantity"></label>
<label data-i18n="fatigue"></label>
<input type="text" name="attr_item_1" />
<input type="number" name="attr_item_qty_1" min="0" value="0"/>
<input type="checkbox" name="attr_fatigue_1" />
<input type="text" name="attr_item_2" />
<input type="number" name="attr_item_qty_2" min="0" value="0" />
<input type="checkbox" name="attr_fatigue_2" />
<input type="text" name="attr_item_3" />
<input type="number" name="attr_item_qty_3" min="0" value="0"/>
<input type="checkbox" name="attr_fatigue_3" />
<input type="text" name="attr_item_4" />
<input type="number" name="attr_item_qty_4" min="0" value="0" />
<input type="checkbox" name="attr_fatigue_4" />
<input type="text" name="attr_item_5" />
<input type="number" name="attr_item_qty_5" min="0" value="0" />
<input type="checkbox" name="attr_fatigue_5" />
<input type="text" name="attr_item_6" />
<input type="number" name="attr_item_qty_6" min="0" value="0" />
<input type="checkbox" name="attr_fatigue_6" />
<input type="text" name="attr_item_7" />
<input type="number" name="attr_item_qty_7" min="0" value="0" />
<input type="checkbox" name="attr_fatigue_7" />
<input type="text" name="attr_item_8" />
<input type="number" name="attr_item_qty_8" min="0" value="0" />
<input type="checkbox" name="attr_fatigue_8" />
<input type="text" name="attr_item_9" />
<input type="number" name="attr_item_qty_9" min="0" value="0" />
<input type="checkbox" name="attr_fatigue_9" />
<input type="text" name="attr_item_10" />
<input type="number" name="attr_item_qty_10" min="0" value="0" />
<input type="checkbox" name="attr_fatigue_10" />
</div>
</div>
</div>
<!-- Notes -->
<h2 data-i18n="everything-else"></h2>
<div class="flex-container column">
<label data-i18n="traits" for="attr_traits" ></label>
<textarea name="attr_traits" id="attr_traits" rows="4"></textarea>
</div>
<div class="flex-container column">
<label data-i18n="notes" ></label>
<textarea name="attr_notes" id="attr_notes" rows="4"></textarea>
</div>
<rolltemplate class="sheet-rolltemplate-test-under">
<div class="sheet-template-container">
<div class="sheet-template-header">{{rollname}}</div>
<div class="sheet-template-result">
<span>{{result}}</span>
{{#^rollGreater() result target}}<span></span>{{/^rollGreater() result target}}
{{#rollGreater() result target}}<span></span>{{/rollGreater() result target}}
<span>{{target}}</span>
</div>
{{#^rollGreater() result target}}<div class="sheet-template-outcome-success">Success</div>
{{/^rollGreater() result target}}
{{#rollGreater() result target}}<div class="sheet-template-outcome-failure">Failure</div>
{{/rollGreater() result target}}
</div>
</rolltemplate>
<rolltemplate class="sheet-rolltemplate-attack">
<div class="sheet-template-container">
<div class="sheet-template-header">{{rollname}}</div>
<div class="sheet-template-result">
<span>{{result}}</span>
</div>
</div>
</rolltemplate>
<script type="text/worker">
const inventory_slot = [1,2,3,4,5,6,7,8,9,10]
function createItemName(inventory_slot) {
return `item_${inventory_slot}`;
}
function createFatigueName(inventory_slot) {
return `fatigue_${inventory_slot}`;
}
on("sheet:opened", () => {
let inventory_slots = 0;
let attribute_names = inventory_slot.map(createItemName).concat(inventory_slot.map(createFatigueName));
getAttrs(attribute_names, values => {
inventory_slot.forEach(inventory_slot => {
let item = values[`item_${inventory_slot}`];
let fatigue = values[`fatigue_${inventory_slot}`];
if ((item !== undefined && item !== "") || fatigue === "on") {
inventory_slots++;
};
if ((item === undefined || item === "") && fatigue !== "on") {
setAttrs({
[`item_${inventory_slot}`]: ""
});
};
});
setAttrs({
["inventory_slots"]: inventory_slots
});
});
});
inventory_slot.forEach(inventory_slot => {
on(`change:fatigue_${inventory_slot}`, () => {
getAttrs(["inventory_slots", "hit_protection", `item_${inventory_slot}`, `fatigue_${inventory_slot}`], values => {
let item = values[`item_${inventory_slot}`];
let fatigue = values[`fatigue_${inventory_slot}`];
let inventory_slots = parseInt(values["inventory_slots"]) || 0;
let hp = parseInt(values["hit_protection"]) || 0;
if (item === undefined || item === "") {
if (fatigue === "on") {
inventory_slots++;
} else {
inventory_slots--;
}
}
hp = inventory_slots >= 10 ? 0 : hp;
setAttrs({
["inventory_slots"]: inventory_slots,
["hit_protection"]: hp
});
});
});
on(`change:item_${inventory_slot}`, eventInfo => {
getAttrs(["inventory_slots", "hit_protection", `item_${inventory_slot}`, `fatigue_${inventory_slot}`], values => {
let previousValue = eventInfo.previousValue;
let newValue = eventInfo.newValue;
let fatigue = values[`fatigue_${inventory_slot}`];
let inventory_slots = parseInt(values["inventory_slots"]) || 0;
let hp = parseInt(values["hit_protection"]) || 0;
if (fatigue !== "on") {
if ((previousValue === undefined || previousValue === "") && newValue !== undefined && newValue !== "") {
inventory_slots++;
} else if (previousValue !== undefined && previousValue !== "" && (newValue === undefined || newValue === "")) {
inventory_slots--;
}
}
hp = inventory_slots >= 10 ? 0 : hp;
setAttrs({
["inventory_slots"]: inventory_slots,
["hit_protection"]: hp
});
});
});
});
</script>