public void PlayCard(AsyncUserToken userToken, int cardInGameId) { var identity = (ServerSideTokenIdentity)userToken.info; var gameWrapper = identity.GameWrapper; if (gameWrapper == null || identity.MatchmakingStatus != UserMatchmakingStatus.GAME) { throw new LogicExecutionException("Korisnik nije u igri"); } lock (gameWrapper.@lock) { var game = gameWrapper.Game; if (gameWrapper.Tokens[game.IndexOfPlayerWhoPlayTheTurn] != userToken) { throw new LogicExecutionException("Igrač nije na potezu"); } var playedCard = executionEngine.PlayCard(game, game.IndexOfPlayerWhoPlayTheTurn, cardInGameId); var cardPlayedNotification = new CardPlayedNotification { PlayerIndex = game.IndexOfPlayerWhoPlayTheTurn, PlayedCard = playedCard, RemainingMana = game.Players[game.IndexOfPlayerWhoPlayTheTurn].Mana }; for (int i = 0; i < gameWrapper.Tokens.Length; i++) { var token = gameWrapper.Tokens[i]; Config.GameServer.Send(token, cardPlayedNotification); } } }
private void HandleCardPlayedNotification(CardPlayedNotification cardPlayedNotification) { if (PlayerIndex == cardPlayedNotification.PlayerIndex) { playersHandController.RemoveCard(cardPlayedNotification.PlayedCard.InGameId); } PrepareCardInGame(cardPlayedNotification.PlayedCard); var currentPlayerControllers = playersControllers[cardPlayedNotification.PlayerIndex]; currentPlayerControllers.dataController.Mana = cardPlayedNotification.RemainingMana; currentPlayerControllers.dataController.HandSize--; currentPlayerControllers.boardSideController.AddCard(cardPlayedNotification.PlayedCard); UpdateHighlightedCards(); }
public Task Handle(CardPlayedNotification notification, CancellationToken cancellationToken) { throw new NotImplementedException(); }