diff --git a/Sources/LoRDeckCodes/Faction.swift b/Sources/LoRDeckCodes/Faction.swift index 6c88201..c74bf32 100644 --- a/Sources/LoRDeckCodes/Faction.swift +++ b/Sources/LoRDeckCodes/Faction.swift @@ -1,11 +1,12 @@ public enum Faction: Int { - case demacia - case freljord - case ionia - case noxus - case piltoverAndZaun - case shadowIsles - case bilgewater + case demacia = 0 + case freljord = 1 + case ionia = 2 + case noxus = 3 + case piltoverAndZaun = 4 + case shadowIsles = 5 + case bilgewater = 6 + case targon = 9 } extension Faction: CustomStringConvertible { @@ -18,6 +19,7 @@ extension Faction: CustomStringConvertible { case .piltoverAndZaun: return "PZ" case .shadowIsles: return "SI" case .bilgewater: return "BW" + case .targon: return "MT" } } } diff --git a/Sources/LoRDeckCodes/Header.swift b/Sources/LoRDeckCodes/Header.swift index 0c3519c..c99a088 100644 --- a/Sources/LoRDeckCodes/Header.swift +++ b/Sources/LoRDeckCodes/Header.swift @@ -1,7 +1,7 @@ public struct Header { // Compatibility list available at https://github.com/RiotGames/LoRDeckCodes#process - static private let maxSupported = [Header(format: 1, version: 1)] + static private let maxSupported = [Header(format: 1, version: 2)] public var format: Int public var version: Int diff --git a/Sources/LoRDeckCodes/Set.swift b/Sources/LoRDeckCodes/Set.swift index 5c7aa3c..aa7638c 100644 --- a/Sources/LoRDeckCodes/Set.swift +++ b/Sources/LoRDeckCodes/Set.swift @@ -1,5 +1,5 @@ -// Names taken from https://leagueoflegends.fandom.com/wiki/Set_(Legends_of_Runeterra) public enum Set: Int { case foundations = 1 case risingTides = 2 + case callOfTheMountain = 3 } diff --git a/Tests/Tests/DecoderIntegrationTests.swift b/Tests/Tests/DecoderIntegrationTests.swift index 144b0a0..0ccba3d 100644 --- a/Tests/Tests/DecoderIntegrationTests.swift +++ b/Tests/Tests/DecoderIntegrationTests.swift @@ -19,7 +19,7 @@ final class DecoderIntegrationTests: XCTestCase { func testDecoderShouldValidateBilgeWaterDeckCode() throws { // Demacia/Bilgewater - let code = "CEBQOAQGBAFQ4HA5FY6QEAQAAEEQGAIAB4QSUAIBAEABUAQBAEADEAICAACQ" + let code = "CIBQEAQAAEEQGAIAB4QSUBYCAYEAWDQ4DUXD2AIBAEABUAQBAEADEAICAACQ" let fizzId = 46 let cards = try Decoder().decode(code).cards @@ -31,6 +31,20 @@ final class DecoderIntegrationTests: XCTestCase { XCTAssertTrue(cards.contains(where: { $0.identifier == fizzId})) } + func testDecoderShouldValidateTargonDeckCode() throws { + // Feljord/Targon + let code = "CIBQEAYBAIDAIAIBBQKBKIIGAMEQMFKIKRLFOAQBAMAQIAIDBELQA" + let asolId = 87 + let cards = try Decoder().decode(code).cards + + XCTAssertEqual(cards.count, 14) + XCTAssertEqual(cards.filter({ $0.numberOfCopies == 2 }).count, 2) + XCTAssertEqual(cards.filter({ $0.numberOfCopies == 1 }).count, 0) + XCTAssertEqual(cards.filter({ $0.faction == .targon }).count, 7) + XCTAssertEqual(cards.filter({ $0.faction == .freljord }).count, 7) + XCTAssertTrue(cards.contains(where: { $0.identifier == asolId})) + } + func testDecoderOnEmptyCodeShouldThrow() { XCTAssertThrowsError(try Decoder().decode("")) }