Exemplo n.º 1
0
 private static void OnCardRequest(PirateClient pclient)
 {
     var c = pclient.GetPlayableCard();
     Assert.That(pclient.HasCard(c));
     pclient.PlayCard(pclient.GetPlayableCard());
     Assert.That(!pclient.HasCard(c));
 }
Exemplo n.º 2
0
 private static void OnCardRequest(PirateClient pclient)
 {
     pclient.PlayCard(pclient.GetPlayableCard());
     return;
     var cardIndex = string.Empty;
     Card card = null;
     while(string.IsNullOrEmpty(cardIndex)) {
         Console.WriteLine("Your hand:");
         for(var i = 0; i < pclient.Hand.Count; i++) {
             Console.WriteLine("\t" + "[" + i + "] " + pclient.Hand[i].ToShortString());
         }
         Console.Write("Pick card to play (index): ");
         cardIndex = Console.ReadLine();
         if (cardIndex == null || !Regex.IsMatch(cardIndex, "^[0-9]+$")) {
             Console.WriteLine("Invalid index specified, try again...");
             cardIndex = string.Empty;
         } else {
             int index = int.Parse(cardIndex);
             if(index >= pclient.Hand.Count) {
                 Console.WriteLine("Invalid index specified, try again...");
                 cardIndex = string.Empty;
             }else {
                 card = pclient.Hand[index];
                 if(!pclient.CardPlayable(card)) {
                     Console.WriteLine("Card not playable, you must play cards of the same suit when possible!");
                     cardIndex = string.Empty;
                 }
             }
         }
     }
     pclient.PlayCard(card);
 }