diff --git a/cypress/integration/Settings/SupplySetups/creationAndRunThrough.spec.ts b/cypress/integration/Settings/SupplySetups/creationAndRunThrough.spec.ts index daa1086c..b0e8e692 100644 --- a/cypress/integration/Settings/SupplySetups/creationAndRunThrough.spec.ts +++ b/cypress/integration/Settings/SupplySetups/creationAndRunThrough.spec.ts @@ -103,7 +103,7 @@ describe('Custom Supply Setup creation and run through', () => { // Should be a Gem with operation ANY cy.get('[data-test=select-type]') .find('input') - .should('have.attr', 'value', 'Gem') + .should('have.attr', 'value', 'ANY') cy.get('[data-test=select-operation]') .find('input') .should('have.attr', 'value', 'ANY') @@ -352,37 +352,37 @@ describe('Custom Supply Setup creation and run through', () => { .find('li') .eq(0) .should('have.attr', 'type', 'gem') - .should('contain', 'ANY') - .closest('[data-test=supply-setup-wrapper]') - .find('li') - .eq(1) - .should('have.attr', 'type', 'gem') .should('contain', '< 4') .closest('[data-test=supply-setup-wrapper]') .find('li') - .eq(2) + .eq(1) .should('have.attr', 'type', 'gem') .should('contain', '> 5') .closest('[data-test=supply-setup-wrapper]') .find('li') - .eq(3) + .eq(2) .should('have.attr', 'type', 'relic') .should('contain', '<= 2') .closest('[data-test=supply-setup-wrapper]') .find('li') - .eq(4) + .eq(3) .should('have.attr', 'type', 'relic') .should('contain', '5') .closest('[data-test=supply-setup-wrapper]') .find('li') - .eq(5) + .eq(4) .should('have.attr', 'type', 'spell') .should('contain', '3/5') .closest('[data-test=supply-setup-wrapper]') .find('li') - .eq(6) + .eq(5) .should('have.attr', 'type', 'spell') .should('contain', '>= 8') + .closest('[data-test=supply-setup-wrapper]') + .find('li') + .eq(6) + .should('have.attr', 'type', 'any') + .should('contain', 'ANY') }) it('should role correct cards for the created custom supply setup', () => { @@ -394,16 +394,13 @@ describe('Custom Supply Setup creation and run through', () => { .should('exist') .click() cy.get('[data-test=btn-create-market]').click() - cy.get('[data-test=market-tile-gem]').should('have.length', 3) - cy.get('[data-test=market-tile-relic]').should('have.length', 2) - cy.get('[data-test=market-tile-spell]').should('have.length', 2) cy.get('[data-test=market-tile-gem]') .eq(0) .find('[data-test=market-tile-cost] span') .invoke('text') .then(value => expect(parseInt(value)).to.be.lt(4)) cy.get('[data-test=market-tile-gem]') - .eq(2) + .eq(1) .find('[data-test=market-tile-cost] span') .invoke('text') .then(value => expect(parseInt(value)).to.be.gt(5)) @@ -422,10 +419,6 @@ describe('Custom Supply Setup creation and run through', () => { .find('[data-test=market-tile-cost] span') .invoke('text') .then(value => expect(parseInt(value)).to.be.oneOf([3, 5])) - cy.get('[data-test=market-tile-spell]') - .eq(1) - .find('[data-test=market-tile-cost] span') - .invoke('text') - .then(value => expect(parseInt(value)).to.be.gte(8)) + // FIXME find good way to test ANY type and ANY operation }) }) diff --git a/package.json b/package.json index 21687f14..086d1789 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "@types/seedrandom": "^2.4.28", "@types/shortid": "^0.0.29", "aer-data": "^2.0.0", - "aer-types": "^1.0.4", + "aer-types": "^1.0.11", "ajv": "^6.12.0", "classnames": "^2.2.6", "core-js": "^3.2.1", diff --git a/src/Redux/Store/Expeditions/Expeditions/sideEffects/helpers.ts b/src/Redux/Store/Expeditions/Expeditions/sideEffects/helpers.ts index 64a61791..3603f786 100644 --- a/src/Redux/Store/Expeditions/Expeditions/sideEffects/helpers.ts +++ b/src/Redux/Store/Expeditions/Expeditions/sideEffects/helpers.ts @@ -50,6 +50,7 @@ export const getSupplyIds = ({ Relic: types.ICard[] Spell: types.ICard[] EMPTY: never[] + ANY: never[] } }) => { const baseResult = { @@ -242,6 +243,7 @@ export const handleCustomRewards = ( expeditionId, }), EMPTY: [], + ANY: [], } const stillAvailableTreasureIdsByLevel = { diff --git a/src/Redux/helpers.ts b/src/Redux/helpers.ts index b4e89d71..3f6fb3a2 100644 --- a/src/Redux/helpers.ts +++ b/src/Redux/helpers.ts @@ -105,9 +105,12 @@ export const getRandomCardsByType = ( seed?: types.Seed ): CardListReduceResult => { const cardSlots = tileSetups.filter(({ type }) => type === cardType) - const availableCardsOfType = availableCards.filter( - ({ type }) => type === cardType - ) + const availableCardsOfType = + cardType === 'ANY' + ? (availableCards as types.ICard[]) + : availableCards.filter(({ type }) => type === cardType) + + console.log({ availableCardsOfType }) return createCardList(availableCardsOfType, cardSlots, getRandomEntity, seed) } @@ -125,25 +128,50 @@ export const createSupply = ( tileSetups: ReadonlyArray, seed?: types.Seed ) => { - const gems = getRandomCardsByType(availableCards, tileSetups, 'Gem', seed) - const relics = getRandomCardsByType( + const gemsResult = getRandomCardsByType( + availableCards, + tileSetups, + 'Gem', + seed + ) + const relicsResult = getRandomCardsByType( availableCards, tileSetups, 'Relic', - gems.seed + gemsResult.seed ) - const spells = getRandomCardsByType( + const spellsResult = getRandomCardsByType( availableCards, tileSetups, 'Spell', - relics.seed + relicsResult.seed ) + const anyResult = getRandomCardsByType( + availableCards, + tileSetups, + 'ANY', + spellsResult.seed + ) + + const gems = [ + ...gemsResult.result, + ...anyResult.result.filter(c => c.type === 'Gem'), + ] + const relics = [ + ...relicsResult.result, + ...anyResult.result.filter(c => c.type === 'Relic'), + ] + const spells = [ + ...spellsResult.result, + ...anyResult.result.filter(c => c.type === 'Spell'), + ] + return { - gems: gems.result, - relics: relics.result, - spells: spells.result, - seed: spells.seed, + gems, + relics, + spells, + seed: anyResult.seed, } } diff --git a/src/components/pages/Settings/Supply/CustomSetupEdit/index.tsx b/src/components/pages/Settings/Supply/CustomSetupEdit/index.tsx index d3ef3301..ca9dd223 100644 --- a/src/components/pages/Settings/Supply/CustomSetupEdit/index.tsx +++ b/src/components/pages/Settings/Supply/CustomSetupEdit/index.tsx @@ -30,7 +30,7 @@ const bluePrintReducer = ( ...state, [id]: { id, - type: 'Gem', + type: 'ANY', operation: 'ANY', }, } diff --git a/src/mainTheme.ts b/src/mainTheme.ts index f605943a..65a6abfd 100644 --- a/src/mainTheme.ts +++ b/src/mainTheme.ts @@ -123,6 +123,10 @@ export const mainTheme = { }, cards: { ...treasureColors, + any: { + color: '#ecf0f1', + background: '#ecf0f1', + }, gem: { color: '#B39DDB', background: '#EDE7F6', diff --git a/yarn.lock b/yarn.lock index 78b7dc91..3bda038c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1977,10 +1977,10 @@ aer-data@^2.0.0: resolved "https://registry.yarnpkg.com/aer-data/-/aer-data-2.2.0.tgz#7b2d443c4ddf728ac75531cd340c0d8a1de4a1f4" integrity sha512-Gxra20m5J3vWJd5gtcqBPgPSzr01nT+3CN0UpRi5xpRpIu/pmzIF0Y1P2EqbaHzAeYWXnK4HHoWmAQNuoCxtMw== -aer-types@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/aer-types/-/aer-types-1.0.4.tgz#7e4abc5e92fadcf120dd34f6e1cffb69043f98cf" - integrity sha512-rjYRGQBR7Up81gS3jE36FI9gTjQYYYGigRGnEOIDM7Bas5774uElPE55jsDBs8rmCixuQX5thm10ro1ugVF2GA== +aer-types@^1.0.11: + version "1.0.11" + resolved "https://registry.yarnpkg.com/aer-types/-/aer-types-1.0.11.tgz#03e5070d9f891323620d51a138c0f1800076a847" + integrity sha512-ehf6vYBPlxmzpXniW3lyzNc2VG714035JFlFBzD/CFMaE0nBwHal9fu1kddLKYWm8nV7IFLBZsg+uGNjLLlKZw== aggregate-error@^3.0.0: version "3.0.1"