Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
Add support for Targon
Browse files Browse the repository at this point in the history
This adds support for set 3 - "Call of the Mountain" and a new region - Targon.

Recently, dev team responsible for deck codes format decided that Rising Tides and Call of the Mountain will use format 1 version 2, so I'm updating supported formats to align with this decision.
  • Loading branch information
tomaszbak committed Sep 3, 2020
1 parent b127d6d commit 9e2086e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
16 changes: 9 additions & 7 deletions Sources/LoRDeckCodes/Faction.swift
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -18,6 +19,7 @@ extension Faction: CustomStringConvertible {
case .piltoverAndZaun: return "PZ"
case .shadowIsles: return "SI"
case .bilgewater: return "BW"
case .targon: return "MT"
}
}
}
2 changes: 1 addition & 1 deletion Sources/LoRDeckCodes/Header.swift
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/LoRDeckCodes/Set.swift
Original file line number Diff line number Diff line change
@@ -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
}
16 changes: 15 additions & 1 deletion Tests/Tests/DecoderIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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(""))
}
Expand Down

0 comments on commit 9e2086e

Please sign in to comment.