minor refactoring

This commit is contained in:
127-Z3R0 2020-06-02 22:18:59 +02:00
parent 09062d5f5d
commit cbf288e86d
2 changed files with 30 additions and 29 deletions

View File

@ -131,35 +131,35 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG
}
if let state = try? jsonDecoder.decode(State.self, from: data) {
switch state.state {
case 0:
os_log("State 0 erhalten", log: LOG, type: .info)
sendStateToPeers(state: State(state: 1))
case 1:
os_log("State 1 erhalten", log: LOG, type: .info)
if isServer {
os_log("Peer hat Player initialisiert", log: LOG, type: .info)
initAndSendMap()
}else {
os_log("Host hat Player initialisiert", log: LOG, type: .info)
}
case 2:
os_log("State 2 erhalten", log: LOG, type: .info)
sendStateToPeers(state: State(state: 3))
initIsFinish = true
os_log("Spiel startet", log: LOG, type: .info)
case 3:
os_log("State 3 erhalten", log: LOG, type: .info)
initIsFinish = true
os_log("Spiel startet", log: LOG, type: .info)
case 4:
os_log("State 4 erhalten, Peer hat verloren", log: LOG, type: .info)
// TODO: Trigger Loser Scene
case 5:
os_log("State 5 erhalten, Peer hat gewonnen", log: LOG, type: .info)
// TODO: Trigger Winner Scene
default:
break
case 0:
os_log("State 0 erhalten", log: LOG, type: .info)
sendStateToPeers(state: State(state: 1))
case 1:
os_log("State 1 erhalten", log: LOG, type: .info)
if isServer {
os_log("Peer hat Player initialisiert", log: LOG, type: .info)
initAndSendMap()
}else {
os_log("Host hat Player initialisiert", log: LOG, type: .info)
}
case 2:
os_log("State 2 erhalten", log: LOG, type: .info)
sendStateToPeers(state: State(state: 3))
initIsFinish = true
os_log("Spiel startet", log: LOG, type: .info)
case 3:
os_log("State 3 erhalten", log: LOG, type: .info)
initIsFinish = true
os_log("Spiel startet", log: LOG, type: .info)
case 4:
os_log("State 4 erhalten, Peer hat verloren", log: LOG, type: .info)
// TODO: Trigger Loser Scene
case 5:
os_log("State 5 erhalten, Peer hat gewonnen", log: LOG, type: .info)
// TODO: Trigger Winner Scene
default:
break
}
}
if let roundData = try? jsonDecoder.decode(LocalRoundData.self, from: data) {

View File

@ -158,6 +158,7 @@ class RoundCalculatorService {
winner = determineWinner(by: "capture")
}
winner == GameCenterManager.sharedInstance.hostingPlayer?.displayName ? GameCenterManager.sharedInstance.sendStateToPeers(state: State(state: 4)) : GameCenterManager.sharedInstance.sendStateToPeers(state: State(state: 5))
//TODO: Trigger Winner/Loser-Scene for Server
return
}
currentRound += 1