public virtual void OnEndTurn(EndTurnMessage msg) { if (msg.isRecipientTheActivePlayer) { isActivePlayer = false; CleanupTurnLocalState(); } effectSolver.OnTurnEnded(); foreach (var entry in gameState.currentPlayer.stats) { entry.Value.OnEndTurn(); } foreach (var zone in gameState.currentPlayer.zones) { foreach (var card in zone.Value.cards) { foreach (var stat in card.stats) { stat.Value.OnEndTurn(); } } } }
/// <summary> /// Ends the current game turn. /// </summary> protected virtual void EndTurn() { Logger.Log("End turn for player " + currentPlayerIndex + "."); // Let the server handlers know the turn has ended. for (var i = 0; i < handlers.Count; i++) { handlers[i].OnEndTurn(); } effectSolver.OnTurnEnded(); var players = gameState.players; foreach (var player in players) { foreach (var entry in player.stats) { entry.Value.OnEndTurn(); } } foreach (var zone in players[currentPlayerIndex].zones) { foreach (var card in zone.Value.cards) { foreach (var stat in card.stats) { stat.Value.OnEndTurn(); } } } // Send the EndTurn message to all players. foreach (var player in players) { var msg = new EndTurnMessage(); msg.recipientNetId = player.netId; msg.isRecipientTheActivePlayer = player == players[currentPlayerIndex]; SafeSendToClient(player, NetworkProtocol.EndTurn, msg); } // Switch to next player. currentPlayerIndex += 1; if (currentPlayerIndex == players.Count) { currentPlayerIndex = 0; // Increase turn count. currentTurn += 1; } }