public static void Main (string[] args)
		{
			DiceGame game = new DiceGame ();
			Console.WriteLine ("Rolling");
			game.play ();
			if (game.Result == 7) {
				Console.WriteLine ("You win (" + game.Result + ")");
			} else {
				Console.WriteLine ("You lose (" + game.Result + ")");
			}
		}
示例#2
0
        static void Main(string[] args)
        {
            DiceGame g = new DiceGame();

            if (g.Play())
            {
                System.Console.WriteLine("You are a winner");
            }
            else
            {
                System.Console.WriteLine("Sorry");
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello Dice World");

            DiceGame g = new DiceGame();

            if (g.Play())
            {
                Console.WriteLine("Win");
            }
            else
            {
                Console.WriteLine("Loose");
            }

            Console.ReadLine();
        }
示例#4
0
        static void Main(string[] args)
        {
            Console.WriteLine("--------------------------------------------------------------------------");
            Console.WriteLine("-----------------------------Soft-Dices Game------------------------------");
            Console.WriteLine("--------------------------------------------------------------------------");
            Console.WriteLine();

            Console.Write("Write Numbers of Players: ");
            DiceGame dg = new DiceGame(int.Parse(Console.ReadLine()));

            List<Player> pList = new List<Player>();

            for (int i = 1; i <= dg.numOfPlayers; i++)
            {
                pList.Add(new Player());
            }
        }
示例#5
0
        public static Enums.resultType Shove(DiceGame inputGame)
        {
            DiceGame shove = new DiceGame();

            shove.shoveDie = Dice.DiceRoll(inputGame.diceType);
            Console.WriteLine("\nÝou've got one chance to save yourself!");
            Console.WriteLine("\nPress a key to roll the die. You have to roll a " + inputGame.playerTurn.pair + " to win.");
            Console.ReadKey();
            Console.WriteLine("\tYou've rolled a " + shove.shoveDie + "!");

            if (shove.shoveDie == inputGame.playerTurn.pair)
            {
                shove.result = Enums.resultType.winShove;
            }
            else
            {
                shove.result = Enums.resultType.lose;
            }

            return(shove.result);
        }
示例#6
0
        public static PlayerTurn PlayerRolls(DiceGame inputGame)
        {
            List <int> currentGameDice = new List <int>();

            currentGameDice.Add(inputGame.pushDie);

            PlayerTurn currentTurn = inputGame.playerTurn;

            int loop = 0;

            while (loop < inputGame.diceAmount)
            {
                Console.WriteLine("\nPress a key to roll a die");
                Console.ReadKey();
                int roll = Dice.DiceRoll(inputGame.diceType);
                Console.WriteLine("\t\tYou've rolled a " + roll);
                currentTurn.PlayerDice.Add(roll);

                foreach (int i in currentGameDice)
                {
                    if (i == roll)
                    {
                        currentTurn.pair = i;
                        Console.WriteLine("With this roll, you have pair of " + roll + "'s. Your turn has ended");
                        inputGame.playerTurn.Result = false;
                        currentTurn.Result          = false;
                        return(currentTurn);
                    }
                }
                currentGameDice.Add(roll);


                loop++;
            }
            currentTurn.Result = true;
            return(currentTurn);
        }
示例#7
0
 static void Main(string[] args)
 {
     DiceGame dg = new DiceGame();
     dg.play();
     Console.ReadLine();
 }
示例#8
0
文件: Main.cs 项目: cbayles/DiceGame
 public static void Main(string[] args)
 {
     Console.WriteLine ("How many players are going to play??????? (press 'q' at any time to stop the game)");
     var playerCount = Console.ReadLine();
     var game = new DiceGame(Convert.ToInt32 (playerCount));
     do
     {
         game.RollDie();
         game.PrintGameSummary();
         Console.WriteLine("It's {0}'s turn. Press a key to roll the die.", game.CurrentPlayer.Name);
     } while(Console.ReadKey().Key != ConsoleKey.Q);
 }
示例#9
0
        public static void PlayDiceGame(int diceAmount, int diceType)
        {
            Console.WriteLine("Welcome to the Dice Game. \nYou can roll three dice. Make sure you don't roll a pair, or you might lose!");


            // initialize
            DiceGame currentGame = new DiceGame();

            currentGame.playerTurn            = new PlayerTurn();
            currentGame.playerTurn.PlayerDice = new List <int>();
            currentGame.diceAmount            = diceAmount;
            currentGame.diceType = diceType;
            currentGame.bet      = enterBet();

            //start
            currentGame.pushDie = Dice.DiceRoll(currentGame.diceType);
            Console.WriteLine("\nThe push is " + currentGame.pushDie);

            //players turn
            currentGame.playerTurn = PlayerRolls(currentGame);

            if (currentGame.playerTurn.Result)
            {
                //win
                currentGame.result = Enums.resultType.winDirect;
            }
            else
            {
                // go to shove
                currentGame.result = Shove(currentGame);
            }

            switch (currentGame.result)
            {
            case Enums.resultType.winDirect:
                currentGame.win = currentGame.bet * 2;
                Console.WriteLine("You won! Single payout, you win " + currentGame.win + "!");
                playerBalance += currentGame.win - currentGame.bet;
                break;

            case Enums.resultType.winShove:
                currentGame.win = currentGame.bet * 10;
                playerBalance  += currentGame.win - currentGame.bet;
                Console.WriteLine("You won the Shove! Nine times payout, you win " + currentGame.win + "!");
                break;

            case Enums.resultType.lose:
                Console.WriteLine("You have lost, better luck next time");
                playerBalance -= currentGame.bet;
                break;

            default:
                Console.WriteLine("An error has occurred, We cannot determine the outcome of the game.");
                break;
            }

            Console.WriteLine("\nYour current balance = " + playerBalance);
            Console.WriteLine("\nPress 'p' to play again, press any other key to end the game");
            string input = Console.ReadLine();

            if (input == "p")
            {
                Play();
            }
        }