New source found from dndbeyond.com

This commit is contained in:
2026-07-08 01:00:09 -07:00
parent 9a983a6d7b
commit dcefa0d2f2
2865 changed files with 222467 additions and 49053 deletions
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
};
import * as ApiAdapterUtils from "../apiAdapter/utils";
import { characterActions } from '../actions';
import { ContainerAccessors, ContainerGenerators, ContainerTypeEnum, ContainerUtils, ContainerValidators, } from '../engine/Container';
import { ContainerGenerators, ContainerTypeEnum, ContainerUtils, ContainerValidators, } from '../engine/Container';
import { EntityTypeEnum, DefaultCharacterName } from '../engine/Core';
import { DefinitionHacks } from '../engine/Definition';
import { HelperUtils } from '../engine/Helper';
@@ -19,6 +19,15 @@ import { ValueHacks } from '../engine/Value';
import { apiCreatorSelectors, characterSelectors, rulesEngineSelectors } from '../selectors';
import { getContainerManager } from './ContainerManager';
import { PartyManager } from './PartyManager';
let inventoryManager = null;
let itemShoppe = null;
export function getInventoryManager(params) {
if (inventoryManager) {
return inventoryManager;
}
inventoryManager = new InventoryManager(params);
return inventoryManager;
}
export class InventoryManager extends PartyManager {
constructor(params) {
super(params);
@@ -89,9 +98,11 @@ export class InventoryManager extends PartyManager {
this.dispatch(characterActions.customItemDestroy(ItemAccessors.getDefinitionId(item), ItemAccessors.getMappingId(item), isShared ? this.getPartyId() : null, this.handleAcceptOnSuccess(isShared, onSuccess)));
}
else {
const itemPlans = rulesEngineSelectors.getAvailableItemPlans(this.state);
const isContainer = ItemAccessors.isContainer(item);
const infusion = ItemAccessors.getInfusion(item);
this.dispatch(characterActions.itemDestroy(ItemAccessors.getMappingId(item), isContainer && infusion ? false : true, this.handleAcceptOnSuccess(isShared, onSuccess)));
const itemPlan = ItemUtils.getItemPlan(item, itemPlans);
this.dispatch(characterActions.itemDestroy(ItemAccessors.getMappingId(item), isContainer && (infusion || itemPlan) ? false : true, this.handleAcceptOnSuccess(isShared, onSuccess)));
}
};
/**
@@ -158,9 +169,19 @@ export class InventoryManager extends PartyManager {
this.dispatch(characterActions.itemCustomizationsDelete(ItemAccessors.getMappingId(item), ItemAccessors.getMappingEntityTypeId(item), isShared ? this.getPartyId() : null, this.handleAcceptOnSuccess(isShared, onSuccess)));
};
// Validators
this.canAddToContainer = (container) => {
const isShared = ContainerAccessors.isShared(container);
return !isShared || this.isSharingTurnedOn();
// check for party inventory restrictions for isClaimable if its a shared item
this.isClaimRestricted = (item) => {
const isShared = this.isShared(item);
if (!isShared) {
return false;
}
const partyInventoryRestrictions = ItemAccessors.getPartyInventoryRestrictions(item);
if ((partyInventoryRestrictions === null || partyInventoryRestrictions === void 0 ? void 0 : partyInventoryRestrictions.length) > 0) {
if (partyInventoryRestrictions.some((restriction) => !restriction.isClaimable && restriction.characterId !== rulesEngineSelectors.getId(this.state))) {
return true;
}
}
return false;
};
/**
* @deprecated
@@ -170,10 +191,7 @@ export class InventoryManager extends PartyManager {
const canEquip = ItemAccessors.canEquip(item);
const isEquipped = ItemAccessors.isEquipped(item);
if (isShared && canEquip) {
if (this.isSharingTurnedOn() || (this.isSharingTurnedDeleteOnly() && isEquipped)) {
return isEquipped ? this.isEquippedToCurrentCharacter(item) : true;
}
return false;
return isEquipped ? this.isEquippedToCurrentCharacter(item) : true;
}
return canEquip;
};
@@ -184,9 +202,6 @@ export class InventoryManager extends PartyManager {
const isAttuned = ItemAccessors.isAttuned(item);
if (!isAttuned) {
if (isShared) {
if (this.isSharingTurnedDeleteOnly()) {
return false;
}
return this.isEquippedToCurrentCharacter(item) && !hasMaxAttunedItems && canAttune;
}
return !hasMaxAttunedItems && canAttune;
@@ -199,30 +214,18 @@ export class InventoryManager extends PartyManager {
}
};
this.canModifyQuantity = (item) => {
const isShared = this.isShared(item);
const isStackable = ItemAccessors.isStackable(item);
if (isShared && isStackable) {
return this.isSharingTurnedOn();
}
return isStackable;
};
this.canCustomizeItem = (item) => {
const isShared = this.isShared(item);
if (isShared) {
return this.isSharingTurnedOn();
}
return true;
};
this.canUseItemCharges = (item) => {
const isShared = this.isShared(item);
if (isShared) {
return this.isSharingTurnedOn();
}
return !!ItemAccessors.getLimitedUse(item);
};
this.canRemoveItem = (item) => {
const isShared = this.isShared(item);
if (isShared) {
if (this.isClaimRestricted(item)) {
return false;
}
const infusion = ItemAccessors.getInfusion(item);
if (infusion) {
const infusionCharacterId = InfusionAccessors.getCharacterId(infusion);
@@ -230,16 +233,22 @@ export class InventoryManager extends PartyManager {
return false;
}
}
return ItemAccessors.isEquipped(item)
? this.isSharingTurnedOnOrDeleteOnly() && this.isEquippedToCurrentCharacter(item)
: this.isSharingTurnedOnOrDeleteOnly();
return ItemAccessors.isEquipped(item) ? this.isEquippedToCurrentCharacter(item) : true;
}
return true;
};
this.canMoveItem = (item) => {
// If you are changing this, you may want to change the canRemoveItem above
const isContainer = ItemAccessors.isContainer(item);
if (isContainer) {
return false;
}
const isShared = this.isShared(item);
if (isShared) {
if (this.isClaimRestricted(item)) {
return false;
}
//Might be able to remove this in favor of the above restriction check
const infusion = ItemAccessors.getInfusion(item);
if (infusion) {
const infusionCharacterId = InfusionAccessors.getCharacterId(infusion);
@@ -247,26 +256,23 @@ export class InventoryManager extends PartyManager {
return false;
}
}
return ItemAccessors.isEquipped(item)
? this.isSharingTurnedOnOrDeleteOnly() && this.isEquippedToCurrentCharacter(item)
: this.isSharingTurnedOnOrDeleteOnly();
}
else if (this.isSharingTurnedDeleteOnly()) {
const localContainers = rulesEngineSelectors.getCharacterInventoryContainers(this.state);
return localContainers.length > 1;
return ItemAccessors.isEquipped(item) ? this.isEquippedToCurrentCharacter(item) : true;
}
const containerLookup = rulesEngineSelectors.getContainerLookup(this.state);
return Object.keys(containerLookup).length > 1;
};
this.canShareItem = (item) => {
//Can a container item be moved into the party inventory?
this.canShareContainer = (item) => {
//check that the item is a container
const isContainer = ItemAccessors.isContainer(item);
if (!isContainer) {
return false;
}
const isShared = this.isShared(item);
return !isShared && this.isSharingTurnedOn();
return !isShared;
};
this.canClaimItem = (item) => {
//Can a container item be "claimed" out of the party inventory?
this.canClaimContainer = (item) => {
const isContainer = ItemAccessors.isContainer(item);
if (!isContainer || (ItemAccessors.isEquipped(item) && !this.isEquippedToCurrentCharacter(item))) {
return false;
@@ -278,6 +284,9 @@ export class InventoryManager extends PartyManager {
const definitionKey = DefinitionHacks.hack__generateDefinitionKey(EntityTypeEnum.ITEM, ItemAccessors.getMappingId(item));
const container = HelperUtils.lookupDataOrFallback(containerLookup, definitionKey);
if (container) {
if (this.isClaimRestricted(item)) {
return false;
}
const infusion = ItemAccessors.getInfusion(item);
if (infusion) {
const infusionCharacterId = InfusionAccessors.getCharacterId(infusion);
@@ -292,7 +301,7 @@ export class InventoryManager extends PartyManager {
return false;
}
}
return this.isSharingTurnedOnOrDeleteOnly();
return true;
}
return false;
};
@@ -370,6 +379,11 @@ export class InventoryManager extends PartyManager {
getInventoryShoppe({ onSuccess, additionalApiConfig, }) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
// If we already have the item shoppe, return it
if (itemShoppe) {
onSuccess(itemShoppe);
return itemShoppe;
}
const characterId = characterSelectors.getId(this.state);
const loadItems = apiCreatorSelectors.makeLoadAvailableItems(this.state);
//set up pagination params
@@ -404,6 +418,7 @@ export class InventoryManager extends PartyManager {
const ruleData = rulesEngineSelectors.getRuleData(this.state);
const shoppeContainer = ContainerGenerators.generateContainer(-1, ContainerTypeEnum.SHOPPE, 'Item Shoppe', transformedItems, false, null, null, characterId, null, ruleData);
const shoppeManager = getContainerManager(Object.assign(Object.assign({}, this.params), { container: shoppeContainer, overrideItems: transformedItems }));
itemShoppe = shoppeManager;
onSuccess(shoppeManager);
return shoppeManager;
});