Skip to content

Commit

Permalink
closes #881
Browse files Browse the repository at this point in the history
  • Loading branch information
Muttley committed Nov 12, 2024
1 parent 1cce20c commit 8a4346e
Show file tree
Hide file tree
Showing 10 changed files with 256 additions and 111 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)*
* [#920] Show tooltips on weapon and armor properties when showing expanded inline view in inventory
Expand Down
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 @@ -267,6 +270,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
65 changes: 61 additions & 4 deletions system/src/apps/LevelUpSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,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 +77,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 +102,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 +155,7 @@ export default class LevelUpSD extends FormApplication {

}
}

return this.data;
}

Expand All @@ -152,6 +179,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 +191,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 +221,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 +261,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 @@ -881,7 +881,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
5 changes: 4 additions & 1 deletion system/src/templates.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,18 @@ export default function() {
"systems/shadowdark/templates/apps/character-generator/details/languages/language-choice.hbs",
"systems/shadowdark/templates/apps/character-generator/details/languages/view.hbs",
"systems/shadowdark/templates/apps/character-generator/details/patron.hbs",
"systems/shadowdark/templates/apps/character-generator/details/patron/view.hbs",
"systems/shadowdark/templates/apps/character-generator/details/patron/edit.hbs",
"systems/shadowdark/templates/apps/character-generator/details/patron/view.hbs",
"systems/shadowdark/templates/apps/character-generator/details/weapons.hbs",
"systems/shadowdark/templates/apps/character-generator/gear.hbs",
"systems/shadowdark/templates/apps/character-generator/gold.hbs",
"systems/shadowdark/templates/apps/character-generator/hit-points.hbs",
"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
124 changes: 20 additions & 104 deletions system/templates/apps/level-up.hbs
Original file line number Diff line number Diff line change
@@ -1,109 +1,25 @@
<form autocomplete="off">
<div class="level-up-grid">
<div class="centered">
<h2 class="centered">{{actor.name}}</h2>
<h3>{{localize "SHADOWDARK.apps.level-up.leveling_to"}} {{targetLevel}}</h3>
</div>

{{!-- Hit Points --}}
<div class="SD-box">
<div class="header">
<label>{{localize "SHADOWDARK.apps.level-up.hit_points"}}</label>
<span>{{class.system.hitPoints}}
{{#if rolls.hp}}
<a class="fas fa-dice" data-action="re-roll-hp"></a>
{{/if}}
</span>
</div>
<div class="content hit-points">
{{#if rolls.hp}}
{{rolls.hp}}
{{#ifEq targetLevel 1}}
<span style="font-size:0.7em">({{numberFormat actor.system.abilities.con.mod decimals=0 sign=true}})</span>
{{/ifEq}}
{{/if}}
{{#unless rolls.hp}}
<button type="button" data-action="roll-hp">{{localize "SHADOWDARK.sheet.general.roll_hp"}}</button>
{{/unless}}
<div class="level-up-grid">
<div class="centered">
<h2 class="centered">
{{actor.name}}
</h2>
<h3>
{{localize "SHADOWDARK.apps.level-up.leveling_to"}}
{{targetLevel}}
</h3>
</div>
</div>

{{!-- Talents --}}
<div class="SD-box">
<div class="header">
<label>{{localize "SHADOWDARK.class.talents.label"}}</label>
<span><a class="fas fa-table-list" data-action="view-talent-table"></a></span>
</div>
<div class="content talents">
{{#unless talentGained}}
{{localize "SHADOWDARK.apps.level-up.notalent"}}
{{/unless}}
{{#if talentGained}}
{{#unless rolls.talent}}
<button type="button" data-action="roll-talent">{{localize "SHADOWDARK.apps.level-up.roll_talent"}}</button>
{{/unless}}
{{#if rolls.talent}}
<fieldset class="items">
{{#unless talents}}<div>{{localize "SHADOWDARK.apps.level-up.dragdrop"}}</div>{{/unless}}
{{#each talents}}
<div style="white-space: nowrap;">
<a class="remove-item fas fa-delete-right" data-action="delete-talent" data-index="{{@index}}"></a>
<a
class="content-link"
data-link
data-tooltip="{{this.name}}"
data-uuid="{{this.uuid}}"
>
{{this.name}}
</a>
</div>
{{/each}}
</fieldset>
{{/if}}
{{/if}}
</div>
</div>
{{> apps/level-up/hp}}
{{> apps/level-up/talents}}
{{> apps/level-up/spells}}

{{!-- Spells --}}
{{#ifCond totalSpellsToChoose ">" 0}}
<div class="SD-box">
<div class="header">
<label>{{localize "SHADOWDARK.sheet.player.spells"}}</label>
<span><a class="fas fa-book" data-action="open-spellbook"></a></span>
</div>
<div class="content spells">
{{#each spells}}
{{#if this.max}}
<div class="flexrow">
<h3>{{this.name}}</h3>
<div class="flex3">
{{#each (addEmptySlots this.objects this.max)}}
<fieldset class="items">
{{#if this}}
<div style="white-space: nowrap;">
<a class="remove-item fas fa-delete-right" data-action="delete-spell" data-tier="{{@../key}}" data-index="{{@index}}"></a>
<a
class="content-link"
data-link
data-tooltip="{{this.name}}"
data-uuid="{{this.uuid}}"
>
{{this.name}}
</a>
</div>
{{/if}}
{{#unless this}}
<div>{{localize "SHADOWDARK.apps.level-up.dragdrop"}}</div>
{{/unless}}
</fieldset>
{{/each}}
</div>
</div>
{{/if}}
{{/each}}
</div>
</div>
{{/ifCond}}
<button class="level-up-button" type="button" data-action="finalize-level-up">{{localize "SHADOWDARK.apps.level-up.level_up"}}</button>
</div>
<button
class="level-up-button"
data-action="finalize-level-up"
type="button"
>
{{localize "SHADOWDARK.apps.level-up.level_up"}}
</button>
</div>
</form>
32 changes: 32 additions & 0 deletions system/templates/apps/level-up/hp.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<div class="SD-box">
<div class="header">
<label>
{{localize "SHADOWDARK.apps.level-up.hit_points"}}
</label>
<span>
{{class.system.hitPoints}}
{{#if rolls.hp}}
<a class="fas fa-dice" data-action="re-roll-hp"></a>
{{/if}}
</span>
</div>

<div class="content hit-points">
{{#if rolls.hp}}
{{rolls.hp}}
{{#ifEq targetLevel 1}}
<span style="font-size:0.7em">
({{numberFormat actor.system.abilities.con.mod
decimals=0
sign=true
}})
</span>
{{/ifEq}}
{{/if}}
{{#unless rolls.hp}}
<button type="button" data-action="roll-hp">
{{localize "SHADOWDARK.sheet.general.roll_hp"}}
</button>
{{/unless}}
</div>
</div>
Loading

0 comments on commit 8a4346e

Please sign in to comment.