Skip to content

Commit

Permalink
Release v26
Browse files Browse the repository at this point in the history
  • Loading branch information
aMediocreDad committed Aug 26, 2024
1 parent 9fe779f commit ce950fc
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 37 deletions.
2 changes: 1 addition & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,4 @@
"adventure": "Adventure",
"greatness": "Greatness",
"Notes": "Notes"
}
}
8 changes: 6 additions & 2 deletions scripts/actor/character/character-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ export class CharacterData extends foundry.abstract.TypeDataModel {
// Make sure only four themes are present
const themes = this.parent.items.filter((item) => item.type === "theme");
if (themes.length > 4) {
warn(`Too many themes found for ${this.parent.name}, attempting to resolve...`);
warn(
`Too many themes found for ${this.parent.name}, attempting to resolve...`,
);
const toDelete = themes.slice(4);
await this.parent.deleteEmbeddedDocuments(
"Item",
Expand All @@ -108,7 +110,9 @@ export class CharacterData extends foundry.abstract.TypeDataModel {
(item) => item.type === "backpack",
);
if (backpacks.length > 1) {
warn(`Too many backpacks found for ${this.parent.name}, attempting to resolve...`);
warn(
`Too many backpacks found for ${this.parent.name}, attempting to resolve...`,
);
const toDelete = backpacks.slice(1);
await this.parent.deleteEmbeddedDocuments(
"Item",
Expand Down
26 changes: 20 additions & 6 deletions scripts/actor/character/character-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,13 +522,19 @@ export class CharacterSheet extends SheetMixin(ActorSheet) {
const { contents } = item.system;
const chosenLoot = await Dialog.wait({
title: game.i18n.localize("Litm.ui.item-transfer-title"),
content: await renderTemplate("systems/litm/templates/apps/loot-dialog.html", { contents, cssClass: "litm--loot-dialog" }),
content: await renderTemplate(
"systems/litm/templates/apps/loot-dialog.html",
{ contents, cssClass: "litm--loot-dialog" },
),
buttons: {
loot: {
icon: '<i class="fas fa-check"></i>',
label: game.i18n.localize("Litm.other.transfer"),
callback: (html) => {
const chosenLoot = html.find("input[type=checkbox]:checked").map((_, i) => i.value).get();
const chosenLoot = html
.find("input[type=checkbox]:checked")
.map((_, i) => i.value)
.get();
return chosenLoot;
},
},
Expand All @@ -542,14 +548,22 @@ export class CharacterSheet extends SheetMixin(ActorSheet) {
if (!backpack) {
error("Litm.ui.error-no-backpack");
throw new Error("Litm.ui.error-no-backpack");
};
}

// Add the loot to the backpack
await backpack.update({ ['system.contents']: [...this.system.backpack, ...loot] });
await backpack.update({
"system.contents": [...this.system.backpack, ...loot],
});
// Remove the loot from the item
await item.update({ ['system.contents']: contents.filter((i) => !chosenLoot.includes(i.id)) });
await item.update({
"system.contents": contents.filter((i) => !chosenLoot.includes(i.id)),
});

ui.notifications.info(game.i18n.format("Litm.ui.item-transfer-success", { items: loot.map((i) => i.name).join(", ") }));
ui.notifications.info(
game.i18n.format("Litm.ui.item-transfer-success", {
items: loot.map((i) => i.name).join(", "),
}),
);
backpack.sheet.render(true);
}

Expand Down
36 changes: 20 additions & 16 deletions scripts/apps/roll-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,26 @@ export class LitmRollDialog extends FormApplication {
negativeStatuses,
});

const formula = typeof CONFIG.litm.roll.formula === "function" ? CONFIG.litm.roll.formula({
burnedTags,
powerTags,
weaknessTags,
positiveStatuses,
negativeStatuses,
burnedValue,
powerValue,
weaknessValue,
positiveStatusValue,
negativeStatusValue,
totalPower,
actorId,
type,
title,
}) : CONFIG.litm.roll.formula || "2d6 + (@burnedValue + @powerValue + @positiveStatusValue - @weaknessValue - @negativeStatusValue)";
const formula =
typeof CONFIG.litm.roll.formula === "function"
? CONFIG.litm.roll.formula({
burnedTags,
powerTags,
weaknessTags,
positiveStatuses,
negativeStatuses,
burnedValue,
powerValue,
weaknessValue,
positiveStatusValue,
negativeStatusValue,
totalPower,
actorId,
type,
title,
})
: CONFIG.litm.roll.formula ||
"2d6 + (@burnedValue + @powerValue + @positiveStatusValue - @weaknessValue - @negativeStatusValue)";

// Roll
const roll = new game.litm.LitmRoll(
Expand Down
12 changes: 5 additions & 7 deletions scripts/apps/roll.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class LitmRoll extends Roll {

// Quick outcomes don't need to track power
if (this.litm.type === "quick") return null;
if (outcome === 'failure') return 0;
if (outcome === "failure") return 0;

// Minimum of 1 power
let totalPower = Math.max(this.litm.totalPower, 1);
Expand All @@ -57,8 +57,7 @@ export class LitmRoll extends Roll {
get outcome() {
const { resolver } = CONFIG.litm.roll;

if (typeof resolver === "function")
return resolver(this);
if (typeof resolver === "function") return resolver(this);

if (this.total > 9)
return { label: "success", description: "Litm.ui.roll-success" };
Expand All @@ -73,7 +72,6 @@ export class LitmRoll extends Roll {
template = this.constructor.CHAT_TEMPLATE,
isPrivate = false,
} = {}) {

if (!this._evaluated) await this.evaluate({ async: true });

const chatData = {
Expand All @@ -94,7 +92,7 @@ export class LitmRoll extends Roll {
hasWeaknessTags:
!this.litm.gainedExp &&
this.litm.weaknessTags.filter((t) => t.type === "weaknessTag").length >
0,
0,
};

return renderTemplate(template, chatData);
Expand All @@ -107,9 +105,9 @@ export class LitmRoll extends Roll {
}

getTooltipData() {
const { label: outcome } = this.outcome
const { label: outcome } = this.outcome;
return {
mitigate: this.litm.type === "mitigate" && outcome === 'success',
mitigate: this.litm.type === "mitigate" && outcome === "success",
burnedTags: this.litm.burnedTags,
powerTags: this.litm.powerTags,
weaknessTags: this.litm.weaknessTags,
Expand Down
3 changes: 1 addition & 2 deletions scripts/system/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export class LitmConfig {

challenge_types = [
"attacker",
"barrier-hazard",
Expand Down Expand Up @@ -104,7 +103,7 @@ export class LitmConfig {
* @link scripts/apps/roll-dialog.js
* @link scripts/apps/roll.js
*/
roll = { formula: null, resolver: null }
roll = { formula: null, resolver: null };

theme_levels = {
origin: [
Expand Down
2 changes: 1 addition & 1 deletion scripts/system/handlebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class HandlebarsHelpers {
Handlebars.registerHelper("includes", (array, value, path) =>
Array.isArray(array)
? (path && array.some((i) => i[path] === value)) ||
array.includes(value)
array.includes(value)
: false,
);

Expand Down
4 changes: 2 additions & 2 deletions system.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/foundryvtt-system-manifest.json",
"id": "litm",
"version": 25,
"version": 26,
"license": "LICENSE",
"title": "Legend in the Mist Demo",
"description": "A <strong>Rustic Fantasy</strong> Game for Foundry Virtual Tabletop.",
Expand Down Expand Up @@ -93,6 +93,6 @@
"url": "https://github.com/aMediocreDad/litm",
"bugs": "https://github.com/aMediocreDad/litm/issues?q=is:issue+is:open+sort:updated-desc",
"manifest": "https://raw.githubusercontent.com/aMediocreDad/litm/main/system.json",
"download": "https://github.com/aMediocreDad/litm/archive/refs/tags/v25.zip",
"download": "https://github.com/aMediocreDad/litm/archive/refs/tags/v26.zip",
"readme": "https://github.com/aMediocreDad/litm/blob/main/README.md"
}

0 comments on commit ce950fc

Please sign in to comment.