Title: Name of book: description (page number)
Why isn’t:
if let localPlayer = gameCenterData?.getLocalPlayer() {
if let index = gameCenterData?.getPlayerIndex(for: localPlayer) {
gameCenterData?.players[index].totalPoints =
gameModel.players[0].totalPoints
}
// Update the remote player's stats
if let remotePlayer = gameCenterData?.getRemotePlayer() {
if let index = gameCenterData?.getPlayerIndex(for: remotePlayer) {
gameCenterData?.players[index].totalPoints =
gameModel.players[1].totalPoints
}
just:
// Update the local player's stats
if let localPlayer = gameCenterData?.getLocalPlayer() {
localPlayer.totalPoints = gameModel.players[0].totalPoints
}
// Update the remote player's stats
if let remotePlayer = gameCenterData?.getRemotePlayer() {
remotePlayer.totalPoints = gameModel.players[1].totalPoints
}
Am I missing something special that’s accomplished by getting the index and then indexing back into players to get to the same player???