diff --git a/modules/pegasus-utility.js b/modules/pegasus-utility.js index dea570b..f11858d 100644 --- a/modules/pegasus-utility.js +++ b/modules/pegasus-utility.js @@ -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", - long: "Long", extreme: "Extreme", sight: "Lineof Sight", tz_close: "TZ/Close", close_medium: "Close/Medium", medium_long: "Medium/Long", - long_extreme: "Long/Extreme"} +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" +} /* -------------------------------------------- */ export class PegasusUtility { @@ -68,7 +70,7 @@ export class PegasusUtility { Handlebars.registerHelper('getDice', function (a) { return PegasusUtility.getDiceFromLevel(a) }) - + } /* -------------------------------------------- */ @@ -112,7 +114,7 @@ export class PegasusUtility { } /* -------------------------------------------- */ - static getRangeText( rangeKey) { + static getRangeText(rangeKey) { return __rangeKeyToText[rangeKey] || "N/A" } @@ -145,10 +147,10 @@ export class PegasusUtility { let newDicePool = rollData.dicePool.filter(dice => dice.name != "effect-bonus-dice") for (let effect of rollData.effectsList) { if (effect && effect.applied && effect.type == "effect" && effect.effect && effect.effect.system.bonusdice) { - newDicePool = newDicePool.concat( this.buildDicePool("effect-bonus-dice", effect.effect.system.effectlevel, 0, effect.effect.name )) + newDicePool = newDicePool.concat(this.buildDicePool("effect-bonus-dice", effect.effect.system.effectlevel, 0, effect.effect.name)) } if (effect && effect.applied && effect.type == "effect" && effect.value && effect.isdynamic) { - newDicePool = newDicePool.concat( this.buildDicePool("effect-bonus-dice", effect.value, 0, effect.name )) + newDicePool = newDicePool.concat(this.buildDicePool("effect-bonus-dice", effect.value, 0, effect.name)) } } rollData.dicePool = newDicePool @@ -159,7 +161,7 @@ export class PegasusUtility { let newDicePool = rollData.dicePool.filter(dice => dice.name != "effect-hindrance") for (let hindrance of rollData.effectsList) { if (hindrance && hindrance.applied && (hindrance.type == "hindrance" || (hindrance.type == "effect" && hindrance.effect?.system?.hindrance))) { - newDicePool = newDicePool.concat( this.buildDicePool("effect-hindrance", (hindrance.value) ? hindrance.value : hindrance.effect.system.effectlevel, 0, hindrance.name )) + newDicePool = newDicePool.concat(this.buildDicePool("effect-hindrance", (hindrance.value) ? hindrance.value : hindrance.effect.system.effectlevel, 0, hindrance.name)) } } rollData.dicePool = newDicePool @@ -170,13 +172,13 @@ export class PegasusUtility { let newDicePool = rollData.dicePool.filter(dice => dice.name != "armor-shield") for (let armor of rollData.armorsList) { if (armor.applied) { - newDicePool = newDicePool.concat( this.buildDicePool("armor-shield", armor.value, 0)) + newDicePool = newDicePool.concat(this.buildDicePool("armor-shield", armor.value, 0)) } } newDicePool = rollData.dicePool.filter(dice => dice.name != "vehicle-shield") for (let shield of rollData.vehicleShieldList) { if (shield.applied) { - newDicePool = newDicePool.concat( this.buildDicePool("vehicle-shield", shield.value, 0)) + newDicePool = newDicePool.concat(this.buildDicePool("vehicle-shield", shield.value, 0)) } } rollData.dicePool = newDicePool @@ -189,17 +191,17 @@ export class PegasusUtility { let newDicePool = rollData.dicePool.filter(dice => dice.name != "damage") for (let weapon of rollData.weaponsList) { if (weapon.applied && weapon.type == "damage") { - newDicePool = newDicePool.concat( this.buildDicePool("damage", weapon.value, 0)) + newDicePool = newDicePool.concat(this.buildDicePool("damage", weapon.value, 0)) } } for (let weapon of rollData.vehicleWeapons) { if (weapon.applied) { - newDicePool = newDicePool.concat( this.buildDicePool("damage", weapon.value, 0)) + newDicePool = newDicePool.concat(this.buildDicePool("damage", weapon.value, 0)) } } rollData.dicePool = newDicePool - } + } } /* -------------------------------------------- */ @@ -207,13 +209,13 @@ export class PegasusUtility { let newDicePool = rollData.dicePool.filter(dice => dice.name != "stat") let statDice = rollData.dicePool.find(dice => dice.name == "stat") if (statDice.level > 0) { - newDicePool = newDicePool.concat( this.buildDicePool( "stat", rollData.statDicesLevel, statDice.mod)) + newDicePool = newDicePool.concat(this.buildDicePool("stat", rollData.statDicesLevel, statDice.mod)) } - + if (rollData.vehicleStat) { newDicePool = rollData.dicePool.filter(dice => dice.name != "vehiclestat") - if (rollData.vehicleStat.currentlevel > 0 ) { - newDicePool = newDicePool.concat( this.buildDicePool( "vehiclestat", rollData.vehicleStat.currentlevel, 0)) + if (rollData.vehicleStat.currentlevel > 0) { + newDicePool = newDicePool.concat(this.buildDicePool("vehiclestat", rollData.vehicleStat.currentlevel, 0)) } rollData.dicePool = newDicePool } @@ -223,7 +225,7 @@ export class PegasusUtility { static updateSpecDicePool(rollData) { let newDicePool = rollData.dicePool.filter(dice => dice.name != "spec") if (rollData.specDicesLevel > 0) { - newDicePool = newDicePool.concat( this.buildDicePool( "spec", rollData.specDicesLevel, 0)) + newDicePool = newDicePool.concat(this.buildDicePool("spec", rollData.specDicesLevel, 0)) } rollData.dicePool = newDicePool } @@ -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 } @@ -912,7 +920,7 @@ export class PegasusUtility { let item if (dataItem.pack) { let id = dataItem.id || dataItem._id - let items = await this.loadCompendium( dataItem.pack, item => item.id == id) + let items = await this.loadCompendium(dataItem.pack, item => item.id == id) //console.log(">>>>>> PACK", items) item = items[0] || undefined //item = await fromUuid(dataItem.pack + "." + id)