Skip to content

Commit

Permalink
Show karma string on stats panel
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed Mar 29, 2022
1 parent 6f7c952 commit 015b7db
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 38 deletions.
47 changes: 47 additions & 0 deletions EOLib/Domain/Extensions/CharacterStatExtensions.cs
@@ -0,0 +1,47 @@
using EOLib.Domain.Character;

namespace EOLib.Domain.Extensions
{
public static class CharacterStatExtensions
{
public static string GetKarmaString(this ICharacterStats characterStats)
{
/* 0 - 100 = Demonic
* 101 - 500 = Doomed
* 501 - 750 = Cursed
* 751 - 900 = Evil
* 901 - 1099 = Neutral
* 1100 - 1249 = Good
* 1250 - 1499 = Blessed
* 1500 - 1899 = Saint
* 1900 - 2000 = Pure
*/

var num = characterStats[CharacterStat.Karma];

if (num >= 0)
{
if (num <= 100)
return "Demonic";
if (num <= 500)
return "Doomed";
if (num <= 750)
return "Cursed";
if (num <= 900)
return "Evil";
if (num <= 1099)
return "Neutral";
if (num <= 1249)
return "Good";
if (num <= 1499)
return "Blessed";
if (num <= 1899)
return "Saint";
if (num <= 2000)
return "Pure";
}

return string.Empty;
}
}
}
3 changes: 2 additions & 1 deletion EndlessClient/HUD/Panels/StatsPanel.cs
Expand Up @@ -5,6 +5,7 @@
using EndlessClient.Dialogs.Factories;
using EOLib;
using EOLib.Domain.Character;
using EOLib.Domain.Extensions;
using EOLib.Graphics;
using Microsoft.Xna.Framework;
using XNAControls;
Expand Down Expand Up @@ -178,7 +179,7 @@ protected override void OnUpdateControl(GameTime gameTime)
_otherInfo[GOLD].Text = $"{CurrentCharacterGold.Amount}";
_otherInfo[EXP].Text = $"{_lastCharacterStats[CharacterStat.Experience]}";
_otherInfo[TNL].Text = $"{ExperienceToNextLevel}";
_otherInfo[KARMA].Text = $"{_lastCharacterStats[CharacterStat.Karma]}";
_otherInfo[KARMA].Text = $"{_lastCharacterStats.GetKarmaString()}";

_characterInfo[NAME].Text = $"{_characterProvider.MainCharacter.Name}";
_characterInfo[GUILD].Text = $"{_characterProvider.MainCharacter.GuildName}";
Expand Down
37 changes: 0 additions & 37 deletions EndlessClient/Old/OldCharacter.cs
Expand Up @@ -181,43 +181,6 @@ public bool NeedsSpellTarget

public bool IsDrunk { get; set; }

public static string KarmaStringFromNum(int num)
{
/* 0 - 100 = Demonic
* 101 - 500 = Doomed
* 501 - 750 = Cursed
* 751 - 900 = Evil
* 901 - 1099 = Neutral
* 1100 - 1249 = Good
* 1250 - 1499 = Blessed
* 1500 - 1899 = Saint
* 1900 - 2000 = Pure
*/
if (num >= 0)
{
if (num <= 100)
return "Demonic";
if (num <= 500)
return "Doomed";
if (num <= 750)
return "Cursed";
if (num <= 900)
return "Evil";
if (num <= 1099)
return "Neutral";
if (num <= 1249)
return "Good";
if (num <= 1499)
return "Blessed";
if (num <= 1899)
return "Saint";
if (num <= 2000)
return "Pure";
}

throw new ArgumentOutOfRangeException(nameof(num), num, "Karma values must be between 0-2000");
}

private readonly PacketAPI m_packetAPI;

public OldCharacter()
Expand Down

0 comments on commit 015b7db

Please sign in to comment.