Skip to content

Commit

Permalink
Removed unused variables, apply game state when constructed from dict…
Browse files Browse the repository at this point in the history
…ionary
  • Loading branch information
SteveBarnegren committed Oct 1, 2020
1 parent ed6444a commit 34a7029
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions SwiftChess/Source/Game.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ extension Game: DictionaryRepresentable {

struct Keys {
static let state = "state"
static let gameType = "gameType"
static let board = "board"
static let whitePlayerType = "whitePlayerType"
static let blackPlayerType = "blackPlayerType"
Expand All @@ -226,8 +225,6 @@ extension Game: DictionaryRepresentable {
// State
guard let stateDict = dictionary[Keys.state] as? [String: Any],
let state = State(dictionary: stateDict),
let gameTypeRaw = dictionary[Keys.gameType] as? Int,
let gameType = GameType(rawValue: gameTypeRaw),
let boardDict = dictionary[Keys.board] as? [String: Any],
let board = Board(dictionary: boardDict),
let currentPlayerColorRaw = dictionary[Keys.currentPlayerColor] as? String,
Expand Down Expand Up @@ -267,13 +264,13 @@ extension Game: DictionaryRepresentable {
secondPlayer: blackPlayer,
board: board,
colorToMove: currentPlayerColor)
self.state = state
}

public var dictionaryRepresentation: [String: Any] {

var dictionary = [String: Any]()
dictionary[Keys.state] = state.dictionaryRepresentation
dictionary[Keys.gameType] = gameType.rawValue
dictionary[Keys.board] = board.dictionaryRepresentation

// White Player
Expand Down

0 comments on commit 34a7029

Please sign in to comment.