Add basic stats menu support

This commit is contained in:
SilicaAndPina 2020-12-22 15:01:34 +13:00
parent 1ed964aacf
commit abb90f5865
9 changed files with 315 additions and 11 deletions

View file

@ -82,18 +82,39 @@
"stats_money_format":"<BR>Money: <FONT COLOR='#003300'>$%MONEY%</FONT>",
"stats_freetime_format":"<BR>Today's Free Time Remaining: <B>%FREEMINUTES% minutes.</B>",
"stats_description_format":"<BR>Description: <B>%PLAYERDESC%</B>",
"stats_experience":"<BR>^HExperience: <B>%EXPERIENCE%</B>",
"stats_experience":"<BR>^HExperience: <B>%EXPPOINTS%</B>",
"stats_questpoints":"<BR>Quest Points: <B>%QUESTPOINTS%</B>",
"stats_hunger":"<BR>Hunger: <B>%HUNGER%</B>",
"stats_thisrt":"<BR>Thirst: <B>%THIRST%</B>",
"stats_tiredness":"<BR>Tiredness: <B>%TIRED%</B>",
"stats_gender":"<BR>Gender: <B>%GENDER%</B>",
"stats_equipped":"<BR>%JEWELFORMAT%",
"stats_competion_gear":"<BR>%GEARFORMAT%"
"stats_competion_gear":"<BR>%GEARFORMAT%",
"stats_private_notes":"^R1^R1^T5Horse Isle Private Notes:^D21|VIEW NOTES^R1",
"stats_quests":"^T5Horse Isle Adventures and Quests:^D3|VIEW LOG^R1",
"stats_minigame_ranking":"^T5Horse Isle Mini-Game Rankings:^D20|VIEW LIST^R1",
"stats_awards":"^T5Your Horse Isle Awards:^D24|VIEW AWARDS^R1",
"stats_misc":"^T5Your Horse Isle Misc Tracked Stats:^D53|VIEW STATS^R1",
"competition_gear":{
"head_format":"^R1^I%ICON%^T7%ITEM% on your head.^B4X1",
"body_format":"^R1^I%ICON%^T7%ITEM% on your body.^B4X2",
"legs_format":"^R1^I%ICON%^T7%ITEM% on your legs.^B4X3",
"feet_format":"^R1^I%ICON%^T7%ITEM% on your feet.^B4X4"
},
"msg":{
"no_jewelry_equipped":"You have no Jewelry on.",
"no_competition_gear":"^LYou have nothing interesting for special competition gear.",
}
"competition_gear_selected":"^LYou have the following selected for competition gear:",
"really_hungry":"really hungry",
"hungry":"hungry",
"tiny_bit_thirsty":"a tiny bit thirsty",
"little_bit_thirsty":"a little bit thirsty",
"kind_of_thirsty":"kind of thirsty",
"tiny_bit_tired":"a tiny bit tired",
"not_at_all_tired":"not at all tired"
},
},
"shop":{
"selling":"^LThings I am selling:",

View file

@ -13,6 +13,35 @@ namespace HISP.Game
public static string RakeNothing;
public static string ShovelNothing;
// Stats Page
public static string StatsBarFormat;
public static string StatsAreaFormat;
public static string StatsMoneyFormat;
public static string StatsFreeTimeFormat;
public static string StatsDescriptionFormat;
public static string StatsExpFormat;
public static string StatsQuestpointsFormat;
public static string StatsHungerFormat;
public static string StatsThirstFormat;
public static string StatsTiredFormat;
public static string StatsGenderFormat;
public static string StatsJewelFormat;
public static string StatsCompetitionGearFormat;
public static string CompetitionGearHeadFormat;
public static string CompetitionGearBodyFormat;
public static string CompetitionGearLegsFormat;
public static string CompetitionGearFeetFormat;
public static string StatsPrivateNotes;
public static string StatsQuests;
public static string StatsMinigameRanking;
public static string StatsAwards;
public static string StatsMisc;
public static string NoJewerlyEquipped;
public static string NoCompetitionGear;
// Announcements
public static string NewUserMessage;
public static string WelcomeFormat;
@ -156,6 +185,62 @@ namespace HISP.Game
// Click
public static string NothingInterestingHere;
public static string FormatStatsBar(string username)
{
return StatsBarFormat.Replace("%USERNAME%", username);
}
public static string FormatStatsArea(string area)
{
return StatsAreaFormat.Replace("%AREA%", area);
}
public static string FormatMoneyStat(int money)
{
return StatsMoneyFormat.Replace("%MONEY%", money.ToString("N0"));
}
public static string FormatFreeTime(int freeMinutes)
{
return StatsFreeTimeFormat.Replace("%FREEMINUTES%", freeMinutes.ToString("N0"));
}
public static string FormatPlayerDescriptionForStatsMenu(string description)
{
return StatsDescriptionFormat.Replace("%PLAYERDESC%", description);
}
public static string FormatExperience(int expPoints)
{
return StatsExpFormat.Replace("%EXPPOINTS%", expPoints.ToString("N0"));
}
public static string FormatQuestPoints(int questPoints)
{
return StatsQuestpointsFormat.Replace("%QUESTPOINTS%", questPoints.ToString("N0"));
}
public static string FormatHungryStat(string status)
{
return StatsHungerFormat.Replace("%HUNGER%", status);
}
public static string FormatThirstStat(string status)
{
return StatsThirstFormat.Replace("%THIRST%", status);
}
public static string FormatTiredStat(string status)
{
return StatsTiredFormat.Replace("%TIRED%", status);
}
public static string FormatGenderStat(string gender)
{
return StatsGenderFormat.Replace("%GENDER%", gender);
}
public static string FormatJewelryStat(string jewelformat)
{
return StatsJewelFormat.Replace("%JEWELFORMAT%", jewelformat);
}
public static string FormatCompetitionGearStat(string competitonGearFormat)
{
return StatsCompetitionGearFormat.Replace("%GEARFORMAT%", competitonGearFormat);
}
public static string FormatYouEarnedAnItemMessage(string itemName)
{
return YouEarnedAnItemFormat.Replace("%ITEM%", itemName);

View file

@ -8,6 +8,13 @@ namespace HISP.Game
// Meta
private static string buildLocationString(int x, int y)
{
string areaString = buildAreaString(x, y);
if (areaString != "")
areaString = Messages.LocationFormat.Replace("%META%", areaString);
return areaString;
}
private static string buildAreaString(int x, int y)
{
string locationString = "";
@ -17,8 +24,6 @@ namespace HISP.Game
locationString += Messages.TownFormat.Replace("%TOWN%", World.GetTown(x, y).Name);
if (World.InIsle(x, y))
locationString += Messages.IsleFormat.Replace("%ISLE%", World.GetIsle(x, y).Name);
if (locationString != "")
locationString = Messages.LocationFormat.Replace("%META%", locationString);
return locationString;
}
@ -212,6 +217,43 @@ namespace HISP.Game
}
return message;
}
public static string BuildWornJewelery(User user)
{
return Messages.NoJewerlyEquipped;
}
public static string BuildWornCompaionEquip(User user)
{
return Messages.NoCompetitionGear;
}
public static string BuildStatsMenu(User user)
{
string message = Messages.FormatStatsBar(user.Username);
string areaString = buildAreaString(user.X, user.Y);
if (areaString != "")
message += Messages.FormatStatsArea(areaString);
message += Messages.FormatMoneyStat(user.Money);
if(!user.Subscribed)
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.FormatGenderStat(user.Gender);
message += Messages.FormatJewelryStat(BuildWornJewelery(user));
message += Messages.FormatCompetitionGearStat(BuildWornCompaionEquip(user));
message += Messages.StatsPrivateNotes;
message += Messages.StatsQuests;
message += Messages.StatsMinigameRanking;
message += Messages.StatsAwards;
message += Messages.StatsMisc;
message += Messages.BackToMap;
message += Messages.MetaTerminator;
return message;
}
public static string BuildSpecialTileInfo(User user, World.SpecialTile specialTile)
{
string message = "";

View file

@ -23,10 +23,9 @@ namespace HISP.Player
public bool MuteBuddyRequests = false;
public bool MuteSocials = false;
public bool MuteLogins = false;
public string Gender;
public bool MetaPriority = false;
public int Facing;
public Mailbox MailBox;
public Friends Friends;
@ -35,6 +34,18 @@ namespace HISP.Player
public Npc.NpcEntry LastTalkedToNpc;
public Shop LastShoppedAt;
public PlayerQuests Quests;
public int FreeMinutes
{
get
{
return freeMinutes;
}
set
{
Database.SetFreeTime(Id, value);
freeMinutes = value;
}
}
public bool Subscribed
{
get
@ -108,6 +119,18 @@ namespace HISP.Player
}
}
public int Experience
{
get
{
return experience;
}
set
{
Database.SetExperience(Id, value);
experience = value;
}
}
public int QuestPoints
{
get
@ -182,8 +205,10 @@ namespace HISP.Player
private bool stealth = false;
private int y;
private int money;
private int freeMinutes;
private int questPoints;
private int bankMoney;
private int experience;
public byte[] SecCodeSeeds = new byte[3];
public int SecCodeInc = 0;
@ -242,7 +267,8 @@ namespace HISP.Player
charId = Database.GetPlayerCharId(UserId);
Facing = PacketBuilder.DIRECTION_DOWN;
freeMinutes = Database.GetFreeTime(UserId);
experience = Database.GetExperience(UserId);
money = Database.GetPlayerMoney(UserId);
bankMoney = Database.GetPlayerBankMoney(UserId);
questPoints = Database.GetPlayerQuestPoints(UserId);
@ -250,6 +276,7 @@ namespace HISP.Player
subscribedUntil = Database.GetUserSubscriptionExpireDate(UserId);
profilePage = Database.GetPlayerProfile(UserId);
Gender = Database.GetGender(UserId);
MailBox = new Mailbox(this);
// Generate SecCodes

View file

@ -407,6 +407,84 @@ namespace HISP.Server
return subscribed;
}
}
public static string GetGender(int playerId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT Gender FROM users WHERE Id=@playerId";
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
sqlCommand.Prepare();
string gender = (string)(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return gender;
}
}
public static int GetExperience(int playerId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT Experience FROM userExt WHERE Id=@playerId";
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
sqlCommand.Prepare();
int xp = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return xp;
}
}
public static void SetExperience(int playerId, int exp)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE userExt SET Experience=@xp WHERE Id=@playerId";
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
sqlCommand.Parameters.AddWithValue("@xp", exp);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetFreeTime(int playerId, int minutes)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE userExt SET FreeMinutes=@minutes WHERE Id=@playerId";
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
sqlCommand.Parameters.AddWithValue("@minutes", minutes);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static int GetFreeTime(int playerId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT FreeMinutes FROM userExt WHERE Id=@playerId";
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
sqlCommand.Prepare();
int freeMinutes = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return freeMinutes;
}
}
public static int GetUserSubscriptionExpireDate(int playerId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))

View file

@ -162,7 +162,7 @@ namespace HISP.Server
case PacketBuilder.PACKET_MOVE:
GameServer.OnMovementPacket(this, Packet);
break;
case PacketBuilder.PACKET_PROFILE:
case PacketBuilder.PACKET_PLAYER:
GameServer.OnProfilePacket(this, Packet);
break;
case PacketBuilder.PACKET_CHAT:

View file

@ -391,6 +391,36 @@ namespace HISP.Server
Messages.LoginMessageForamt = gameData.messages.login_format;
Messages.LogoutMessageFormat = gameData.messages.logout_format;
// Stats
Messages.StatsBarFormat = gameData.messages.meta.stats_page.stats_bar_format;
Messages.StatsAreaFormat = gameData.messages.meta.stats_page.stats_area_format;
Messages.StatsMoneyFormat = gameData.messages.meta.stats_page.stats_money_format;
Messages.StatsFreeTimeFormat = gameData.messages.meta.stats_page.stats_freetime_format;
Messages.StatsDescriptionFormat = gameData.messages.meta.stats_page.stats_description_format;
Messages.StatsExpFormat = gameData.messages.meta.stats_page.stats_experience;
Messages.StatsQuestpointsFormat = gameData.messages.meta.stats_page.stats_questpoints;
Messages.StatsHungerFormat = gameData.messages.meta.stats_page.stats_hunger;
Messages.StatsThirstFormat = gameData.messages.meta.stats_page.stats_thisrt;
Messages.StatsTiredFormat = gameData.messages.meta.stats_page.stats_tiredness;
Messages.StatsGenderFormat = gameData.messages.meta.stats_page.stats_gender;
Messages.StatsJewelFormat = gameData.messages.meta.stats_page.stats_equipped;
Messages.StatsCompetitionGearFormat = gameData.messages.meta.stats_page.stats_competion_gear;
Messages.CompetitionGearHeadFormat = gameData.messages.meta.stats_page.competition_gear.head_format;
Messages.CompetitionGearBodyFormat = gameData.messages.meta.stats_page.competition_gear.body_format;
Messages.CompetitionGearLegsFormat = gameData.messages.meta.stats_page.competition_gear.legs_format;
Messages.CompetitionGearFeetFormat = gameData.messages.meta.stats_page.competition_gear.feet_format;
Messages.StatsPrivateNotes = gameData.messages.meta.stats_page.stats_private_notes;
Messages.StatsQuests = gameData.messages.meta.stats_page.stats_quests;
Messages.StatsMinigameRanking = gameData.messages.meta.stats_page.stats_minigame_ranking;
Messages.StatsAwards = gameData.messages.meta.stats_page.stats_awards;
Messages.StatsMisc = gameData.messages.meta.stats_page.stats_misc;
Messages.NoJewerlyEquipped = gameData.messages.meta.stats_page.msg.no_jewelry_equipped;
Messages.NoCompetitionGear = gameData.messages.meta.stats_page.msg.no_competition_gear;
// Transport
Messages.CantAffordTransport = gameData.messages.transport.not_enough_money;

View file

@ -133,6 +133,21 @@ namespace HISP.Server
Logger.DebugPrint("Sending " + sender.LoggedinUser.Username + " updated info...");
UpdatePlayer(sender);
}
}
public static void OnStatsPacket(GameClient sender, byte[] packet)
{
if(!sender.LoggedIn)
{
Logger.ErrorPrint(sender.RemoteIp + " Requested stats when not logged in.");
return;
}
if(packet.Length < 3)
{
Logger.ErrorPrint(sender.LoggedinUser.Username + "Sent an invalid Stats Packet");
return;
}
}
public static void OnProfilePacket(GameClient sender, byte[] packet)
{
@ -148,6 +163,12 @@ namespace HISP.Server
}
byte method = packet[1];
if(method == PacketBuilder.PACKET_CLIENT_TERMINATOR)
{
string metaWind = Meta.BuildStatsMenu(sender.LoggedinUser);
byte[] statsPacket = PacketBuilder.CreateMetaPacket(metaWind);
sender.SendPacket(statsPacket);
}
if (method == PacketBuilder.VIEW_PROFILE)
{
sender.LoggedinUser.MetaPriority = true;

View file

@ -27,7 +27,7 @@ namespace HISP.Server
public const byte PACKET_TILE_FLAGS = 0x75;
public const byte PACKET_PLAYSOUND = 0x23;
public const byte PACKET_KEEP_ALIVE = 0x7C;
public const byte PACKET_PROFILE = 0x18;
public const byte PACKET_PLAYER = 0x18;
public const byte PACKET_INVENTORY = 0x17;
public const byte PACKET_TRANSPORT = 0x29;
public const byte PACKET_KICK = 0x80;
@ -179,7 +179,7 @@ namespace HISP.Server
{
MemoryStream ms = new MemoryStream();
ms.WriteByte(PACKET_PROFILE);
ms.WriteByte(PACKET_PLAYER);
byte[] strBytes = Encoding.UTF8.GetBytes(userProfile);
ms.Write(strBytes, 0x00, strBytes.Length);