Exemplo n.º 1
0
        public void UpdateStats(MashSet newmashes, MashSet newmashes2)
        {
            mashes  = newmashes;
            mashes2 = newmashes2;
            long mymed  = 0;
            long mymed2 = 0;

            Countdown(0);

            double score = CalculateScore();

            statusBar.Fill = Brushes.Red;
            if (onebutton)
            {
                mymed = mashes.GetMedian();

                newStats = new Stats(Math.Round(mashes.count / (mashes.totalTime / 1000.0), 3), mashes.upTotal / mashes.count, mashes.downTotal / mashes.count, score, Math.Round(1000.00 / mymed, 3));
            }
            else
            {
                double totalmashes = mashes.count + mashes2.count;
                double totaltime   = Math.Max(mashes.totalTime, mashes2.totalTime);
                double totalup     = mashes.upTotal + mashes2.upTotal;
                double totaldown   = mashes.downTotal + mashes2.downTotal;

                mymed = mashes.GetMedian();

                mymed2 = mashes2.GetMedian();

                newStats = new Stats(Math.Round(totalmashes / (totaltime / 1000.0), 3), Math.Round(totalup / totalmashes), Math.Round(totaldown / totalmashes), score, Math.Round(1000.00 / ((mymed + mymed2) / 4), 3));
            }

            sheets.SaveSession(newStats, usersBox.SelectedValue.ToString(), input, mode);
            playerStats = sheets.GetPlayer();
            globalStats = sheets.GetGlobal();

            CheckWinner();

            if (relative)
            {
                UpdateStatsRelative();
            }
            else
            {
                UpdateStatLabels();
            }

            timerLabel.Visibility = Visibility.Hidden;
            PlotResults(mymed, mymed2);
        }
Exemplo n.º 2
0
        private double CalculateScore()
        {
            double score = 0;
            double temp  = 0;

            double mymed = 1000.0 / mashes.GetMedian();

            for (int i = 1; i < mashes.count; i++)
            {
                temp   = 1000.0 / mashes.GetMash(i);
                temp   = Math.Round(Math.Abs(temp - mymed) * 10);
                score += 10 - Math.Min(10, temp);
            }

            //Stats session = new MashAttack.Stats((long)mashes.totalTime, mashes.count, (long)mashes.upTotal, (long)mashes.downTotal, 1, (long)score);
            //Console.WriteLine(usersBox.SelectedValue.ToString());
            //Console.WriteLine(configBox.SelectedValue.ToString());
            //session.UpdateAll(usersBox.SelectedValue.ToString(), configBox.SelectedValue.ToString(), "SNES");

            if (!onebutton)
            {
                mymed = 1000.0 / mashes2.GetMedian();

                for (int i = 1; i < mashes2.count; i++)
                {
                    temp   = 1000.0 / mashes2.GetMash(i);
                    temp   = Math.Round(Math.Abs(temp - mymed) * 10);
                    score += 10 - Math.Min(10, temp);
                }
            }

            scoreLabel.Content = String.Format("Score: {0}", score);
            //scoreLabel.Visibility = Visibility.Visible;

            return(score);
        }