Skip to content

Commit

Permalink
Merge pull request #790 from Muttley/release/2.2.0
Browse files Browse the repository at this point in the history
Release/2.2.0
  • Loading branch information
Muttley authored May 13, 2024
2 parents 35bcae5 + e634af5 commit 9a6ee1a
Show file tree
Hide file tree
Showing 26 changed files with 219 additions and 223 deletions.
16 changes: 16 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
# v2.2.0

## Enhancements
* [#763] Make attributes.hp primaryTokenAttribute in system.json
* [#765] Implement generic loading dialog that can be used whenever potentially slow compendium searching occurs
* [#767] Load times when accessing certain items and menus significantly improved when hosting on Forge VTTs

## Bugfixes
* [#780] A level up screen being shown directly after creating level 0 characters.
* [#761] Advantage on Magic Missile talent missing from Wizard Class item
* [#768] Level 1 characters generating with 1 hp, despite HP roll
* [#776] NPC spell DC not calculating when converting from PC spell
* [#758] Unable to drag light spell items onto player sheets.

## Chores
* [#774] Merged Finnish language updates from Crowdin
* [#762] Ensure the Shadowdark system works without issues in Foundry V12 Development Releases
* [#784] The {{select}} handlebars helper is deprecated *(Foundry V12 compatibility)*
* [#785] The async option for Roll#evaluate has been removed *(Foundry V12 compatibility)*
* [#786] globalThis.mergeObject which must now be accessed via foundry.utils.mergeObject *(Foundry V12 compatibility)*
* [#787] Global AudioHelper instance is deprecated *(Foundry V12 compatibility)*
* [#788] CONST.CHAT_MESSAGE_TYPES is deprecated in favor of CONST.CHAT_MESSAGE_STYLES *(Foundry V12 compatibility)*
* [#789] ActiveEffect#icon has been migrated to ActiveEffect#img *(Foundry V12 compatibility)*

---

Expand Down
38 changes: 19 additions & 19 deletions system/src/apps/CharacterGeneratorSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default class CharacterGeneratorSD extends FormApplication {

/** @inheritdoc */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["character-generator"],
width: 836,
resizable: false,
Expand Down Expand Up @@ -182,7 +182,7 @@ export default class CharacterGeneratorSD extends FormApplication {
expandedData.level0 = (data.level0 === "true");

// merge incoming data into the main formData object
this.formData = mergeObject(this.formData, expandedData);
this.formData = foundry.utils.mergeObject(this.formData, expandedData);

// if stats were changed, calculate new modifiers
if (event.target.id === "stat") {
Expand Down Expand Up @@ -298,7 +298,7 @@ export default class CharacterGeneratorSD extends FormApplication {
diceSound() {
const sounds = [CONFIG.sounds.dice];
const src = sounds[0];
AudioHelper.play({src});
game.audio.play(src);
}

async _randomizeHandler(event) {
Expand Down Expand Up @@ -335,7 +335,7 @@ export default class CharacterGeneratorSD extends FormApplication {

// randomize alignment
if (eventStr === "randomize-alignment" || eventStr === "randomize-all") {
switch (this._roll("d6")) {
switch (await this._roll("d6")) {
case 1:
case 2:
case 3:
Expand All @@ -360,8 +360,8 @@ export default class CharacterGeneratorSD extends FormApplication {

// randomize stats
if (eventStr === "randomize-stats" || eventStr === "randomize-all") {
CONFIG.SHADOWDARK.ABILITY_KEYS.forEach(x => {
this.formData.actor.system.abilities[x].base = this._roll("3d6");
CONFIG.SHADOWDARK.ABILITY_KEYS.forEach(async x => {
this.formData.actor.system.abilities[x].base = await this._roll("3d6");
});
this._calculateModifiers();
}
Expand All @@ -373,13 +373,13 @@ export default class CharacterGeneratorSD extends FormApplication {

// Roll starting gold
if (eventStr === "randomize-gold" || eventStr === "randomize-all") {
let startingGold = this._roll("2d6")*5;
let startingGold = await this._roll("2d6")*5;
this.formData.actor.system.coins.gp = startingGold;
}

// Roll starting gear
if (eventStr === "randomize-gear" || eventStr === "randomize-all") {
this._randomizeGear();
await this._randomizeGear();
}

this.diceSound();
Expand All @@ -394,7 +394,7 @@ export default class CharacterGeneratorSD extends FormApplication {
*/
async _loadClass(UuID, randomize) {
// find the class object
let classObj = this._getClassObject(UuID);
let classObj = await this._getClassObject(UuID);
let talentData = [];
// grab fixed talents from class item
if (classObj.system.talents) {
Expand Down Expand Up @@ -471,9 +471,9 @@ export default class CharacterGeneratorSD extends FormApplication {

}

async _loadAncestry(UuID, randomize) {
async _loadAncestry(uuid, randomize) {
// grab static talents from ancestry item
let ancestryObj = this.formData.ancestries.find(x => x.uuid === UuID);
let ancestryObj = await fromUuid(uuid);

this.formData.ancestryTalents.selection = [];
this.formData.ancestryTalents.fixed = [];
Expand Down Expand Up @@ -637,16 +637,16 @@ export default class CharacterGeneratorSD extends FormApplication {
this.render();
}

_getClassObject(UuID) {
async _getClassObject(uuid) {
// find the class object from uuid including looking at level0
let classObj = {};
if (UuID === this.formData.level0Class.uuid) {
if (uuid === this.formData.level0Class.uuid) {
classObj = this.formData.level0Class;
}
else {
classObj = this.formData.classes.find(x => x.uuid === UuID);
classObj = await fromUuid(uuid);
}
return classObj;
return classObj ?? {};
}

_setRandomLanguage(key, count) {
Expand Down Expand Up @@ -677,10 +677,10 @@ export default class CharacterGeneratorSD extends FormApplication {
}
}

_randomizeGear() {
async _randomizeGear() {
this.formData.gearSelected = [];
let tempGearTable = [...this.gearTable];
let gearCount = this._roll("d4");
let gearCount = await this._roll("d4");
// get an item from the temp table, then remove that item to prevent duplicates
for (let i = 0; i < gearCount; i++) {
let randomIndex = this._getRandom(12-i);
Expand All @@ -694,8 +694,8 @@ export default class CharacterGeneratorSD extends FormApplication {
return Math.floor(Math.random() * max);
}

_roll(formula) {
let roll = new Roll(formula).evaluate({async: false});
async _roll(formula) {
let roll = await new Roll(formula).evaluate();
return roll._total;
}

Expand Down
9 changes: 3 additions & 6 deletions system/src/apps/CompendiumItemSelector.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export default class CompendiumItemSelector extends FormApplication {

itemsLoaded = false;

uuid = randomID();
uuid = foundry.utils.randomID();

static get defaultOptions() {
const options = super.defaultOptions;

mergeObject(options, {
foundry.utils.mergeObject(options, {
classes: ["shadowdark", "compendium-item-selector"],
height: "auto",
width: 320,
Expand Down Expand Up @@ -85,16 +85,13 @@ export default class CompendiumItemSelector extends FormApplication {
async getCurrentItemData() {
this.currentItemUuids = await this.getUuids() ?? [];
this.currentItems = await this.getCurrentItems() ?? [];

for (const item of this.availableItems) {
item.decoratedName = await this.decorateName(item);
}
}

async getCurrentItems() {
const items = [];
for (const uuid of this.currentItemUuids) {
const item = await fromUuid(uuid);
item.decoratedName = await this.decorateName(item);
items.push(item);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class AncestrySelector extends CompendiumItemSelector {
}

async getAvailableItems() {
return await shadowdark.compendiums.ancestries();
return shadowdark.compendiums.ancestries();
}

async getUuids() {
Expand Down
2 changes: 1 addition & 1 deletion system/src/apps/ItemImporterSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default class ItemImporterSD extends FormApplication {

/** @inheritdoc */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["item-importer"],
width: 300,
resizable: false,
Expand Down
6 changes: 3 additions & 3 deletions system/src/apps/LevelUpSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class LevelUpSD extends FormApplication {

/** @inheritdoc */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
width: 275,
resizable: false,
closeOnSubmit: true,
Expand Down Expand Up @@ -334,7 +334,7 @@ export default class LevelUpSD extends FormApplication {
};

// update values on actor
this.data.actor.update({
await this.data.actor.update({
"system.level.value": this.data.targetLevel,
"system.level.xp": newXP,
"system.attributes.hp.base": newBaseHP,
Expand All @@ -343,7 +343,7 @@ export default class LevelUpSD extends FormApplication {
});

// add talents and spells to actor
this.data.actor.createEmbeddedDocuments("Item", allItems);
await this.data.actor.createEmbeddedDocuments("Item", allItems);

// show actor sheet
this.data.actor.sheet.render(true);
Expand Down
2 changes: 1 addition & 1 deletion system/src/apps/LoadingSD.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default class LoadingSD extends Application {

static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["shadowdark", "loading-spinner"],
resizable: false,
width: "auto",
Expand Down
2 changes: 1 addition & 1 deletion system/src/apps/MonsterImporterSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default class MonsterImporterSD extends FormApplication {

/** @inheritdoc */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["monster-importer"],
width: 600,
height: 600,
Expand Down
2 changes: 1 addition & 1 deletion system/src/apps/ShadowdarklingImporterSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default class ShadowdarklingImporterSD extends FormApplication {

/** @inheritdoc */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["shadowdark-importer"],
width: 300,
height: 310,
Expand Down
3 changes: 0 additions & 3 deletions system/src/apps/SourceFilterSettings.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ export default class SourceFilterSettings extends FormApplication {
data.selectedSources.push(source);
}
}
// data.selectedSources = this.filtered.map(
// choice => ({uuid: choice, name: CONFIG.CONAN.sources[choice]})
// );

data.hasSelectedSources = data.selectedSources.length > 0;

Expand Down
31 changes: 3 additions & 28 deletions system/src/apps/SpellBookSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default class SpellBookSD extends FormApplication {

/** @inheritdoc */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
width: 450,
left: 100,
resizable: true,
Expand Down Expand Up @@ -61,36 +61,11 @@ export default class SpellBookSD extends FormApplication {
class: await fromUuid(this.classID),
};

// get source filter settings
const sources = game.settings.get("shadowdark", "sourceFilters") ?? [];
const sourcesSet = (sources.length > 0);

// load all spells for class based on source filter
let unsortedSpells = [];
for (let pack of game.packs) {
if (pack.metadata.type !== "Item") continue;

let ids = pack.index.filter(d => (d.type === "Spell")).map(d => d._id);

for (const id of ids) {
const spell = await pack.getDocument(id);
const source = spell.system?.source?.title ?? "";
if (spell.system.class.includes(this.classID)) {
if (source !== "" && sourcesSet && !sources.includes(source)) {
continue;
}
unsortedSpells.push(spell);
}
}

}

// sort spells
let sortedSpells = unsortedSpells.sort(
(a, b) => a.name < b.name ? -1 : 1);
const spells = await shadowdark.compendiums.classSpellBook(this.classID);

// group spells by tier
this.data.spellList = Object.groupBy(sortedSpells, ({system}) => system.tier);
this.data.spellList = Object.groupBy(spells, ({system}) => system.tier);

return this.data;
}
Expand Down
2 changes: 1 addition & 1 deletion system/src/apps/SpellImporterSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default class SpellImporter extends FormApplication {

/** @inheritdoc */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["spell-importer"],
width: 300,
resizable: false,
Expand Down
2 changes: 1 addition & 1 deletion system/src/dice/RollSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export default class RollSD extends Roll {
// Put back the main dice
parts.unshift(mainDice);

const roll = await new Roll(parts.join(" + "), data).evaluate({async: true});
const roll = await new Roll(parts.join(" + "), data).evaluate();
const renderedHTML = await roll.render();

// Also send the actors critical bonuses in case it has modified thresholds
Expand Down
8 changes: 6 additions & 2 deletions system/src/documents/ActorSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,15 @@ export default class ActorSD extends Actor {

const title = game.i18n.localize("SHADOWDARK.chat.spell_learn.title");

const messageStyles = shadowdark.utils.getMessageStyles();

await ChatMessage.create({
title,
content,
flags: { "core.canPopout": true },
flavor: title,
speaker: ChatMessage.getSpeaker({ actor: this, token: this.token }),
type: CONST.CHAT_MESSAGE_TYPES.OTHER,
type: messageStyles.OTHER,
user: game.user.id,
});

Expand Down Expand Up @@ -1350,13 +1352,15 @@ export default class ActorSD extends Actor {

const content = await renderTemplate(template, cardData);

const messageStyles = shadowdark.utils.getMessageStyles();

await ChatMessage.create({
title,
content,
flags: { "core.canPopout": true },
flavor: title,
speaker: ChatMessage.getSpeaker({actor: this, token: this.token}),
type: CONST.CHAT_MESSAGE_TYPES.OTHER,
type: messageStyles.OTHER,
user: game.user.id,
});

Expand Down
Loading

0 comments on commit 9a6ee1a

Please sign in to comment.