Exemplo n.º 1
0
        private void dg_games_DClick(object sender, RoutedEventArgs e)
        {
            List <gamePlayer> temp   = new List <gamePlayer>();
            gamePlayer        pltemp = new gamePlayer();

            foreach (var dataItem in dg_games.SelectedItems)
            {
                myGame game = dataItem as myGame;
                pltemp.RACE = game.REPLAY;
                temp.Add(pltemp);
                foreach (gamePlayer pl in game.PLAYERS)
                {
                    temp.Add(pl);
                }
            }

            if (temp.Count > 300)
            {
                pltemp.RACE = "Visibility ilmit is 300. Sorry.";
                List <gamePlayer> bab = new List <gamePlayer>();
                bab.Add(pltemp);

                dg_player.ItemsSource = bab;
            }
            else
            {
                dg_player.ItemsSource = temp;
            }

            if (temp.Count < 120)
            {
                dg_player.EnableRowVirtualization = false;

                Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.ApplicationIdle, new Action(ProcessRows_player));
            }
            //ProcessRows_player();
        }
Exemplo n.º 2
0
        public void collectData(List <myReplay> single_replays)
        {
            myGame            game       = new myGame();
            gamePlayer        player     = new gamePlayer();
            List <gamePlayer> gameplayer = new List <gamePlayer>();

            foreach (myReplay srep in single_replays)
            {
                if (String.Equals(srep.NAME, player_name))
                {
                    game.ID       = srep.ID;
                    game.REPLAY   = srep.REPLAY;
                    game.GAMETIME = srep.GAMETIME;

                    player.POS       = srep.PLAYERID;
                    player.RACE      = srep.RACE;
                    player.NAME      = srep.NAME;
                    player.KILLSUM   = srep.KILLSUM;
                    player.PDURATION = srep.DURATION;
                    player.INCOME    = srep.INCOME;
                    player.ARMY      = srep.ARMY;
                    player.RESULT    = 2;
                    player.REPLAY    = srep.REPLAY;
                    player.ID        = srep.ID;

                    game.DURATION = srep.DURATION;
                    int result = srep.RESULT;
                    if (srep.PLAYERID <= 3)
                    {
                        player.TEAM = 0;
                        if (srep.RESULT == 1)
                        {
                            player.RESULT = 1;
                            game.WINNER   = 0;
                        }
                        else
                        {
                            game.WINNER = 1;
                        }
                    }
                    else if (srep.PLAYERID > 3)
                    {
                        player.TEAM = 1;
                        if (srep.RESULT == 1)
                        {
                            player.RESULT = 1;
                            game.WINNER   = 1;
                        }
                        else
                        {
                            game.WINNER = 0;
                        }
                    }
                }
                else
                {
                }
            }

            int           minkillsum = 0;
            int           minarmy    = 0;
            double        minincome  = 0;
            int           maxleaver  = 0;
            List <string> races      = new List <string>();

            foreach (myReplay srep in single_replays)
            {
                game.PLAYERCOUNT++;

                if (minkillsum == 0)
                {
                    minkillsum = srep.KILLSUM;
                }
                else
                {
                    if (srep.KILLSUM < minkillsum)
                    {
                        minkillsum = srep.KILLSUM;
                    }
                }

                if (minincome == 0)
                {
                    minincome = srep.INCOME;
                }
                else
                {
                    if (srep.INCOME < minincome)
                    {
                        minincome = srep.INCOME;
                    }
                }

                if (minarmy == 0)
                {
                    minarmy = srep.ARMY;
                }
                else
                {
                    if (srep.ARMY < minarmy)
                    {
                        minarmy = srep.ARMY;
                    }
                }

                int leaver = game.DURATION - srep.DURATION;

                if (maxleaver == 0)
                {
                    maxleaver = leaver;
                }
                else
                {
                    if (leaver > maxleaver)
                    {
                        maxleaver = leaver;
                    }
                }

                races.Add(srep.RACE);

                if (String.Equals(srep.NAME, player_name))
                {
                    gameplayer.Add(player);
                    players.Add(player);
                }
                else
                {
                    gamePlayer mplayer = new gamePlayer();
                    mplayer.POS       = srep.PLAYERID;
                    mplayer.RACE      = srep.RACE;
                    mplayer.NAME      = srep.NAME;
                    mplayer.KILLSUM   = srep.KILLSUM;
                    mplayer.PDURATION = srep.DURATION;
                    mplayer.INCOME    = srep.INCOME;
                    mplayer.ARMY      = srep.ARMY;
                    mplayer.REPLAY    = srep.REPLAY;
                    mplayer.ID        = srep.ID;
                    mplayer.RESULT    = 2;
                    if (srep.PLAYERID <= 3)
                    {
                        mplayer.TEAM = 0;
                        if (game.WINNER == 0)
                        {
                            mplayer.RESULT = 1;
                        }
                    }
                    else if (srep.PLAYERID > 3)
                    {
                        mplayer.TEAM = 1;
                        if (game.WINNER == 1)
                        {
                            mplayer.RESULT = 1;
                        }
                    }

                    gameplayer.Add(mplayer);
                    players.Add(mplayer);
                }
            }

            game.MAXLEAVER  = maxleaver;
            game.MINARMY    = minarmy;
            game.MININCOME  = minincome;
            game.MINKILLSUM = minkillsum;
            game.RACES      = new List <string>(races);
            game.PLAYERS    = new List <gamePlayer>(gameplayer);
            games.Add(game);


            gameplayer.Clear();
        }