Skip to content

Commit

Permalink
Merge pull request #942 from Muttley/881-support-rolling-on-a-charact…
Browse files Browse the repository at this point in the history
…ers-patrons-boon-table-if-necessary-in-the-level-up-app

closes #881
  • Loading branch information
Muttley authored Nov 16, 2024
2 parents 2b95f7c + edbbbc1 commit 5e76af6
Show file tree
Hide file tree
Showing 14 changed files with 263 additions and 152 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* [#847] Add support for Warlock class Boon which gives the ability to learn a Wizard spell
* [#879] Add new Patron item class
* [#880] Create a new Patron Boon type for Talents
* [#881] Support rolling on a character's Patron's Boon table if necessary in the Level Up app
* [#901] Added Russian as a partially complete system language.
* [#908] Add rollable dice to Cure Wounds spell that includes the necessary calculations *(Many thanks to **nschoenwald** for contributing to this issue)*
* [#910] Implement prompt for DC Checks
Expand Down
1 change: 0 additions & 1 deletion data/packs/talents.db/patron__4pcEgD8oLA5euovK.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"_id": "4pcEgD8oLA5euovK",
"_key": "!items!4pcEgD8oLA5euovK",
"effects": [
"P4y8Bovr14XbN0PO"
],
"folder": "8t1Gmpgn1Q6HXJAz",
"img": "icons/magic/unholy/silhouette-light-fire-blue.webp",
Expand Down
33 changes: 0 additions & 33 deletions data/packs/talents.db/patron__P4y8Bovr14XbN0PO.json

This file was deleted.

4 changes: 4 additions & 0 deletions i18n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,15 @@ SHADOWDARK.apps.item-importer.instruction2d: Features
SHADOWDARK.apps.item-importer.instruction3: 3. Click Import Item.
SHADOWDARK.apps.item-importer.title: Import Item
SHADOWDARK.apps.level-up.dragdrop: Drag and Drop Here
SHADOWDARK.apps.level-up.errors.missing_boon_table: Unable to roll Patron Boon as the configured RollTable could not be loaded
SHADOWDARK.apps.level-up.hit_points: Hit Points
SHADOWDARK.apps.level-up.level_up: Level Up!
SHADOWDARK.apps.level-up.leveling_to: Leveling up to level
SHADOWDARK.apps.level-up.missing_selections: Missing Selections
SHADOWDARK.apps.level-up.notalent: No talents gained at this level
SHADOWDARK.apps.level-up.or_boons: or Boons
SHADOWDARK.apps.level-up.prompt: Not all required selections have been made. Continue with level up anyways?
SHADOWDARK.apps.level-up.roll_boon: Roll Boon
SHADOWDARK.apps.level-up.roll_talent: Roll Talent
SHADOWDARK.apps.level-up.title: Leveling Up
SHADOWDARK.apps.monster-importer.import_button: Import Monster
Expand Down Expand Up @@ -276,6 +279,7 @@ SHADOWDARK.dialog.general.no: "No"
SHADOWDARK.dialog.general.select: Select
SHADOWDARK.dialog.general.yes: "Yes"
SHADOWDARK.dialog.gm: Gamemaster
SHADOWDARK.dialog.hp_re_roll.title: HP Re-roll
SHADOWDARK.dialog.hp_roll.per_level: Roll HP for level {level}
SHADOWDARK.dialog.hp_roll.previous_hp: "HP before rolling: {hp}"
SHADOWDARK.dialog.hp_roll.roll_level_1: Rolled {hp} hp for level 1 (incl. con mod)
Expand Down
7 changes: 0 additions & 7 deletions scss/apps/_level-up.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
line-height: 1.7;
}

.level-up-grid {
display: grid;
gap: 8px;
grid-template-columns: 1fr;
grid-template-rows: auto 75px 105px auto;
}

.hit-points {
text-align: center;
font-size: 24px;
Expand Down
71 changes: 67 additions & 4 deletions system/src/apps/LevelUpSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ export default class LevelUpSD extends FormApplication {
hp: 0,
hpEdit: false,
talent: false,
boon: false,
};
this.data.actor = game.actors.get(uid);
this.data.talents = [];
this.data.spells = {};
this.data.talentsRolled = false;
this.data.talentsChosen = false;

for (let i = 1; i <= 5; i++) {
this.data.spells[i] = {
Expand All @@ -26,6 +29,7 @@ export default class LevelUpSD extends FormApplication {
static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["shadowdark", "level-up"],
height: "auto",
width: 300,
resizable: false,
closeOnSubmit: true,
Expand Down Expand Up @@ -57,9 +61,14 @@ export default class LevelUpSD extends FormApplication {
event => this._onReRollHP(event)
);

html.find("[data-action='view-boon-table']").click(
event => this._viewBoonTable(event)
);

html.find("[data-action='view-talent-table']").click(
event => this._viewTalentTable(event)
);

html.find("[data-action='open-spellbook']").click(
event => this._openSpellBook(event)
);
Expand All @@ -72,6 +81,10 @@ export default class LevelUpSD extends FormApplication {
event => this._onDeleteSpell(event)
);

html.find("[data-action='roll-boon']").click(
event => this._onRollBoon(event)
);

html.find("[data-action='roll-talent']").click(
event => this._onRollTalent(event)
);
Expand All @@ -93,10 +106,27 @@ export default class LevelUpSD extends FormApplication {
this.data.class = await fromUuid(this.data.actor.system.class);
this.data.talentTable = await fromUuid(this.data.class.system.classTalentTable);
this.data.currentLevel = this.data.actor.system.level.value;
this.data.targetLevel = this.data.currentLevel +1;
this.data.targetLevel = this.data.currentLevel + 1;
this.data.talentGained = (this.data.targetLevel % 2 !== 0);
this.data.totalSpellsToChoose = 0;

this.data.patron = await fromUuid(this.data.actor.system.patron);

this.data.boonTable = this.data.patron
? await fromUuid(this.data.patron.system.boonTable)
: undefined;

this.data.startingBoons = 0;
const classData = this.data.class.system;
this.data.canRollBoons = classData.patron.required;

const needsStartingBoons = classData.patron.required
&& classData.patron.startingBoons > 0;

if (this.data.targetLevel === 1 && needsStartingBoons) {
this.data.startingBoons = classData.patron.startingBoons;
}

if (await this.data.actor.isSpellCaster()) {
this.data.spellcastingClass =
this.data.class.system.spellcasting.class === ""
Expand Down Expand Up @@ -129,6 +159,9 @@ export default class LevelUpSD extends FormApplication {

}
}
this.data.talentsRolled = this.data.rolls.talent || this.data.rolls.boon;
this.data.talentsChosen = this.data.talents.length > 0;

return this.data;
}

Expand All @@ -152,6 +185,10 @@ export default class LevelUpSD extends FormApplication {
}
}

async _viewBoonTable() {
this.data.boonTable.sheet.render(true);
}

async _viewTalentTable() {
this.data.talentTable.sheet.render(true);
}
Expand All @@ -160,13 +197,17 @@ export default class LevelUpSD extends FormApplication {
this.data.actor.openSpellBook();
}

async _onRollHP() {
async _onRollHP({isReroll = false}) {
const data = {
rollType: "hp",
actor: this.data.actor,
};
let options = {};
options.title = game.i18n.localize("SHADOWDARK.dialog.hp_roll.title");

options.title = isReroll
? game.i18n.localize("SHADOWDARK.dialog.hp_re_roll.title")
: game.i18n.localize("SHADOWDARK.dialog.hp_roll.title");

options.flavor = options.title;
options.chatCardTemplate = "systems/shadowdark/templates/chat/roll-hp.hbs";
options.fastForward = true;
Expand All @@ -186,12 +227,30 @@ export default class LevelUpSD extends FormApplication {
Dialog.confirm({
title: "Re-Roll HP",
content: "Are you sure you want to re-roll hit points?",
yes: () => this._onRollHP(),
yes: () => this._onRollHP({isReroll: true}),
no: () => null,
defaultYes: false,
});
}

async _onRollBoon() {
if (!this.data.boonTable) {
return ui.notifications.warn(
game.i18n.localize("SHADOWDARK.apps.level-up.errors.missing_boon_table")
);
}

await this.data.boonTable.draw();
ui.sidebar.activateTab("chat");

if (this.data.targetLevel > 1) {
this.data.rolls.talent = true;
}
this.data.rolls.boon = true;

this.render();
}

async _onRollTalent() {
await this.data.talentTable.draw();
ui.sidebar.activateTab("chat");
Expand All @@ -208,7 +267,11 @@ export default class LevelUpSD extends FormApplication {
}
}

if (this.data.targetLevel > 1) {
this.data.rolls.boon = true;
}
this.data.rolls.talent = true;

this.render();
}

Expand Down
9 changes: 8 additions & 1 deletion system/src/documents/ActorSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,14 @@ export default class ActorSD extends Actor {
const spellcasterClasses =
await shadowdark.compendiums.spellcastingBaseClasses();

for (const bonusClass of this.system.bonuses.spellcastingClasses ?? []) {
// De-duplicate any bonus classes the Actor has
const bonusClasses = [
...new Set(
this.system.bonuses.spellcastingClasses ?? []
),
];

for (const bonusClass of bonusClasses) {
playerSpellClasses.push(
spellcasterClasses.find(c => c.name.slugify() === bonusClass)
);
Expand Down
2 changes: 1 addition & 1 deletion system/src/sheets/PlayerSheetSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export default class PlayerSheetSD extends ActorSheetSD {
);

context.characterClass = await this.actor.getClass();
context.classHasPatron = context.characterClass?.system?.patron?.required;
context.classHasPatron = context.characterClass?.system?.patron?.required ?? false;
context.classTitle = await this.actor.getTitle();

context.characterPatron = await this.actor.getPatron();
Expand Down
3 changes: 3 additions & 0 deletions system/src/templates.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ export default function() {
"systems/shadowdark/templates/apps/character-generator/name.hbs",
"systems/shadowdark/templates/apps/character-generator/stats.hbs",
"systems/shadowdark/templates/apps/character-generator/type.hbs",
"systems/shadowdark/templates/apps/level-up/hp.hbs",
"systems/shadowdark/templates/apps/level-up/spells.hbs",
"systems/shadowdark/templates/apps/level-up/talents.hbs",
"systems/shadowdark/templates/items/_partials/choice-selector.hbs",
"systems/shadowdark/templates/items/_partials/cost.hbs",
"systems/shadowdark/templates/items/_partials/description-tab.hbs",
Expand Down
2 changes: 1 addition & 1 deletion system/templates/actors/player/details.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{{> actors/player/details/patron }}
</div>
{{else}}
<div class="background-grid-b">
<div class="grid-2-columns">
{{> actors/player/details/alignment }}
{{> actors/player/details/deity }}
</div>
Expand Down
Loading

0 comments on commit 5e76af6

Please sign in to comment.