Ejemplo n.º 1
0
 private static void ShowResults()
 {
     windowScore = new WindowScore()
     {
         Owner = UserBonesZone.mainWindow
     };
     windowScore.ShowDialog();
 }
Ejemplo n.º 2
0
        internal static void StartNewGame(int opponentsQty)
        {
            isGameActive = true;
            FullReset(false);
            switch (opponentsQty)
            {
            case 0:
                isPairGame    = true;
                activePlayers = new List <UserOrOppenentZone> {
                    UserZone, OpponentLeftZone, OpponentTopZone, OpponentRightZone
                };
                break;

            case 1:
                activePlayers = new List <UserOrOppenentZone> {
                    UserZone, OpponentTopZone
                };
                break;

            case 2:
                activePlayers = new List <UserOrOppenentZone> {
                    UserZone, OpponentLeftZone, OpponentTopZone
                };
                break;

            case 3:
                activePlayers = new List <UserOrOppenentZone> {
                    UserZone, OpponentLeftZone, OpponentTopZone, OpponentRightZone
                };
                break;
            }
            WindowScore.SetNewScoreWindow(opponentsQty);
            SetAllPlayersBackground(Brushes.AliceBlue, activePlayers.ToArray());
            StartNewRound();
            FindFirstMover();
            UpdateCurrentScore();
        }
Ejemplo n.º 3
0
 private static void AddScores()
 {
     int[] scores = new int[activePlayers.Count];
     for (int i = 0; i < activePlayers.Count; i++)
     {
         for (int j = 0; j < activePlayers[i].Bones.Count; j++)
         {
             scores[i] += activePlayers[i].Bones[j].SumOfPoints;
         }
         if (scores[i] == 0 && activePlayers[i].Bones.Count > 0)
         {
             scores[i] = 10;
         }
     }
     if (isPairGame)
     {
         if (scores[0] + scores[2] > scores[1] + scores[3])
         {
             UserZone.Score        += scores[0] + (int)Math.Floor(equalScore / 2.0);
             OpponentTopZone.Score += scores[2] + (int)Math.Ceiling(equalScore / 2.0);
             equalScore             = 0;
             WindowScore.AddNewRoundScore(equalScore, scores[0], 0, scores[2], 0);
         }
         else
         {
             if (scores[0] + scores[2] < scores[1] + scores[3])
             {
                 OpponentLeftZone.Score  += scores[1] + (int)Math.Floor(equalScore / 2.0);
                 OpponentRightZone.Score += scores[3] + (int)Math.Ceiling(equalScore / 2.0);
                 equalScore = 0;
                 WindowScore.AddNewRoundScore(equalScore, 0, scores[1], 0, scores[3]);
             }
             else
             {
                 equalScore += scores[0] + scores[2];
                 WindowScore.AddNewRoundScore(equalScore);
             }
         }
     }
     else
     {
         int        maxScore            = scores.Max();
         List <int> indexesWithMaxScore = new List <int>();
         for (int i = 0; i < activePlayers.Count; i++)
         {
             if (scores[i].Equals(maxScore))
             {
                 indexesWithMaxScore.Add(i);
             }
         }
         if (indexesWithMaxScore.Count == activePlayers.Count)
         {
             equalScore += scores[0];
             WindowScore.AddNewRoundScore(equalScore);
         }
         else
         {
             WindowScore.AddNewRoundScore(maxScore, indexesWithMaxScore);
             int counter = equalScore;
             for (int i = 0; i < indexesWithMaxScore.Count; i++)
             {
                 if (i != indexesWithMaxScore.Count - 1)
                 {
                     activePlayers[indexesWithMaxScore[i]].Score += scores[indexesWithMaxScore[i]] + equalScore / indexesWithMaxScore.Count;
                     counter -= equalScore / indexesWithMaxScore.Count;
                 }
                 else
                 {
                     activePlayers[indexesWithMaxScore[i]].Score += scores[indexesWithMaxScore[i]] + counter;
                 }
             }
             equalScore = 0;
         }
     }
 }