diff --git a/src/Redux/Store/Expeditions/Expeditions/helpers/convertExpeditionFromConfig.ts b/src/Redux/Store/Expeditions/Expeditions/helpers/convertExpeditionFromConfig.ts
index d233df88..70a41ea2 100644
--- a/src/Redux/Store/Expeditions/Expeditions/helpers/convertExpeditionFromConfig.ts
+++ b/src/Redux/Store/Expeditions/Expeditions/helpers/convertExpeditionFromConfig.ts
@@ -32,7 +32,9 @@ export const convertExpeditionFromConfig = (
...config.settingsSnapshotConfig,
usedExpansions: determineUsedExpansions(
state,
- config.settingsSnapshotConfig
+ config.settingsSnapshotConfig,
+ config.sequenceConfig.branches,
+ config.initialBarracksConfig
),
},
sequence: {
diff --git a/src/Redux/Store/Expeditions/Expeditions/migrations/__test__/__snapshots__/migrations.test.ts.snap b/src/Redux/Store/Expeditions/Expeditions/migrations/__test__/__snapshots__/migrations.test.ts.snap
index fd233eee..34105bd0 100644
--- a/src/Redux/Store/Expeditions/Expeditions/migrations/__test__/__snapshots__/migrations.test.ts.snap
+++ b/src/Redux/Store/Expeditions/Expeditions/migrations/__test__/__snapshots__/migrations.test.ts.snap
@@ -581,7 +581,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
- "ids": Array [],
+ "type": "regular",
},
"tier": 3,
"treasure": Object {
@@ -600,7 +600,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": false,
- "ids": Array [],
+ "type": "regular",
},
"tier": 1,
"treasure": Object {
@@ -634,7 +634,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
- "ids": Array [],
+ "type": "regular",
},
"tier": 2,
"treasure": Object {
@@ -653,7 +653,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
- "ids": Array [],
+ "type": "regular",
},
"tier": 4,
"treasure": Object {
@@ -1051,7 +1051,6 @@ Object {
],
},
"upgradedBasicNemesisCards": Array [],
- "variantId": "DEFAULT",
},
"HPEBVeG9": Object {
"banished": Array [],
@@ -1352,7 +1351,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
- "ids": Array [],
+ "type": "regular",
},
"tier": 3,
"treasure": Object {
@@ -1371,7 +1370,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
- "ids": Array [],
+ "type": "regular",
},
"tier": 4,
"treasure": Object {
@@ -1389,7 +1388,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": false,
- "ids": Array [],
+ "type": "regular",
},
"tier": 1,
"treasure": Object {
@@ -1408,7 +1407,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
- "ids": Array [],
+ "type": "regular",
},
"tier": 2,
"treasure": Object {
@@ -1807,7 +1806,6 @@ Object {
],
},
"upgradedBasicNemesisCards": Array [],
- "variantId": "DEFAULT",
},
"V884fJ4MT": Object {
"banished": Array [],
@@ -2115,7 +2113,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
- "ids": Array [],
+ "type": "regular",
},
"tier": 2,
"treasure": Object {
@@ -2134,7 +2132,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
- "ids": Array [],
+ "type": "regular",
},
"tier": 3,
"treasure": Object {
@@ -2153,7 +2151,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
- "ids": Array [],
+ "type": "regular",
},
"tier": 4,
"treasure": Object {
@@ -2551,7 +2549,6 @@ Object {
],
},
"upgradedBasicNemesisCards": Array [],
- "variantId": "SHORT",
},
"WITHOUT_SNAPSHOT": Object {
"banished": Array [],
@@ -2859,7 +2856,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
- "ids": Array [],
+ "type": "regular",
},
"tier": 2,
"treasure": Object {
@@ -2878,7 +2875,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
- "ids": Array [],
+ "type": "regular",
},
"tier": 3,
"treasure": Object {
@@ -2897,7 +2894,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
- "ids": Array [],
+ "type": "regular",
},
"tier": 4,
"treasure": Object {
@@ -3295,7 +3292,6 @@ Object {
],
},
"upgradedBasicNemesisCards": Array [],
- "variantId": "SHORT",
},
},
}
diff --git a/src/Redux/Store/Expeditions/Expeditions/migrations/__test__/migrateToExpeditionDSL.test.ts b/src/Redux/Store/Expeditions/Expeditions/migrations/__test__/migrateToExpeditionDSL.test.ts
index bc853703..4337adee 100644
--- a/src/Redux/Store/Expeditions/Expeditions/migrations/__test__/migrateToExpeditionDSL.test.ts
+++ b/src/Redux/Store/Expeditions/Expeditions/migrations/__test__/migrateToExpeditionDSL.test.ts
@@ -13,6 +13,7 @@ describe('migrateToExpeditionDSL()', () => {
name: 'Oldstyle',
migrationVersion: 2020030301,
score: 6,
+ bigPocketVariant: false,
seed: {
seed: 'OLD_STYLE',
supplyState: true,
@@ -106,8 +107,6 @@ describe('migrateToExpeditionDSL()', () => {
},
upgradedBasicNemesisCards: [],
banished: ['VimDynamo', 'FocusingOrb', 'Tethered Darts'],
- variantId: 'DEFAULT',
- bigPocketVariant: false,
finished: false,
sequence: {
firstBranchId: 'fHFX3VH99',
@@ -121,7 +120,7 @@ describe('migrateToExpeditionDSL()', () => {
config: {
tier: 1,
newUBNCards: {
- ids: [],
+ type: 'regular',
addRandom: false,
},
treasure: {
@@ -131,6 +130,7 @@ describe('migrateToExpeditionDSL()', () => {
},
status: 'finished',
tries: 1,
+ // @ts-ignore disable-line
rewards: {
treasure: [
'GexsShatteredGeode',
@@ -150,7 +150,7 @@ describe('migrateToExpeditionDSL()', () => {
config: {
tier: 2,
newUBNCards: {
- ids: [],
+ type: 'regular',
addRandom: true,
},
treasure: {
@@ -169,7 +169,7 @@ describe('migrateToExpeditionDSL()', () => {
config: {
tier: 3,
newUBNCards: {
- ids: [],
+ type: 'regular',
addRandom: true,
},
treasure: {
@@ -182,12 +182,13 @@ describe('migrateToExpeditionDSL()', () => {
},
y0gQDPjY5: {
id: 'y0gQDPjY5',
+ nextBranchId: undefined,
type: 'battle',
expeditionId: 'OLD_STYLE',
config: {
tier: 4,
newUBNCards: {
- ids: [],
+ type: 'regular',
addRandom: true,
},
treasure: {
diff --git a/src/Redux/Store/Expeditions/Expeditions/migrations/migrateToExpeditionDSL.ts b/src/Redux/Store/Expeditions/Expeditions/migrations/migrateToExpeditionDSL.ts
index b8adf799..609e3b6d 100644
--- a/src/Redux/Store/Expeditions/Expeditions/migrations/migrateToExpeditionDSL.ts
+++ b/src/Redux/Store/Expeditions/Expeditions/migrations/migrateToExpeditionDSL.ts
@@ -6,12 +6,10 @@ export const migrateToExpeditionDSL = (
expedition: types.OldStyleExpedition
) => {
const { battles, ...expeditionProps } = expedition
-
- const bigPocketVariantConfig = expeditionProps.bigPocketVariant
+ const { variantId, ...actualProps } = expeditionProps
return {
- ...expeditionProps,
- bigPocketVariantConfig,
+ ...actualProps,
sequence: {
firstBranchId: battles[0].id,
branches: battles.reduce((acc, battle, index) => {
@@ -26,7 +24,7 @@ export const migrateToExpeditionDSL = (
config: {
tier: nemesisTier.tier,
newUBNCards: {
- ids: [],
+ type: 'regular',
addRandom: nemesisTier.isNewTier,
},
treasure,
diff --git a/src/Redux/Store/Expeditions/Expeditions/sideEffects/createExpeditionConfig/handleExistingConfig.ts b/src/Redux/Store/Expeditions/Expeditions/sideEffects/createExpeditionConfig/handleExistingConfig.ts
index bcf76b04..af152be2 100644
--- a/src/Redux/Store/Expeditions/Expeditions/sideEffects/createExpeditionConfig/handleExistingConfig.ts
+++ b/src/Redux/Store/Expeditions/Expeditions/sideEffects/createExpeditionConfig/handleExistingConfig.ts
@@ -45,11 +45,14 @@ export const handleExistingConfig = (
// because 'convertExpeditionFromConfig' already calculates the
// 'usedExpansions' property. Technically we would only have to
// check the market setup which was chosen
- const settingsSnapshot = createSettingsSnapshot(
- state,
- expeditionConfig.settingsSnapshotConfig,
- marketId
- )
+ const settingsSnapshot = {
+ ...createSettingsSnapshot(
+ state,
+ expeditionConfig.settingsSnapshotConfig,
+ marketId
+ ),
+ usedExpansions: baseExpedition.settingsSnapshot.usedExpansions,
+ }
///////////////////////////
// Content randomziation //
diff --git a/src/Redux/Store/Expeditions/Expeditions/sideEffects/createSettingsSnapshot/determineUsedExpansions.ts b/src/Redux/Store/Expeditions/Expeditions/sideEffects/createSettingsSnapshot/determineUsedExpansions.ts
index 33200c5b..c485bab5 100644
--- a/src/Redux/Store/Expeditions/Expeditions/sideEffects/createSettingsSnapshot/determineUsedExpansions.ts
+++ b/src/Redux/Store/Expeditions/Expeditions/sideEffects/createSettingsSnapshot/determineUsedExpansions.ts
@@ -6,13 +6,177 @@ import { SelectedNemesesLookupStateSlice } from 'Redux/Store/Settings/Expansions
import { TreasuresStateSlice } from 'Redux/Store/Settings/Expansions/Treasures'
import { UpgradedBasicNemesisCardsStateSlice } from 'Redux/Store/Settings/Expansions/UpgradedBasicNemesisCards'
+const getFixIdsFromRewardsConfig = (config: types.RewardsConfig) => {
+ return {
+ cardIds:
+ config.type === 'custom' && config.supply && config.supply.ids
+ ? config.supply.ids.filter((id): id is string => typeof id === 'string')
+ : [],
+ treasureIds:
+ config.type === 'custom' && config.treasure && config.treasure.ids
+ ? config.treasure.ids.filter(
+ (id): id is string => typeof id === 'string'
+ )
+ : [],
+ mageIds:
+ config.type === 'custom' && config.mage && config.mage.ids
+ ? config.mage.ids.filter((id): id is string => typeof id === 'string')
+ : [],
+ }
+}
+
+// TODO add tests + refactor
+const getFixIdsFromSequenceBranches = (
+ branches?: types.BranchesConfig
+): {
+ cardIds: string[]
+ mageIds: string[]
+ nemesisIds: string[]
+ treasureIds: string[]
+ upgradedBasicNemesisIds: string[]
+} => {
+ if (!branches) {
+ return {
+ cardIds: [],
+ mageIds: [],
+ nemesisIds: [],
+ treasureIds: [],
+ upgradedBasicNemesisIds: [],
+ }
+ }
+
+ const branchConfigs = Object.values(branches)
+
+ return branchConfigs.reduce(
+ (
+ acc: {
+ cardIds: string[]
+ mageIds: string[]
+ nemesisIds: string[]
+ treasureIds: string[]
+ upgradedBasicNemesisIds: string[]
+ },
+ config
+ ) => {
+ const defaultResult = {
+ cardIds: [],
+ treasureIds: [],
+ mageIds: [],
+ }
+
+ switch (config.type) {
+ case 'battle': {
+ const {
+ nemesisId,
+ lossRewards,
+ winRewards,
+ newUBNCards,
+ } = config.config
+
+ const fromLossRewards =
+ lossRewards && lossRewards.length > 0
+ ? lossRewards.reduce(
+ (
+ acc: {
+ cardIds: string[]
+ treasureIds: string[]
+ mageIds: string[]
+ },
+ rewards
+ ) => {
+ if (rewards.type === 'custom') {
+ const fromConfig = getFixIdsFromRewardsConfig(rewards)
+
+ return {
+ cardIds: [...acc.cardIds, ...fromConfig.cardIds],
+ treasureIds: [
+ ...acc.treasureIds,
+ ...fromConfig.treasureIds,
+ ],
+ mageIds: [...acc.mageIds, ...fromConfig.mageIds],
+ }
+ } else {
+ return acc
+ }
+ },
+ defaultResult
+ )
+ : defaultResult
+
+ const fromWinRewards = (() => {
+ if (winRewards && winRewards.type === 'custom') {
+ const fromConfig = getFixIdsFromRewardsConfig(winRewards)
+
+ return {
+ cardIds: [...acc.cardIds, ...fromConfig.cardIds],
+ treasureIds: [...acc.treasureIds, ...fromConfig.treasureIds],
+ mageIds: [...acc.mageIds, ...fromConfig.mageIds],
+ }
+ }
+
+ return defaultResult
+ })()
+
+ const fromNewUBNCards =
+ newUBNCards && newUBNCards.type === 'custom' ? newUBNCards.ids : []
+
+ return {
+ ...acc,
+ cardIds: [
+ ...acc.cardIds,
+ ...fromLossRewards.cardIds,
+ ...fromWinRewards.cardIds,
+ ],
+ mageIds: [
+ ...acc.mageIds,
+ ...fromLossRewards.mageIds,
+ ...fromWinRewards.mageIds,
+ ],
+ nemesisIds: [...acc.nemesisIds, ...(nemesisId ? [nemesisId] : [])],
+ upgradedBasicNemesisIds: fromNewUBNCards,
+ treasureIds: [
+ ...acc.treasureIds,
+ ...fromLossRewards.treasureIds,
+ ...fromWinRewards.treasureIds,
+ ],
+ }
+ }
+
+ case 'reward': {
+ const fromConfig = getFixIdsFromRewardsConfig(config.config)
+ return {
+ ...acc,
+ cardIds: [...acc.cardIds, ...fromConfig.cardIds],
+ mageIds: [...acc.mageIds, ...fromConfig.mageIds],
+ treasureIds: [...acc.treasureIds, ...fromConfig.treasureIds],
+ }
+ }
+
+ case 'narrative':
+ default: {
+ return acc
+ }
+ }
+ },
+ {
+ cardIds: [],
+ mageIds: [],
+ nemesisIds: [],
+ treasureIds: [],
+ upgradedBasicNemesisIds: [],
+ }
+ )
+}
+
export const determineUsedExpansions = (
state: SelectedCardsLookupStateSlice &
SelectedMagesLookupStateSlice &
SelectedNemesesLookupStateSlice &
TreasuresStateSlice &
UpgradedBasicNemesisCardsStateSlice,
- settingsSnapshot: Omit
The following error was encountered:
@@ -122,14 +130,6 @@ const ConfigImport = ({ configImportHandler }: Props) => {
inputProps={{ accept: '.json' }}
onChange={handleFileUpload}
/>
-