Inheritance: INotifyPropertyChanged
        public LeaguePointsWindow(Tournament tournament)
            : this()
        {
            this.tournament = tournament;

            this.Recalculate();
        }
Example #2
0
        private static int GetGALAKTAPlayerId(Guid idplayer, Tournament tournament)
        {
            int idRet = 0;

            if (tournament.PointsTable.Count(p => p.Id == idplayer) > 0)
            {
                return tournament.PointsTable.First(p => p.Id == idplayer).IdGalakta;
            }

            return idRet;
        }
Example #3
0
        public static bool SavePlayers(Tournament tournament, string filepath)
        {
            List<Player> playersList = tournament.PointsTable.Where(p => p.Active == true).ToList();

            try
            {
                XmlSerializer serializer = new XmlSerializer(playersList.GetType());
                TextWriter textWriter = new StreamWriter(filepath);
                serializer.Serialize(textWriter, playersList);
                textWriter.Close();
            }
            catch (Exception ex)
            {
                new PME(String.Format(Resources.StringTable.Tournament_ErrorSavePlayers, filepath, ex.Message));
                return false;
            }

            return true;
        }
Example #4
0
        /// <summary>
        /// Zapis obiektu do pliku
        /// </summary>
        /// <param name="tournament"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public static bool Save(Tournament tournament, string path)
        {
            try
            {
                XmlSerializer serializer = new XmlSerializer(tournament.GetType());
                TextWriter textWriter = new StreamWriter(path);
                serializer.Serialize(textWriter, tournament);
                textWriter.Close();
            }
            catch (Exception ex)
            {
                new PME(String.Format(Resources.StringTable.Tournament_ErrorSaveTournament, path, ex.Message));
                return false;
            }

            return true;
        }
Example #5
0
        public void DiceSystem(Tournament tournament)
        {
            switch (App.Settings.DiceSystem)
            {
                case ANRTournament.DiceSystem.OnlyRandom:
                    if (this.player2id == Guid.Empty)
                    {
                        return;
                    }
                    else
                    {
                        this.player1dice = Tournament.RandomGenerator.Next(9999) % 2 == 1;
                        this.player2dice = !this.player1dice;

                        NotifyPropertyChanged("Player1Dice");
                        NotifyPropertyChanged("Player2Dice");
                        return;
                    }

                case ANRTournament.DiceSystem.FullEnabled:
                    if (this.player2id == Guid.Empty)
                    {
                        if (App.Settings.BYEHasDice)
                        {
                            this.player1dice = true;
                            NotifyPropertyChanged("Player1Dice");
                        }
                        return;
                    }
                    else
                    {
                        int player1dc = tournament.PointsTable.First(p => p.Id == this.player1id).DiceCount;
                        int player2dc = tournament.PointsTable.First(p => p.Id == this.player2id).DiceCount;

                        if (player1dc == player2dc)
                        {
                            //Jeśli kostka równa to losowo
                            this.player1dice = Tournament.RandomGenerator.Next(9999) % 2 == 1;
                            this.player2dice = !this.player1dice;
                        }
                        else
                        {
                            //Jeśli kostka nie jest równa zaczyna ten co ma mniejszą
                            this.player1dice = player1dc < player2dc;
                            this.player2dice = player1dc > player2dc;
                        }

                        NotifyPropertyChanged("Player1Dice");
                        NotifyPropertyChanged("Player2Dice");
                    }
                    break;

                case ANRTournament.DiceSystem.Disabled:
                default:
                    return;
            }
        }
        private void mniPlayersImport_Click(object sender, RoutedEventArgs e)
        {
            if (this.tournament.Rounds.Count > 0)
            {
                if (PMW.Show(StringTable.MainWindow_ResetTournament, MessageBoxButton.YesNo) != MessageBoxResult.Yes) return;
            }

            OpenFileDialog openDialog = new OpenFileDialog()
            {
                Filter = StringTable.MainWindow_PlikiGraczy + " (*.anp)|*.anp",
                ValidateNames = true,
                InitialDirectory = Directory.GetCurrentDirectory(),
                AddExtension = true,
                DefaultExt = ".anp",
                CheckPathExists = true,
                CheckFileExists = true,
            };

            if (openDialog.ShowDialog() == true)
            {
                this.BusyIndicator.IsBusy = true;
                List<Player> playerList = Tournament.LoadPlayers(openDialog.FileName);
                if (playerList == null) return;

                this.tournament = new Tournament();

                foreach (Player player in playerList)
                {
                    player.Active = true;
                    player.Bucholz = 0;
                    player.CorpoWins = 0;
                    player.DeckCheck = false;
                    player.DiceCount = 0;
                    player.GamesDraw = 0;
                    player.GamesWin = 0;
                    player.GamesLoose = 0;
                    player.MBucholz = 0;
                    player.Place = 0;
                    player.Points = 0;
                    player.RankBeforeTournament = 0;
                    player.SmallPointsMinus = 0;
                    player.SmallPointsPlus = 0;
                    player.Payment = false;
                    player.SuperBYE = false;
                    this.tournament.AddPlayer(player);
                }

                this.tournament.RefreshPointsTable();
                this.RefreshTournamentDataContexts();
                this.BusyIndicator.IsBusy = false;
            }
        }
        private void mniOpen_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openDialog = new OpenFileDialog()
            {
                Filter = StringTable.MainWindow_PlikiTurniejow + " (*.ant)|*.ant",
                ValidateNames = true,
                InitialDirectory = Directory.GetCurrentDirectory(),
                AddExtension = true,
                DefaultExt = ".ant",
                CheckPathExists = true,
                CheckFileExists = true,
            };

            if (openDialog.ShowDialog() == true)
            {
                this.BusyIndicator.IsBusy = true;
                this.tournamentFilePath = openDialog.FileName;
                this.tournament = Tournament.Load(openDialog.FileName);
                this.RefreshTournamentDataContexts();
                this.BusyIndicator.IsBusy = false;
            }
        }
        private void mniNew_Click(object sender, RoutedEventArgs e)
        {
            if (PMW.Show(StringTable.MainWindow_NiezapisaneDane, MessageBoxButton.YesNo) != MessageBoxResult.Yes) return;

            this.tournament = new Tournament();
            this.RefreshTournamentDataContexts();
        }
        public StatisticsWindow(Tournament tournament)
            : this()
        {
            #region Rozkład % korpo-runner

            SortedList<string, int> sortedStatRace = new SortedList<string, int>()
            {                
                { "iCHB", tournament.PointsTable.Where(p => p.RaceCorpo == RaceCorpo.HaasBioroid).Count() },
                { "iCJT", tournament.PointsTable.Where(p => p.RaceCorpo == RaceCorpo.Jinteki).Count()  },
                { "iCNB", tournament.PointsTable.Where(p => p.RaceCorpo == RaceCorpo.NBN).Count() },
                { "iCWL", tournament.PointsTable.Where(p => p.RaceCorpo == RaceCorpo.WeylandConsortium).Count() },
                
                { "iRAN", tournament.PointsTable.Where(p => p.RaceRunner == RaceRunner.Anarch).Count() },
                { "iRCR", tournament.PointsTable.Where(p => p.RaceRunner == RaceRunner.Criminal).Count() },
                { "iRSH", tournament.PointsTable.Where(p => p.RaceRunner == RaceRunner.Shaper).Count() },
                { "iRAP", tournament.PointsTable.Where(p => p.RaceRunner == RaceRunner.Apex).Count() },
                { "iRAD", tournament.PointsTable.Where(p => p.RaceRunner == RaceRunner.Adam).Count() },
                { "iRSU", tournament.PointsTable.Where(p => p.RaceRunner == RaceRunner.Sunny).Count() },
            };

            ObservableCollection<PieSegment> raceStatCollection = new ObservableCollection<PieSegment>();

            foreach (var item in sortedStatRace)
            {
                string name = string.Empty;
                Color color = Colors.Black;

                switch (item.Key)
                {
                    case "iCHB":
                        name = StringTable.MainWindow_CMenu_CorpoHB;
                        color = Colors.Violet;
                        break;

                    case "iCJT":
                        name = StringTable.MainWindow_CMenu_CorpoJinteki;
                        color = Colors.DarkRed;
                        break;

                    case "iCNB":
                        name = StringTable.MainWindow_CMenu_CorpoNBN;
                        color = Colors.Gold;
                        break;

                    case "iCWL":
                        name = StringTable.MainWindow_CMenu_CorpoWeyland;
                        color = Colors.DarkGreen;
                        break;

                    case "iRAN":
                        name = StringTable.MainWindow_CMenu_RunnerAnarch;
                        color = Colors.OrangeRed;
                        break;

                    case "iRCR":
                        name = StringTable.MainWindow_CMenu_RunnerCriminal;
                        color = Colors.Blue;
                        break;

                    case "iRSH":
                        name = StringTable.MainWindow_CMenu_RunnerShaper;
                        color = Colors.LightGreen;
                        break;

                    case "iRAP":
                        name = StringTable.MainWindow_CMenu_RunnerApex;
                        color = Colors.OrangeRed;
                        break;

                    case "iRAD":
                        name = StringTable.MainWindow_CMenu_RunnerAdam;
                        color = Colors.Olive;
                        break;

                    case "iRSU":
                        name = StringTable.MainWindow_CMenu_RunnerSunny;
                        color = Colors.LightGray;
                        break;

                    default:
                        break;
                }

                raceStatCollection.Add(new PieSegment { Color = color, Value = item.Value, Name = name });
            }

            ctrlRaseChart.Data = raceStatCollection;

            #endregion

            #region Top 16

            if (tournament.PointsTable.Count > 16)
            {
                IEnumerable<Player> top16 = tournament.PointsTable.OrderBy(c => c.Place).Take(16);
                SortedList<string, int> sortedStatRaceTop = new SortedList<string, int>()
                {
                    { "iCHB", top16.Where(p => p.RaceCorpo == RaceCorpo.HaasBioroid).Count() },
                    { "iCJT", top16.Where(p => p.RaceCorpo == RaceCorpo.Jinteki).Count()  },
                    { "iCNB", top16.Where(p => p.RaceCorpo == RaceCorpo.NBN).Count() },
                    { "iCWL", top16.Where(p => p.RaceCorpo == RaceCorpo.WeylandConsortium).Count() },

                    { "iRAN", top16.Where(p => p.RaceRunner == RaceRunner.Anarch).Count() },
                    { "iRCR", top16.Where(p => p.RaceRunner == RaceRunner.Criminal).Count() },
                    { "iRSH", top16.Where(p => p.RaceRunner == RaceRunner.Shaper).Count() },
                    { "iRAP", top16.Where(p => p.RaceRunner == RaceRunner.Apex).Count() },
                    { "iRAD", top16.Where(p => p.RaceRunner == RaceRunner.Adam).Count() },
                    { "iRSU", top16.Where(p => p.RaceRunner == RaceRunner.Sunny).Count() },
                };

                ObservableCollection<PieSegment> raceStatCollectionTop = new ObservableCollection<PieSegment>();

                foreach (var item in sortedStatRaceTop)
                {
                    string name = string.Empty;
                    Color color = Colors.Black;

                    switch (item.Key)
                    {
                        case "iCHB":
                            name = StringTable.MainWindow_CMenu_CorpoHB;
                            color = Colors.Violet;
                            break;

                        case "iCJT":
                            name = StringTable.MainWindow_CMenu_CorpoJinteki;
                            color = Colors.DarkRed;
                            break;

                        case "iCNB":
                            name = StringTable.MainWindow_CMenu_CorpoNBN;
                            color = Colors.Gold;
                            break;

                        case "iCWL":
                            name = StringTable.MainWindow_CMenu_CorpoWeyland;
                            color = Colors.DarkGreen;
                            break;

                        case "iRAN":
                            name = StringTable.MainWindow_CMenu_RunnerAnarch;
                            color = Colors.OrangeRed;
                            break;

                        case "iRCR":
                            name = StringTable.MainWindow_CMenu_RunnerCriminal;
                            color = Colors.Blue;
                            break;

                        case "iRSH":
                            name = StringTable.MainWindow_CMenu_RunnerShaper;
                            color = Colors.LightGreen;
                            break;

                        case "iRAP":
                            name = StringTable.MainWindow_CMenu_RunnerApex;
                            color = Colors.OrangeRed;
                            break;

                        case "iRAD":
                            name = StringTable.MainWindow_CMenu_RunnerAdam;
                            color = Colors.Olive;
                            break;

                        case "iRSU":
                            name = StringTable.MainWindow_CMenu_RunnerSunny;
                            color = Colors.LightGray;
                            break;

                        default:
                            break;
                    }

                    raceStatCollectionTop.Add(new PieSegment { Color = color, Value = item.Value, Name = name });
                }

                ctrlRaseTopChart.Data = raceStatCollectionTop;
            }
            else
            {
                this.grpStatRaceTop.Visibility = System.Windows.Visibility.Collapsed;

            }
            #endregion

            #region Wygrane / Przegrane



            #endregion
        }