Skip to content

Commit

Permalink
Merge pull request #13268 from coreyhickson/master
Browse files Browse the repository at this point in the history
Torchbearer 2E: add new roll page to replace outdated roll modal
  • Loading branch information
kfroll20 authored Sep 3, 2024
2 parents aca44e3 + cb51641 commit 59915f6
Show file tree
Hide file tree
Showing 67 changed files with 14,885 additions and 14,542 deletions.
22 changes: 15 additions & 7 deletions Torchbearer 2E/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@ Use `npm install` to download dependancies and `npm install pug-cli -g` to downl

Start compiling for SCSS & PUG with `npm start` from the Torchbearer 2E directory.

## Feature Log
## Prioritized Slices

- Make the sheet responsive
- Add wises help text
- Improve calculate dice firing too much
- Roll template details
- Opponent successes
- Show successes on roll page
- Might and precedence for rolling

## Known Bugs
## Nice to Haves

- Spacing on invocations is funky
- Background isn't responsive
- New skills start with full BL track
- Dynamic beginner's luck menu
- Spend artha button
- Upgrade skills and abilities option
- Hidable relics & spells
- Dynamic trait dropdown
- Auto add wise advancement
- Dark theme
- i18n
95 changes: 95 additions & 0 deletions Torchbearer 2E/src/js/calculate_dice.js
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;
};
26 changes: 26 additions & 0 deletions Torchbearer 2E/src/js/gaining_wisdom.js
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 });
});
});
});
36 changes: 36 additions & 0 deletions Torchbearer 2E/src/js/init.js
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);
});
}
30 changes: 30 additions & 0 deletions Torchbearer 2E/src/js/pips.js
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
});
});
});
31 changes: 31 additions & 0 deletions Torchbearer 2E/src/js/reset_roll.js
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,
})
};
Loading

0 comments on commit 59915f6

Please sign in to comment.