Skip to content

Commit

Permalink
close #2225
Browse files Browse the repository at this point in the history
  • Loading branch information
moo-man committed Sep 16, 2024
1 parent f744da3 commit 2d9ccc2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
21 changes: 8 additions & 13 deletions modules/actor/sheet/actor-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1709,20 +1709,15 @@ export default class ActorSheetWFRP4e extends WarhammerActorSheet {
let dragData = JSON.parse(ev.dataTransfer.getData("text/plain"));
let dropID = $(ev.target).parents(".item").attr("data-id");

let item = (await Item.implementation.fromDropData(dragData))?.toObject()

item.system.location.value = dropID; // Change location value of item to the id of the container it is in

// this will unequip/remove items like armor and weapons when moved into a container
if (item.type == "armour")
item.system.worn.value = false;
if (item.type == "weapon")
item.system.equipped = false;
if (item.type == "trapping" && item.system.trappingType.value == "clothingAccessories")
item.system.worn = false;

let item = (await Item.implementation.fromDropData(dragData))
let update = {system : {location : {value : dropID}}};

if (item.system.isEquippable)
{
update.system.equipped = {value : false};
}

return this.actor.updateEmbeddedDocuments("Item", [item]);
return item.update(update);
}

// Dropping a character creation result
Expand Down
7 changes: 4 additions & 3 deletions modules/model/item/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ export class ContainerModel extends EquippableItemModel {
{
await super._onUpdate(data, options, user);

if (data.system?.location?.value) {
if (data.system?.location?.value)
{
let allContainers = this.parent.actor?.getItemTypes("container")
if (this.formsLoop(this.parent, allContainers))
{
ui.notifications.error("Loop formed - Resetting Container Location")
data["system.location.value"] = "";
this.parent.update({"system.location.value" : ""});
}
}
}
}


Expand Down

0 comments on commit 2d9ccc2

Please sign in to comment.