コード例 #1
0
    public TrickResult PlayTrick(TrickResult previousResult)
    {
        var bottlePrice = previousResult != null ? previousResult.BottlePrice : 19;
        var bottleOwner = previousResult?.BottleOwner;
        // Create player order
        var order = Enumerable.Range(0, PlayerCount)
                    .Select(index =>
        {
            var startIndex = previousResult != null ? previousResult.Winner.Index : 0;

            var current = (startIndex + index) % PlayerCount;
            return(_seats[current]);
        });

        List <Play> playedCards = AskMoves();

        // Decide winner
        Play winner = GetWinner(playedCards, bottlePrice);

        if (winner.Card.Number < bottlePrice)
        {
            bottleOwner = _seats[winner.Index];
            bottlePrice = winner.Card.Number;
        }

        var cardsBySeat = playedCards.OrderBy(play => play.Index).Select(play => play.Card);
        var result      = new Core.External.TrickResult(bottlePrice, cardsBySeat.ToArray());

        foreach (var seat in _seats)
        {
            seat.Player.TrickFinished(result);
        }
        return(new TrickResult(bottlePrice, _seats[winner.Index], bottleOwner, cardsBySeat.ToArray()));
    }
コード例 #2
0
        public void TrickFinished(Core.External.TrickResult result)
        {
            var winningCard = WinningCard(result.PlayedCards);
            var myCard      = result.PlayedCards[_seatAtTable];
            var winnerScore = result.PlayedCards.Sum(card => card.Score);

            _logger.LogInformation("Trick finished. Winning card {0}, my card {1}, bottle price {2}, winner price: {3}", winningCard, myCard, result.BottlePrice, winnerScore);
            _bottlePrice = result.BottlePrice;
        }
コード例 #3
0
ファイル: Random.cs プロジェクト: Hekku2/bottle-imp-ai
 public void TrickFinished(Core.External.TrickResult result)
 {
     //
 }