Skip to content

Commit

Permalink
Updates to Level up process
Browse files Browse the repository at this point in the history
  • Loading branch information
PrototypeESBU committed Sep 8, 2024
1 parent d9221b8 commit 7d73e0e
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 36 deletions.
4 changes: 2 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* [#693] Changes made to active effects on actors will now take effect immediately
* [#849] The UI and functionality of the Shadowdarklings importer has been improved
* [#853] CSS Styling for Journals
* [#854] Added SoloDark journals
* [#854] Added SoloDark journals, roll tables and a new oracle app
* [#856] Beauty pass over Quickstart journals
* [#874] Added class descriptions to the character generator and class sheet remain open during level up

## Bugfixes
* [#852] Fixed a bug where ranged attacks were not showing correct damage
Expand All @@ -22,7 +23,6 @@
- Welcome message now includes a link to the video tutorial: https://youtu.be/hoBxiK71DBQ

* [#872] Updated Bard abilities to the definitions in the Bard and Ranger v1.3 PDF
* [#875] Fixes to links in Quickstart Adventure and make use of new Journal

**NOTE:** This release marks the end of support for Foundry VTT v11.

Expand Down
40 changes: 29 additions & 11 deletions system/src/apps/CharacterGeneratorSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export default class CharacterGeneratorSD extends FormApplication {
sp: 0,
cp: 0,
},
showLevelUp: false,
},
};

Expand Down Expand Up @@ -771,7 +772,12 @@ export default class CharacterGeneratorSD extends FormApplication {
const ownership = newActor.ownership;
ownership[userId] = CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER;

await newActor.update({ownership});
await newActor.update({
ownership,
system: {
showLevelUp: !level0,
},
});

const user = game.users.get(userId);

Expand All @@ -787,12 +793,8 @@ export default class CharacterGeneratorSD extends FormApplication {
});
}
else {
if (level0) {
newActor.sheet.render(true);
}
else {
new shadowdark.apps.LevelUpSD(newActor.id).render(true);
}

newActor.sheet.render(true);

return ui.notifications.info(
game.i18n.localize("SHADOWDARK.apps.character-generator.success"),
Expand All @@ -803,6 +805,12 @@ export default class CharacterGeneratorSD extends FormApplication {

async _createCharacter() {

// sets initial totals on all stats
for (const key of CONFIG.SHADOWDARK.ABILITY_KEYS) {
this.formData.actor.system.abilities[key].total =
this.formData.actor.system.abilities[key].base;
}

const allItems = [];

// load all talents and promp player to choose effects
Expand All @@ -813,6 +821,7 @@ export default class CharacterGeneratorSD extends FormApplication {
...this.formData.classTalents.selection,
];

// load talents with selection of options
for (const talentItem of allTalents) {
allItems.push(await shadowdark.utils.createItemWithEffect(talentItem));
}
Expand Down Expand Up @@ -892,17 +901,26 @@ export default class CharacterGeneratorSD extends FormApplication {
class: this.formData.actor.system.class,
languages: this.formData.actor.system.languages,
coins: {gp: this.formData.actor.system.coins.gp},
showLevelUp: true,
} });

// add class talents
const allItems = [

// Add class talents and promp player to choose effects
const allTalents = [
...this.formData.classTalents.fixed,
...this.formData.classTalents.selection,
];

// load talents with selection of options
const allItems = [];
for (const talentItem of allTalents) {
allItems.push(await shadowdark.utils.createItemWithEffect(talentItem));
}

await actorRef.createEmbeddedDocuments("Item", allItems);

// go to level up screen
new shadowdark.apps.LevelUpSD(this.actorUid).render(true);
// open actor sheet
actorRef.sheet.render(true);
this.close();
}
}
14 changes: 1 addition & 13 deletions system/src/apps/LevelUpSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class LevelUpSD extends FormApplication {
static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["shadowdark", "level-up"],
width: 275,
width: 300,
resizable: false,
closeOnSubmit: true,
submitOnChange: false,
Expand Down Expand Up @@ -347,18 +347,6 @@ export default class LevelUpSD extends FormApplication {
// add talents and spells to actor
await this.data.actor.createEmbeddedDocuments("Item", allItems);

// show actor sheet
this.close();
}

/** @override */
async close() {
try {
this.data.actor.sheet.render(true);
}
catch(err) {
console.log("Counld't open Actor");
}
super.close();
}
}
12 changes: 11 additions & 1 deletion system/src/sheets/PlayerSheetSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ export default class PlayerSheetSD extends ActorSheetSD {
return data;
}

/** @override */
async render(options, _options) {
await super.render(options, _options);

if (this.actor.system.showLevelUp) {
this.actor.update({"system.showLevelUp": false});
new shadowdark.apps.LevelUpSD(this.actor.id).render(true);
}
}

/** @override */
async getData(options) {
const context = await super.getData(options);
Expand Down Expand Up @@ -587,11 +597,11 @@ export default class PlayerSheetSD extends ActorSheetSD {
let actorClass = await this.actor.getClass();
if (this.actor.system.level.value === 0 && actorClass.name.includes("Level 0")) {
new shadowdark.apps.CharacterGeneratorSD(this.actor._id).render(true);
this.close();
}
else {
new shadowdark.apps.LevelUpSD(this.actor._id).render(true);
}
this.close();
}

async _onOpenGemBag(event) {
Expand Down
9 changes: 1 addition & 8 deletions system/src/socket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ export default function listenOnSocket() {
if (event.type === "openNewCharacter") {
if (event.payload.userId === game.userId) {
const actor = game.actors.get(event.payload.actorId);
actor.sheet.render(true);

if (actor) {
if (event.payload.level0) {
actor.sheet.render(true);
}
else {
new shadowdark.apps.LevelUpSD(event.payload.actorId).render(true);
}
}
return ui.notifications.info(
game.i18n.localize("SHADOWDARK.apps.character-generator.success"),
{permanent: false}
Expand Down
2 changes: 1 addition & 1 deletion system/templates/apps/level-up.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<form autocomplete="off">
<div class="level-up-grid">
<div>
<div class="centered">
<h2 class="centered">{{actor.name}}</h2>
<h3>{{localize "SHADOWDARK.apps.level-up.leveling_to"}} {{targetLevel}}</h3>
</div>
Expand Down

0 comments on commit 7d73e0e

Please sign in to comment.