Ejemplo n.º 1
0
 private static void OnBetRequest(PirateClient pclient)
 {
     var bet = CollectionFnc.PickRandom(0, pclient.Hand.Count);
     Assert.That(bet >= 0 && bet <= pclient.Game.CardsToDeal);
     pclient.SetBet(bet);
     Assert.That(pclient.Bet == bet);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Receive bet from player.
        /// </summary>
        /// <param name="host">The host.</param>
        /// <param name="player">The client.</param>
        /// <param name="msg">The data received from the client.</param>
        public static void ReceiveBet(PirateHost host, PirateClient player, PirateMessage msg)
        {
            Contract.Requires(host != null && player != null && msg != null && msg.Head == PirateMessageHead.Pbet && host.Game.Round.AwaitingBets);

            lock (host.Game.Round) {
                var bet = 0;
                if (int.TryParse(msg.Body, out bet)) {
                    player.SetBet(bet);
                } else {
                    ErrorMessage(host, player, PirateError.InvalidBet);
                }

                if (host.Game.Round.BetsDone) {
                    BeginRound(host);
                }
            }
        }
Ejemplo n.º 3
0
 private static void OnBetRequest(PirateClient pclient)
 {
     pclient.SetBet(CollectionFnc.PickRandom(0, pclient.Hand.Count));
     return;
     var bet = string.Empty;
     var pbet = 0;
     Console.WriteLine("Your hand:");
     for (var i = 0; i < pclient.Hand.Count; i++) {
         Console.WriteLine("\t" + "[" + i + "] " + pclient.Hand[i].ToShortString());
     }
     while (string.IsNullOrEmpty(bet)) {
         Console.Write("Input bet (0 - " + pclient.Game.Round.Cards + "): ");
         bet = Console.ReadLine();
         if (bet == null || !Regex.IsMatch(bet, "^[0-9]+$")) {
             Console.WriteLine("Invalid bet specified, try again...");
             bet = string.Empty;
         } else {
             pbet = int.Parse(bet);
             if (pbet > pclient.Game.Round.Cards) {
                 pbet = pclient.Game.Round.Cards;
             }
         }
     }
     pclient.SetBet(pbet);
 }