Example #1
0
        private void BuildSummaryForRace()
        {
            GrandPrix race = (GrandPrix)this.GrandPrixSelection.SelectedItem;

            if (race != null)
            {
                this.RaceSummary.Text = app.Comp.BuildSummaryForGrandPrix(race); // race.GenerateSummary();
            }
        }
        public string GetGrandPrixResults(GrandPrix grandprix)
        {
            StringBuilder sb      = new StringBuilder();
            var           results = grandprix.Results;

            foreach (var result in results)
            {
                sb.AppendFormat("{0} | {1}", result.Person.PersonName, result.Score);
            }
            return(sb.ToString());
        }
Example #3
0
        private void RaceReset_Click(object sender, RoutedEventArgs e)
        {
            GrandPrix race = (GrandPrix)this.GrandPrixSelection.SelectedItem;

            if (race != null)
            {
                race.RaceResults = new List <Driver>();
            }

            RaceResultsCollection.Clear();
            RaceDrivers = new ObservableCollection <Driver>(app.Comp.Season.Drivers);
        }
Example #4
0
        private void RaceOK_Click(object sender, RoutedEventArgs e)
        {
            GrandPrix race = (GrandPrix)this.GrandPrixSelection.SelectedItem;

            if (race != null)
            {
                race.RaceResults = new List <Driver>();

                for (int i = 0; i < this.RaceResultsCollection.Count; i++)
                {
                    race.RaceResults.Add(this.RaceResultsCollection[i]);
                }
            }

            app.Comp.GenerateScores();
        }
Example #5
0
        private void UpdateSummary(object sender, RoutedEventArgs e)
        {
            if (this.GrandPrixSelection.SelectedItem != null)
            {
                GrandPrix grandPrix = (GrandPrix)this.GrandPrixSelection.SelectedItem;

                var tippingSummary =
                    app.Comp.Tipsters
                    .Where(t => t.Tips.ContainsKey(grandPrix))
                    .Select(t =>
                            new
                {
                    Tipster    = t,
                    Qualifying = t.Tips.FirstOrDefault(a => a.Key == grandPrix).Value.Qualifying,
                    Race       = t.Tips.FirstOrDefault(a => a.Key == grandPrix).Value.Race
                });

                tippingSummaryGrid.DataContext = tippingSummary;
            }
        }
Example #6
0
 public void LoadIff()
 {
     try
     {
         if (File.Exists("data/pangya_gb.iff"))
         {
             Card.Load();
             Items.Load();
             SetItem.Load();
             Character.Load();
             HairStyle.Load();
             Club.Load();
             Caddie.Load();
             Skin.Load();
             CaddieItem.Load();
             Mascot.Load();
             CutinInfo.Load();
             GrandPrix.Load();
             LevelPrize.Load();
             Ball.Load();
             GPSpecial.Load();
             GPReward.Load();
             MemorialRare.Load();
             MemorialCoin.Load();
             MgicBox.Load();
             AuxPart.Load();
             Desc.Load();
             Part.Load();
         }
         else
         {
             MessageBox.Show("data/pangya_gb.iff file in folder not found !", "Pangya File Core", MessageBoxButtons.OK, MessageBoxIcon.Error);
             throw new Exception("[ERROR_IFF]: data/pangya_gb.iff file in folder not found !");
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message, ConsoleColor.Red);
         Environment.Exit(0);
     }
 }
Example #7
0
        static void RunTest()
        {
            TippingCompetition comp = new TippingCompetition();

            // Create new Season
            Season season = comp.Season;

            GrandPrix Melbourne;
            GrandPrix KL;

            season.Races.Add(Melbourne = new GrandPrix()
            {
                Location = "Australian"
            });
            season.Races.Add(KL = new GrandPrix()
            {
                Location = "Malaysian"
            });
            season.Races.Add(new GrandPrix()
            {
                Location = "Chinese"
            });
            season.Races.Add(new GrandPrix()
            {
                Location = "Bahrain"
            });

            Driver Webber;
            Driver Vettel;
            Driver Kimi;

            season.Drivers.Add(Webber = new Driver()
            {
                Name = "Mark Webber", TeamName = "Red Bull"
            });
            season.Drivers.Add(Vettel = new Driver()
            {
                Name = "Sebastian Vettel", TeamName = "Red Bull"
            });
            season.Drivers.Add(Kimi = new Driver()
            {
                Name = "Kimi Raikkonen", TeamName = "Lotus"
            });

            Tipster Matt;
            Tipster Dave;
            Tipster Hanky;

            comp.Tipsters.Add(Matt = new Tipster()
            {
                FirstName = "Matt", Surname = "Nicholls"
            });
            comp.Tipsters.Add(Dave = new Tipster()
            {
                FirstName = "David", Surname = "Mutch"
            });
            comp.Tipsters.Add(Hanky = new Tipster()
            {
                FirstName = "Daniel", Surname = "Hancock"
            });

            //Matt.Tips.Add(Melbourne, new Tip() { Qualifying = Webber, Race = Webber });
            //Dave.Tips.Add(Melbourne, new Tip() { Qualifying = Kimi, Race = Vettel });
            //Hanky.Tips.Add(Melbourne, new Tip() { Qualifying = Vettel, Race = Webber });

            //Matt.Tips.Add(KL, new Tip() { Qualifying = Webber, Race = Webber });
            //Dave.Tips.Add(KL, new Tip() { Qualifying = Kimi, Race = Vettel });
            ////Hanky.Tips.Add(KL, new Tip() { Qualifying = Vettel, Race = Webber });

            comp.AddTip(Matt, Melbourne, new Tip()
            {
                Qualifying = Webber, Race = Webber
            });
            comp.AddTip(Dave, Melbourne, new Tip()
            {
                Qualifying = Kimi, Race = Vettel
            });
            comp.AddTip(Hanky, Melbourne, new Tip()
            {
                Qualifying = Vettel, Race = Webber
            });
            comp.AddTip(Matt, KL, new Tip()
            {
                Qualifying = Webber, Race = Vettel
            });
            comp.AddTip(Dave, KL, new Tip()
            {
                Qualifying = Kimi, Race = Vettel
            });

            Melbourne.QualifyingResults.Add(Webber);
            Melbourne.QualifyingResults.Add(Kimi);
            Melbourne.QualifyingResults.Add(Vettel);

            Melbourne.RaceResults.Add(Kimi);
            Melbourne.RaceResults.Add(Vettel);
            Melbourne.RaceResults.Add(Webber);

            KL.QualifyingResults.Add(Vettel);
            KL.QualifyingResults.Add(Webber);
            KL.QualifyingResults.Add(Kimi);

            KL.RaceResults.Add(Vettel);
            KL.RaceResults.Add(Webber);
            KL.RaceResults.Add(Kimi);


            comp.GenerateScores();

            PersistTippingComp(comp);

            comp = null;

            comp = DeserializeTippingCompFile(comp);

            comp.GenerateScores();
            Console.Write(comp.BuildLeaderTable());

            Console.ReadLine();
        }
Example #8
0
        private static bool NewRecord()
        {
            Person    person;
            Country   countryPerson, countryGrandPrix;
            City      city;
            GrandPrix grandprix;
            Result    result;

            person = Person.Read();
            //
            if (personRep.IsPersonExist(person))
            {
                Console.WriteLine("Skater with this name is already exist.\nTry again.");
                return(false);
            }
            countryPerson = Country.Read();
            //
            if (countryRep.IsCountryExist(countryPerson))
            {
                countryPerson = countryRep.GetSameExist(countryPerson);
            }
            countryPerson.AddPerson(person);
            grandprix = GrandPrix.Read();
            //
            if (grandprixRep.IsGrandPrixExist(grandprix))
            {
                grandprix = grandprixRep.GetSameExist(grandprix);
                Console.WriteLine(grandprix);
                result = Result.Read();
                grandprix.AddResult(result);
                person.AddResult(result);

                countryRep.Save(countryPerson);
                personRep.Save(person);
                grandprixRep.Save(grandprix);
                resultRep.Save(result);
                Console.WriteLine("Add new record:");
                Console.WriteLine(person);
                return(true);
            }
            city = City.Read();
            //
            if (cityRep.IsCityExist(city))
            {
                Console.WriteLine("Grand Prix in this city is already exist.\nTry again.");
                return(false);
            }
            city.AddGrandPrix(grandprix);
            countryGrandPrix = Country.Read();
            //
            if (countryRep.IsCountryExist(countryGrandPrix))
            {
                countryGrandPrix = countryRep.GetSameExist(countryGrandPrix);
                countryGrandPrix.AddCity(city);

                result = Result.Read();
                grandprix.AddResult(result);
                person.AddResult(result);

                countryRep.Save(countryPerson);
                countryRep.Save(countryGrandPrix);
                cityRep.Save(city);
                personRep.Save(person);
                grandprixRep.Save(grandprix);
                resultRep.Save(result);
                Console.WriteLine("Add new record:");
                Console.WriteLine(person);
                return(true);
            }
            countryGrandPrix.AddCity(city);
            result = Result.Read();
            grandprix.AddResult(result);
            person.AddResult(result);

            countryRep.Save(countryPerson);
            countryRep.Save(countryGrandPrix);
            cityRep.Save(city);
            personRep.Save(person);
            grandprixRep.Save(grandprix);
            resultRep.Save(result);
            Console.WriteLine("Add new record:");
            Console.WriteLine(person);
            return(true);
        }
Example #9
0
        private static bool AddSkaterToGrandPrix()
        {
            ShowAllSkaters();
            int SkaterID;

            Console.Write("Input the skater ID: ");
            try
            {
                SkaterID = Convert.ToInt32(Console.ReadLine());
            }
            catch (FormatException)
            {
                Console.WriteLine("Be more careful and try again.");
                throw;
            }
            catch (OverflowException)
            {
                Console.WriteLine("Be more careful and try again.");
                throw;
            }

            if (!personRep.IsIDExist(SkaterID))
            {
                Console.WriteLine("Be more careful and try again.");
                return(false);
            }

            Console.Clear();
            Console.WriteLine("Skater {0} add to Grand Prix:", SkaterID);
            Person    person    = personRep.GetById(SkaterID);
            GrandPrix grandprix = GrandPrix.Read();
            Country   country;
            City      city;
            Result    result;

            //
            if (grandprixRep.IsGrandPrixExist(grandprix))
            {
                grandprix = grandprixRep.GetSameExist(grandprix);
                Console.WriteLine(grandprix);

                result = Result.Read();
                grandprix.AddResult(result);
                person.AddResult(result);

                personRep.Save(person);
                grandprixRep.Save(grandprix);
                resultRep.Save(result);
                Console.WriteLine("Add skater to Grand Prix:");
                Console.WriteLine(person);
                return(true);
            }
            //
            city = City.Read();
            //
            if (cityRep.IsCityExist(city))
            {
                Console.WriteLine("Grand Prix in this city is already exist.\nTry again.");
                return(false);
            }
            city.AddGrandPrix(grandprix);
            //
            country = Country.Read();
            if (countryRep.IsCountryExist(country))
            {
                country = countryRep.GetSameExist(country);
                country.AddCity(city);

                result = Result.Read();
                grandprix.AddResult(result);
                person.AddResult(result);

                countryRep.Save(country);
                cityRep.Save(city);
                personRep.Save(person);
                grandprixRep.Save(grandprix);
                resultRep.Save(result);
                Console.WriteLine("Add skater to Grand Prix:");
                Console.WriteLine(person);
                return(true);
            }
            country.AddCity(city);
            result = Result.Read();
            grandprix.AddResult(result);
            person.AddResult(result);

            countryRep.Save(country);
            cityRep.Save(city);
            personRep.Save(person);
            grandprixRep.Save(grandprix);
            resultRep.Save(result);
            Console.WriteLine("Add skater to Grand Prix:");
            Console.WriteLine(person);
            return(true);
        }