Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.7.2 #654

Merged
merged 5 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# v1.7.2

## Bugfixes

* [#650] New hotbar support breaks standard document drag to hotbar support

## Enhancements

* [#649] Apply compendium source filtering to selectors on Item sheets as well as player Sheets
* [#653] Allow spell items to be dragged from character sheet to hotbar

# v1.7.1

## Bugfixes
Expand Down
10 changes: 5 additions & 5 deletions system/src/apps/ShadowdarklingImporterSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -199,37 +199,37 @@ export default class ShadowdarklingImporterSD extends FormApplication {

// Ancestry
if (json.ancestry) {
const ancestries = await shadowdark.compendiums.ancestries();
const ancestries = await shadowdark.compendiums.ancestries(false);
const ancestry = ancestries.find(
i => i.name.toLowerCase() === json.ancestry.toLowerCase()
);
importedActor.system.ancestry = ancestry?.uuid ?? "";
}

// Background
const backgrounds = await shadowdark.compendiums.backgrounds();
const backgrounds = await shadowdark.compendiums.backgrounds(false);
const background = backgrounds.find(
i => i.name.toLowerCase() === json.background.toLowerCase()
);
importedActor.system.background = background?.uuid ?? "";

// Class
const classes = await shadowdark.compendiums.classes();
const classes = await shadowdark.compendiums.classes(false);
const characterClass = classes.find(
i => i.name.toLowerCase() === json.class.toLowerCase()
);
importedActor.system.class = characterClass?.uuid ?? "";

// Deity
const deities = await shadowdark.compendiums.deities();
const deities = await shadowdark.compendiums.deities(false);
const deity = deities.find(
i => i.name.toLowerCase() === json.deity.toLowerCase()
);
importedActor.system.deity = deity?.uuid ?? "";

// Languages
const jsonLanguages = json.languages.toLowerCase().split(", ");
const allLanguages = await shadowdark.compendiums.languages();
const allLanguages = await shadowdark.compendiums.languages([], false);
for (const jsonLanguage of jsonLanguages) {
const language = allLanguages.find(l => l.name.toLowerCase() === jsonLanguage);
if (language) importedActor.system.languages.push(language.uuid);
Expand Down
10 changes: 10 additions & 0 deletions system/src/documents/ItemSD.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
export default class ItemSD extends Item {

get isRollable() {
return [
"Potion",
"Scroll",
"Spell",
"Wand",
"Weapon",
].includes(this.type);
}

/* Set the start time and initiative roll of newly created effect */
/** @override */
async _preCreate(data, options, user) {
Expand Down
9 changes: 5 additions & 4 deletions system/src/hooks/hotbar.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
export const hotbarHooks = {
attach: () => {
Hooks.on("hotbarDrop", (bar, data, slot) => {
if (data.type === "Item") {
shadowdark.utils.createHotbarMacro(data, slot);
return false;
}
if (data.type !== "Item") return true;
if (data.type === "Macro" || data.type === "RollTable") return true;

shadowdark.utils.createHotbarMacro(data, slot);
return false;
});
},
};
2 changes: 1 addition & 1 deletion system/src/migrations/updates/Update_230916_1.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class Update_230916_1 extends UpdateBaseSD {

if (currentValue !== "") {
const itemLut = {};
(await shadowdark.compendiums.ancestries()).forEach(
(await shadowdark.compendiums.ancestries(false)).forEach(
item => itemLut[item.name.slugify()] = item.uuid
);

Expand Down
4 changes: 2 additions & 2 deletions system/src/migrations/updates/Update_230920_1.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class Update_230920_1 extends UpdateBaseSD {

if (currentValue !== "") {
const itemLut = {};
(await shadowdark.compendiums.classes()).forEach(
(await shadowdark.compendiums.classes(false)).forEach(
item => itemLut[item.name.slugify()] = item.uuid
);

Expand Down Expand Up @@ -58,7 +58,7 @@ export default class Update_230920_1 extends UpdateBaseSD {

if (currentValues.length > 0) {
const itemLut = {};
(await shadowdark.compendiums.spellcastingClasses()).forEach(
(await shadowdark.compendiums.spellcastingClasses(false)).forEach(
item => itemLut[item.name.slugify()] = item.uuid
);

Expand Down
2 changes: 1 addition & 1 deletion system/src/migrations/updates/Update_230923_1.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class Update_230923_1 extends UpdateBaseSD {

if (currentValue !== "") {
const itemLut = {};
(await shadowdark.compendiums.backgrounds()).forEach(
(await shadowdark.compendiums.backgrounds(false)).forEach(
item => itemLut[item.name.slugify()] = item.uuid
);

Expand Down
2 changes: 1 addition & 1 deletion system/src/migrations/updates/Update_230923_2.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class Update_230923_2 extends UpdateBaseSD {

if (currentValue !== "") {
const itemLut = {};
(await shadowdark.compendiums.deities()).forEach(
(await shadowdark.compendiums.deities(false)).forEach(
item => itemLut[item.name.slugify()] = item.uuid
);

Expand Down
2 changes: 1 addition & 1 deletion system/src/migrations/updates/Update_231025_1.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class Update_231025_1 extends UpdateBaseSD {
const spellcasterClass = itemData.system.class;
if (typeof spellcasterClass === "string") {
const itemLut = {};
(await shadowdark.compendiums.spellcastingClasses()).forEach(
(await shadowdark.compendiums.spellcastingClasses(false)).forEach(
item => itemLut[item.name.slugify()] = item.uuid
);

Expand Down
24 changes: 12 additions & 12 deletions system/src/sheets/ItemSheetSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default class ItemSheetSD extends ItemSheet {
async getAncestrySelectorConfigs(context) {
const [selectedLanguages, availableLanguages] =
await shadowdark.utils.getDedupedSelectedItems(
await shadowdark.compendiums.languages([], false),
await shadowdark.compendiums.languages(),
this.item.system.languages.fixed ?? []
);

Expand All @@ -105,7 +105,7 @@ export default class ItemSheetSD extends ItemSheet {

const [selectedTalents, availableTalents] =
await shadowdark.utils.getDedupedSelectedItems(
await shadowdark.compendiums.ancestryTalents(false),
await shadowdark.compendiums.ancestryTalents(),
this.item.system.talents ?? []
);

Expand All @@ -123,7 +123,7 @@ export default class ItemSheetSD extends ItemSheet {
async getClassSelectorConfigs(context) {
const [selectedArmor, availableArmor] =
await shadowdark.utils.getDedupedSelectedItems(
await shadowdark.compendiums.baseArmor(false),
await shadowdark.compendiums.baseArmor(),
this.item.system.armor ?? []
);

Expand All @@ -138,10 +138,10 @@ export default class ItemSheetSD extends ItemSheet {
};

context.classTalentTables =
await shadowdark.compendiums.classTalentTables(false);
await shadowdark.compendiums.classTalentTables();

const classTalentTables =
await shadowdark.compendiums.classTalentTables(false);
await shadowdark.compendiums.classTalentTables();

context.classTalentTables = {};
for (const classTalentTable of classTalentTables) {
Expand All @@ -152,7 +152,7 @@ export default class ItemSheetSD extends ItemSheet {

const [selectedLanguages, availableLanguages] =
await shadowdark.utils.getDedupedSelectedItems(
await shadowdark.compendiums.languages([], false),
await shadowdark.compendiums.languages(),
this.item.system.languages.selectOptions ?? []
);

Expand All @@ -166,7 +166,7 @@ export default class ItemSheetSD extends ItemSheet {
selectedItems: selectedLanguages,
};

const classTalents = await shadowdark.compendiums.talents([], false);
const classTalents = await shadowdark.compendiums.talents();

const [selectedTalents, availableTalents] =
await shadowdark.utils.getDedupedSelectedItems(
Expand Down Expand Up @@ -201,7 +201,7 @@ export default class ItemSheetSD extends ItemSheet {
};

const spellcastingClasses =
await shadowdark.compendiums.spellcastingClasses(false);
await shadowdark.compendiums.spellcastingClasses();

context.spellcastingClasses = {};
for (const spellcastingClass of spellcastingClasses) {
Expand All @@ -212,7 +212,7 @@ export default class ItemSheetSD extends ItemSheet {

const [selectedWeapons, availableWeapons] =
await shadowdark.utils.getDedupedSelectedItems(
await shadowdark.compendiums.baseWeapons(false),
await shadowdark.compendiums.baseWeapons(),
this.item.system.weapons ?? []
);

Expand All @@ -230,7 +230,7 @@ export default class ItemSheetSD extends ItemSheet {
async getSpellSelectorConfigs(context) {
const [selectedClasses, availableClasses] =
await shadowdark.utils.getDedupedSelectedItems(
await shadowdark.compendiums.spellcastingClasses(false),
await shadowdark.compendiums.spellcastingClasses(),
this.item.system.class ?? []
);

Expand Down Expand Up @@ -331,14 +331,14 @@ export default class ItemSheetSD extends ItemSheet {

if (item.type === "Armor") {
context.baseArmor = await shadowdark.utils.getSlugifiedItemList(
await shadowdark.compendiums.baseArmor(false)
await shadowdark.compendiums.baseArmor()
);

delete context.baseArmor[mySlug];
}
if (item.type === "Weapon") {
context.baseWeapons = await shadowdark.utils.getSlugifiedItemList(
await shadowdark.compendiums.baseWeapons(false)
await shadowdark.compendiums.baseWeapons()
);

delete context.baseWeapons[mySlug];
Expand Down
21 changes: 17 additions & 4 deletions system/src/utils/UtilitySD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,26 @@ export default class UtilitySD {
);
}

let command = `await Hotbar.toggleDocumentSheet("${itemData.uuid}");`;
let flags = {};
let name = itemData.name;

if (itemData.isRollable) {
command = `shadowdark.macro.rollItemMacro("${itemData.name}")`;
flags = {"shadowdark.itemMacro": true};
name = `${game.i18n.localize("Roll")} ${name}`;
}
else {
name = `${game.i18n.localize("Display")} ${name}`;
}

const macroData = {
command: `shadowdark.macro.rollItemMacro("${itemData.name}")`,
flags: {"shadowdark.itemMacro": true},
command,
flags,
img: itemData.img,
name: itemData.name,
name,
scope: "actor",
type: "script",
type: CONST.MACRO_TYPES.SCRIPT,
};

// Assign the macro to the hotbar
Expand Down
2 changes: 1 addition & 1 deletion system/system.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "shadowdark",
"title": "Shadowdark RPG",
"desciption": "A system for playing the Shadowdark RPG from Arcane Library",
"version": "1.7.1",
"version": "1.7.2",
"compatibility": {
"minimum": "11",
"verified": "11"
Expand Down
1 change: 1 addition & 0 deletions system/templates/actors/player/spells.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<tr
class="item"
data-item-id="{{spell._id}}"
draggable="true"
>
<td>
<div
Expand Down