async createLootItem(item, actor, stackSame = true) {
        const itemData = await this.buildItemData(item);

        const itemPrice = getProperty(itemData, BRTCONFIG.PRICE_PROPERTY_PATH) || 0;
        /** if the item is already owned by the actor (same name and same PRICE) */
        const sameItemOwnedAlready = actor.getEmbeddedCollection("OwnedItem").find(i => i.name === itemData.name && itemPrice == getProperty(i, BRTCONFIG.PRICE_PROPERTY_PATH));

        if (sameItemOwnedAlready && stackSame) {
            /** add quantity to existing item*/
            const itemQuantity = getProperty(itemData, BRTCONFIG.QUANTITY_PROPERTY_PATH) || 1;
            const sameItemOwnedAlreadyQuantity = getProperty(sameItemOwnedAlready, BRTCONFIG.QUANTITY_PROPERTY_PATH) || 1;
            let updateItem = { _id: sameItemOwnedAlready._id };
            setProperty(updateItem, BRTCONFIG.QUANTITY_PROPERTY_PATH, +sameItemOwnedAlreadyQuantity + +itemQuantity);

            await actor.updateEmbeddedEntity("OwnedItem", updateItem);
            return actor.getOwnedItem(sameItemOwnedAlready._id);
        } else {
            /**we create a new item if we don't own already */
            return await actor.createOwnedItem(itemData);
        }
    }
/**
     * 
     * @param {LootData.lootItem} item rapresentation 
     * @param {Actor} actor to which to add items to
     * @param {boolean} stackSame if true add quantity to an existing item of same name in the current actor
     * @returns {Item} the create Item (foundry item)
     */
@param {LootData.lootItem} item rapresentation
@param {Actor} actor to which to add items to
@param {boolean} stackSame if true add quantity to an existing item of same name in the current actor
@returns {Item} the create Item (foundry item)
@param { LootData . lootItem } item rapresentation @param { Actor } actor to which to add items to @param { boolean } stackSame if true add quantity to an existing item of same name in the current actor @returns { Item } the create Item ( foundry item )
async createLootItem(item, actor, stackSame = true) {
        const itemData = await this.buildItemData(item);
        const itemPrice = getProperty(itemData, BRTCONFIG.PRICE_PROPERTY_PATH) || 0;
        const sameItemOwnedAlready = actor.getEmbeddedCollection("OwnedItem").find(i => i.name === itemData.name && itemPrice == getProperty(i, BRTCONFIG.PRICE_PROPERTY_PATH));
        if (sameItemOwnedAlready && stackSame) {
            const itemQuantity = getProperty(itemData, BRTCONFIG.QUANTITY_PROPERTY_PATH) || 1;
            const sameItemOwnedAlreadyQuantity = getProperty(sameItemOwnedAlready, BRTCONFIG.QUANTITY_PROPERTY_PATH) || 1;
            let updateItem = { _id: sameItemOwnedAlready._id };
            setProperty(updateItem, BRTCONFIG.QUANTITY_PROPERTY_PATH, +sameItemOwnedAlreadyQuantity + +itemQuantity);
            await actor.updateEmbeddedEntity("OwnedItem", updateItem);
            return actor.getOwnedItem(sameItemOwnedAlready._id);
        } else {
            return await actor.createOwnedItem(itemData);
        }
    }
async createLootItem ( item , actor , stackSame = true ) { const itemData = await this . buildItemData ( item ) ; const itemPrice = getProperty ( itemData , BRTCONFIG . PRICE_PROPERTY_PATH ) || 0 ; const sameItemOwnedAlready = actor . getEmbeddedCollection ( "OwnedItem" ) . find ( i => i . name === itemData . name && itemPrice == getProperty ( i , BRTCONFIG . PRICE_PROPERTY_PATH ) ) ; if ( sameItemOwnedAlready && stackSame ) { const itemQuantity = getProperty ( itemData , BRTCONFIG . QUANTITY_PROPERTY_PATH ) || 1 ; const sameItemOwnedAlreadyQuantity = getProperty ( sameItemOwnedAlready , BRTCONFIG . QUANTITY_PROPERTY_PATH ) || 1 ; let updateItem = { _id : sameItemOwnedAlready . _id } ; setProperty ( updateItem , BRTCONFIG . QUANTITY_PROPERTY_PATH , + sameItemOwnedAlreadyQuantity + + itemQuantity ) ; await actor . updateEmbeddedEntity ( "OwnedItem" , updateItem ) ; return actor . getOwnedItem ( sameItemOwnedAlready . _id ) ; } else { return await actor . createOwnedItem ( itemData ) ; } }
@param {LootData.lootItem} item rapresentation
 @param {Actor} actor to which to add items to
 @param {boolean} stackSame if true add quantity to an existing item of same name in the current actor
 @returns {Item} the create Item (foundry item)
@param { LootData . lootItem } item rapresentation @param { Actor } actor to which to add items to @param { boolean } stackSame if true add quantity to an existing item of same name in the current actor @returns { Item } the create Item ( foundry item )
/** if the item is already owned by the actor (same name and same PRICE) */ /** add quantity to existing item*/ /**we create a new item if we don't own already */