From 9105420656a61913a08ca672c4ab52c6d0be8631 Mon Sep 17 00:00:00 2001 From: Melon-PieldeSapo Date: Mon, 16 Dec 2024 16:10:48 +0100 Subject: [PATCH] Fix arguments and import --- module/actor/actor.js | 10 ++++++---- module/actor/ship-sheet-sbt.js | 3 ++- module/mosh.js | 11 ++++++----- module/windows/ship-megadamage.js | 3 ++- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/module/actor/actor.js b/module/actor/actor.js index c0db14c..a8fa578 100644 --- a/module/actor/actor.js +++ b/module/actor/actor.js @@ -1,3 +1,5 @@ +import { fromIdUuid } from "../mosh"; + /** * Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system. * @extends {Actor} @@ -1376,7 +1378,7 @@ export class MothershipActor extends Actor { //A script to return the data from a table. async getRollTableData(tableId){ - let tableData = await fromIdUuid(tableId,type="RollTable"); + let tableData = await fromIdUuid(tableId,{type:"RollTable"}); //get table name let tableName = tableData.name; //get table name @@ -1525,7 +1527,7 @@ export class MothershipActor extends Actor { rollString = chosenRollType[0]; } - let tableData = await fromIdUuid(tableId,type="RollTable"); + let tableData = await fromIdUuid(tableId,{type:"RollTable"}); //get current compendium //get table name let tableName = tableData.name; @@ -2588,7 +2590,7 @@ export class MothershipActor extends Actor { //get the bankruptcy table let tableId = game.settings.get('mosh','table1eBankruptcy'); //get Table Data - let tableData = await fromIdUuid(tableId,type="RollTable"); + let tableData = await fromIdUuid(tableId,{type:"RollTable"}); //prep text for success if (parsedRollResult.success && parsedRollResult.critical) { //flavor text @@ -3063,7 +3065,7 @@ export class MothershipActor extends Actor { let flavorText = ``; let chatId = (game.release.generation >= 12 ? foundry.utils.randomID(): randomID()) //get item data - let itemData = await fromIdUuid(itemId,type="Item"); + let itemData = await fromIdUuid(itemId,{type:"Item"}); //add or increase the count of the item, depending on type, if the actor has it if (this.items.getName(itemData.name)) { //if this is an item, increase the count diff --git a/module/actor/ship-sheet-sbt.js b/module/actor/ship-sheet-sbt.js index e3a0a74..76b7582 100644 --- a/module/actor/ship-sheet-sbt.js +++ b/module/actor/ship-sheet-sbt.js @@ -1,3 +1,4 @@ +import { fromIdUuid } from "../mosh"; /** * Extend the basic ActorSheet with some very simple modifications @@ -180,7 +181,7 @@ export class MothershipShipSheetSBT extends ActorSheet { //A script to return the data from a table. let tableId = game.settings.get('mosh', 'table1eMegadamageEffects'); //get table data - let tableData = await fromIdUuid(tableId,type="RollTable"); + let tableData = await fromIdUuid(tableId,{type:"RollTable"}); let megadamageHTML = ""; diff --git a/module/mosh.js b/module/mosh.js index 2ba8b2f..07c5e5b 100644 --- a/module/mosh.js +++ b/module/mosh.js @@ -937,7 +937,8 @@ async function noShipSelected() { //get item from world or compendiums by id or UUID. -export async function fromIdUuid(id_uuid,type="", options={}){ +export async function fromIdUuid(id_uuid, options={}){ + let type = options.type; let item = await fromUuid(id_uuid,options); if(item != null){ //we found the item with the id, it probably was an uuid. @@ -970,19 +971,19 @@ export async function fromIdUuid(id_uuid,type="", options={}){ //it is a world item. switch (type) { case "RollTable": - return game.tables.filter(i=> i.id == id_uuid); + return game.tables.filter(i=> i.id == id_uuid)[0]; case "Item": - return game.items.filter(i=> i.id == id_uuid); + return game.items.filter(i=> i.id == id_uuid)[0]; default: //type is not defined, and we could not find it in a compendium, //now we search all world elements. let itemData = game.tables.filter(i=> i.id == id_uuid); if (itemData){ - return itemData + return itemData[0]; } itemData = game.items.filter(i=> i.id == id_uuid); if (itemData){ - return itemData + return itemData[0]; } } } diff --git a/module/windows/ship-megadamage.js b/module/windows/ship-megadamage.js index 3ff2610..8c780db 100644 --- a/module/windows/ship-megadamage.js +++ b/module/windows/ship-megadamage.js @@ -1,3 +1,4 @@ +import { fromIdUuid } from "../mosh"; export class DLShipMegaDamage extends FormApplication { static get defaultOptions() { const options = super.defaultOptions; @@ -42,7 +43,7 @@ export class DLShipMegaDamage extends FormApplication { //A script to return the data from a table. let tableId = game.settings.get('mosh','table1eMegadamageEffects'); //get table data - let tableData = await fromIdUuid(tableId,type="RollTable"); + let tableData = await fromIdUuid(tableId,{type:"RollTable"}); let entries = Array.from(tableData.results.entries());