[Heart: The City Beneath] Improve roll template (#7349)
* [Heart: The City Beneath mk2] Improve roll template Changes styling of the roll template to show the final result, depending on difficulty, along with the individual rolls. Also shows a message summarizing the result of the roll. * Fix line endings * Try fixing botched merge (due to bad line endings) * [Heart: The City Benath] Tweak difficulty error * [Heart: The City Beneath] Translation adjustment * [Heart: The City Beneath] Use enum-like construct for difficulty
This commit is contained in:
@@ -16,12 +16,12 @@
|
||||
.sheet-container {
|
||||
display: grid;
|
||||
grid-template-areas:
|
||||
"top stress"
|
||||
"beats abilities-fallout"
|
||||
"equipment abilities-fallout"
|
||||
"resources abilities-fallout"
|
||||
"top stress"
|
||||
"beats abilities-fallout"
|
||||
"equipment abilities-fallout"
|
||||
"resources abilities-fallout"
|
||||
"skills-domains abilities-fallout"
|
||||
"notes notes";
|
||||
"notes notes";
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-gap: var(--large-gap) calc(2 * var(--large-gap));
|
||||
align-items: start;
|
||||
@@ -323,9 +323,9 @@ input[type="text"].sheet-redtext {
|
||||
align-items: start;
|
||||
grid-column: span 2;
|
||||
grid-template-areas:
|
||||
"skill text text text"
|
||||
"domain text text text"
|
||||
"mastery extradice difficulty button";
|
||||
"skill text text text"
|
||||
"domain text text text"
|
||||
"mastery extradice difficulty button";
|
||||
grid-gap: var(--tiny-gap) var(--large-gap);
|
||||
}
|
||||
.sheet-rollbutton .sheet-mastery {
|
||||
@@ -462,7 +462,6 @@ label.sheet-extradice input[type="number"] {
|
||||
padding: 5px;
|
||||
overflow: hidden;
|
||||
user-select: none;
|
||||
display:grid;
|
||||
cursor: default;
|
||||
overflow: hidden;
|
||||
font-family: "Times New Roman", serif;
|
||||
@@ -470,6 +469,14 @@ label.sheet-extradice input[type="number"] {
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100% auto;
|
||||
background-image: url("https://raw.githubusercontent.com/roll20/roll20-character-sheets/master/Heart-the-City-Beneath-mk2/Heart-bg.png");
|
||||
display: grid;
|
||||
grid-template-areas:
|
||||
"title roll"
|
||||
"name roll"
|
||||
"details roll";
|
||||
grid-template-columns: 1fr auto;
|
||||
grid-template-rows: auto auto 1fr;
|
||||
grid-column-gap: 3px;
|
||||
}
|
||||
.withoutavatars .sheet-rolltemplate-heart {
|
||||
margin-left: -12px;
|
||||
@@ -477,13 +484,6 @@ label.sheet-extradice input[type="number"] {
|
||||
.sheet-rolltemplate-heart div {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.sheet-rolltemplate-heart .inlinerollresult {
|
||||
border: none !important;
|
||||
background-color: transparent;
|
||||
font-weight: bold;
|
||||
padding: 0 3px 0 0;
|
||||
font-size: 1.4em;
|
||||
}
|
||||
.sheet-rolltemplate-heart .sheet-title {
|
||||
color: #a00a03;
|
||||
font-size: 1.2em;
|
||||
@@ -493,3 +493,32 @@ label.sheet-extradice input[type="number"] {
|
||||
font-size: 1.1em;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
.sheet-rolltemplate-heart .sheet-roll {
|
||||
grid-area: roll;
|
||||
align-self: center;
|
||||
justify-self: center;
|
||||
border: 2px solid black;
|
||||
border-radius: 10px;
|
||||
min-width: 40px;
|
||||
min-height: 40px;
|
||||
max-width: 80px;
|
||||
text-align: center;
|
||||
padding: 5px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
.sheet-rolltemplate-heart .sheet-main-roll {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
.sheet-rolltemplate-heart .inlinerollresult {
|
||||
border: none !important;
|
||||
background-color: transparent;
|
||||
font-weight: bold;
|
||||
padding: 0 3px 0 0;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
.sheet-rolltemplate-heart .sheet-main-roll .inlinerollresult {
|
||||
font-size: 1.6em;
|
||||
}
|
||||
.sheet-rolltemplate-heart .sheet-details {
|
||||
grid-column: span 2;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
</div>
|
||||
|
||||
<button type="roll" title="Receive fallout?" name="roll_fallout" data-i18n="fallout-test-label"
|
||||
value="&{template:heart} {{title=^{fallout-label}}} {{name=@{character_name}}} {{fallout_against=[[@{total_stress}]]}} {{roll=[[1d12cs0cf0]] vs. [[@{total_stress}]]}}">Fallout</button>
|
||||
value="&{template:heart} {{title=^{fallout-label}}} {{name=@{character_name}}} {{fallout_against=[[@{total_stress}]]}} {{roll=[[1d12cs0cf0]] vs [[@{total_stress}]]}}">Fallout</button>
|
||||
|
||||
<div class="rollbutton grid-large">
|
||||
<select name="attr_roll_skill" class="skill-select">
|
||||
@@ -118,10 +118,12 @@
|
||||
<option value="2" data-i18n="dangerous">Dangerous</option>
|
||||
</select>
|
||||
<button type="roll" title="roll dice" name="roll_normal" data-i18n="roll-label"
|
||||
value="&{template:heart} {{title=@{roll_title}}} {{name=@{character_name}}} {{roll=@{roll_formula}}} {{details=@{roll_message}}}">Roll</button>
|
||||
value="&{template:heart} {{title=@{roll_title}}} {{name=@{character_name}}} {{roll=@{roll_formula}}} {{roll_details=@{roll_formula_single}}} {{details=@{roll_message}}} {{showresult=1}} @{roll_zerodice}">Roll</button>
|
||||
<input type="hidden" name="attr_roll_formula" value="" />
|
||||
<input type="hidden" name="attr_roll_formula_single" value="" />
|
||||
<input type="hidden" name="attr_roll_message" value="" />
|
||||
<input type="hidden" name="attr_roll_title" value="" />
|
||||
<input type="hidden" name="attr_roll_zerodice" value="" />
|
||||
<div class="small-text">
|
||||
<b><span data-i18n="standard">Standard</span>:</b>
|
||||
<span data-i18n="standard-pool-label">use highest result</span>
|
||||
@@ -440,9 +442,41 @@
|
||||
</div>
|
||||
<div class="name">{{name}}</div>
|
||||
<div class="roll">
|
||||
{{roll}}
|
||||
{{#fallout_against}}
|
||||
<span>—</span>
|
||||
<div class="main-roll">{{roll}}</div>
|
||||
<div class="roll-details">{{roll_details}}</div>
|
||||
</div>
|
||||
{{#showresult}}<div class="result">
|
||||
{{^zerodice}}
|
||||
{{#rollTotal() roll 1}}
|
||||
<span data-i18n="critical-failure-msg"></span>
|
||||
{{/rollTotal() roll 1}}
|
||||
{{#rollBetween() roll 2 5}}
|
||||
<span data-i18n="failure-msg"></span>
|
||||
{{/rollBetween() roll 2 5}}
|
||||
{{#rollBetween() roll 6 7}}
|
||||
<span data-i18n="success-at-a-cost-msg"></span>
|
||||
{{/rollBetween() roll 6 7}}
|
||||
{{#rollBetween() roll 8 9}}
|
||||
<span data-i18n="success-msg"></span>
|
||||
{{/rollBetween() roll 8 9}}
|
||||
{{#rollTotal() roll 10}}
|
||||
<span data-i18n="critical-success-msg"></span>
|
||||
{{/rollTotal() roll 10}}
|
||||
{{/zerodice}}
|
||||
{{#zerodice}}
|
||||
{{#rollTotal() roll 1}}
|
||||
<span data-i18n="critical-failure-msg"></span>
|
||||
{{/rollTotal() roll 1}}
|
||||
{{#rollBetween() roll 2 9}}
|
||||
<span data-i18n="failure-msg"></span>
|
||||
{{/rollBetween() roll 2 9}}
|
||||
{{#rollTotal() roll 10}}
|
||||
<span data-i18n="success-at-a-cost-msg"></span>
|
||||
{{/rollTotal() roll 10}}
|
||||
{{/zerodice}}
|
||||
</div>{{/showresult}}
|
||||
{{#details}}<div class="details">{{details}}</div>{{/details}}
|
||||
{{#fallout_against}}<div class="fallout">
|
||||
{{#rollGreater() roll fallout_against}}
|
||||
<span data-i18n="no-fallout"></span>.
|
||||
{{/rollGreater() roll fallout_against}}
|
||||
@@ -450,9 +484,7 @@
|
||||
{{#rollGreater() roll 6}}<span data-i18n="take-major-fallout"></span>.{{/rollGreater() roll 6}}
|
||||
{{#^rollGreater() roll 6}}<span data-i18n="take-minor-fallout"></span>.{{/^rollGreater() roll 6}}
|
||||
{{/^rollGreater() roll fallout_against}}
|
||||
{{/fallout_against}}
|
||||
</div>
|
||||
{{#details}}<div class="details">{{details}}</div>{{/details}}
|
||||
</div>{{/fallout_against}}
|
||||
|
||||
</rolltemplate>
|
||||
|
||||
@@ -482,6 +514,11 @@ const kDomains = [
|
||||
"warren",
|
||||
"wild",
|
||||
];
|
||||
const Difficulty = {
|
||||
Standard: 0,
|
||||
Risky: 1,
|
||||
Dangerous: 2,
|
||||
};
|
||||
|
||||
const kRollAffectingAttributes = [
|
||||
...kSkills.map((skill) => `skill_${skill}`),
|
||||
@@ -494,7 +531,7 @@ const kRollAffectingAttributes = [
|
||||
];
|
||||
|
||||
function getTranslation(key) {
|
||||
return getTranslationByKey(key) || "";
|
||||
return key ? (getTranslationByKey(key) || "") : "";
|
||||
}
|
||||
|
||||
// This is not very efficient, but it only runs at most once.
|
||||
@@ -583,27 +620,33 @@ function calculateTotalStress() {
|
||||
});
|
||||
}
|
||||
|
||||
function getDifficultyMessage(difficulty) {
|
||||
function getDifficultyMessage(difficulty, is_zero) {
|
||||
let difficulty_str = "";
|
||||
switch (difficulty) {
|
||||
case 0:
|
||||
return `**${getTranslation("standard")}:** ${getTranslation(
|
||||
"standard-pool-label"
|
||||
)}.`;
|
||||
case 1:
|
||||
return `**${getTranslation("risky")}:** ${getTranslation(
|
||||
"risky-pool-label"
|
||||
)}.`;
|
||||
case 2:
|
||||
return `**${getTranslation("dangerous")}:** ${getTranslation(
|
||||
"dangerous-pool-label"
|
||||
)}.`;
|
||||
default:
|
||||
return "Error retrieving difficulty. This should never happen.";
|
||||
case Difficulty.Standard:
|
||||
difficulty_str = getTranslation("standard");
|
||||
break;
|
||||
case Difficulty.Risky:
|
||||
difficulty_str = getTranslation("risky");
|
||||
break;
|
||||
case Difficulty.Dangerous:
|
||||
difficulty_str = getTranslation("dangerous");
|
||||
}
|
||||
return (
|
||||
`**${getTranslation("difficulty")}:** ${difficulty_str}.` +
|
||||
(is_zero ? ` **${getTranslation("zero-effective-dice")}**.` : "")
|
||||
);
|
||||
}
|
||||
|
||||
function computeFormula(number) {
|
||||
return [...Array(number)].map(() => "[[d10]]").join(", ");
|
||||
function computeFormula(num_dice, difficulty) {
|
||||
const rolls = [...Array(num_dice)].map(() => "[[d10]]").join(", ");
|
||||
return `[[{${rolls}}dh${difficulty}kh${difficulty + 1}]]`;
|
||||
}
|
||||
|
||||
function computeSingleDice(num_dice) {
|
||||
return num_dice <= 1
|
||||
? ""
|
||||
: [...Array(num_dice)].map((_, i) => `$[[${i}]]`).join("");
|
||||
}
|
||||
|
||||
function buildDicePool() {
|
||||
@@ -619,19 +662,24 @@ function buildDicePool() {
|
||||
parseInt(v["roll_mastery"], 10) +
|
||||
parseInt(v["roll_extra_dice"], 10);
|
||||
const is_zero = roll_dice - difficulty <= 0;
|
||||
const number_of_dice = is_zero ? 1 : roll_dice;
|
||||
|
||||
const roll_formula = computeFormula(is_zero ? 1 : roll_dice);
|
||||
const roll_message = is_zero
|
||||
? `**${getTranslation("zero-effective-dice")}:** ${
|
||||
getTranslation("zero-dice-label")
|
||||
}`
|
||||
: getDifficultyMessage(difficulty);
|
||||
const roll_formula = computeFormula(number_of_dice, difficulty);
|
||||
const roll_formula_single = computeSingleDice(number_of_dice);
|
||||
const roll_message = getDifficultyMessage(difficulty, is_zero);
|
||||
const roll_title =
|
||||
roll_skill && roll_domain
|
||||
? `${getTranslation(roll_skill)} + ${getTranslation(roll_domain)}`
|
||||
: `${getTranslation(roll_skill)}${getTranslation(roll_domain)}`;
|
||||
const roll_zerodice = is_zero ? "{{zerodice=1}}" : "";
|
||||
|
||||
setAttrs({ roll_formula, roll_message, roll_title });
|
||||
setAttrs({
|
||||
roll_formula,
|
||||
roll_formula_single,
|
||||
roll_zerodice,
|
||||
roll_message,
|
||||
roll_title,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
"clear-label": "Clear",
|
||||
"clearstress-label": "Clear Stress",
|
||||
"compel": "Compel",
|
||||
"critical-failure-msg": "<strong>Critical failure</strong> (take double stress)",
|
||||
"critical-label": "Critical",
|
||||
"critical-success-msg": "<strong>Critical success</strong> (increase outgoing stress die size)",
|
||||
"cursed": "Cursed",
|
||||
"dangerous": "Dangerous",
|
||||
"dangerous-pool-label": "drop 2 highest results, use third-highest result",
|
||||
@@ -19,12 +21,14 @@
|
||||
"description-label": "Domains/Tags",
|
||||
"desolate": "Desolate",
|
||||
"die-label": "Die",
|
||||
"difficulty": "Difficulty",
|
||||
"discern": "Discern",
|
||||
"domains-label": "Domains",
|
||||
"echo-label": "Echo",
|
||||
"endure": "Endure",
|
||||
"equipment-label": "Equipment",
|
||||
"evade": "Evade",
|
||||
"failure-msg": "<strong>Failure</strong> (take stress)",
|
||||
"fallout-label": "Fallout",
|
||||
"fallout-test-label": "Fallout Test",
|
||||
"fallout_name": "Fallout name",
|
||||
@@ -39,7 +43,7 @@
|
||||
"mind-label": "Mind",
|
||||
"minor-label": "Minor",
|
||||
"name-label": "Name",
|
||||
"no-fallout": "no fallout",
|
||||
"no-fallout": "No fallout",
|
||||
"none": "None",
|
||||
"notes-label": "Notes",
|
||||
"occult": "Occult",
|
||||
@@ -50,13 +54,15 @@
|
||||
"risky-pool-label": "drop highest result, use second-highest result",
|
||||
"roll-label": "Roll",
|
||||
"skills-label": "Skills",
|
||||
"success-at-a-cost-msg": "<strong>Success at a cost</strong> (take stress)",
|
||||
"success-msg": "<strong>Success</strong> (take no stress)",
|
||||
"sneak": "Sneak",
|
||||
"standard": "Standard",
|
||||
"standard-pool-label": "use highest result",
|
||||
"stress-label": "Stress",
|
||||
"supplies-label": "Supplies",
|
||||
"take-major-fallout": "take major fallout",
|
||||
"take-minor-fallout": "take minor fallout",
|
||||
"take-major-fallout": "Take major fallout",
|
||||
"take-minor-fallout": "Take minor fallout",
|
||||
"technology": "Technology",
|
||||
"total-label": "Total",
|
||||
"warren": "Warren",
|
||||
|
||||
Reference in New Issue
Block a user