Skip to content

Commit

Permalink
FEATURE: Improve usedExpansions calculation and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
on3iro committed May 23, 2020
1 parent 921edd2 commit c10f81c
Show file tree
Hide file tree
Showing 7 changed files with 240 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export const convertExpeditionFromConfig = (
...config.settingsSnapshotConfig,
usedExpansions: determineUsedExpansions(
state,
config.settingsSnapshotConfig
config.settingsSnapshotConfig,
config.sequenceConfig.branches,
config.initialBarracksConfig
),
},
sequence: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
"ids": Array [],
"type": "regular",
},
"tier": 3,
"treasure": Object {
Expand All @@ -600,7 +600,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": false,
"ids": Array [],
"type": "regular",
},
"tier": 1,
"treasure": Object {
Expand Down Expand Up @@ -634,7 +634,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
"ids": Array [],
"type": "regular",
},
"tier": 2,
"treasure": Object {
Expand All @@ -653,7 +653,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
"ids": Array [],
"type": "regular",
},
"tier": 4,
"treasure": Object {
Expand Down Expand Up @@ -1051,7 +1051,6 @@ Object {
],
},
"upgradedBasicNemesisCards": Array [],
"variantId": "DEFAULT",
},
"HPEBVeG9": Object {
"banished": Array [],
Expand Down Expand Up @@ -1352,7 +1351,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
"ids": Array [],
"type": "regular",
},
"tier": 3,
"treasure": Object {
Expand All @@ -1371,7 +1370,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
"ids": Array [],
"type": "regular",
},
"tier": 4,
"treasure": Object {
Expand All @@ -1389,7 +1388,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": false,
"ids": Array [],
"type": "regular",
},
"tier": 1,
"treasure": Object {
Expand All @@ -1408,7 +1407,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
"ids": Array [],
"type": "regular",
},
"tier": 2,
"treasure": Object {
Expand Down Expand Up @@ -1807,7 +1806,6 @@ Object {
],
},
"upgradedBasicNemesisCards": Array [],
"variantId": "DEFAULT",
},
"V884fJ4MT": Object {
"banished": Array [],
Expand Down Expand Up @@ -2115,7 +2113,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
"ids": Array [],
"type": "regular",
},
"tier": 2,
"treasure": Object {
Expand All @@ -2134,7 +2132,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
"ids": Array [],
"type": "regular",
},
"tier": 3,
"treasure": Object {
Expand All @@ -2153,7 +2151,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
"ids": Array [],
"type": "regular",
},
"tier": 4,
"treasure": Object {
Expand Down Expand Up @@ -2551,7 +2549,6 @@ Object {
],
},
"upgradedBasicNemesisCards": Array [],
"variantId": "SHORT",
},
"WITHOUT_SNAPSHOT": Object {
"banished": Array [],
Expand Down Expand Up @@ -2859,7 +2856,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
"ids": Array [],
"type": "regular",
},
"tier": 2,
"treasure": Object {
Expand All @@ -2878,7 +2875,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
"ids": Array [],
"type": "regular",
},
"tier": 3,
"treasure": Object {
Expand All @@ -2897,7 +2894,7 @@ Object {
"config": Object {
"newUBNCards": Object {
"addRandom": true,
"ids": Array [],
"type": "regular",
},
"tier": 4,
"treasure": Object {
Expand Down Expand Up @@ -3295,7 +3292,6 @@ Object {
],
},
"upgradedBasicNemesisCards": Array [],
"variantId": "SHORT",
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('migrateToExpeditionDSL()', () => {
name: 'Oldstyle',
migrationVersion: 2020030301,
score: 6,
bigPocketVariant: false,
seed: {
seed: 'OLD_STYLE',
supplyState: true,
Expand Down Expand Up @@ -106,8 +107,6 @@ describe('migrateToExpeditionDSL()', () => {
},
upgradedBasicNemesisCards: [],
banished: ['VimDynamo', 'FocusingOrb', 'Tethered Darts'],
variantId: 'DEFAULT',
bigPocketVariant: false,
finished: false,
sequence: {
firstBranchId: 'fHFX3VH99',
Expand All @@ -121,7 +120,7 @@ describe('migrateToExpeditionDSL()', () => {
config: {
tier: 1,
newUBNCards: {
ids: [],
type: 'regular',
addRandom: false,
},
treasure: {
Expand All @@ -131,6 +130,7 @@ describe('migrateToExpeditionDSL()', () => {
},
status: 'finished',
tries: 1,
// @ts-ignore disable-line
rewards: {
treasure: [
'GexsShatteredGeode',
Expand All @@ -150,7 +150,7 @@ describe('migrateToExpeditionDSL()', () => {
config: {
tier: 2,
newUBNCards: {
ids: [],
type: 'regular',
addRandom: true,
},
treasure: {
Expand All @@ -169,7 +169,7 @@ describe('migrateToExpeditionDSL()', () => {
config: {
tier: 3,
newUBNCards: {
ids: [],
type: 'regular',
addRandom: true,
},
treasure: {
Expand All @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -26,7 +24,7 @@ export const migrateToExpeditionDSL = (
config: {
tier: nemesisTier.tier,
newUBNCards: {
ids: [],
type: 'regular',
addRandom: nemesisTier.isNewTier,
},
treasure,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 //
Expand Down
Loading

0 comments on commit c10f81c

Please sign in to comment.