From 7688532d39593afa2330b278b34ac41546a09c73 Mon Sep 17 00:00:00 2001 From: Jason Gessner Date: Sun, 28 Jan 2024 16:17:47 -0600 Subject: [PATCH 1/2] Add position to v2 Card Cycles (plus schema and tests). --- schema/v2/card_cycles_schema.json | 4 ++++ test/validate_v1_v2_equality.ts | 6 ++++++ v2/card_cycles.json | 27 +++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/schema/v2/card_cycles_schema.json b/schema/v2/card_cycles_schema.json index c4ca68b1f..2385ffc8a 100644 --- a/schema/v2/card_cycles_schema.json +++ b/schema/v2/card_cycles_schema.json @@ -19,6 +19,10 @@ "minLength": 1, "type": "string" }, + "position": { + "minimum": 0, + "type": "integer" + }, "released_by": { "enum": ["fantasy_flight_games", "null_signal_games"], "minLength": 1, diff --git a/test/validate_v1_v2_equality.ts b/test/validate_v1_v2_equality.ts index fe3f3011a..9fbf66e80 100644 --- a/test/validate_v1_v2_equality.ts +++ b/test/validate_v1_v2_equality.ts @@ -15,12 +15,16 @@ import { expect } from "chai"; describe('Card Cycles v1/v2', () => { // id in v2 is the textToId'd version of the set name, not the same as the NRDB classic code. const cyclesByCode = new Map(); + const positionByLegacyCycleCode = new Map(); getCyclesJson().forEach(c => { cyclesByCode.set(c.code, c.name); + positionByLegacyCycleCode.set(c.code, c.position); }); const cardCyclesByLegacyCode = new Map(); + const v2PositionByLegacyCycleCode = new Map(); getCardCyclesV2Json().forEach(s => { cardCyclesByLegacyCode.set(s.legacy_code, s.name); + v2PositionByLegacyCycleCode.set(s.legacy_code, s.position); }); it('has correct number of cardCycles', () => { @@ -31,6 +35,8 @@ describe('Card Cycles v1/v2', () => { cardCyclesByLegacyCode.forEach((name, legacyCode) => { expect(cyclesByCode.has(legacyCode), `legacy_code ${legacyCode} exists in packsByCode map`).to.be.true; expect(name, `name mismatch for card set ${name} with legacy_code ${legacyCode}`).to.equal(cyclesByCode.get(legacyCode)); + expect(v2PositionByLegacyCycleCode.get(legacyCode), `position mismatch for card set ${name} with position ${v2PositionByLegacyCycleCode.get(legacyCode)}`) + .to.equal(positionByLegacyCycleCode.get(legacyCode)); }); }); }); diff --git a/v2/card_cycles.json b/v2/card_cycles.json index cffa04f81..ee9fa3aa4 100644 --- a/v2/card_cycles.json +++ b/v2/card_cycles.json @@ -3,162 +3,189 @@ "id": "draft", "legacy_code": "draft", "name": "Draft", + "position": 0, "released_by": "fantasy_flight_games" }, { "id": "core_set", "legacy_code": "core", "name": "Core Set", + "position": 1, "released_by": "fantasy_flight_games" }, { "id": "genesis", "legacy_code": "genesis", "name": "Genesis", + "position": 2, "released_by": "fantasy_flight_games" }, { "id": "creation_and_control", "legacy_code": "creation-and-control", "name": "Creation and Control", + "position": 3, "released_by": "fantasy_flight_games" }, { "id": "spin", "legacy_code": "spin", "name": "Spin", + "position": 4, "released_by": "fantasy_flight_games" }, { "id": "honor_and_profit", "legacy_code": "honor-and-profit", "name": "Honor and Profit", + "position": 5, "released_by": "fantasy_flight_games" }, { "id": "lunar", "legacy_code": "lunar", "name": "Lunar", + "position": 6, "released_by": "fantasy_flight_games" }, { "id": "order_and_chaos", "legacy_code": "order-and-chaos", "name": "Order and Chaos", + "position": 7, "released_by": "fantasy_flight_games" }, { "id": "sansan", "legacy_code": "sansan", "name": "SanSan", + "position": 8, "released_by": "fantasy_flight_games" }, { "id": "data_and_destiny", "legacy_code": "data-and-destiny", "name": "Data and Destiny", + "position": 9, "released_by": "fantasy_flight_games" }, { "id": "mumbad", "legacy_code": "mumbad", "name": "Mumbad", + "position": 10, "released_by": "fantasy_flight_games" }, { "id": "flashpoint", "legacy_code": "flashpoint", "name": "Flashpoint", + "position": 11, "released_by": "fantasy_flight_games" }, { "id": "red_sand", "legacy_code": "red-sand", "name": "Red Sand", + "position": 12, "released_by": "fantasy_flight_games" }, { "id": "terminal_directive", "legacy_code": "terminal-directive", "name": "Terminal Directive", + "position": 13, "released_by": "fantasy_flight_games" }, { "id": "revised_core_set", "legacy_code": "core2", "name": "Revised Core Set", + "position": 20, "released_by": "fantasy_flight_games" }, { "id": "kitara", "legacy_code": "kitara", "name": "Kitara", + "position": 21, "released_by": "fantasy_flight_games" }, { "id": "reign_and_reverie", "legacy_code": "reign-and-reverie", "name": "Reign and Reverie", + "position": 22, "released_by": "fantasy_flight_games" }, { "id": "magnum_opus", "legacy_code": "magnum-opus", "name": "Magnum Opus", + "position": 23, "released_by": "fantasy_flight_games" }, { "id": "napd_multiplayer", "legacy_code": "napd", "name": "NAPD Multiplayer", + "position": 24, "released_by": "fantasy_flight_games" }, { "id": "system_core_2019", "legacy_code": "sc19", "name": "System Core 2019", + "position": 25, "released_by": "null_signal_games" }, { "id": "ashes", "legacy_code": "ashes", "name": "Ashes", + "position": 26, "released_by": "null_signal_games" }, { "id": "magnum_opus_reprint", "legacy_code": "magnum-opus-reprint", "name": "Magnum Opus Reprint", + "position": 28, "released_by": "null_signal_games" }, { "id": "salvaged_memories", "legacy_code": "salvaged-memories", "name": "Salvaged Memories", + "position": 29, "released_by": "null_signal_games" }, { "id": "system_gateway", "legacy_code": "system-gateway", "name": "System Gateway", + "position": 30, "released_by": "null_signal_games" }, { "id": "system_update_2021", "legacy_code": "system-update-2021", "name": "System Update 2021", + "position": 31, "released_by": "null_signal_games" }, { "id": "borealis", "legacy_code": "borealis", "name": "Borealis", + "position": 32, "released_by": "null_signal_games" }, { "id": "liberation", "legacy_code": "liberation", "name": "Liberation", + "position": 33, "released_by": "null_signal_games" } ] From 744232296a67fe6fe7ad753378331a0086e428ff Mon Sep 17 00:00:00 2001 From: Jason Gessner Date: Sun, 28 Jan 2024 16:26:20 -0600 Subject: [PATCH 2/2] Reformat test file a bit. --- test/validate_v1_v2_equality.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/validate_v1_v2_equality.ts b/test/validate_v1_v2_equality.ts index 9fbf66e80..aa5633afe 100644 --- a/test/validate_v1_v2_equality.ts +++ b/test/validate_v1_v2_equality.ts @@ -35,7 +35,8 @@ describe('Card Cycles v1/v2', () => { cardCyclesByLegacyCode.forEach((name, legacyCode) => { expect(cyclesByCode.has(legacyCode), `legacy_code ${legacyCode} exists in packsByCode map`).to.be.true; expect(name, `name mismatch for card set ${name} with legacy_code ${legacyCode}`).to.equal(cyclesByCode.get(legacyCode)); - expect(v2PositionByLegacyCycleCode.get(legacyCode), `position mismatch for card set ${name} with position ${v2PositionByLegacyCycleCode.get(legacyCode)}`) + expect(v2PositionByLegacyCycleCode.get(legacyCode), + `position mismatch for card set ${name} with position ${v2PositionByLegacyCycleCode.get(legacyCode)}`) .to.equal(positionByLegacyCycleCode.get(legacyCode)); }); });