implement player stats

This commit is contained in:
SilicaAndPina 2020-12-24 15:43:49 +13:00
parent b6dd899372
commit 1fab8eb864
14 changed files with 991 additions and 147 deletions

View file

@ -55,9 +55,9 @@ namespace HISP.Game.Chat
if (message[0] == '%')
{
if(message.StartsWith("%STICKBUG"))
{
return Command.Stickbug(message, args, user);
}
if (message.StartsWith("%GIVE"))
return Command.Give(message, args, user); ;
return false;
}
if (message[0] == '!')

View file

@ -1,5 +1,6 @@
using HISP.Player;
using HISP.Server;
using System;
using System.Collections.Generic;
namespace HISP.Game.Chat
@ -7,6 +8,46 @@ namespace HISP.Game.Chat
class Command
{
public static bool Give(string message, string[] args, User user)
{
if (args.Length <= 0)
return false;
if (!user.Administrator)
return false;
if(args[0] == "OBJECT")
{
int itemId = 0;
try
{
itemId = int.Parse(args[1]);
Item.GetItemById(itemId);
ItemInstance newItemInstance = new ItemInstance(itemId);
user.Inventory.AddIgnoringFull(newItemInstance);
}
catch(Exception)
{
return false;
}
}
if (args[0] == "MONEY")
{
int money = 0;
try
{
money = int.Parse(args[1]);
user.Money += money;
}
catch (Exception)
{
return false;
}
}
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
user.LoggedinClient.SendPacket(chatPacket);
return true;
}
public static bool Stickbug(string message, string[] args, User user)
{
if (args.Length <= 0)

View file

@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HISP.Game
{

View file

@ -7,6 +7,8 @@ namespace HISP.Game
public static int RequiredChatViolations;
public static int DefaultInventoryMax;
// Tools
public static string BinocularsNothing;
public static string MagnifyNothing;
@ -28,6 +30,11 @@ namespace HISP.Game
public static string StatsJewelFormat;
public static string StatsCompetitionGearFormat;
public static string JewelrySlot1Format;
public static string JewelrySlot2Format;
public static string JewelrySlot3Format;
public static string JewelrySlot4Format;
public static string CompetitionGearHeadFormat;
public static string CompetitionGearBodyFormat;
public static string CompetitionGearLegsFormat;
@ -41,8 +48,15 @@ namespace HISP.Game
public static string NoJewerlyEquipped;
public static string NoCompetitionGear;
public static string JewelrySelected;
public static string CompetitionGearSelected;
public static string StatHunger;
public static string StatThirst;
public static string StatTired;
public static string[] StatPlayerFormats;
// Announcements
public static string NewUserMessage;
public static string WelcomeFormat;
@ -87,6 +101,7 @@ namespace HISP.Game
public static string ChatViolationMessageFormat;
public static string PasswordNotice;
public static string CapsNotice;
public static string RandomMovement;
// Transport
@ -109,8 +124,13 @@ namespace HISP.Game
// Competition Gear
public static string EquipItemFormat;
public static string UnequipItem;
public static string EquipCompetitionGearFormat;
public static string RemoveCompetitionGear;
// Jewelry
public static string EquipJewelryFormat;
public static string MaxJewelryMessage;
public static string RemoveJewelry;
// Inventory
public static string InventoryItemFormat;
@ -182,9 +202,10 @@ namespace HISP.Game
public static string MetaTerminator;
// Disconnect Messages
public static string BanMessage;
public static string DuplicateLogin;
public static string IdleKickMessageFormat;
public static string KickReasonBanned;
public static string KickReasonDuplicateLogin;
public static string KickReasonIdleFormat;
public static string KickReasonNoTime;
// Swf
public static string BoatCutscene;
@ -194,6 +215,41 @@ namespace HISP.Game
// Click
public static string NothingInterestingHere;
public static string FormatRandomMovementMessage(string statName)
{
return RandomMovement.Replace("%STAT%", statName);
}
public static string FormatJewerlyEquipMessage(string itemName)
{
return EquipJewelryFormat.Replace("%ITEM%", itemName);
}
public static string FormatEquipCompetitionGearMessage(string name)
{
return EquipCompetitionGearFormat.Replace("%ITEM%", name);
}
public static string FormatPlayerStat(string statFormat, string statName)
{
return statFormat.Replace("%STAT%", statName);
}
public static string FormatJewelrySlot1(string itemName, int icon)
{
return JewelrySlot1Format.Replace("%ITEM%", itemName).Replace("%ICON%", icon.ToString());
}
public static string FormatJewelrySlot2(string itemName, int icon)
{
return JewelrySlot2Format.Replace("%ITEM%", itemName).Replace("%ICON%", icon.ToString());
}
public static string FormatJewelrySlot3(string itemName, int icon)
{
return JewelrySlot3Format.Replace("%ITEM%", itemName).Replace("%ICON%", icon.ToString());
}
public static string FormatJewelrySlot4(string itemName, int icon)
{
return JewelrySlot4Format.Replace("%ITEM%", itemName).Replace("%ICON%", icon.ToString());
}
public static string FormatCompetitionGearHead(string itemName, int icon)
{
return CompetitionGearHeadFormat.Replace("%ITEM%", itemName).Replace("%ICON%",icon.ToString());
@ -273,10 +329,6 @@ namespace HISP.Game
return PlayerCommandFormat.Replace("%COMMAND%", command);
}
public static string FormatEquipItemMessage(string name)
{
return EquipItemFormat.Replace("%ITEM%", name);
}
public static string FormatYouEarnedAnItemMessage(string itemName)
{
return YouEarnedAnItemFormat.Replace("%ITEM%", itemName);
@ -552,7 +604,7 @@ namespace HISP.Game
// Disconnect
public static string FormatIdleKickMessage()
{
return IdleKickMessageFormat.Replace("%KICK%", GameServer.IdleTimeout.ToString());
return KickReasonIdleFormat.Replace("%KICK%", GameServer.IdleTimeout.ToString());
}
}

View file

@ -1,5 +1,6 @@
using HISP.Player;
using HISP.Server;
using System;
namespace HISP.Game
{
@ -160,7 +161,43 @@ namespace HISP.Game
return message;
}
public static string buildNpc(User user, int x, int y)
private static string buildWornJewelery(User user)
{
string message = Messages.JewelrySelected;
if (user.EquipedJewelry.Slot1 != null)
message += Messages.FormatJewelrySlot1(user.EquipedJewelry.Slot1.Name, user.EquipedJewelry.Slot1.IconId);
if (user.EquipedJewelry.Slot2 != null)
message += Messages.FormatJewelrySlot2(user.EquipedJewelry.Slot2.Name, user.EquipedJewelry.Slot2.IconId);
if (user.EquipedJewelry.Slot3 != null)
message += Messages.FormatJewelrySlot3(user.EquipedJewelry.Slot3.Name, user.EquipedJewelry.Slot3.IconId);
if (user.EquipedJewelry.Slot4 != null)
message += Messages.FormatJewelrySlot4(user.EquipedJewelry.Slot4.Name, user.EquipedJewelry.Slot4.IconId);
if (message == Messages.JewelrySelected)
message = Messages.NoJewerlyEquipped;
return message;
}
private static string buildEquippedCompetitionGear(User user)
{
string message = Messages.CompetitionGearSelected;
if (user.EquipedCompetitionGear.Head != null)
message += Messages.FormatCompetitionGearHead(user.EquipedCompetitionGear.Head.Name, user.EquipedCompetitionGear.Head.IconId);
if (user.EquipedCompetitionGear.Body != null)
message += Messages.FormatCompetitionGearBody(user.EquipedCompetitionGear.Body.Name, user.EquipedCompetitionGear.Body.IconId);
if (user.EquipedCompetitionGear.Legs != null)
message += Messages.FormatCompetitionGearLegs(user.EquipedCompetitionGear.Legs.Name, user.EquipedCompetitionGear.Legs.IconId);
if (user.EquipedCompetitionGear.Feet != null)
message += Messages.FormatCompetitionGearFeet(user.EquipedCompetitionGear.Feet.Name, user.EquipedCompetitionGear.Feet.IconId);
if (message == Messages.CompetitionGearSelected)
message = Messages.NoCompetitionGear;
return message;
}
private static string buildNpc(User user, int x, int y)
{
string message = "";
Npc.NpcEntry[] entries = Npc.GetNpcByXAndY(x, y);
@ -187,6 +224,22 @@ namespace HISP.Game
}
return message;
}
public static string EvenUserStatDistribution(int statValue)
{
int curValue = 1000;
int devisibleBy = Convert.ToInt32(Math.Floor((decimal)curValue / Messages.StatPlayerFormats.Length));
for (int i = 0; i < Messages.StatPlayerFormats.Length; i++)
{
curValue -= devisibleBy;
if (statValue >= curValue)
return Messages.StatPlayerFormats[i];
}
throw new Exception("A mathematically impossible error occured. please check wether the laws of physics still apply.");
}
public static string BuildNpcInfo(Npc.NpcEntry npcInfo)
{
string message = "";
@ -217,28 +270,6 @@ namespace HISP.Game
}
return message;
}
public static string BuildWornJewelery(User user)
{
return Messages.NoJewerlyEquipped;
}
public static string BuildEquippedCompetitionGear(User user)
{
string message = Messages.CompetitionGearSelected;
if (user.EquipedCompetitionGear.Head != null)
message += Messages.FormatCompetitionGearHead(user.EquipedCompetitionGear.Head.Name, user.EquipedCompetitionGear.Head.IconId);
if (user.EquipedCompetitionGear.Body != null)
message += Messages.FormatCompetitionGearBody(user.EquipedCompetitionGear.Body.Name, user.EquipedCompetitionGear.Body.IconId);
if (user.EquipedCompetitionGear.Legs != null)
message += Messages.FormatCompetitionGearLegs(user.EquipedCompetitionGear.Legs.Name, user.EquipedCompetitionGear.Legs.IconId);
if (user.EquipedCompetitionGear.Feet != null)
message += Messages.FormatCompetitionGearFeet(user.EquipedCompetitionGear.Feet.Name, user.EquipedCompetitionGear.Feet.IconId);
if (message == Messages.CompetitionGearSelected)
message = Messages.NoCompetitionGear;
return message;
}
public static string BuildStatsMenu(User user)
{
string message = Messages.FormatStatsBar(user.Username);
@ -251,12 +282,12 @@ namespace HISP.Game
message += Messages.FormatFreeTime(user.FreeMinutes);
message += Messages.FormatPlayerDescriptionForStatsMenu(user.ProfilePage);
message += Messages.FormatExperience(user.Experience);
message += Messages.FormatHungryStat("Not implemented yet :3");
message += Messages.FormatThirstStat("Not implemented yet :3");
message += Messages.FormatTiredStat("Not implemented yet :3");
message += Messages.FormatHungryStat(Messages.FormatPlayerStat(EvenUserStatDistribution(user.Hunger), Messages.StatHunger));
message += Messages.FormatThirstStat(Messages.FormatPlayerStat(EvenUserStatDistribution(user.Thirst), Messages.StatThirst));
message += Messages.FormatTiredStat(Messages.FormatPlayerStat(EvenUserStatDistribution(user.Thirst), Messages.StatTired));
message += Messages.FormatGenderStat(user.Gender);
message += Messages.FormatJewelryStat(BuildWornJewelery(user));
message += Messages.FormatCompetitionGearStat(BuildEquippedCompetitionGear(user));
message += Messages.FormatJewelryStat(buildWornJewelery(user));
message += Messages.FormatCompetitionGearStat(buildEquippedCompetitionGear(user));
message += Messages.StatsPrivateNotes;
message += Messages.StatsQuests;
message += Messages.StatsMinigameRanking;
@ -346,11 +377,13 @@ namespace HISP.Game
message += Messages.FormatPlayerInventoryItemMeta(itemInfo.IconId, item.ItemInstances.Count, title);
int randomId = item.ItemInstances[0].RandomId;
if (itemInfo.Type != "QUEST" && itemInfo.Type != "TEXT" && World.CanDropItems(inv.BaseUser.X, inv.BaseUser.Y))
message += Messages.FormatItemDropButton(randomId);
if (itemInfo.Id == Item.Present || itemInfo.Id == Item.DorothyShoes || itemInfo.Id == Item.Telescope)
message += Messages.FormatItemUseButton(randomId);
if (itemInfo.Type == "CLOTHES")
if (itemInfo.Type == "CLOTHES" || itemInfo.Type == "JEWELRY")
message += Messages.FormatWearButton(randomId);
if (itemInfo.Type == "TEXT")
@ -362,8 +395,6 @@ namespace HISP.Game
if (Item.IsThrowable(itemInfo.Id))
message += Messages.FormatItemThrowButton(randomId);
if (itemInfo.Type != "QUEST" && itemInfo.Type != "TEXT" && World.CanDropItems(inv.BaseUser.X, inv.BaseUser.Y))
message += Messages.FormatItemDropButton(randomId);
message += Messages.FormatItemInformationButton(randomId);
message += "^R1";
}