Fix #75 Token drag&drop

This commit is contained in:
sladecraven 2022-09-29 13:07:57 +02:00
parent a5e17b8276
commit cfcc9ca557

View File

@ -8,9 +8,11 @@ import { PegasusRollDialog } from "./pegasus-roll-dialog.js";
const __level2Dice = ["d0", "d4", "d6", "d8", "d10", "d12"]
const __name2DiceValue = { "0": 0, "d0": 0, "d4": 4, "d6": 6, "d8": 8, "d10": 10, "d12": 12 }
const __dice2Level = { "d0": 0, "d4": 1, "d6": 2, "d8": 3, "d10": 4, "d12": 5 }
const __rangeKeyToText = { notapplicable: "N/A", touch: "Self Only", touchself: "Touch/Self", tz: "Threat Zone", close: "Close", medium: "Medium",
const __rangeKeyToText = {
notapplicable: "N/A", touch: "Self Only", touchself: "Touch/Self", tz: "Threat Zone", close: "Close", medium: "Medium",
long: "Long", extreme: "Extreme", sight: "Lineof Sight", tz_close: "TZ/Close", close_medium: "Close/Medium", medium_long: "Medium/Long",
long_extreme: "Long/Extreme"}
long_extreme: "Long/Extreme"
}
/* -------------------------------------------- */
export class PegasusUtility {
@ -271,6 +273,7 @@ export class PegasusUtility {
/* -------------------------------------------- */
static async addItemDropToActor(actor, item) {
console.log("ITEM DROPPED", actor, item)
actor.preprocessItem("none", item, false)
let chatData = {
user: game.user.id,
@ -294,11 +297,16 @@ export class PegasusUtility {
for (let token of tokensList) {
if (x >= token.x && x <= (token.x + token.width)
&& y >= token.y && y <= (token.y + token.height)) {
let item = await this.searchItem(data)
const item = fromUuidSync(data.uuid)
if (item == undefined) {
item = this.actor.items.get(data.uuid)
}
let itemFull = await PegasusUtility.searchItem(item)
console.log("DROPPED DATA", data.uuid)
if (game.user.isGM || token.actor.isOwner) {
this.addItemDropToActor(token.actor, item)
this.addItemDropToActor(token.actor, itemFull)
} else {
game.socket.emit("system.fvtt-pegasus-rpg", { name: "msg_gm_item_drop", data: { actorId: token.actor.id, itemId: item.id, isPack: item.pack } })
game.socket.emit("system.fvtt-pegasus-rpg", { name: "msg_gm_item_drop", data: { actorId: token.actor.id, itemId: itemFull.id, isPack: item.pack } })
}
return
}