private void btnStartGame_Click(object sender, RoutedEventArgs e)
        {
            yatzy = CreateGame();

            this.NavigationService.Navigate(new GameBoard(yatzy));


            //nav.Navigate(new Uri("GameBoard.xaml", UriKind.RelativeOrAbsolute));
        }
 private Yatzy CreateGame()
 {
     yatzy = new Yatzy
     {
         GameID  = 1,
         Rolls   = 3,
         Players = AddPlayerProtocols()
     };
     return(yatzy);
 }
Exemple #3
0
        private void SetTotalSum(Yatzy yatzy)
        {
            int resultLower = 0;

            foreach (Player p in yatzy.Players)
            {
                resultLower += p.PlayerProtocol.OnePair;
                resultLower += p.PlayerProtocol.TwoPair;
                resultLower += p.PlayerProtocol.ThreeOfAKind;
                resultLower += p.PlayerProtocol.FourOfAKind;
                resultLower += p.PlayerProtocol.SmallStraight;
                resultLower += p.PlayerProtocol.LargeStraight;
                resultLower += p.PlayerProtocol.FullHouse;
                resultLower += p.PlayerProtocol.Yatzy;
                resultLower += p.PlayerProtocol.Chance;

                p.PlayerProtocol.TotalSum += p.PlayerProtocol.UpperSum + resultLower;
            }
        }
Exemple #4
0
        public Yatzy SetUpperSum(/*Yatzy yatzy*/)
        {
            //Start Testkod
            Player pl;
            Yatzy  yatzy = new Yatzy()
            {
                GameID = 1, Players = new List <Player>()
            };

            pl = new Player()
            {
                NickName = "w00t", PlayerProtocol = new Protocol()
            };
            yatzy.Players.Add(pl);
            pl = new Player()
            {
                NickName = "Maestro", PlayerProtocol = new Protocol()
            };
            yatzy.Players.Add(pl);
            // S**t testkod

            int resultUpper = 0;

            foreach (Player p in yatzy.Players)
            {
                resultUpper += p.PlayerProtocol.Ones;
                resultUpper += p.PlayerProtocol.Twos;
                resultUpper += p.PlayerProtocol.Threes;
                resultUpper += p.PlayerProtocol.Fours;
                resultUpper += p.PlayerProtocol.Fives;
                resultUpper += p.PlayerProtocol.Sixes;
                p.PlayerProtocol.UpperSum = resultUpper;
                p.PlayerProtocol.SetBonus();
                SetTotalSum(yatzy);
            }
            return(yatzy);
        }
Exemple #5
0
 public GameBoard(Yatzy yatzy)
 {
     InitializeComponent();
     this.yatzy = yatzy;
 }