AdvancedLogParser.InfoGather.GetMedWealth C# (CSharp) Method

GetMedWealth() public static method

public static GetMedWealth ( uint nXP ) : uint
nXP uint
return uint
        public static uint GetMedWealth(uint nXP)
        {
            uint nPercent, nBelowNumber, nAboveNumber;
            if (nXP < 1000)
            {
                nPercent = (100 * nXP) / 1000;
                nBelowNumber = 600;
                nAboveNumber = 1175;
            }
            else if (nXP < 3000)
            {
                nPercent = (100 * (nXP - 1000)) / 2000;
                nBelowNumber = 1175;
                nAboveNumber = 3500;
            }
            else if (nXP < 6000)
            {
                nPercent = (100 * (nXP - 3000)) / 3000;
                nBelowNumber = 3500;
                nAboveNumber = 7025;
            }
            else if (nXP < 10000)
            {
                nPercent = (100 * (nXP - 6000)) / 4000;
                nBelowNumber = 7025;
                nAboveNumber = 11700;
            }
            else if (nXP < 15000)
            {
                nPercent = (100 * (nXP - 10000)) / 5000;
                nBelowNumber = 11700;
                nAboveNumber = 16900;
            }
            else if (nXP < 21000)
            {
                nPercent = (100 * (nXP - 15000)) / 6000;
                nBelowNumber = 16900;
                nAboveNumber = 24700;
            }
            else if (nXP < 28000)
            {
                nPercent = (100 * (nXP - 21000)) / 7000;
                nBelowNumber = 24700;
                nAboveNumber = 35100;
            }
            else if (nXP < 36000)
            {
                nPercent = (100 * (nXP - 28000)) / 8000;
                nBelowNumber = 35100;
                nAboveNumber = 46800;
            }
            else if (nXP < 45000)
            {
                nPercent = (100 * (nXP - 36000)) / 9000;
                nBelowNumber = 46800;
                nAboveNumber = 63700;
            }
            else if (nXP < 55000)
            {
                nPercent = (100 * (nXP - 45000)) / 10000;
                nBelowNumber = 63700;
                nAboveNumber = 85800;
            }
            else if (nXP < 66000)
            {
                nPercent = (100 * (nXP - 55000)) / 11000;
                nBelowNumber = 85800;
                nAboveNumber = 114400;
            }
            else if (nXP < 78000)
            {
                nPercent = (100 * (nXP - 66000)) / 12000;
                nBelowNumber = 114400;
                nAboveNumber = 143000;
            }
            else if (nXP < 91000)
            {
                nPercent = (100 * (nXP - 78000)) / 13000;
                nBelowNumber = 143000;
                nAboveNumber = 195000;
            }
            else if (nXP < 105000)
            {
                nPercent = (100 * (nXP - 91000)) / 14000;
                nBelowNumber = 195000;
                nAboveNumber = 260000;
            }
            else if (nXP < 120000)
            {
                nPercent = (100 * (nXP - 105000)) / 15000;
                nBelowNumber = 260000;
                nAboveNumber = 338000;
            }
            else if (nXP < 136000)
            {
                nPercent = (100 * (nXP - 120000)) / 16000;
                nBelowNumber = 338000;
                nAboveNumber = 442000;
            }
            else if (nXP < 153000)
            {
                nPercent = (100 * (nXP - 136000)) / 17000;
                nBelowNumber = 442000;
                nAboveNumber = 572000;
            }
            else if (nXP < 171000)
            {
                nPercent = (100 * (nXP - 153000)) / 18000;
                nBelowNumber = 572000;
                nAboveNumber = 754000;
            }
            else if (nXP < 190000)
            {
                nPercent = (100 * (nXP - 171000)) / 19000;
                nBelowNumber = 754000;
                nAboveNumber = 1000000;
            }
            else
            {
                nPercent = 100;
                nBelowNumber = 1000000;
                nAboveNumber = 1000000;
            }

            return (((nAboveNumber - nBelowNumber) * nPercent) / 100) + nBelowNumber;
        }

Usage Example

Beispiel #1
0
        public CharacterDetails(Character character)
        {
            this.Name = character.Name;
            this.Text = character.Name;

            switch (character.Alignment)
            {
            case Alignment.LawfulGood:
                alignment.Text = "Lawful Good";
                break;

            case Alignment.NeutralGood:
                alignment.Text = "Neutral Good";
                break;

            case Alignment.ChaoticGood:
                alignment.Text = "Chaotic Good";
                break;

            case Alignment.LawfulNeutral:
                alignment.Text = "Lawful Neutral";
                break;

            case Alignment.TrueNeutral:
                alignment.Text = "True Neutral";
                break;

            case Alignment.ChaoticNeutral:
                alignment.Text = "Chaotic Neutral";
                break;

            case Alignment.LawfulEvil:
                alignment.Text = "Lawful Evil";
                break;

            case Alignment.NeutralEvil:
                alignment.Text = "Neutral Evil";
                break;

            case Alignment.ChaoticEvil:
                alignment.Text = "Chaotic Evil";
                break;
            }
            alignment.Text    += " " + SubraceToString(character.SubRace);
            alignment.Size     = alignment.PreferredSize;
            alignment.Location = new Point(leftColumn, 5);

            classLabel.Text     = "Class:";
            classLabel.Size     = classLabel.PreferredSize;
            classLabel.Location = new Point(leftColumn, alignment.Location.Y + alignment.Height);

            string classes = PlayerDetails.ClassToAbbreviation(character.Class1) + character.Level1;

            if (character.Class2 < 255)
            {
                classes += "/" + PlayerDetails.ClassToAbbreviation(character.Class2) + character.Level2;
            }
            if (character.Class3 < 255)
            {
                classes += "/" + PlayerDetails.ClassToAbbreviation(character.Class3) + character.Level3;
            }
            classes            += String.Format(" ({0} XP)", character.XP);
            classValue.Text     = classes;
            classValue.Size     = classValue.PreferredSize;
            classValue.Location = new Point(rightColumn, classLabel.Location.Y);

            wealthLabel.Text     = "Wealth";
            wealthLabel.Size     = wealthLabel.PreferredSize;
            wealthLabel.Location = new Point(leftColumn, classLabel.Location.Y + classLabel.Height);

            WealthLevel lvl    = InfoGather.GetWealthLevel(character);
            uint        target = InfoGather.GetMedWealth(character.XP);

            switch (lvl)
            {
            case WealthLevel.VeryPoor:
                wealthValue.Text      = String.Format("Very Poor ({0} / {1})", character.Wealth, target);
                wealthValue.ForeColor = Color.Red;
                wealthValue.BackColor = Color.Yellow;
                break;

            case WealthLevel.Poor:
                wealthValue.Text = String.Format("Poor ({0} / {1})", character.Wealth, target);
                break;

            case WealthLevel.Target:
                wealthValue.Text = String.Format("Near Target ({0} / {1})", character.Wealth, target);
                break;

            case WealthLevel.Rich:
                wealthValue.Text = String.Format("Rich ({0} / {1})", character.Wealth, target);
                break;

            case WealthLevel.VeryRich:
                wealthValue.Text = String.Format("Very Rich ({0} / {1})", character.Wealth, target);
                break;

            case WealthLevel.Cutoff:
                wealthValue.Text      = String.Format("Cutoff ({0} / {1})", character.Wealth, target);
                wealthValue.ForeColor = Color.Red;
                wealthValue.BackColor = Color.Yellow;
                break;
            }
            wealthValue.Size     = wealthValue.PreferredSize;
            wealthValue.Location = new Point(rightColumn, wealthLabel.Location.Y);

            deityLabel.Text     = "Deity:";
            deityLabel.Size     = deityLabel.PreferredSize;
            deityLabel.Location = new Point(leftColumn, wealthLabel.Location.Y + wealthLabel.Height);

            deityValue.Text     = character.Deity;
            deityValue.Size     = deityValue.PreferredSize;
            deityValue.Location = new Point(rightColumn, deityLabel.Location.Y);

            strengthLabel.Text     = "Strength:";
            strengthLabel.Size     = strengthLabel.PreferredSize;
            strengthLabel.Location = new Point(leftColumn, deityLabel.Location.Y + deityLabel.Height);

            if (character.Strength >= 10)
            {
                strengthValue.Text = String.Format("{0} (+{1})", character.Strength, ((int)character.Strength - 10) / 2);
            }
            else
            {
                strengthValue.Text = String.Format("{0} ({1})", character.Strength, ((int)character.Strength - 10) / 2);
            }
            strengthValue.Size     = strengthValue.PreferredSize;
            strengthValue.Location = new Point(rightColumn, strengthLabel.Location.Y);

            dexterityLabel.Text     = "Dexterity:";
            dexterityLabel.Size     = dexterityLabel.PreferredSize;
            dexterityLabel.Location = new Point(leftColumn, strengthLabel.Location.Y + strengthLabel.Height);

            if (character.Dexterity >= 10)
            {
                dexterityValue.Text = String.Format("{0} (+{1})", character.Dexterity, ((int)character.Dexterity - 10) / 2);
            }
            else
            {
                dexterityValue.Text = String.Format("{0} ({1})", character.Dexterity, ((int)character.Dexterity - 10) / 2);
            }
            dexterityValue.Size     = dexterityValue.PreferredSize;
            dexterityValue.Location = new Point(rightColumn, dexterityLabel.Location.Y);

            constitutionLabel.Text     = "Constitution:";
            constitutionLabel.Size     = constitutionLabel.PreferredSize;
            constitutionLabel.Location = new Point(leftColumn, dexterityLabel.Location.Y + dexterityLabel.Height);

            if (character.Constitution >= 10)
            {
                constitutionValue.Text = String.Format("{0} (+{1})", character.Constitution, ((int)character.Constitution - 10) / 2);
            }
            else
            {
                constitutionValue.Text = String.Format("{0} ({1})", character.Constitution, ((int)character.Constitution - 10) / 2);
            }
            constitutionValue.Size     = constitutionValue.PreferredSize;
            constitutionValue.Location = new Point(rightColumn, constitutionLabel.Location.Y);

            intelligenceLabel.Text     = "Intelligence:";
            intelligenceLabel.Size     = intelligenceLabel.PreferredSize;
            intelligenceLabel.Location = new Point(leftColumn, constitutionLabel.Location.Y + constitutionLabel.Height);

            if (character.Intelligence >= 10)
            {
                intelligenceValue.Text = String.Format("{0} (+{1})", character.Intelligence, ((int)character.Intelligence - 10) / 2);
            }
            else
            {
                intelligenceValue.Text = String.Format("{0} ({1})", character.Intelligence, ((int)character.Intelligence - 10) / 2);
            }
            intelligenceValue.Size     = intelligenceValue.PreferredSize;
            intelligenceValue.Location = new Point(rightColumn, intelligenceLabel.Location.Y);

            wisdomLabel.Text     = "Wisdom:";
            wisdomLabel.Size     = wisdomLabel.PreferredSize;
            wisdomLabel.Location = new Point(leftColumn, intelligenceLabel.Location.Y + intelligenceLabel.Height);

            if (character.Wisdom >= 10)
            {
                wisdomValue.Text = String.Format("{0} (+{1})", character.Wisdom, ((int)character.Wisdom - 10) / 2);
            }
            else
            {
                wisdomValue.Text = String.Format("{0} ({1})", character.Wisdom, ((int)character.Wisdom - 10) / 2);
            }
            wisdomValue.Size     = wisdomValue.PreferredSize;
            wisdomValue.Location = new Point(rightColumn, wisdomLabel.Location.Y);

            charismaLabel.Text     = "Charisma:";
            charismaLabel.Size     = charismaLabel.PreferredSize;
            charismaLabel.Location = new Point(leftColumn, wisdomLabel.Location.Y + wisdomLabel.Height);

            if (character.Charisma >= 10)
            {
                charismaValue.Text = String.Format("{0} (+{1})", character.Charisma, ((int)character.Charisma - 10) / 2);
            }
            else
            {
                charismaValue.Text = String.Format("{0} ({1})", character.Charisma, ((int)character.Charisma - 10) / 2);
            }
            charismaValue.Size     = charismaValue.PreferredSize;
            charismaValue.Location = new Point(rightColumn, charismaLabel.Location.Y);

            this.Controls.Add(alignment);
            this.Controls.Add(classLabel);
            this.Controls.Add(classValue);
            this.Controls.Add(wealthLabel);
            this.Controls.Add(wealthValue);
            this.Controls.Add(deityLabel);
            this.Controls.Add(deityValue);
            this.Controls.Add(strengthLabel);
            this.Controls.Add(strengthValue);
            this.Controls.Add(dexterityLabel);
            this.Controls.Add(dexterityValue);
            this.Controls.Add(constitutionLabel);
            this.Controls.Add(constitutionValue);
            this.Controls.Add(intelligenceLabel);
            this.Controls.Add(intelligenceValue);
            this.Controls.Add(wisdomLabel);
            this.Controls.Add(wisdomValue);
            this.Controls.Add(charismaLabel);
            this.Controls.Add(charismaValue);
        }