Ejemplo n.º 1
0
        static void AddSoloMatch()
        {
            IPlayerManipulations playerLogic = new PlayerLogic();
            IGameManipulations gameLogic = new GameLogic();
            IMatchManipulations matchLogic = new MatchLogic();
            IRankingSource rankingLogic = new RankingLogic();

            // add match between 2 players
            List<PlayerType> players = playerLogic.GetPlayers();
            List<GameType> games = gameLogic.GetGames();
            Console.WriteLine("-> adding match (Solo)...");
            Console.WriteLine("\t\t#Method AddOrUpdateSoloMatch()");
            matchLogic.AddOrUpdateSoloMatch(new SoloMatch(new List<PlayerType> { players[0], players[2] }, new List<int> { 2500, 2300 }, MatchCategories.Competition, games[0]));
            // print match
            Console.WriteLine("\t\t#Method GetMatches()");
            Console.WriteLine("\t\t#Method SoloMatch.ToString()");
            Console.WriteLine("------- First Match -------");
            SoloMatch solo = (SoloMatch)matchLogic.GetMatches(games[0], ParticipantTypes.Solo, MatchCategories.Competition)[0];
            Console.WriteLine(solo.ToString());
            Console.WriteLine("------- @@@@@ -------\n\n");

            // print ranking
            Console.WriteLine("\t\t#Method GetGameRankingsAll()");
            Console.WriteLine("------- Ranking Game -------");
            foreach (PlayerGameRankingType g in rankingLogic.GetGameRankingsAll(games[0], ParticipantTypes.All))
            {
                Console.WriteLine(g.ToString());
            }
            Console.WriteLine("------- @@@@@ -------\n\n");
            // wait for user
            Wait();
        }
Ejemplo n.º 2
0
 private void btnAddSoloMatch_Click(object sender, EventArgs e)
 {
     IMatchManipulations matchLogic = new MatchLogic();
     IPlayerManipulations playerLogic = new PlayerLogic();
     IGameManipulations gameLogic = new GameLogic();
     try
     {
         List<PlayerType> players = new List<PlayerType>();
         MatchCategories cat = (MatchCategories)Enum.Parse(typeof(MatchCategories), downUpSoloCat.SelectedItem.ToString());
         GameType game = gameLogic.GetGames()[downUpSoloGame.SelectedIndex];
         List<int> scores = new List<int>();
         string[] parts = tbSoloScores.Text.Split(',');
         foreach (string s in parts)
         {
             scores.Add(int.Parse(s));
         }
         for (int i = 0; i < clSoloMembers.CheckedItems.Count; i++)
         {
             players.Add(playerLogic.GetPlayers()[clSoloMembers.Items.IndexOf(clSoloMembers.CheckedItems[i])]);
         }
         if ((players.Count > 0) && (players.Count == scores.Count))
         {
             matchLogic.AddOrUpdateSoloMatch(new SoloMatch(players, scores, cat, game));
             tbSoloScores.Text = "";
         }
         else
         {
             MessageBox.Show("Invalid scores.", "Error: Add Match", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error: Add Match", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     UpdateTree();
 }