示例#1
0
        public Task CardPlayed(CardPlayedDto data)
        {
            var ctx = new GameEventContext(data.GameId, data.RoundIndex);
            var e   = new CardPlayed(ctx, new PlayerIndex(data.PlayerIndex), _deck[data.CardIndex]);

            _gameEventCallback(e);
            return(Task.CompletedTask);
        }
示例#2
0
        public Task PlayCard(Card card)
        {
            System.Console.WriteLine("Playing card");
            var cardIndex = _deck.AllCards.ToList().IndexOf(card);
            // TODO dont reuse the event dto
            var data = new CardPlayedDto(null, -1, PlayerIndex, cardIndex);

            return(_connection.SendAsync(nameof(IGameHub.PlayCard), data));
        }
示例#3
0
文件: GameHub.cs 项目: npaulsen/eumel
        public Task PlayCard(CardPlayedDto data)
        {
            _logger.LogInformation("Received move for card {cardIndex}", data.CardIndex);
            var(room, playerIndex) = _connectionManager.GetPlayerConnection(Context.ConnectionId);
            var res = room.TryPlayCard(playerIndex, data.CardIndex);

            if (!res)
            {
                _logger.LogInformation("move is currently INVALID");
            }
            return(Task.CompletedTask);
        }