static void Main(string[] args)
        {
            Player player1 = new Player(1);
            Player player2 = new Player(2);
            Game.DeckCards();
            Game.NewPlayers(player1, player2);
            Game.GivePlayerADeck(player1, player2);
            Console.Write("Player1's name : ");
            player1.name = Console.ReadLine();
            Console.Write("Player2's name : ");
            player2.name = Console.ReadLine();
            Console.WriteLine("");
            Console.WriteLine("START!!");
            Console.WriteLine("");

            int result = 0;
            int turn = 1;
            do
            {
                Console.WriteLine("Turn " + turn );
                result = Game.CompareCardDeck(player1, player2);
                player1.ShowPlayerProperties();
                player2.ShowPlayerProperties();
                if (player1.playerdeck.Cards.Count == 0)
                {
                    Console.WriteLine("[Summary] No more card left in the both players card deck");
                    break;
                }
                Console.WriteLine("");
                ++turn;

            } while (result != -1);
            Game.endgame(player1, player2);
            Console.ReadKey();
        }
Example #2
0
        static void Main(string[] args)
        {
            Player player1 = new Player();
            Player player2 = new Player();
            Control.Setting();
            Console.Write("Player1's name : ");
            String nPlayer1 = Console.ReadLine();
            Console.Write("Player2's name : ");
            String nPlayer2 = Console.ReadLine();
            Control.CreatePlayers(player1, player2, nPlayer1, nPlayer2);
            Control.GiveCards(player1, player2);

            int result = 0;
            int nextTurn = 1;
            do
            {
                result = Control.CompareCard(player1, player2);
                player1.ShowPlayerScore(player1);
                player2.ShowPlayerScore(player2);
                if (player1.PlayingDeck.Cards.Count == 0)
                    break;
                Console.WriteLine("Press any key and Enter to Continue...");
                String next = Console.ReadLine();
                Console.WriteLine();
                Console.WriteLine();

            } while (result != -1 && nextTurn == 1);
            Control.EndGame(player1, player2);
            Console.ReadKey();
        }
 static void Main(string[] args)
 {
     Player play1 = new Player();
     Player play2 = new Player();
     Game.Setting(play1, play2);
     do
         Game.Playing(play1, play2);
     while (play1.PlayDeck.CardDeck.Count != 0);
     Game.WhoWinGame(play1, play2);
     System.Console.ReadKey();
 }
Example #4
0
        static void Main(string[] args)
        {
            Player player1 = new Player(1);
            Player player2 = new Player(2);
            Control.SettingUp();
            Control.NewPlayers(player1, player2);
            Control.GivePlayerADeck(player1, player2);

            // Display all cards in both player decks
            //Console.WriteLine("== [" + player1.Name + "] Card deck is containing these cards :");
            //player1.PlayingDeck.ViewCardsinDeck();
            //Console.WriteLine("== [" + player2.Name + "] Card deck is containing these cards :");
            //player2.PlayingDeck.ViewCardsinDeck();

            Console.WriteLine("");
            Console.WriteLine("> STARTING GAME <");

            int result = 0;
            int turn = 1;
            do
            {
                Console.WriteLine("___ {Turn " + turn + " } ___ ");
                //Console.WriteLine("Comparing player 1 and player 2 card deck");
                //Console.Write("{0, -35}", "[" + player1.Name + "]");
                //Console.WriteLine("{0, -35}", "[" + player2.Name + "]");
                result = Control.CompareCardDeck(player1, player2);
                player1.ShowPlayerProperties();
                player2.ShowPlayerProperties();
                //if (player1.PlayingDeck.Cards.Count == 0)
                //{
                //    Console.WriteLine("[Summary] No more card left in the both players card deck");
                //    break;
                //}
                Console.WriteLine("");
                ++turn;
                //Console.ReadKey();
            } while (result != -1);
            Control.FinishedPlaying(player1, player2);
            Console.ReadKey();
        }
Example #5
0
 public void ShowPlayerScore(Player player)
 {
     Console.WriteLine("> " + Name + " : " + Count + " Points");
 }
 public static void win(Player player, int NumberofCards = 1)
 {
     player.count += (NumberofCards) * 2;
     Console.WriteLine("Player" + player.player + " " + player.name + " win! get 2 cards");
 }
 public static void removecards(Player player1, Player player2, int range)
 {
     int LastCard = player1.playerdeck.Cards.Count - 1;
     player1.playerdeck.Cards.RemoveRange(LastCard - range + 1, range);
     player2.playerdeck.Cards.RemoveRange(LastCard - range + 1, range);
 }
        public static void GivePlayerADeck(Player player1, Player player2)
        {
            for (int i = 0; i < 26; i++)
            {
                player1.playerdeck.Cards.Add(base_deck.Cards[i]);
            }

            for (int i = 0; i < 26; i++)
            {
                player2.playerdeck.Cards.Add(base_deck.Cards[i + 26]);
            }
        }
Example #9
0
 public static int CompareCardDeck(Player pPlayer1, Player pPlayer2)
 {
     tie = false;
     if (pPlayer1.PlayingDeck.Cards.Count == 0) // No longer be playing
     {
         Console.WriteLine("[Summary] No more card left in the both players card deck");
         return -1;
     }
     int LastCard = pPlayer1.PlayingDeck.Cards.Count - 1;
     int pPlayer1_last = pPlayer1.PlayingDeck.Cards[LastCard].Value;
     int pPlayer2_last = pPlayer2.PlayingDeck.Cards[LastCard].Value;
     // Show a top card of each players
     Console.WriteLine("[" + pPlayer1.Name + "] has " + pPlayer1.PlayingDeck.Cards[LastCard], -30);
     Console.WriteLine("[" + pPlayer2.Name + "] has " + pPlayer2.PlayingDeck.Cards[LastCard]);
     if (pPlayer1.PlayingDeck.Cards.Count == 1 && pPlayer1.PlayingDeck.Cards[LastCard].Value == pPlayer2.PlayingDeck.Cards[LastCard].Value) // No longer be playing
     {
         Console.WriteLine("[Tie] The last card of both players is the same.");
         return -1;
     }
     else if (pPlayer1_last == pPlayer2_last)
     {
         bool Continue_Game = true;
         for (int i = 0; i <= LastCard; i++)
         {
             for (int j = 0; j <= LastCard; j++)
             {
                 if (pPlayer1.PlayingDeck.Cards[i].Value > pPlayer2.PlayingDeck.Cards[j].Value)
                 {
                     Continue_Game = false;
                 }
                 else
                 {
                     Continue_Game = true;
                 }
             }
         }
         if (!Continue_Game)
         {
             Console.WriteLine("== [" + pPlayer1.Name + "] Card deck is containing these cards :");
             pPlayer1.PlayingDeck.ViewCardsinDeck();
             Console.WriteLine("== [" + pPlayer2.Name + "] Card deck is containing these cards :");
             pPlayer2.PlayingDeck.ViewCardsinDeck();
             return -1;
         }
         int NumberFromLastCard = pPlayer1_last;
         if (NumberFromLastCard > LastCard) // More value of the card than number of left cards
         {
             //TieTurn(pPlayer1, pPlayer2);
             NumberFromLastCard = LastCard;
             //return 0;
         }
         Console.WriteLine("[" + pPlayer1.Name + "] has " + pPlayer1.PlayingDeck.Cards[NumberFromLastCard]);
         Console.WriteLine("[" + pPlayer2.Name + "] has " + pPlayer2.PlayingDeck.Cards[NumberFromLastCard]);
         int pPlayer1_fromlast = pPlayer1.PlayingDeck.Cards[NumberFromLastCard].Value;
         int pPlayer2_fromlast = pPlayer2.PlayingDeck.Cards[NumberFromLastCard].Value;
         if (pPlayer1_fromlast < pPlayer2_fromlast) // Player 1 WIN
         {
             PlayerWinTurn(pPlayer1, NumberFromLastCard);
             RemovePlayerCards(pPlayer1, pPlayer2, NumberFromLastCard);
             return 1;
         }
         else if (pPlayer1_fromlast > pPlayer2_fromlast) // Player 2 WIN
         {
             PlayerWinTurn(pPlayer2, NumberFromLastCard);
             RemovePlayerCards(pPlayer1, pPlayer2, NumberFromLastCard);
             return 2;
         }
         else // Tie
         {
             TieTurn(pPlayer1, pPlayer2);
             return 0;
         }
     }
     // Player 1 WIN
     else if (pPlayer1_last < pPlayer2_last)
     {
         PlayerWinTurn(pPlayer1);
         RemovePlayerCards(pPlayer1, pPlayer2, 1);
         return 1;
     }
     // Player 2 WIN
     else if (pPlayer1_last > pPlayer2_last)
     {
         PlayerWinTurn(pPlayer2);
         RemovePlayerCards(pPlayer1, pPlayer2, 1);
         return 2;
     }
     return -1;
 }
Example #10
0
 public static void RemovePlayerCards(Player pPlayer1, Player pPlayer2, int range)
 {
     int LastCard = pPlayer1.PlayingDeck.Cards.Count - 1;
     pPlayer1.PlayingDeck.Cards.RemoveRange(LastCard - range + 1, range);
     pPlayer2.PlayingDeck.Cards.RemoveRange(LastCard - range + 1, range);
     //Console.WriteLine("[Remove] " + range + " card(s) of both players card deck");
 }
Example #11
0
 public static void RemoveCards(Player player1, Player player2, int range)
 {
     int LastCard = player1.PlayingDeck.Cards.Count - 1;
     player1.PlayingDeck.Cards.RemoveRange(LastCard - range + 1, range);
     player2.PlayingDeck.Cards.RemoveRange(LastCard - range + 1, range);
 }
Example #12
0
 public static void PlayerWinTurn(Player player, int NumberofCards = 1)
 {
     player.Count += (NumberofCards) * 2;
 }
 public Game()
 {
     Player1 = new Player();
     Player2 = new Player();
     Dec = new Deck();
 }
 public int TopCard(Player p)
 {
     int r = p.Mycard.deck[0].Rank;
     Console.WriteLine(p.Name + "'s card is " + p.Mycard.deck[0].ToString());
     p.Mycard.deck.RemoveAt(0);
     return r;
 }
 public void creatPlayer()
 {
     string p1name, p2name;
     Console.Write("Please enter first player name: ");
     p1name = Console.ReadLine();
     Console.Write("Please enter second player name: ");
     p2name = Console.ReadLine();
     Player1 = new Player(p1name, 0, pDeck);
     Console.WriteLine();
     Player2 = new Player(p2name, 26, pDeck);
 }
Example #16
0
 public static void NewPlayers(Player pPlayer1, Player pPlayer2, string pPlayerName1 = "Anonymous", string pPlayerName2 = "Anonymous")
 {
     //Console.WriteLine("Creating new two players...");
     Console.Write("[Player 1] What's your name? : ");
     pPlayerName1 = Console.ReadLine();
     Console.Write("[Player 2] What's your name? : ");
     pPlayerName2 = Console.ReadLine();
     pPlayer1.Name = pPlayerName1;
     pPlayer2.Name = pPlayerName2;
     Console.WriteLine("[" + pPlayer1.Name + "] is " + pPlayer1.Name);
     Console.WriteLine("[" + pPlayer2.Name + "] is " + pPlayer2.Name);
 }
Example #17
0
 public static void PlayerWinTurn(Player pPlayer, int NumberofCards = 1)
 {
     pPlayer.Count += (NumberofCards) * 2;
     if (tie) pPlayer.Count += 2;
     //Console.WriteLine("[WIN][Player " + pPlayer.Order + "] get 2 card into his/her pile");
     Console.WriteLine("[Winner = " + pPlayer.Name + "] get " + (NumberofCards * 2) + " card into his/her pile");
 }
Example #18
0
 public static void TieTurn(Player player1, Player player2)
 {
     Console.WriteLine("<Tie 2 times> : Reshuffle the deck.");
     Console.WriteLine("....");
     player1.PlayingDeck.Shuffle();
     if (player1.PlayingDeck.Cards.Count != 2)
     {
         player2.PlayingDeck.Shuffle();
     }
 }
Example #19
0
 public static void TieTurn(Player pPlayer1, Player pPlayer2)
 {
     Console.WriteLine("[Tie] Reshuffle the both players card deck");
     pPlayer1.PlayingDeck.Shuffle();
     //if (pPlayer1.PlayingDeck.Cards.Count != 2)
     {
         pPlayer2.PlayingDeck.Shuffle();
     }
     tie = true;
 }
Example #20
0
        public static int CompareCard(Player player1, Player player2)
        {
            int LastCard = player1.PlayingDeck.Cards.Count - 1;
            int player1_vLast = player1.PlayingDeck.Cards[LastCard].Value;
            int player2_vLast = player2.PlayingDeck.Cards[LastCard].Value;
            Console.WriteLine();
            Console.WriteLine(player1.Name + " has " + player1.PlayingDeck.Cards[LastCard]);
            Console.WriteLine(player2.Name + " has " + player2.PlayingDeck.Cards[LastCard]);
            if (player1.PlayingDeck.Cards.Count < player1_vLast && player1_vLast == player2_vLast) // Tie and not enough card to play
            {
                Console.WriteLine("<Tie> : not enough card to play.");
                Console.WriteLine("....");
                return -1;
            }
            //else if (player1_vLast == player2_vLast && (player1_vLast + player2.Count + player2.Count) > 52)
            //{
            //    Console.WriteLine("<Tie> : not enough card to play.");
            //    return -1;
            //}
            else if (player1_vLast == player2_vLast) // Tie Value Card
            {
                int LastCardTie = player1_vLast;
                Console.WriteLine("<Tie> : Draw " + LastCardTie + " Cards.");
                Console.WriteLine("....");
                Console.WriteLine(player1.Name + " has " + player1.PlayingDeck.Cards[LastCardTie]);
                Console.WriteLine(player2.Name + " has " + player2.PlayingDeck.Cards[LastCardTie]);
                int player1_fromlast = player1.PlayingDeck.Cards[LastCardTie].Value;
                int player2_fromlast = player2.PlayingDeck.Cards[LastCardTie].Value;
                if (player1_fromlast < player2_fromlast) // Tie : Player1 Win
                {
                    PlayerWinTurn(player1, LastCardTie+1);
                    RemoveCards(player1, player2, LastCardTie+1);
                    Console.WriteLine(" ----- " + player1.Name + " Win!!  -----");
                    return 1;
                }
                else if (player1_fromlast > player2_fromlast) // Tie : Player2 Win
                {
                    PlayerWinTurn(player2, LastCardTie+1);
                    RemoveCards(player1, player2, LastCardTie+1);
                    Console.WriteLine(" ----- " + player2.Name + " Win!!  -----");
                    return 2;
                }
                else // Tie 2 times
                {
                    TieTurn(player1, player2);
                    return 0;
                }

            }
            else if (player1_vLast < player2_vLast) // Player1 Win
            {
                PlayerWinTurn(player1);
                Console.WriteLine(" ----- " + player1.Name + " Win!! -----");
                RemoveCards(player1, player2, 1);
                return 1;
            }
            else if (player1_vLast > player2_vLast) // Player2 Win
            {
                PlayerWinTurn(player2);
                Console.WriteLine(" ----- " + player2.Name + " Win!!  -----");
                RemoveCards(player1, player2, 1);
                return 2;
            }
            return -1;
        }
 public static void endgame(Player player1, Player player2)
 {
     Console.WriteLine( "Player" + (player1.count > player2.count ? player1.player : player2.player) + " WIN!!!");
 }
Example #22
0
 public static void CreatePlayers(Player player1, Player player2, String playerName1, String playerName2)
 {
     player1.Name = playerName1;
     player2.Name = playerName2;
 }
 public static void NewPlayers(Player player1, Player player2)
 {
     player1.player = 1;
     player2.player = 2;
 }
Example #24
0
 public static void EndGame(Player player1, Player player2)
 {
     Console.WriteLine("");
     Console.WriteLine("!!!+++>> Congratulation : " + (player1.Count > player2.Count ? player1.Name : player2.Name) + " WIN!! <<+++!!!");
 }
 public static void tie(Player player1, Player player2)
 {
     Console.WriteLine("Tie! Shuffle the cards deck!!");
     player1.playerdeck.shuffle();
     player2.playerdeck.shuffle();
 }
Example #26
0
 public static void GiveCards(Player player1, Player player2)
 {
     for (int i = 0; i < 26; i++)
     {
         player1.PlayingDeck.Cards.Add(baseDeck.Cards[i]);
     }
     for (int i = 0; i < 26; i++)
     {
         player2.PlayingDeck.Cards.Add(baseDeck.Cards[i + 26]);
     }
 }
        public static int CompareCardDeck(Player player1, Player player2)
        {
            if (player1.playerdeck.Cards.Count == 0)
            {
                Console.WriteLine("No more card left in the both players card deck");
                return -1;
            }

            int LastCard = player1.playerdeck.Cards.Count - 1;
            int player1_last = player1.playerdeck.Cards[LastCard].face;
            int player2_last = player2.playerdeck.Cards[LastCard].face;

            Console.WriteLine("Player" + player1.player + " " + player1.name + " has " + player1.playerdeck.Cards[LastCard]);
            Console.WriteLine("Player" + player2.player + " " + player2.name + " has " + player2.playerdeck.Cards[LastCard]);

            if (player1.playerdeck.Cards.Count == 1 && player1.playerdeck.Cards[LastCard].face == player2.playerdeck.Cards[LastCard].face)
            {
                Console.WriteLine("Tie! The last card of both players is the same.");
                return -1;
            }

            if (player1_last == player2_last)
            {
                bool Continue_Game = true;
                for (int i = 0; i <= LastCard; i++)
                {
                    for (int j = 0; j <= LastCard; j++)
                    {
                        if (player1.playerdeck.Cards[i].face > player2.playerdeck.Cards[j].face)
                        {
                            Continue_Game = false;
                        }
                        else
                        {
                            Continue_Game = true;
                        }
                    }
                }

                if (!Continue_Game)
                {
                    return -1;
                }

                int NumberFromLastCard = player1_last;

                if (NumberFromLastCard > LastCard)
                {
                    tie(player1, player2);
                     return 0;
                }

                Console.WriteLine("Player" + player1.player + " has " + player1.playerdeck.Cards[NumberFromLastCard]);
                Console.WriteLine("Player" + player2.player + " has " + player2.playerdeck.Cards[NumberFromLastCard]);

                int player1_fromlast = player1.playerdeck.Cards[NumberFromLastCard].face;
                int player2_fromlast = player2.playerdeck.Cards[NumberFromLastCard].face;
                if (player1_fromlast < player2_fromlast)
                {
                    win(player1, NumberFromLastCard);
                    removecards(player1, player2, NumberFromLastCard);
                    return 1;
                }

                else if (player1_fromlast > player2_fromlast)
                {
                    win(player2, NumberFromLastCard);
                    removecards(player1, player2, NumberFromLastCard);
                    return 2;
                }

                else
                {
                    tie(player1, player2);
                    return 0;
                }
            }

            //Player1 WIN
            else if (player1_last < player2_last)
            {
                win(player1);
                removecards(player1, player2, 1);
                return 1;
            }

            //Player2 WIN
            else if (player1_last > player2_last)
            {
                win(player2);
                removecards(player1, player2, 1);
                return 2;
            }
            return -1;
        }
Example #28
0
 public static void FinishedPlaying(Player pPlayer1, Player pPlayer2)
 {
     Console.WriteLine("");
     string WinningMSG = "=== [ The winner is ";
     if (pPlayer1.Count > pPlayer2.Count) WinningMSG += pPlayer1.Name;
     else if (pPlayer2.Count > pPlayer1.Count) WinningMSG += pPlayer2.Name;
     else WinningMSG += "NO ONE";
     WinningMSG += "] ===";
     Console.WriteLine(WinningMSG);
 }
Example #29
0
        public void Setup()
        {
            string nameP1, nameP2;

            Console.Write("Player1 Name: ");
            nameP1 = Console.ReadLine();
            Console.Write("Player2 Name: ");
            nameP2 = Console.ReadLine();

            p1 = new Player(nameP1, 0, nDeck);
            Console.WriteLine("\n");
            p2 = new Player(nameP2, 26, nDeck);
        }
Example #30
0
 public static void GivePlayerADeck(Player pPlayer1, Player pPlayer2)
 {
     for (int i = 0; i < 26; i++)
     {
         pPlayer1.PlayingDeck.Cards.Add(base_deck.Cards[i]);
         pPlayer2.PlayingDeck.Cards.Add(base_deck.Cards[i + 26]);
     }
     //Console.WriteLine("[Control] Two players card deck are each equal to the number of cards");
 }