New source found from dndbeyond.com
This commit is contained in:
@@ -2,11 +2,10 @@ import { call, put, select } from 'redux-saga/effects';
|
||||
import { characterActions, serviceDataActions } from '../../actions';
|
||||
import { ApiRequests } from '../../api';
|
||||
import * as apiShared from '../../api/requests';
|
||||
import { CampaignAccessors, PartyInventorySharingStateEnum } from '../../engine/Campaign';
|
||||
import { CampaignAccessors } from '../../engine/Campaign';
|
||||
import { CreatureAccessors } from '../../engine/Creature';
|
||||
import { DefinitionAccessors, DefinitionTypeEnum, DefinitionUtils } from '../../engine/Definition';
|
||||
import { DefinitionPoolUtils } from '../../engine/DefinitionPool';
|
||||
import { FeatureFlagEnum, FeatureFlagInfoUtils } from '../../engine/FeatureFlagInfo';
|
||||
import { HelperUtils } from '../../engine/Helper';
|
||||
import { InfusionAccessors, InfusionTypeEnum } from '../../engine/Infusion';
|
||||
import { InfusionChoiceAccessors } from '../../engine/InfusionChoice';
|
||||
@@ -17,7 +16,7 @@ import { VehicleAccessors, VehicleSimulators } from '../../engine/Vehicle';
|
||||
import { VehicleComponentAccessors } from '../../engine/VehicleComponent';
|
||||
import { initialCoinState } from '../../reducers/character';
|
||||
import * as SagaHelpers from '../../sagas/SagaHelpers';
|
||||
import { characterSelectors, featureFlagInfoSelectors, rulesEngineSelectors, serviceDataSelectors, } from '../../selectors';
|
||||
import { characterSelectors, rulesEngineSelectors, serviceDataSelectors, } from '../../selectors';
|
||||
import { TypeScriptUtils } from '../../utils';
|
||||
import { callCommitAction } from '../../utils/ReduxActionUtils';
|
||||
import { apiCreatureCreate, apiItemsCreate, handleLoadDefinitions } from '../character/handlers';
|
||||
@@ -95,6 +94,8 @@ export function* handleInfusionCreate(action) {
|
||||
entityId: itemId,
|
||||
entityTypeId: itemEntityTypeId,
|
||||
quantity: 1,
|
||||
originEntityId: null,
|
||||
originEntityTypeId: null,
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -165,14 +166,15 @@ export function* handleInfusionDestroy(action) {
|
||||
//if infused item is a REPLICATE type remove the item from inventory
|
||||
//otherwise leave the item but un-attune and reset charges
|
||||
if (infusionType === InfusionTypeEnum.REPLICATE && inventoryMappingId !== null) {
|
||||
yield put(characterActions.itemRemove(inventoryMappingId, true));
|
||||
yield put(characterActions.itemDestroy(inventoryMappingId, true, action.meta.accept, action.meta.reject));
|
||||
// Mapping was removed on the backend due to being an item
|
||||
// Only call commit action to mirror backend
|
||||
yield put(callCommitAction(serviceDataActions.infusionMappingRemove, action.payload.infusionId, action.payload.inventoryMappingId));
|
||||
}
|
||||
else {
|
||||
const inventoryLookup = yield select(rulesEngineSelectors.getInventoryLookup);
|
||||
const foundItem = HelperUtils.lookupDataOrFallback(inventoryLookup, action.payload.inventoryMappingId);
|
||||
const partyInventoryLookup = yield select(rulesEngineSelectors.getPartyInventoryLookup);
|
||||
const foundItem = HelperUtils.lookupDataOrFallback(Object.assign(Object.assign({}, inventoryLookup), partyInventoryLookup), action.payload.inventoryMappingId);
|
||||
if (foundItem) {
|
||||
if (ItemAccessors.isAttuned(foundItem)) {
|
||||
yield put(characterActions.itemAttuneSet(inventoryMappingId, false));
|
||||
@@ -182,6 +184,9 @@ export function* handleInfusionDestroy(action) {
|
||||
// TODO IMS Infusions come back here and switch this out
|
||||
yield put(characterActions.itemChargesSet(ItemAccessors.getMappingId(foundItem), 0));
|
||||
}
|
||||
if (action.meta.accept) {
|
||||
action.meta.accept();
|
||||
}
|
||||
}
|
||||
yield put(serviceDataActions.infusionMappingRemove(action.payload.infusionId, action.payload.inventoryMappingId));
|
||||
}
|
||||
@@ -244,31 +249,27 @@ export function* handleVehicleRemove(action) {
|
||||
}
|
||||
export function* handlePartyInventoryRequest(action) {
|
||||
var _a, _b, _c, _d, _e, _f;
|
||||
const featureFlagInfo = yield select(featureFlagInfoSelectors.getFeatureFlagInfo);
|
||||
const partyFlag = FeatureFlagInfoUtils.getFeatureFlagInfoValue(FeatureFlagEnum.RELEASE_GATE_IMS, featureFlagInfo);
|
||||
// Party Inventory
|
||||
if (partyFlag) {
|
||||
const campaignInfo = yield select(characterSelectors.getCampaign);
|
||||
if (campaignInfo) {
|
||||
const data = yield call(SagaHelpers.getApiRequestData, apiShared.getPartyInventory, { campaignId: CampaignAccessors.getId(campaignInfo) });
|
||||
// This sets the data in the serviceData.partyInfo state
|
||||
yield put(serviceDataActions.partyCampaignInfoSet(Object.assign(Object.assign({}, campaignInfo), { sharingState: (_a = data === null || data === void 0 ? void 0 : data.sharingState) !== null && _a !== void 0 ? _a : PartyInventorySharingStateEnum.OFF, partyInventory: (_b = data === null || data === void 0 ? void 0 : data.partyItems) !== null && _b !== void 0 ? _b : [], spells: (_c = data === null || data === void 0 ? void 0 : data.spells) !== null && _c !== void 0 ? _c : null, modifiers: (_d = data === null || data === void 0 ? void 0 : data.modifiers) !== null && _d !== void 0 ? _d : null, coin: (_e = data === null || data === void 0 ? void 0 : data.currency) !== null && _e !== void 0 ? _e : initialCoinState })));
|
||||
yield call(handleUpdatePartyInventoryValues, data);
|
||||
// Party infusions set into serviceData
|
||||
if ((_f = data.partyInfusions) === null || _f === void 0 ? void 0 : _f.length) {
|
||||
let infusionDefinitionIds = new Set();
|
||||
for (let i = 0; i < data.partyInfusions.length; i++) {
|
||||
const mapping = data.partyInfusions[i];
|
||||
yield put(callCommitAction(serviceDataActions.infusionMappingAdd, mapping));
|
||||
const definitionKey = InfusionAccessors.getDefinitionKey(mapping);
|
||||
if (definitionKey !== null) {
|
||||
infusionDefinitionIds.add(DefinitionUtils.getDefinitionKeyId(definitionKey));
|
||||
}
|
||||
}
|
||||
if (infusionDefinitionIds.size > 0) {
|
||||
yield call(handleLoadDefinitions, DefinitionTypeEnum.INFUSION, Array.from(infusionDefinitionIds));
|
||||
const campaignInfo = yield select(characterSelectors.getCampaign);
|
||||
if (campaignInfo) {
|
||||
const data = yield call(SagaHelpers.getApiRequestData, apiShared.getPartyInventory, { campaignId: CampaignAccessors.getId(campaignInfo) });
|
||||
// This sets the data in the serviceData.partyInfo state
|
||||
yield put(serviceDataActions.partyCampaignInfoSet(Object.assign(Object.assign({}, campaignInfo), { partyInventory: (_a = data === null || data === void 0 ? void 0 : data.partyItems) !== null && _a !== void 0 ? _a : [], spells: (_b = data === null || data === void 0 ? void 0 : data.spells) !== null && _b !== void 0 ? _b : null, modifiers: (_c = data === null || data === void 0 ? void 0 : data.modifiers) !== null && _c !== void 0 ? _c : null, coin: (_d = data === null || data === void 0 ? void 0 : data.currency) !== null && _d !== void 0 ? _d : initialCoinState, partyRestrictions: (_e = data === null || data === void 0 ? void 0 : data.partyRestrictions) !== null && _e !== void 0 ? _e : [] })));
|
||||
yield call(handleUpdatePartyInventoryValues, data);
|
||||
// Party infusions set into serviceData
|
||||
if ((_f = data.partyInfusions) === null || _f === void 0 ? void 0 : _f.length) {
|
||||
let infusionDefinitionIds = new Set();
|
||||
for (let i = 0; i < data.partyInfusions.length; i++) {
|
||||
const mapping = data.partyInfusions[i];
|
||||
yield put(callCommitAction(serviceDataActions.infusionMappingAdd, mapping));
|
||||
const definitionKey = InfusionAccessors.getDefinitionKey(mapping);
|
||||
if (definitionKey !== null) {
|
||||
infusionDefinitionIds.add(DefinitionUtils.getDefinitionKeyId(definitionKey));
|
||||
}
|
||||
}
|
||||
if (infusionDefinitionIds.size > 0) {
|
||||
yield call(handleLoadDefinitions, DefinitionTypeEnum.INFUSION, Array.from(infusionDefinitionIds));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user