diff --git a/docs/api.md b/docs/api.md index ac556692..27115e7a 100644 --- a/docs/api.md +++ b/docs/api.md @@ -39,7 +39,14 @@ * [rattleItemPile](#rattleItemPile) * [isItemPileLocked](#isItemPileLocked) * [isItemPileClosed](#isItemPileClosed) + * [isValidItemPile](#isValidItemPile) + * [isRegularItemPile](#isRegularItemPile) * [isItemPileContainer](#isItemPileContainer) + * [isItemPileLootable](#isItemPileLootable) + * [isItemPileVault](#isItemPileVault) + * [isItemPileMerchant](#isItemPileMerchant) + * [isItemPileAuctioneer](#isItemPileAuctioneer) + * [isItemPileEmpty](#isItemPileEmpty) * [updateItemPile](#updateItemPile) * [deleteItemPile](#deleteItemPile) * [splitItemPileContents](#splitItemPileContents) @@ -515,9 +522,10 @@ Causes the item pile to play a sound as it was attempted to be opened, but was l Whether an item pile is locked. If it is not enabled or not a container, it is always false. -| Param | Type | -|--------|-----------------------| -| target | `Token/TokenDocument` | +| Param | Type | Default | Description | +|--------------------|-------------------------------|---------|-------------------------------| +| target | `Token/TokenDocument` | | Target token to check | +| [data] | `Object/boolean` | `false` | Existing data flags to use | --- @@ -527,9 +535,36 @@ Whether an item pile is locked. If it is not enabled or not a container, it is a Whether an item pile is closed. If it is not enabled or not a container, it is always false. -| Param | Type | -|--------|-----------------------| -| target | `Token/TokenDocument` | +| Param | Type | Default | Description | +|--------------------|-------------------------------|---------|-------------------------------| +| target | `Token/TokenDocument` | | Target token to check | +| [data] | `Object/boolean` | `false` | Existing data flags to use | + +--- + +### isValidItemPile + +`game.itempiles.API.isValidItemPile(target)` ⇒ `boolean` + +Whether an item pile is a valid item pile. If it is not enabled, it is always false. + +| Param | Type | Default | Description | +|--------------------|-------------------------------|---------|-------------------------------| +| target | `Token/TokenDocument` | | Target token to check | +| [data] | `Object/boolean` | `false` | Existing data flags to use | + +--- + +### isRegularItemPile + +`game.itempiles.API.isRegularItemPile(target)` ⇒ `boolean` + +Whether an item pile is a regular item pile. If it is not enabled, it is always false. + +| Param | Type | Default | Description | +|--------------------|-------------------------------|---------|-------------------------------| +| target | `Token/TokenDocument` | | Target token to check | +| [data] | `Object/boolean` | `false` | Existing data flags to use | --- @@ -539,12 +574,78 @@ Whether an item pile is closed. If it is not enabled or not a container, it is a Whether an item pile is a container. If it is not enabled, it is always false. -| Param | Type | -|--------|-----------------------| -| target | `Token/TokenDocument` | +| Param | Type | Default | Description | +|--------------------|-------------------------------|---------|-------------------------------| +| target | `Token/TokenDocument` | | Target token to check | +| [data] | `Object/boolean` | `false` | Existing data flags to use | + +--- + +### isItemPileLootable + +`game.itempiles.API.isItemPileLootable(target)` ⇒ `boolean` + +Whether an item pile is a lootable. If it is not enabled, it is always false. + +| Param | Type | Default | Description | +|--------------------|-------------------------------|---------|-------------------------------| +| target | `Token/TokenDocument` | | Target token to check | +| [data] | `Object/boolean` | `false` | Existing data flags to use | + +--- + +### isItemPileVault + +`game.itempiles.API.isItemPileVault(target)` ⇒ `boolean` + +Whether an item pile is a vault. If it is not enabled, it is always false. + +| Param | Type | Default | Description | +|--------------------|-------------------------------|---------|-------------------------------| +| target | `Token/TokenDocument` | | Target token to check | +| [data] | `Object/boolean` | `false` | Existing data flags to use | --- +### isItemPileMerchant + +`game.itempiles.API.isItemPileMerchant(target)` ⇒ `boolean` + +Whether an item pile is a merchant. If it is not enabled, it is always false. + +| Param | Type | Default | Description | +|--------------------|-------------------------------|---------|-------------------------------| +| target | `Token/TokenDocument` | | Target token to check | +| [data] | `Object/boolean` | `false` | Existing data flags to use | + +--- + +### isItemPileAuctioneer + +`game.itempiles.API.isItemPileAuctioneer(target)` ⇒ `boolean` + +Whether an item pile is a auctioneer. If it is not enabled, it is always false. + +| Param | Type | Default | Description | +|--------------------|-------------------------------|---------|-------------------------------| +| target | `Token/TokenDocument` | | Target token to check | +| [data] | `Object/boolean` | `false` | Existing data flags to use | + +--- + +### isItemPileEmpty + +`game.itempiles.API.isItemPileEmpty(target)` ⇒ `boolean` + +Whether an item pile is a empty pile. If it is not enabled, it is always false. + +| Param | Type | Default | Description | +|--------------------|-------------------------------|---------|-------------------------------| +| target | `Token/TokenDocument` | | Target token to check | + +--- + + ### updateItemPile `game.itempiles.API.updateItemPile(target, newData, options)` ⇒ `Promise` @@ -1243,3 +1344,5 @@ Trades multiple items between one actor to another, and currencies and/or change | items | `Array>` | | An array of objects containing the item or the id of the item to be sold, the quantity to be sold, and the payment index to be used | | [interactionId] | `string/boolean` | `false` | The ID of this interaction | + + diff --git a/src/API/api.js b/src/API/api.js index bd6bc442..aeeb1077 100644 --- a/src/API/api.js +++ b/src/API/api.js @@ -951,33 +951,109 @@ class API { * Whether an item pile is locked. If it is not enabled or not a container, it is always false. * * @param {Token/TokenDocument} target - * + * @param {Object/boolean} [data=false] data existing flags data to use * @return {boolean} */ - static isItemPileLocked(target) { - return PileUtilities.isItemPileLocked(target); + static isItemPileLocked(target, data = false) { + return PileUtilities.isItemPileLocked(target, data); } /** * Whether an item pile is closed. If it is not enabled or not a container, it is always false. * * @param {Token/TokenDocument} target - * + * @param {Object/boolean} [data=false] data existing flags data to use * @return {boolean} */ - static isItemPileClosed(target) { - return PileUtilities.isItemPileClosed(target); + static isItemPileClosed(target, data = false) { + return PileUtilities.isItemPileClosed(target, data); } + /** + * Whether an item pile is a valid item pile. If it is not enabled, it is always false. + * + * @param {Token/TokenDocument} target + * @param {Object/boolean} [data=false] data existing flags data to use + * @return {boolean} + */ + static isValidItemPile(target, data = false) { + return PileUtilities.isValidItemPile(target, data); + } + + /** + * Whether an item pile is a regular item pile. If it is not enabled, it is always false. + * + * @param {Token/TokenDocument} target + * @param {Object/boolean} [data=false] data existing flags data to use + * @return {boolean} + */ + static isRegularItemPile(target, data = false) { + return PileUtilities.isRegularItemPile(target, data); + } + /** * Whether an item pile is a container. If it is not enabled, it is always false. * * @param {Token/TokenDocument} target + * @param {Object/boolean} [data=false] data existing flags data to use + * @return {boolean} + */ + static isItemPileContainer(target, data = false) { + return PileUtilities.isItemPileContainer(target, data); + } + + /** + * Whether an item pile is a lootable. If it is not enabled, it is always false. * + * @param {Token/TokenDocument} target + * @param {Object/boolean} [data=false] data existing flags data to use + * @return {boolean} + */ + static isItemPileLootable(target, data = false) { + return PileUtilities.isItemPileLootable(target, data); + } + + /** + * Whether an item pile is a vault. If it is not enabled, it is always false. + * + * @param {Token/TokenDocument} target + * @param {Object/boolean} [data=false] data existing flags data to use + * @return {boolean} + */ + static isItemPileVault(target, data = false) { + return PileUtilities.isItemPileVault(target, data); + } + + /** + * Whether an item pile is a merchant. If it is not enabled, it is always false. + * + * @param {Token/TokenDocument} target + * @param {Object/boolean} [data=false] data existing flags data to use + * @return {boolean} + */ + static isItemPileMerchant(target, data = false) { + return PileUtilities.isItemPileMerchant(target, data); + } + + /** + * Whether an item pile is a merchant. If it is not enabled, it is always false. + * + * @param {Token/TokenDocument} target + * @param {Object/boolean} [data=false] data existing flags data to use + * @return {boolean} + */ + static isItemPileAuctioneer(target, data = false) { + return PileUtilities.isItemPileAuctioneer(target, data); + } + + /** + * Whether an item pile is empty pile. If it is not enabled, it is always false. + * + * @param {Token/TokenDocument} target * @return {boolean} */ - static isItemPileContainer(target) { - return PileUtilities.isItemPileContainer(target); + static isItemPileEmpty(target) { + return PileUtilities.isItemPileEmpty(target); } /** diff --git a/src/constants/constants.js b/src/constants/constants.js index 6602342d..e514ab3c 100644 --- a/src/constants/constants.js +++ b/src/constants/constants.js @@ -75,7 +75,8 @@ const CONSTANTS = { PILE: "pile", CONTAINER: "container", MERCHANT: "merchant", - VAULT: "vault" + VAULT: "vault", + AUCTIONEER: "auctioneer", }, VAULT_LOGGING_TYPES: { diff --git a/src/helpers/pile-utilities.js b/src/helpers/pile-utilities.js index a701e8f8..bb50c337 100644 --- a/src/helpers/pile-utilities.js +++ b/src/helpers/pile-utilities.js @@ -129,6 +129,12 @@ export function isItemPileMerchant(target, data = false) { return pileData?.enabled && pileData?.type === CONSTANTS.PILE_TYPES.MERCHANT; } +export function isItemPileAuctioneer(target, data = false) { + const targetActor = Utilities.getActor(target); + const pileData = getActorFlagData(targetActor, data); + return pileData?.enabled && pileData?.type === CONSTANTS.PILE_TYPES.AUCTIONEER; +} + export function isItemPileClosed(target, data = false) { const targetActor = Utilities.getActor(target); const pileData = getActorFlagData(targetActor, data); diff --git a/src/helpers/utilities.js b/src/helpers/utilities.js index 87ddebb4..4ae3fb4c 100644 --- a/src/helpers/utilities.js +++ b/src/helpers/utilities.js @@ -132,6 +132,10 @@ export function refreshItemTypesThatCanStack() { getItemTypesThatCanStack(); } +/** + * Retrieve all system item types that can be stacked + * @returns {Set} The items type that can be stacked on this system + */ export function getItemTypesThatCanStack() { if (!itemTypesWithQuantities) {