-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13268 from coreyhickson/master
Torchbearer 2E: add new roll page to replace outdated roll modal
- Loading branch information
Showing
67 changed files
with
14,885 additions
and
14,542 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
const calculateDiceValues = [ | ||
// Also needs all the skills, abilities, and custom skills | ||
"rolling", | ||
"rolling_bl_select", | ||
"taxed_nature", | ||
"rolling_help", | ||
"rolling_aid", | ||
"rolling_gearetal", | ||
"rolling_trait", | ||
"rolling_trait_option", | ||
"rolling_trait_option", | ||
"rolling_persona", | ||
"rolling_channel_nature", | ||
"taxed_nature", | ||
"rolling_otherdice", | ||
"injured", | ||
"sick", | ||
"fresh" | ||
]; | ||
|
||
calculateDiceValues.forEach(v => { | ||
on("change:" + v, function () { | ||
console.log('calculateDiceValues', "change:" + v); | ||
let attrsToGet = [...calculateDiceValues, ...abilities, ...skills, ...customSkills]; | ||
|
||
getAttrs(attrsToGet, function (values) { | ||
setAttrs({ | ||
rolling_dice: calculateDice(values, values['rolling']), | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
function calculateDice(values, rolling) { | ||
const isBeginnersLuck = calculateBeginnersLuck(values, rolling); | ||
|
||
// Get the skill or ability | ||
let rollValue = parseInt(values[rolling]); | ||
|
||
if (rolling == 'nature') { | ||
rollValue = parseInt(values['taxed_nature']); | ||
} | ||
|
||
// Change it if we're doing beginners luck | ||
if (isBeginnersLuck) { | ||
let blSelected = values['rolling_bl_select']; | ||
rollValue = parseInt(values[blSelected]); | ||
|
||
if (blSelected == "nature") { | ||
rollValue = parseInt(values['taxed_nature']); | ||
} | ||
} | ||
|
||
// Add help, aid, supplies, gear | ||
rollValue += parseInt(values['rolling_help']); | ||
rollValue += parseInt(values['rolling_aid']); | ||
rollValue += parseInt(values['rolling_gearetal']); | ||
|
||
// Check to half for beginners luck | ||
if (isBeginnersLuck) { | ||
rollValue = Math.floor(rollValue / 2); | ||
} | ||
|
||
// Add traits, persona, channelled nature, conditions, etc. | ||
if (values['rolling_trait'] > 0) { | ||
if (values['rolling_trait_option'] == "forme") { | ||
rollValue += 1 | ||
} | ||
if (values['rolling_trait_option'] == "againstme") { | ||
rollValue -= 1 | ||
} | ||
} | ||
|
||
rollValue += parseInt(values['rolling_persona']); | ||
|
||
if (values['rolling_channel_nature'] == "on") { | ||
rollValue += parseInt(values['taxed_nature']); | ||
} | ||
|
||
rollValue += parseInt(values['rolling_otherdice']); | ||
|
||
if (values['injured'] > 0) { | ||
rollValue -= 1; | ||
} | ||
|
||
if (values['sick'] > 0) { | ||
rollValue -= 1; | ||
} | ||
|
||
if (values['fresh'] > 0) { | ||
rollValue += 1; | ||
} | ||
|
||
return rollValue; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const wiseAttrs = []; | ||
|
||
[1, 2, 3, 4].forEach(function (value) { | ||
wiseAttrs.push("wise" + value + "_pass"); | ||
wiseAttrs.push("wise" + value + "_fail"); | ||
wiseAttrs.push("wise" + value + "_fate"); | ||
wiseAttrs.push("wise" + value + "_persona"); | ||
}); | ||
|
||
wiseAttrs.forEach(function (wises) { | ||
on("change:" + wises, function (eventInfo) { | ||
getAttrs(wiseAttrs, function (values) { | ||
for (let i = 1; i <= 4; i++) { | ||
if (values["wise" + i + "_pass"] == 1 | ||
&& values["wise" + i + "_fail"] == 1 | ||
&& values["wise" + i + "_fate"] == 1 | ||
&& values["wise" + i + "_persona"] == 1) { | ||
setAttrs({ rolling_gaining_wisdom: true }); | ||
return; | ||
} | ||
} | ||
|
||
setAttrs({ rolling_gaining_wisdom: false }); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
on("sheet:opened", function (eventinfo) { | ||
console.log('initialize'); | ||
initialize(); | ||
}); | ||
|
||
function initializeTabs(values) { | ||
if (!(values['tab'] in ["anatomy", "kit", "magic", "relationships", "levels", "roll"])) { | ||
setAttrs({tab: "anatomy"}); | ||
} | ||
if (!(values['edit'] in ["playing", "editing"])) { | ||
setAttrs({edit: "playing"}); | ||
} | ||
} | ||
|
||
function initialize() { | ||
const attrsToGet = [ | ||
"trait1_name", | ||
"trait2_name", | ||
"trait3_name", | ||
"trait4_name", | ||
"wise1_name", | ||
"wise2_name", | ||
"wise3_name", | ||
"wise4_name", | ||
"rolling_trait", | ||
"rolling_du_wise", | ||
"tab", | ||
"edit" | ||
]; | ||
|
||
getAttrs(attrsToGet, function (values) { | ||
populateTraitOptions(values); | ||
populateWiseOptions(values); | ||
initializeTabs(values); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const traitUses = ["trait1_uses", "trait2_uses", "trait3_uses", "trait4_uses"]; | ||
const traitChecks = ["trait1_checks", "trait2_checks", "trait3_checks", "trait4_checks"]; | ||
|
||
const abilityPasses = abilities.map(a => a + "_pass"); | ||
const abilityFails = abilities.map(a => a + "_fail"); | ||
|
||
const skillPasses = skills.map(s => s + "_pass"); | ||
const skillFails = skills.map(s => s + "_fail"); | ||
const skillBl = skills.map(s => s + "_bl"); | ||
|
||
const customSkillPasses = []; | ||
const customSkillFails = []; | ||
const customSkillBl = []; | ||
|
||
for (let i = 1; i <= 5; i++) { | ||
customSkillPasses.push("skill" + i + "_pass"); | ||
customSkillFails.push("skill" + i + "_fail"); | ||
customSkillBl.push("skill" + i + "_bl"); | ||
} | ||
|
||
const allListeners = [].concat(...traitUses, ...traitChecks, ...abilityPasses, ...abilityFails, ...skillPasses, ...skillFails, ...skillBl, ...customSkillPasses, ...customSkillFails, ...customSkillBl) | ||
|
||
allListeners.forEach(function (value) { | ||
on(`clicked:${value}`, function (event) { | ||
console.log(`clicked:${value}`); | ||
setAttrs({ | ||
[value]: event.htmlAttributes.value | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
function resetRoll() { | ||
setAttrs({ | ||
rolling_type: "independent", | ||
rolling_obstacle: 1, | ||
rolling_disposition_ability: "will", | ||
rolling_grind: 1, | ||
rolling_bl_select: "health", | ||
rolling_bl_nature_within: "within", | ||
rolling_trait: 0, | ||
rolling_trait_option: "forme", | ||
rolling_persona: 0, | ||
rolling_channel_nature: 0, | ||
rolling_nature_within: "within", | ||
rolling_help: 0, | ||
rolling_synergy: 0, | ||
rolling_aid: 0, | ||
rolling_gearetal: 0, | ||
rolling_otherdice: 0, | ||
rolling_othersuccesses: 0, | ||
rolling_hnt: 0, | ||
rolling_exhausted: 0, | ||
rolling_deeper_understanding: 0, | ||
rolling_du_wise: 0, | ||
rolling_luck: 0, | ||
rolling_luck_dice: 0, | ||
rolling_of_course: 0, | ||
rolling_oc_wise: 0, | ||
rolling_failed_dice: 0, | ||
rolling_beginners_luck_roll: 0, | ||
}) | ||
}; |
Oops, something went wrong.