mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-07 13:45:42 +12:00
Add Town Halls and Mail
This commit is contained in:
parent
7b8583dcea
commit
35afd32d6c
8 changed files with 991 additions and 40 deletions
|
@ -194,6 +194,55 @@
|
|||
"venus_flytrap_format":"The Giant Venus Flytrap chomped at you!<BR><B>OUCH!!</B><BR>It chomped your pocket, taking $%MONEY% with it!!",
|
||||
"password_input":"<BR>^PLReply:|^PS14|ANSWER^R1",
|
||||
"last_poet":"^R1^LLast Player Poet:%USERNAME% ^R1",
|
||||
"mail":{
|
||||
"mail_received":"A message has been sent to you from another player. It is in your inventory now.",
|
||||
"mail_ripped":"You permanently ripped up the message.",
|
||||
"mail_se":"MAIL",
|
||||
"mail_read":"<I>Reading a Mail Message from Player <BR> By: %PLAYERNAME% (DATE:%DATE%) :</I><BR><BR><CENTER><B>%SUBJECT%</B></CENTER><BR>%MESSAGE%<BR><BR>^T5To get rid of message:^B4Z%RANDOMID%^R5",
|
||||
"mail_select":"<B>Select from the following:</B>",
|
||||
"mail_entry":"^I276^T6%SUBJECT% by %PLAYERNAME%^B4VR%RANDOMID%^R1",
|
||||
},
|
||||
"city_hall":{
|
||||
"menu":"The little post office here can deliver a message to someone on Horse Isle. Postage is $3 per message.^T5Write a message to another player?^D2|COMPOSE^R1^LAlso, the hall has records on several subjects:^R1^T4View current Horses up for Sale^D29|AUTOSELL HORSES^R1^T4View top valued ranches^D14|RANCH RECORDS^R1^T4View richest players^D15|MONEY RECORDS^R1^T4View top spoiled horses^D61|SPOILED HORSES^R1^T4View most adventurous players^D16|QUEST RECORDS^R1^T4View most experienced players^D17|EXPER RECORDS^R1^T4View most active minigamers^D18|GAMES RECORDS^R1^T4View top players' horses^D19|HORSE RECORDS^R1",
|
||||
"mail_send_meta":"^LComposing a message to another player in Horse Isle^R1^PLSend to Player Name:|^PLSubject:|^LMessage:^R1^PB120|^PS2|MAIL MESSAGE",
|
||||
"sent_mail":"Your message will be given to %PLAYERNAME% the next time they visit a Town Hall",
|
||||
"cant_afford_postage":"You cannot afford the postage!",
|
||||
"cant_find_player":"Could not find a player named (%PLAYERNAME%) to address the letter to!",
|
||||
"auto_sell":{
|
||||
"top_100_cheapest":"100 Cheapest Horses on Auto-Sell<BR>",
|
||||
"cheap_horse_entry":"<B>$%PRICE%</B> %PLAYERNAME%'s %HORSENAME% (%COLOR% %BREED% %EXP%exp)<BR>",
|
||||
"top_50_most_exp":"<BR><BR>50 Most Experienced Horses on Auto-Sell<BR>",
|
||||
"exp_horse_entry":"<B>%EXP% exp</B> %PLAYERNAME%'s %HORSENAME% ($%PRICE% %COLOR% %BREED%)<BR>"
|
||||
},
|
||||
"ranch_investment":{
|
||||
"top_25":"25 Top Money Invested in a Ranch:",
|
||||
"ranch_entry":"^T7 #%PLACING%: %PLAYERNAME%'s Ranch - $%VALUE% ^B1M%MAPXY%^R1"
|
||||
},
|
||||
"richest_players":{
|
||||
"top_25":"25 Richest Players (money + bank balance):<BR>(ranch and equipment is worth LOTS and not counted in this list)<BR>",
|
||||
"rich_player_format":"#%PLACING%: <B>$%MONEY%</B> - %PLAYERNAME%<BR>",
|
||||
},
|
||||
"spoiled_horses":{
|
||||
"top_100":"100 Top Spoiled Horses<BR>",
|
||||
"spoiled_horse_entry":"<B>%SPOILED%pts</B> %PLAYERNAME%'s %HORSENAME% <BR>"
|
||||
},
|
||||
"most_adventurous_players":{
|
||||
"top_25":"25 Most Quest Points Completed!<BR>",
|
||||
"adventurous_player_entry":"#%PLACING%: <B>%QUESTPOINTS% pts</B> - %PLAYERNAME%<BR>"
|
||||
},
|
||||
"most_experinced_players":{
|
||||
"top_25":"25 Most Experience Points Earned!<BR>",
|
||||
"experienced_player_entry":"#%PLACING%: <B>%EXP% pts</B> - %PLAYERNAME%<BR>"
|
||||
},
|
||||
"most_active_minigame_players":{
|
||||
"top_25":"25 Most Active Minigame players!<BR>(only for those that are tracked)<BR>",
|
||||
"minigame_player_entry":"#%PLACING%: <B>%GAMESPLAYED% games played</B> - %PLAYERNAME%<BR>"
|
||||
},
|
||||
"most_experienced_horses":{
|
||||
"top_25":"25 Most Experienced Horses<BR>",
|
||||
"experienced_horse_entry":"#%PLACING%: <B>%EXP% exp</B> - %PLAYERNAME%'s %HORSENAME%<BR>"
|
||||
}
|
||||
},
|
||||
"trainer_pen":{
|
||||
"train_success":"Your horse, %HORSENAME%, has been successfully trained in %STAT%.",
|
||||
"train_header":"<BR><BR><B>Purchase a training session:</B><BR>Costs: $%PRICE% + thirst/hunger/mood<BR>Benefits: %AMOUNT% %STAT% + %EXPAMOUNT% experience<BR>Click a Horse to Train Them:",
|
||||
|
@ -235,7 +284,10 @@
|
|||
"placing":"<B>%PLACE%</B> player %USERNAME% scored: %SCORE%<BR>",
|
||||
"first_place":"First place:",
|
||||
"second_place":"Second place:",
|
||||
|
||||
"third_place":"Third place",
|
||||
"fourth_place":"Fourth place:",
|
||||
"fifth_place":"Fifth place:",
|
||||
"sixth_place":"Sixth place:",
|
||||
"enter_into":"You entered your horse in the competition. The event will begin when it is time!",
|
||||
"already_entered":"You are already entered into an arena event!",
|
||||
|
||||
|
@ -248,6 +300,7 @@
|
|||
"too_hungry":"Your poor horse is too hungry to compete!",
|
||||
"too_thisty":"Your poor horse is too thirsty to compete!",
|
||||
"farrier":"Your poor horse needs a farrier!",
|
||||
"too_tired":"Your poor horse is too tired to compete!",
|
||||
"needs_vet":"Your poor horse needs a vet!",
|
||||
},
|
||||
"ranch":{
|
||||
|
@ -780,7 +833,7 @@
|
|||
"item_throw_button":"^B4T%RANDOMID%",
|
||||
"item_use_button":"^B4UD%RANDOMID%",
|
||||
"item_open_button":"^B4O%RANDOMID%",
|
||||
"item_read_button":"^B4VL%RANDOMID%",
|
||||
"item_read_button":"^B4VL%ITEMID%",
|
||||
"buy_button":"^B4BN%ITEMID%",
|
||||
"buy_5_button":"^B4B5%ITEMID%",
|
||||
"buy_25_button":"^B4B2%ITEMID%",
|
||||
|
|
|
@ -16,6 +16,57 @@ namespace HISP.Game
|
|||
// Click
|
||||
public static string PlayerHereFormat;
|
||||
|
||||
// City Hall
|
||||
public static string CityHallMenu;
|
||||
public static string CityHallMailSendMeta;
|
||||
public static string CityHallSentMessageFormat;
|
||||
public static string CityHallCantAffordPostageMessage;
|
||||
public static string CityHallCantFindPlayerMessageFormat;
|
||||
|
||||
// City Hall : Auto Sell
|
||||
public static string CityHallCheapestAutoSells;
|
||||
public static string CityHallCheapestAutoSellHorseEntryFormat;
|
||||
public static string CityHallMostExpAutoSells;
|
||||
public static string CityHallMostExpAutoSellHorseEntryFormat;
|
||||
|
||||
// City Hall : Ranch Investment
|
||||
public static string CityHallTop25Ranches;
|
||||
public static string CityHallRanchEntryFormat;
|
||||
|
||||
// City Hall : Richest Players
|
||||
public static string CityHallTop25Players;
|
||||
public static string CityHallRichPlayerFormat;
|
||||
|
||||
// City Hall : Spoiled Horses
|
||||
public static string CityHallTop100SpoiledHorses;
|
||||
public static string CityHallSpoiledHorseEntryFormat;
|
||||
|
||||
// City Hall : Most Adventurous Players
|
||||
public static string CityHallTop25AdventurousPlayers;
|
||||
public static string CityHallAdventurousPlayerEntryFormat;
|
||||
|
||||
// City Hall : Most Experienced Players
|
||||
public static string CityHallTop25ExperiencedPlayers;
|
||||
public static string CityHallExperiencePlayerEntryFormat;
|
||||
|
||||
// City Hall : Most Played Minigames
|
||||
public static string CityHallTop25MinigamePlayers;
|
||||
public static string CityHallMinigamePlayerEntryFormat;
|
||||
|
||||
// City Hall : Most Experienced Horses
|
||||
public static string CityHallTop25ExperiencedHorses;
|
||||
public static string CityHallExperiencedHorseEntryFormat;
|
||||
|
||||
|
||||
// Mail Messages
|
||||
public static string MailReceivedMessage;
|
||||
public static string MailSe;
|
||||
public static string MailSelectFromFollowing;
|
||||
|
||||
public static string MailEntryFormat;
|
||||
public static string MailReadMetaFormat;
|
||||
public static string MailRippedMessage;
|
||||
|
||||
// Ranch
|
||||
public static string RanchUnownedRanchFormat;
|
||||
public static string RanchYouCouldPurchaseThisRanch;
|
||||
|
@ -741,6 +792,62 @@ namespace HISP.Game
|
|||
// Click
|
||||
public static string NothingInterestingHere;
|
||||
|
||||
public static string FormatCityHallCantFindPlayerMessage(string playerName)
|
||||
{
|
||||
return CityHallCantFindPlayerMessageFormat.Replace("%PLAYERNAME%", playerName);
|
||||
}
|
||||
public static string FormatCityHallTopExperiencedHorses(int placing, int experiencePoints, string playerName, string horseName)
|
||||
{
|
||||
return CityHallExperiencedHorseEntryFormat.Replace("%PLACING%", placing.ToString()).Replace("%EXP%", experiencePoints.ToString("N0", CultureInfo.InvariantCulture)).Replace("%PLAYERNAME%", playerName).Replace("%HORSENAME%", horseName);
|
||||
}
|
||||
public static string FormatCityHallTopMinigamePlayers(int placing, int gamesPlayed, string playerName)
|
||||
{
|
||||
return CityHallMinigamePlayerEntryFormat.Replace("%PLACING%", placing.ToString()).Replace("%GAMESPLAYED%", gamesPlayed.ToString("N0", CultureInfo.InvariantCulture)).Replace("%PLAYERNAME%", playerName);
|
||||
}
|
||||
public static string FormatCityHallTopExperiencedPlayersEntry(int placing, int experiencePoints, string playerName)
|
||||
{
|
||||
return CityHallExperiencePlayerEntryFormat.Replace("%PLACING%", placing.ToString()).Replace("%EXP%", experiencePoints.ToString()).Replace("%PLAYERNAME%", playerName);
|
||||
}
|
||||
public static string FormatCityHallTopAdventurousPlayersEntry(int placing, int questPoints, string playerName)
|
||||
{
|
||||
return CityHallAdventurousPlayerEntryFormat.Replace("%PLACING%", placing.ToString()).Replace("%QUESTPOINTS%", questPoints.ToString("N0", CultureInfo.InvariantCulture)).Replace("%PLAYERNAME%", playerName);
|
||||
}
|
||||
public static string FormatCityHallTopSpoiledHorseEntry(int spoiled, string playerName, string horseName)
|
||||
{
|
||||
return CityHallSpoiledHorseEntryFormat.Replace("%SPOILED%", spoiled.ToString()).Replace("%PLAYERNAME%", playerName).Replace("%HORSENAME%", horseName);
|
||||
}
|
||||
public static string FormatCityHallTopPlayerEntry(int placing, double money, string playerName)
|
||||
{
|
||||
return CityHallRichPlayerFormat.Replace("%PLACING%", placing.ToString()).Replace("%MONEY%", money.ToString("N0", CultureInfo.InvariantCulture)).Replace("%PLAYERNAME%", playerName);
|
||||
}
|
||||
public static string FormatCityHallTopRanchEntry(int placing, string playerName, int value, string mapxy)
|
||||
{
|
||||
return CityHallRanchEntryFormat.Replace("%PLACING%", placing.ToString()).Replace("%PLAYERNAME%", playerName).Replace("%VALUE%", value.ToString("N0", CultureInfo.InvariantCulture)).Replace("%MAPXY%", mapxy);
|
||||
}
|
||||
public static string FormatCityHallBestExpAutoSellEntry(int exp, string playerName, string horseName, int price, string color, string breed)
|
||||
{
|
||||
return CityHallMostExpAutoSellHorseEntryFormat.Replace("%EXP%", exp.ToString()).Replace("%PLAYERNAME%", playerName).Replace("%HORSENAME%", horseName).Replace("%PRICE%", price.ToString("N0", CultureInfo.InvariantCulture)).Replace("%COLOR%", color).Replace("%BREED%", breed);
|
||||
}
|
||||
public static string FormatCityHallCheapAutoSellEntry(int price, string playerName, string horseName, string color, string breed, int exp)
|
||||
{
|
||||
return CityHallCheapestAutoSellHorseEntryFormat.Replace("%PRICE%", price.ToString("N0", CultureInfo.InvariantCulture)).Replace("%PLAYERNAME%", playerName).Replace("%HORSENAME%", horseName).Replace("%COLOR%", color).Replace("%BREED%", breed).Replace("%EXP%", exp.ToString("N0", CultureInfo.InvariantCulture));
|
||||
}
|
||||
public static string FormatCityHallSendMailMessage(string playerName)
|
||||
{
|
||||
return CityHallSentMessageFormat.Replace("%PLAYERNAME%", playerName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static string FormatMailReadMessage(string fromUser, string date, string subject, string message, int randomId)
|
||||
{
|
||||
return MailReadMetaFormat.Replace("%PLAYERNAME%", fromUser).Replace("%DATE%", date).Replace("%SUBJECT%", subject).Replace("%MESSAGE%", message).Replace("%RANDOMID%", randomId.ToString());
|
||||
}
|
||||
public static string FormatMailEntry(string subject, string fromUser, int randomId)
|
||||
{
|
||||
return MailEntryFormat.Replace("%SUBJECT%", subject).Replace("%PLAYERNAME%", fromUser).Replace("%RANDOMID%", randomId.ToString());
|
||||
}
|
||||
|
||||
public static string FormatTrainerCantTrainAgainIn(int time)
|
||||
{
|
||||
return TrainerCantTrainAgainInFormat.Replace("%TIME%", time.ToString());
|
||||
|
@ -1817,7 +1924,7 @@ namespace HISP.Game
|
|||
}
|
||||
public static string FormatItemReadButton(int randomid)
|
||||
{
|
||||
return ItemReadButton.Replace("%RANDOMID%", randomid.ToString());
|
||||
return ItemReadButton.Replace("%ITEMID%", randomid.ToString());
|
||||
}
|
||||
|
||||
// Meta
|
||||
|
|
|
@ -666,7 +666,7 @@ namespace HISP.Game
|
|||
}
|
||||
else
|
||||
{
|
||||
message += Messages.FormatRanchTrainFail(horse.Name, horse.TrainTimer);
|
||||
message += Messages.FormatRanchTrainFail(horse.Name, horse.TrainTimer);
|
||||
}
|
||||
}
|
||||
message += Messages.BackToMap;
|
||||
|
@ -1133,6 +1133,137 @@ namespace HISP.Game
|
|||
|
||||
return message;
|
||||
}
|
||||
public static string BuildMinigamePlayers()
|
||||
{
|
||||
string message = Messages.CityHallTop25MinigamePlayers;
|
||||
int placing = 1;
|
||||
foreach (int userId in Database.GetMinigamePlayers())
|
||||
{
|
||||
string username = Database.GetUsername(userId);
|
||||
int totalMinigames = Database.GetPlayerTotalMinigamesPlayed(userId);
|
||||
|
||||
message += Messages.FormatCityHallTopMinigamePlayers(placing, totalMinigames, username);
|
||||
placing++;
|
||||
}
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildMostExperienedHoses()
|
||||
{
|
||||
string message = Messages.CityHallTop25ExperiencedHorses;
|
||||
|
||||
int placing = 1;
|
||||
foreach (HorseInstance horse in Database.GetMostExperiencedHorses())
|
||||
{
|
||||
message += Messages.FormatCityHallTopExperiencedHorses(placing, horse.BasicStats.Experience, Database.GetUsername(horse.Owner), horse.Name);
|
||||
placing++;
|
||||
}
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildExperiencedPlayers()
|
||||
{
|
||||
string message = Messages.CityHallTop25ExperiencedPlayers;
|
||||
int placing = 1;
|
||||
foreach (int userId in Database.GetAdventurousPlayers())
|
||||
{
|
||||
string username = Database.GetUsername(userId);
|
||||
int exp = Database.GetExperience(userId);
|
||||
|
||||
message += Messages.FormatCityHallTopExperiencedPlayersEntry(placing, exp, username);
|
||||
placing++;
|
||||
}
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildAdventurousPlayers()
|
||||
{
|
||||
string message = Messages.CityHallTop25AdventurousPlayers;
|
||||
int placing = 1;
|
||||
foreach (int userId in Database.GetAdventurousPlayers())
|
||||
{
|
||||
string username = Database.GetUsername(userId);
|
||||
int questPoints = Database.GetPlayerQuestPoints(userId);
|
||||
|
||||
message += Messages.FormatCityHallTopAdventurousPlayersEntry(placing, questPoints, username);
|
||||
placing++;
|
||||
}
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildMostSpoiledHorses()
|
||||
{
|
||||
string message = Messages.CityHallTop100SpoiledHorses;
|
||||
foreach(HorseInstance horse in Database.GetMostSpoiledHorses())
|
||||
{
|
||||
message += Messages.FormatCityHallTopSpoiledHorseEntry(horse.Spoiled, Database.GetUsername(horse.Owner), horse.Name);
|
||||
}
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildRichestPlayers()
|
||||
{
|
||||
string message = Messages.CityHallTop25Players;
|
||||
int placing = 1;
|
||||
foreach(int userId in Database.GetRichestPlayers())
|
||||
{
|
||||
string username = Database.GetUsername(userId);
|
||||
double totalMoney = Math.Floor(Database.GetPlayerMoney(userId) + Database.GetPlayerBankMoney(userId));
|
||||
|
||||
message += Messages.FormatCityHallTopPlayerEntry(placing, totalMoney, username);
|
||||
placing++;
|
||||
}
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildMostValuedRanches()
|
||||
{
|
||||
string message = Messages.CityHallTop25Ranches;
|
||||
int total = 1;
|
||||
|
||||
foreach(Ranch ranch in Ranch.Ranches.OrderBy(o => o.InvestedMoney).Reverse().ToList())
|
||||
{
|
||||
if (ranch.OwnerId == -1)
|
||||
continue;
|
||||
|
||||
|
||||
message += Messages.FormatCityHallTopRanchEntry(total, Database.GetUsername(ranch.OwnerId), ranch.InvestedMoney, Messages.FormatMapLocation(ranch.X, ranch.Y));
|
||||
|
||||
if (total > 26)
|
||||
break;
|
||||
|
||||
total++;
|
||||
}
|
||||
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
|
||||
public static string BuildTopAutoSellHorses()
|
||||
{
|
||||
string message = Messages.CityHallCheapestAutoSells;
|
||||
HorseInstance[] horses = Database.GetCheapestHorseAutoSell();
|
||||
foreach(HorseInstance horse in horses)
|
||||
{
|
||||
message += Messages.FormatCityHallCheapAutoSellEntry(horse.AutoSell, Database.GetUsername(horse.Owner), horse.Name, horse.Color, horse.Breed.Name, horse.BasicStats.Experience);
|
||||
}
|
||||
message += Messages.CityHallMostExpAutoSells;
|
||||
horses = Database.GetBiggestExpAutoSell();
|
||||
foreach (HorseInstance horse in horses)
|
||||
{
|
||||
message += Messages.FormatCityHallBestExpAutoSellEntry(horse.BasicStats.Experience, Database.GetUsername(horse.Owner), horse.Name, horse.AutoSell, horse.Color, horse.Breed.Name);
|
||||
}
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildRanchEdit(Ranch ranch)
|
||||
{
|
||||
return Messages.FormatRanchEditDescriptonMeta(ranch.Title, ranch.Description) + Messages.BackToMap + Messages.MetaTerminator;
|
||||
|
@ -1512,6 +1643,45 @@ namespace HISP.Game
|
|||
|
||||
return message;
|
||||
}
|
||||
public static string BuildMailLetter(Mailbox.Mail mailMessage, int itemRandomId)
|
||||
{
|
||||
DateTime time = Converters.UnixTimeStampToDateTime(mailMessage.Timestamp);
|
||||
string amOrPm = "am";
|
||||
string[] months = new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
||||
string minutes = time.Minute.ToString();
|
||||
if (minutes.Length <= 1)
|
||||
minutes = "0" + minutes;
|
||||
int hours = time.Hour;
|
||||
if (hours == 0)
|
||||
{
|
||||
amOrPm = "am";
|
||||
hours = 12;
|
||||
}
|
||||
if (hours > 12)
|
||||
{
|
||||
hours -= 12;
|
||||
amOrPm = "pm";
|
||||
}
|
||||
|
||||
|
||||
string date = months[time.Month-1] + " " + time.Day + ", " + time.Year + " " + hours + ":" + minutes + amOrPm;
|
||||
string message = Messages.FormatMailReadMessage(Database.GetUsername(mailMessage.FromUser), date, mailMessage.Subject, mailMessage.Message, itemRandomId);
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildMailList(User user, InventoryItem mailMessageForPlayer)
|
||||
{
|
||||
string message = Messages.MailSelectFromFollowing;
|
||||
foreach(ItemInstance inst in mailMessageForPlayer.ItemInstances)
|
||||
{
|
||||
Mailbox.Mail mail = user.MailBox.GetMessageByRandomId(inst.Data);
|
||||
message += Messages.FormatMailEntry(mail.Subject, Database.GetUsername(mail.FromUser), inst.RandomId);
|
||||
}
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildInventoryInfo(PlayerInventory inv)
|
||||
{
|
||||
string message = "";
|
||||
|
@ -1541,7 +1711,7 @@ namespace HISP.Game
|
|||
message += Messages.FormatWearButton(randomId);
|
||||
|
||||
if (itemInfo.Type == "TEXT")
|
||||
message += Messages.FormatItemReadButton(randomId);
|
||||
message += Messages.FormatItemReadButton(item.ItemId);
|
||||
|
||||
if (itemInfo.Type == "PLAYERFOOD")
|
||||
message += Messages.FormatItemConsumeButton(randomId);
|
||||
|
@ -2022,6 +2192,32 @@ namespace HISP.Game
|
|||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildComposeMailMenu()
|
||||
{
|
||||
string message = Messages.CityHallMailSendMeta;
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
private static string buildTownHall(User user)
|
||||
{
|
||||
if(user.MailBox.UnreadMailCount > 0)
|
||||
{
|
||||
|
||||
byte[] RipOffAOLSound = PacketBuilder.CreatePlaysoundPacket(Messages.MailSe);
|
||||
user.LoggedinClient.SendPacket(RipOffAOLSound);
|
||||
|
||||
byte[] mailReceivedText = PacketBuilder.CreateChat(Messages.MailReceivedMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
user.LoggedinClient.SendPacket(mailReceivedText);
|
||||
|
||||
user.MailBox.ReadAllMail();
|
||||
}
|
||||
|
||||
string message = Messages.CityHallMenu;
|
||||
message += Messages.ExitThisPlace;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildSpecialTileInfo(User user, World.SpecialTile specialTile)
|
||||
{
|
||||
string message = "";
|
||||
|
@ -2080,6 +2276,10 @@ namespace HISP.Game
|
|||
message += buildShopInfo(shop, user.Inventory);
|
||||
|
||||
}
|
||||
if(TileCode == "TOWNHALL")
|
||||
{
|
||||
message += buildTownHall(user);
|
||||
}
|
||||
if (TileCode == "VET")
|
||||
{
|
||||
message += buildVet(user, Vet.GetVetById(int.Parse(TileArg)));
|
||||
|
|
|
@ -1,16 +1,120 @@
|
|||
using HISP.Server;
|
||||
using HISP.Game;
|
||||
using HISP.Game.Inventory;
|
||||
using HISP.Game.Items;
|
||||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Player
|
||||
{
|
||||
public class Mailbox
|
||||
{
|
||||
private User baseUser;
|
||||
public int MailCount;
|
||||
private List<Mail> mails = new List<Mail>();
|
||||
public int MailCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return MailMessages.Length;
|
||||
}
|
||||
}
|
||||
public int UnreadMailCount
|
||||
{
|
||||
get
|
||||
{
|
||||
int i = 0;
|
||||
foreach (Mail mail in MailMessages)
|
||||
if (!mail.Read)
|
||||
i++;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
public Mail[] MailMessages
|
||||
{
|
||||
get
|
||||
{
|
||||
return mails.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public class Mail
|
||||
{
|
||||
public int RandomId;
|
||||
public bool Read;
|
||||
public int FromUser;
|
||||
public int ToUser;
|
||||
public string Subject;
|
||||
public string Message;
|
||||
public int Timestamp;
|
||||
}
|
||||
|
||||
public void RipUpMessage(Mail message)
|
||||
{
|
||||
Database.DeleteMail(message.RandomId);
|
||||
mails.Remove(message);
|
||||
|
||||
InventoryItem item = baseUser.Inventory.GetItemByItemId(Item.MailMessage);
|
||||
foreach(ItemInstance instance in item.ItemInstances)
|
||||
{
|
||||
if (instance.Data == message.RandomId)
|
||||
{
|
||||
baseUser.Inventory.Remove(instance);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] rippedUpMessage = PacketBuilder.CreateChat(Messages.MailRippedMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
baseUser.LoggedinClient.SendPacket(rippedUpMessage);
|
||||
GameServer.UpdateInventory(baseUser.LoggedinClient);
|
||||
}
|
||||
|
||||
public void ReadAllMail()
|
||||
{
|
||||
|
||||
Database.ReadAllMail(baseUser.Id);
|
||||
|
||||
for (int i = 0; i < MailCount; i++)
|
||||
{
|
||||
if(!mails[i].Read)
|
||||
{
|
||||
ItemInstance mailMessageFromPlayer = new ItemInstance(Item.MailMessage, -1, mails[i].RandomId);
|
||||
baseUser.Inventory.AddIgnoringFull(mailMessageFromPlayer);
|
||||
mails[i].Read = true;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] BaseStatsPacketData = PacketBuilder.CreatePlayerData(baseUser.Money, GameServer.GetNumberOfPlayers(), baseUser.MailBox.UnreadMailCount);
|
||||
baseUser.LoggedinClient.SendPacket(BaseStatsPacketData);
|
||||
}
|
||||
public void AddMail(Mail mailMessage)
|
||||
{
|
||||
mails.Add(mailMessage);
|
||||
Database.AddMail(mailMessage.RandomId, mailMessage.ToUser, mailMessage.FromUser, mailMessage.Subject, mailMessage.Message, mailMessage.Timestamp, mailMessage.Read);
|
||||
}
|
||||
public bool MessageExists(int randomId)
|
||||
{
|
||||
foreach (Mail mail in MailMessages)
|
||||
{
|
||||
if (mail.RandomId == randomId)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public Mail GetMessageByRandomId(int randomId)
|
||||
{
|
||||
foreach(Mail mail in MailMessages)
|
||||
{
|
||||
if (mail.RandomId == randomId)
|
||||
return mail;
|
||||
}
|
||||
throw new KeyNotFoundException("Mail w id " + randomId + " NOT FOUND.");
|
||||
}
|
||||
public Mailbox(User user)
|
||||
{
|
||||
MailCount = Database.CheckMailcount(user.Id);
|
||||
baseUser = user;
|
||||
Mail[] mailMessages = Database.LoadMailbox(user.Id);
|
||||
foreach (Mail mailMessage in mailMessages)
|
||||
mails.Add(mailMessage);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ using HISP.Player;
|
|||
using HISP.Game.Horse;
|
||||
using HISP.Game.Inventory;
|
||||
using HISP.Game.Items;
|
||||
using HISP.Security;
|
||||
|
||||
namespace HISP.Server
|
||||
{
|
||||
|
@ -21,8 +22,8 @@ namespace HISP.Server
|
|||
db.Open();
|
||||
string UserTable = "CREATE TABLE Users(Id INT, Username TEXT(16),Email TEXT(128),Country TEXT(128),SecurityQuestion Text(128),SecurityAnswerHash TEXT(128),Age INT,PassHash TEXT(128), Salt TEXT(128),Gender TEXT(16), Admin TEXT(3), Moderator TEXT(3))";
|
||||
string ExtTable = "CREATE TABLE UserExt(Id INT, X INT, Y INT, LastLogin INT, Money INT, QuestPoints INT, BankBalance DOUBLE, BankInterest DOUBLE, ProfilePage Text(1028),IpAddress TEXT(1028),PrivateNotes Text(1028), CharId INT, ChatViolations INT,Subscriber TEXT(3), SubscribedUntil INT, Experience INT, Tiredness INT, Hunger INT, Thirst INT, FreeMinutes INT)";
|
||||
string MailTable = "CREATE TABLE Mailbox(IdTo INT, PlayerFrom TEXT(16),Subject TEXT(128), Message Text(1028), TimeSent INT)";
|
||||
string BuddyTable = "CREATE TABLE BuddyList(Id INT, IdFriend INT, Pending BOOL)";
|
||||
string MailTable = "CREATE TABLE Mailbox(RandomId INT, IdTo INT, IdFrom INT, Subject TEXT(128), Message Text(1028), TimeSent INT, BeenRead TEXT(3))";
|
||||
string BuddyTable = "CREATE TABLE BuddyList(Id INT, IdFriend INT, Pending TEXT(3))";
|
||||
string WorldTable = "CREATE TABLE World(Time INT, Day INT, Year INT)";
|
||||
string WeatherTable = "CREATE TABLE Weather(Area TEXT(1028), Weather TEXT(64))";
|
||||
string InventoryTable = "CREATE TABLE Inventory(PlayerID INT, RandomID INT, ItemID INT, Data INT)";
|
||||
|
@ -2713,22 +2714,6 @@ namespace HISP.Server
|
|||
}
|
||||
}
|
||||
|
||||
public static int CheckMailcount(int id)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "SELECT COUNT(1) FROM Mailbox WHERE IdTo=@id";
|
||||
sqlCommand.Parameters.AddWithValue("@id", id);
|
||||
sqlCommand.Prepare();
|
||||
Int32 count = Convert.ToInt32(sqlCommand.ExecuteScalar());
|
||||
|
||||
sqlCommand.Dispose();
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool HasJewelry(int playerId)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
|
@ -3803,20 +3788,81 @@ namespace HISP.Server
|
|||
}
|
||||
|
||||
}
|
||||
public static void AddMail(int toId, string fromName, string subject, string message)
|
||||
public static Mailbox.Mail[] LoadMailbox(int toId)
|
||||
{
|
||||
List<Mailbox.Mail> mailList = new List<Mailbox.Mail>();
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
|
||||
|
||||
sqlCommand.CommandText = "SELECT * FROM Mailbox WHERE IdTo=@toId";
|
||||
sqlCommand.Parameters.AddWithValue("@toId", toId);
|
||||
sqlCommand.Prepare();
|
||||
MySqlDataReader reader = sqlCommand.ExecuteReader();
|
||||
while(reader.Read())
|
||||
{
|
||||
Mailbox.Mail MailMessage = new Mailbox.Mail();
|
||||
MailMessage.RandomId = RandomID.NextRandomId(reader.GetInt32(0));
|
||||
MailMessage.ToUser = reader.GetInt32(1);
|
||||
MailMessage.FromUser = reader.GetInt32(2);
|
||||
MailMessage.Subject = reader.GetString(3);
|
||||
MailMessage.Message = reader.GetString(4);
|
||||
MailMessage.Timestamp = reader.GetInt32(5);
|
||||
MailMessage.Read = reader.GetString(6) == "YES";
|
||||
mailList.Add(MailMessage);
|
||||
}
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
return mailList.ToArray();
|
||||
}
|
||||
public static void ReadAllMail(int toId)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
int epoch = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
|
||||
sqlCommand.CommandText = "INSERT INTO Mailbox VALUES(@toId,@from,@subject,@message,@time)";
|
||||
|
||||
sqlCommand.CommandText = "UPDATE Mailbox SET BeenRead='YES' WHERE IdTo=@toId";
|
||||
sqlCommand.Parameters.AddWithValue("@toId", toId);
|
||||
sqlCommand.Parameters.AddWithValue("@from", fromName);
|
||||
sqlCommand.Prepare();
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
}
|
||||
public static void DeleteMail(int randomId)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
|
||||
|
||||
sqlCommand.CommandText = "DELETE FROM Mailbox WHERE randomId=@randomId";
|
||||
sqlCommand.Parameters.AddWithValue("@randomId", randomId);
|
||||
sqlCommand.Prepare();
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
}
|
||||
public static void AddMail(int randomId, int toId, int fromId, string subject, string message, int timestamp, bool read)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
|
||||
|
||||
sqlCommand.CommandText = "INSERT INTO Mailbox VALUES(@randomId, @toId,@from,@subject,@message,@time,@read)";
|
||||
sqlCommand.Parameters.AddWithValue("@randomId", randomId);
|
||||
sqlCommand.Parameters.AddWithValue("@toId", toId);
|
||||
sqlCommand.Parameters.AddWithValue("@from", fromId);
|
||||
sqlCommand.Parameters.AddWithValue("@subject", subject);
|
||||
sqlCommand.Parameters.AddWithValue("@mesasge", message);
|
||||
sqlCommand.Parameters.AddWithValue("@time", epoch);
|
||||
sqlCommand.Parameters.AddWithValue("@message", message);
|
||||
sqlCommand.Parameters.AddWithValue("@time", timestamp);
|
||||
sqlCommand.Parameters.AddWithValue("@read", read ? "YES" : "NO");
|
||||
sqlCommand.Prepare();
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
|
@ -3927,7 +3973,7 @@ namespace HISP.Server
|
|||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "SELECT COUNT(1) FROM BuddyList WHERE Id=@id OR IdFriend=@id AND Pending=false";
|
||||
sqlCommand.CommandText = "SELECT COUNT(1) FROM BuddyList WHERE Id=@id OR IdFriend=@id AND Pending='NO'";
|
||||
sqlCommand.Parameters.AddWithValue("@id", id);
|
||||
sqlCommand.Prepare();
|
||||
|
||||
|
@ -3949,7 +3995,7 @@ namespace HISP.Server
|
|||
List<int> BuddyList = new List<int>();
|
||||
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "SELECT Id,IdFriend FROM BuddyList WHERE Id=@id OR IdFriend=@id AND Pending=false";
|
||||
sqlCommand.CommandText = "SELECT Id,IdFriend FROM BuddyList WHERE Id=@id OR IdFriend=@id AND Pending='NO'";
|
||||
sqlCommand.Parameters.AddWithValue("@id", id);
|
||||
sqlCommand.Prepare();
|
||||
MySqlDataReader dataReader = sqlCommand.ExecuteReader();
|
||||
|
@ -3975,7 +4021,7 @@ namespace HISP.Server
|
|||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "SELECT COUNT(1) FROM BuddyList WHERE (Id=@id AND IdFriend=@friendId) OR (Id=@friendid AND IdFriend=@Id) AND Pending=true";
|
||||
sqlCommand.CommandText = "SELECT COUNT(1) FROM BuddyList WHERE (Id=@id AND IdFriend=@friendId) OR (Id=@friendid AND IdFriend=@Id) AND Pending='YES'";
|
||||
sqlCommand.Parameters.AddWithValue("@id", id);
|
||||
sqlCommand.Parameters.AddWithValue("@friendId", friendId);
|
||||
sqlCommand.Prepare();
|
||||
|
@ -4020,7 +4066,7 @@ namespace HISP.Server
|
|||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "INSERT INTO BuddyList VALUES(@id,@friendId,true)";
|
||||
sqlCommand.CommandText = "INSERT INTO BuddyList VALUES(@id,@friendId,'YES')";
|
||||
sqlCommand.Parameters.AddWithValue("@id", id);
|
||||
sqlCommand.Parameters.AddWithValue("@friendId", friendId);
|
||||
sqlCommand.Prepare();
|
||||
|
@ -4409,6 +4455,180 @@ namespace HISP.Server
|
|||
}
|
||||
}
|
||||
|
||||
public static HorseInstance[] GetMostExperiencedHorses()
|
||||
{
|
||||
List<HorseInstance> inst = new List<HorseInstance>();
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "SELECT * FROM Horses ORDER BY experience DESC LIMIT 25";
|
||||
sqlCommand.Prepare();
|
||||
MySqlDataReader reader = sqlCommand.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
inst.Add(ReadHorseInstance(reader));
|
||||
}
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
return inst.ToArray();
|
||||
}
|
||||
public static int[] GetMinigamePlayers()
|
||||
{
|
||||
List<int> userIds = new List<int>();
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "SELECT DISTINCT playerId, SUM(timesplayed) OVER (PARTITION BY playerId) AS totalPlays FROM leaderboards ORDER BY totalPlays DESC LIMIT 25";
|
||||
sqlCommand.Prepare();
|
||||
MySqlDataReader reader = sqlCommand.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
userIds.Add(reader.GetInt32(0));
|
||||
}
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
return userIds.ToArray();
|
||||
}
|
||||
|
||||
|
||||
public static int[] GetExperiencedPlayers()
|
||||
{
|
||||
List<int> userIds = new List<int>();
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "SELECT id FROM UserExt ORDER BY Experience DESC LIMIT 25";
|
||||
sqlCommand.Prepare();
|
||||
MySqlDataReader reader = sqlCommand.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
userIds.Add(reader.GetInt32(0));
|
||||
}
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
return userIds.ToArray();
|
||||
|
||||
}
|
||||
public static int[] GetAdventurousPlayers()
|
||||
{
|
||||
List<int> userIds = new List<int>();
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "SELECT id FROM UserExt ORDER BY QuestPoints DESC LIMIT 25";
|
||||
sqlCommand.Prepare();
|
||||
MySqlDataReader reader = sqlCommand.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
userIds.Add(reader.GetInt32(0));
|
||||
}
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
return userIds.ToArray();
|
||||
|
||||
}
|
||||
public static int[] GetRichestPlayers()
|
||||
{
|
||||
List<int> userIds = new List<int>();
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "SELECT id FROM UserExt ORDER BY Money+BankBalance DESC LIMIT 25";
|
||||
sqlCommand.Prepare();
|
||||
MySqlDataReader reader = sqlCommand.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
userIds.Add(reader.GetInt32(0));
|
||||
}
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
return userIds.ToArray();
|
||||
|
||||
}
|
||||
public static HorseInstance[] GetMostSpoiledHorses()
|
||||
{
|
||||
List<HorseInstance> inst = new List<HorseInstance>();
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "SELECT * FROM Horses ORDER BY spoiled DESC LIMIT 100";
|
||||
sqlCommand.Prepare();
|
||||
MySqlDataReader reader = sqlCommand.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
inst.Add(ReadHorseInstance(reader));
|
||||
}
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
return inst.ToArray();
|
||||
}
|
||||
public static HorseInstance[] GetBiggestExpAutoSell()
|
||||
{
|
||||
List<HorseInstance> inst = new List<HorseInstance>();
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "SELECT * FROM Horses ORDER BY experience DESC LIMIT 50";
|
||||
sqlCommand.Prepare();
|
||||
MySqlDataReader reader = sqlCommand.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
inst.Add(ReadHorseInstance(reader));
|
||||
}
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
return inst.ToArray();
|
||||
}
|
||||
public static HorseInstance[] GetCheapestHorseAutoSell()
|
||||
{
|
||||
List<HorseInstance> inst = new List<HorseInstance>();
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "SELECT * FROM Horses ORDER BY autoSell LIMIT 100";
|
||||
sqlCommand.Prepare();
|
||||
MySqlDataReader reader = sqlCommand.ExecuteReader();
|
||||
while(reader.Read())
|
||||
{
|
||||
inst.Add(ReadHorseInstance(reader));
|
||||
}
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
return inst.ToArray();
|
||||
}
|
||||
public static int GetPlayerTotalMinigamesPlayed(int playerId)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "SELECT SUM(timesplayed) FROM Leaderboards WHERE playerId=@playerId";
|
||||
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
|
||||
sqlCommand.Prepare();
|
||||
int count = Convert.ToInt32(sqlCommand.ExecuteScalar());
|
||||
|
||||
sqlCommand.Dispose();
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddNewHighscore(int playerId, string gameTitle, int score, string type)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
|
|
|
@ -746,9 +746,54 @@ namespace HISP.Server
|
|||
Map.ModIsleX = gameData.messages.commands.mod_isle.x;
|
||||
Map.ModIsleY = gameData.messages.commands.mod_isle.y;
|
||||
|
||||
// City Hall
|
||||
Messages.CityHallMenu = gameData.messages.meta.city_hall.menu;
|
||||
Messages.CityHallMailSendMeta = gameData.messages.meta.city_hall.mail_send_meta;
|
||||
|
||||
Messages.CityHallSentMessageFormat = gameData.messages.meta.city_hall.sent_mail;
|
||||
Messages.CityHallCantAffordPostageMessage = gameData.messages.meta.city_hall.cant_afford_postage;
|
||||
Messages.CityHallCantFindPlayerMessageFormat = gameData.messages.meta.city_hall.cant_find_player;
|
||||
|
||||
Messages.CityHallCheapestAutoSells = gameData.messages.meta.city_hall.auto_sell.top_100_cheapest;
|
||||
Messages.CityHallCheapestAutoSellHorseEntryFormat = gameData.messages.meta.city_hall.auto_sell.cheap_horse_entry;
|
||||
|
||||
Messages.CityHallMostExpAutoSells = gameData.messages.meta.city_hall.auto_sell.top_50_most_exp;
|
||||
Messages.CityHallMostExpAutoSellHorseEntryFormat = gameData.messages.meta.city_hall.auto_sell.exp_horse_entry;
|
||||
|
||||
Messages.CityHallTop25Ranches = gameData.messages.meta.city_hall.ranch_investment.top_25;
|
||||
Messages.CityHallRanchEntryFormat = gameData.messages.meta.city_hall.ranch_investment.ranch_entry;
|
||||
|
||||
Messages.CityHallTop25Players = gameData.messages.meta.city_hall.richest_players.top_25;
|
||||
Messages.CityHallRichPlayerFormat = gameData.messages.meta.city_hall.richest_players.rich_player_format;
|
||||
|
||||
Messages.CityHallTop100SpoiledHorses = gameData.messages.meta.city_hall.spoiled_horses.top_100;
|
||||
Messages.CityHallSpoiledHorseEntryFormat = gameData.messages.meta.city_hall.spoiled_horses.spoiled_horse_entry;
|
||||
|
||||
Messages.CityHallTop25AdventurousPlayers = gameData.messages.meta.city_hall.most_adventurous_players.top_25;
|
||||
Messages.CityHallAdventurousPlayerEntryFormat = gameData.messages.meta.city_hall.most_adventurous_players.adventurous_player_entry;
|
||||
|
||||
Messages.CityHallTop25ExperiencedPlayers = gameData.messages.meta.city_hall.most_experinced_players.top_25;
|
||||
Messages.CityHallExperiencePlayerEntryFormat = gameData.messages.meta.city_hall.most_experinced_players.experienced_player_entry;
|
||||
|
||||
Messages.CityHallTop25MinigamePlayers = gameData.messages.meta.city_hall.most_active_minigame_players.top_25;
|
||||
Messages.CityHallMinigamePlayerEntryFormat = gameData.messages.meta.city_hall.most_active_minigame_players.minigame_player_entry;
|
||||
|
||||
Messages.CityHallTop25ExperiencedHorses = gameData.messages.meta.city_hall.most_experienced_horses.top_25;
|
||||
Messages.CityHallExperiencedHorseEntryFormat = gameData.messages.meta.city_hall.most_experienced_horses.experienced_horse_entry;
|
||||
|
||||
// Mail Messages
|
||||
Messages.MailReceivedMessage = gameData.messages.meta.mail.mail_received;
|
||||
Messages.MailSelectFromFollowing = gameData.messages.meta.mail.mail_select;
|
||||
Messages.MailSe = gameData.messages.meta.mail.mail_se;
|
||||
|
||||
Messages.MailReadMetaFormat = gameData.messages.meta.mail.mail_read;
|
||||
Messages.MailEntryFormat = gameData.messages.meta.mail.mail_entry;
|
||||
Messages.MailRippedMessage = gameData.messages.meta.mail.mail_ripped;
|
||||
|
||||
// Click
|
||||
Messages.PlayerHereFormat = gameData.messages.player_here;
|
||||
|
||||
|
||||
// Ranch
|
||||
Messages.RanchUnownedRanchFormat = gameData.messages.meta.ranch.unowned_ranch;
|
||||
Messages.RanchYouCouldPurchaseThisRanch = gameData.messages.meta.ranch.you_could_purchase_this;
|
||||
|
|
|
@ -84,11 +84,24 @@ namespace HISP.Server
|
|||
|
||||
foreach(GameClient client in ConnectedClients)
|
||||
if (client.LoggedIn)
|
||||
{
|
||||
if (!client.LoggedinUser.MetaPriority)
|
||||
UpdateArea(client);
|
||||
Update(client);
|
||||
byte[] BaseStatsPacketData = PacketBuilder.CreatePlayerData(client.LoggedinUser.Money, GameServer.GetNumberOfPlayers(), client.LoggedinUser.MailBox.UnreadMailCount);
|
||||
client.SendPacket(BaseStatsPacketData);
|
||||
}
|
||||
|
||||
|
||||
Database.IncPlayerTirednessForOfflineUsers();
|
||||
|
||||
if(totalMinutesElapsed % 60 == 0)
|
||||
{
|
||||
foreach (HorseInstance horse in Database.GetMostSpoiledHorses())
|
||||
{
|
||||
horse.BasicStats.Tiredness = 1000;
|
||||
horse.BasicStats.Hunger = 1000;
|
||||
horse.BasicStats.Thirst = 1000;
|
||||
}
|
||||
}
|
||||
|
||||
if (totalMinutesElapsed % 5 == 0)
|
||||
{
|
||||
|
@ -1453,6 +1466,56 @@ namespace HISP.Server
|
|||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid dynamic input (private notes, wrong size)");
|
||||
break;
|
||||
}
|
||||
case 2: // Send Mail
|
||||
if(dynamicInput.Length >= 4)
|
||||
{
|
||||
string to = dynamicInput[1];
|
||||
string subject = dynamicInput[2];
|
||||
string message = dynamicInput[3];
|
||||
|
||||
if(sender.LoggedinUser.Money >= 3)
|
||||
{
|
||||
if(Database.CheckUserExist(to))
|
||||
{
|
||||
int playerId = Database.GetUserid(to);
|
||||
|
||||
sender.LoggedinUser.Money -= 3;
|
||||
Mailbox.Mail mailMessage = new Mailbox.Mail();
|
||||
mailMessage.RandomId = RandomID.NextRandomId();
|
||||
mailMessage.FromUser = sender.LoggedinUser.Id;
|
||||
mailMessage.ToUser = playerId;
|
||||
mailMessage.Timestamp = Convert.ToInt32((DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds);
|
||||
mailMessage.Read = false;
|
||||
mailMessage.Subject = subject;
|
||||
mailMessage.Message = message;
|
||||
|
||||
if(IsUserOnline(playerId))
|
||||
{
|
||||
User user = GetUserById(playerId);
|
||||
user.MailBox.AddMail(mailMessage);
|
||||
|
||||
byte[] BaseStatsPacketData = PacketBuilder.CreatePlayerData(user.Money, GameServer.GetNumberOfPlayers(), user.MailBox.UnreadMailCount);
|
||||
user.LoggedinClient.SendPacket(BaseStatsPacketData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Database.AddMail(mailMessage.RandomId, mailMessage.ToUser, mailMessage.FromUser, mailMessage.Subject, mailMessage.Message, mailMessage.Timestamp, mailMessage.Read);
|
||||
}
|
||||
|
||||
byte[] mailMessageSent = PacketBuilder.CreateChat(Messages.FormatCityHallSendMailMessage(to.ToLower()),PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(mailMessageSent);
|
||||
|
||||
UpdateArea(sender);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] userDontExistFormat = PacketBuilder.CreateChat(Messages.FormatCityHallCantFindPlayerMessage(to), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(userDontExistFormat);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case 6: // Riddle Room
|
||||
if (dynamicInput.Length >= 2)
|
||||
{
|
||||
|
@ -1724,9 +1787,20 @@ namespace HISP.Server
|
|||
|
||||
switch(buttonIdStr)
|
||||
{
|
||||
case "2": // Compose Mail
|
||||
if(sender.LoggedinUser.Money <= 3)
|
||||
{
|
||||
byte[] cantAffordPostage = PacketBuilder.CreateChat(Messages.CityHallCantAffordPostageMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(cantAffordPostage);
|
||||
break;
|
||||
}
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
byte[] metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildComposeMailMenu());
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "3": // Quest Log
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
byte[] metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildQuestLog(sender.LoggedinUser));
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildQuestLog(sender.LoggedinUser));
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "4": // View Horse Breeds
|
||||
|
@ -1836,6 +1910,36 @@ namespace HISP.Server
|
|||
}
|
||||
}
|
||||
break;
|
||||
case "14": // Most Valued Ranches
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildMostValuedRanches());
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "15": // Most Richest Players
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildRichestPlayers());
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "16": // Most Adventurous Players
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildAdventurousPlayers());
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "17": // Most Experienced Players
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildExperiencedPlayers());
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "18": // Best Minigame Players
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildMinigamePlayers());
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "19": // Most Experienced Horses
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildMostExperienedHoses());
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "20": // Minigame Rankings
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildMinigameRankingsForUser(sender.LoggedinUser));
|
||||
|
@ -1869,6 +1973,11 @@ namespace HISP.Server
|
|||
sender.SendPacket(metaPacket);
|
||||
}
|
||||
break;
|
||||
case "29": // Auto Sell Horses
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildTopAutoSellHorses());
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "31":
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildRanchSearchLibary());
|
||||
|
@ -1938,6 +2047,11 @@ namespace HISP.Server
|
|||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildRanchSellConfirmation());
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "61": // Most Spoiled Horse
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildMostSpoiledHorses());
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "28c1": // Abuse Report
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildAbuseReportPage());
|
||||
|
@ -2256,7 +2370,7 @@ namespace HISP.Server
|
|||
byte[] SecCodePacket = PacketBuilder.CreateSecCode(user.SecCodeSeeds, user.SecCodeInc, user.Administrator, user.Moderator);
|
||||
sender.SendPacket(SecCodePacket);
|
||||
|
||||
byte[] BaseStatsPacketData = PacketBuilder.CreatePlayerData(user.Money, GameServer.GetNumberOfPlayers(), user.MailBox.MailCount);
|
||||
byte[] BaseStatsPacketData = PacketBuilder.CreatePlayerData(user.Money, GameServer.GetNumberOfPlayers(), user.MailBox.UnreadMailCount);
|
||||
sender.SendPacket(BaseStatsPacketData);
|
||||
|
||||
UpdateArea(sender);
|
||||
|
@ -4993,7 +5107,111 @@ namespace HISP.Server
|
|||
sender.SendPacket(inventoryFullMessage);
|
||||
}
|
||||
break;
|
||||
case PacketBuilder.ITEM_RIP:
|
||||
packetStr = Encoding.UTF8.GetString(packet);
|
||||
randomIdStr = packetStr.Substring(2, packet.Length - 2);
|
||||
randomId = 0;
|
||||
try
|
||||
{
|
||||
randomId = Int32.Parse(randomIdStr);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Sent an invalid object interaction packet.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sender.LoggedinUser.Inventory.HasItem(randomId))
|
||||
{
|
||||
Logger.HackerPrint(sender.LoggedinUser.Username + " Tried to rip someone elses mail. " + randomId.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
InventoryItem ripItems = sender.LoggedinUser.Inventory.GetItemByRandomid(randomId);
|
||||
foreach (ItemInstance item in ripItems.ItemInstances)
|
||||
{
|
||||
if (item.RandomId == randomId)
|
||||
{
|
||||
if (item.Data == 0)
|
||||
continue;
|
||||
sender.LoggedinUser.MailBox.RipUpMessage(sender.LoggedinUser.MailBox.GetMessageByRandomId(item.Data));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PacketBuilder.ITEM_VIEW:
|
||||
byte method = packet[2];
|
||||
if (method == PacketBuilder.ITEM_LOOK)
|
||||
{
|
||||
packetStr = Encoding.UTF8.GetString(packet);
|
||||
itemIdStr = packetStr.Substring(3, packet.Length - 3);
|
||||
itemId = 0;
|
||||
try
|
||||
{
|
||||
itemId = Int32.Parse(itemIdStr);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Sent an invalid object interaction packet.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemId == Item.MailMessage)
|
||||
{
|
||||
if (!sender.LoggedinUser.Inventory.HasItemId(Item.MailMessage))
|
||||
{
|
||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to view a mail message when they didnt have one.");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
byte[] mailList = PacketBuilder.CreateMetaPacket(Meta.BuildMailList(sender.LoggedinUser, sender.LoggedinUser.Inventory.GetItemByItemId(Item.MailMessage)));
|
||||
sender.SendPacket(mailList);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(method == PacketBuilder.ITEM_READ)
|
||||
{
|
||||
packetStr = Encoding.UTF8.GetString(packet);
|
||||
randomIdStr = packetStr.Substring(3, packet.Length - 3);
|
||||
randomId = 0;
|
||||
try
|
||||
{
|
||||
randomId = Int32.Parse(randomIdStr);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Sent an invalid object interaction packet.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sender.LoggedinUser.Inventory.HasItem(randomId))
|
||||
{
|
||||
Logger.HackerPrint(sender.LoggedinUser.Username + " Tried to view someone elses mail. " + randomId.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
InventoryItem items = sender.LoggedinUser.Inventory.GetItemByRandomid(randomId);
|
||||
foreach (ItemInstance item in items.ItemInstances)
|
||||
{
|
||||
if (item.RandomId == randomId)
|
||||
{
|
||||
if (item.Data == 0)
|
||||
continue;
|
||||
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
byte[] readMail = PacketBuilder.CreateMetaPacket(Meta.BuildMailLetter(sender.LoggedinUser.MailBox.GetMessageByRandomId(item.Data), randomId));
|
||||
sender.SendPacket(readMail);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Unknown Method- " + method.ToString("X") + " " + BitConverter.ToString(packet).Replace("-", " "));
|
||||
break;
|
||||
case PacketBuilder.PACKET_INFORMATION:
|
||||
packetStr = Encoding.UTF8.GetString(packet);
|
||||
string valueStr = packetStr.Substring(3, packet.Length - 3);
|
||||
|
|
|
@ -153,6 +153,10 @@ namespace HISP.Server
|
|||
public const byte ITEM_SELL = 0x3C;
|
||||
public const byte ITEM_WRAP = 0x17;
|
||||
public const byte ITEM_SELL_ALL = 0x3D;
|
||||
public const byte ITEM_VIEW = 0x2A;
|
||||
public const byte ITEM_LOOK = 0x4C;
|
||||
public const byte ITEM_READ = 0x52;
|
||||
public const byte ITEM_RIP = 0x2B;
|
||||
public const byte ITEM_OPEN = 0x16;
|
||||
public const byte ITEM_WEAR = 0x46;
|
||||
public const byte ITEM_REMOVE = 0x47;
|
||||
|
|
Loading…
Add table
Reference in a new issue