コード例 #1
0
ファイル: Blackjack.cs プロジェクト: Royathe/CIRCB
        private void HitPlayer(BlackjackPlayer player, int numOfCards = 1)
        {
            string message = player.Username.ToUpper() + ": ";

            for (int i = 0; i < numOfCards; i++)
            {
                var card = Decks.Draw();

                message += card.Name + " ";

                int score = CardScore(card);

                player.Score += score;
                if (score == 11)
                {
                    player.Aces++;
                }

                if (player.Score > 21 && player.Aces > 0)
                {
                    player.Score -= 10;
                    player.Aces--;
                }
            }

            Bot.Say(message + " | Pisteet: " + player.Score);

            if (player.Score > 21)
            {
                Bot.Say(player.Username.ToUpper() + " YLI!");
                PlayerLose(player);
                CheckStatuses();
            }
        }
コード例 #2
0
ファイル: Blackjack.cs プロジェクト: Royathe/CIRCB
        private void PlayerLose(BlackjackPlayer player)
        {
            var newScore = new Score(player.UserId, Score.Blackjack).Started();

            newScore.Gains(player.CurrentBet * -1);

            player.User.UpdateScore(newScore);

            Players.Remove(player);
        }
コード例 #3
0
ファイル: Blackjack.cs プロジェクト: Royathe/CIRCB
        private void Raise(BlackjackPlayer player, int raise)
        {
            int newBet = player.CurrentBet + raise;

            if (newBet > MaximumBet)
            {
                newBet = MaximumBet;
            }

            if (player.CurrentBet != newBet)
            {
                player.CurrentBet = newBet;
                Bot.Say(player.Username + " bettaa: " + player.CurrentBet);
            }
            player.Checked = true;
            CheckStatuses();
        }
コード例 #4
0
ファイル: Blackjack.cs プロジェクト: Royathe/CIRCB
 public bool Join(User user)
 {
     if (currentPhase == Phase.Join)
     {
         if (Players.Any(x => x.UserId == user.UserId))
         {
             Bot.Say(user.Username, "Olet jo blackjack pelissä.");
         }
         else
         {
             var player = new BlackjackPlayer(user);
             HitPlayer(player, 2);
             Players.Add(player);
             Bot.Say(user.Username, "Liityit blackjack peliin.");
             return(true);
         }
     }
     else
     {
         Bot.Say(user.Username, "Et voi enää liittyä blackjack peliin.");
     }
     return(false);
 }
コード例 #5
0
ファイル: Blackjack.cs プロジェクト: Royathe/CIRCB
 /// <summary>
 /// Check if valid player and output the player from the player list
 /// </summary>
 private bool ValidPlayer(Msg message, out BlackjackPlayer player)
 {
     player = Players.FirstOrDefault(x => x.UserId == message.From.UserId);
     return(player != null);
 }