Ejemplo n.º 1
0
    public static string GetStatsPage(int page)
    {
        string statsPage = "";

        switch (page)
        {
        case 0:
            statsPage += "ALIGNLEFTANCHORTOPPARAMS_12_14_1_Zone		Deaths	Time			Pickups		PPM";
            foreach (string zone in Offsets.Keys)
            {
                int    offset = Offsets[zone];
                string line   = ZonePrettyNames[zone];
                if (zone == "unknown")
                {
                    line += "\t\tN/A";
                }
                else
                {
                    line += "\t\t" + get(Deaths + offset).ToString();
                }
                int    time    = get(Time + offset);
                string timestr = FormatTime(time);
                line += "\t\t" + timestr;
                if (timestr.Length < 4)
                {
                    line += "\t";
                }
                if (PickupCounts.ContainsKey(zone))
                {
                    int    count     = get(Pickups + offset);
                    string pickupstr = count.ToString() + "/" + PickupCounts[zone];
                    line += "\t\t" + pickupstr;
                    if (pickupstr.Length < 5)
                    {
                        line += "\t";
                    }
                    float ppm = (float)count / ((float)time / 60f);
                    if (time == 0 || ppm > 256 || zone == "unknown")
                    {
                        line += "\t\tN/A";
                    }
                    else
                    {
                        line += "\t\t" + Math.Round(ppm, 2).ToString();
                    }
                }
                else
                {
                    line += "\t\tN/A\t\t\tN/A";
                }
                statsPage += "\n" + line;
            }
            break;

        case 1:
            float ppm_max = (float)get(PPM_max) / 100f;
            statsPage  = "ALIGNLEFTANCHORTOPPADDING_0_2_0_0_PARAMS_16_12_1_\nSaves:					"+ get(Saves).ToString();
            statsPage += "\nReloads:					"+ get(Reloads).ToString();
            statsPage += "\nAlt+Rs Used:				"+ get(AltRCount).ToString();
            statsPage += "\nTeleporters Used:			"+ get(TeleporterCount).ToString();
            statsPage += "\nEnemies Killed:				"+ get(EnemiesKilled).ToString();
            statsPage += "\nBy Leveling up:				"+ get(LevelUpKills).ToString();
            statsPage += "\nExp collected:				"+ get(ExpGained).ToString();
            if (get(ExpBonus) > 0)
            {
                statsPage += " + " + get(ExpBonus).ToString() + " bonus";
            }
            statsPage += "\nPeak Pickups Per Minute:		"+ ppm_max.ToString();
            if (ppm_max > 0)
            {
                statsPage += " (" + get(PPM_max_count).ToString() + " / " + FormatTime(get(PPM_max_time), false) + ")";
            }
            statsPage += "\nLongest Drought:			"+ FormatTime(get(Drought_max), false);
            if (get(Drought_max) > 0)
            {
                string startTime    = "0:00";
                int    droughtStart = get(Drought_max_end) - get(Drought_max);
                if (droughtStart > 0)
                {
                    startTime = FormatTime(droughtStart, false);
                }
                statsPage += " (" + startTime + "-" + FormatTime(get(Drought_max_end), false) + ")";
            }
            statsPage += "\nWorst death (time lost):		"+ FormatTime(get(TSLDOS_max), false);
            statsPage += "\nWorst death (pickups lost):	" + get(PSLDOS_max).ToString();
            statsPage += "\nMost deaths at one save:		"+ Math.Max(get(DSLS_max), get(DSLS)).ToString();
            statsPage += "\nTotal time lost to deaths:		"+ FormatTime(get(shoof_sum), false);
            statsPage += "\nLongest time without dying:	" + FormatTime(Math.Max(get(TSLD_max), get(TSLD)), false);
            break;

        case 2:
            statsPage += "ALIGNLEFTANCHORTOPPADDING_0_2_0_0_PARAMS_16_12_1_Item				Found At		Zone";
            SortedDictionary <int, List <string> > linesByTime = new SortedDictionary <int, List <string> >();
            foreach (string item in KeyItemOffsets.Keys)
            {
                string line = item + ":";
                if (line.Length < 10)
                {
                    line += "\t\t";
                }
                else if (line.Length < 16)
                {
                    line += "\t";
                }
                line += "\t";
                int offset = KeyItemTime + KeyItemOffsets[item];
                int raw    = get(offset);
                int time   = -1;
                if (raw > 0)
                {
                    time = raw % (1 << 18);
                    int    zoneOffset = raw >> 18;
                    string zoneName   = ZonePrettyNames[Offsets.First(x => x.Value == zoneOffset).Key].Trim();
                    line += FormatTime(time);
                    if (FormatTime(time).Length < 4)
                    {
                        line += "\t";
                    }
                    line += "\t\t" + zoneName;
                }
                else
                {
                    line += "   N/A\t\tUnknown";
                }
                if (!linesByTime.ContainsKey(time))
                {
                    linesByTime[time] = new List <string>();
                }
                linesByTime[time].Add(line);
            }
            List <string> last;
            if (linesByTime.ContainsKey(-1))
            {
                last = linesByTime[-1];
                linesByTime.Remove(-1);
            }
            else
            {
                last = new List <string>();
            }
            foreach (List <string> lines in linesByTime.Values)
            {
                foreach (string line in lines)
                {
                    statsPage += "\n" + line;
                }
            }
            foreach (string line in last)
            {
                statsPage += "\n" + line;
            }
            break;

        default:
            break;
        }
        return(statsPage);
    }