Add Town Halls and Mail

This commit is contained in:
SilicaAndPina 2021-02-17 00:38:56 +13:00
parent 7b8583dcea
commit 35afd32d6c
8 changed files with 991 additions and 40 deletions

View file

@ -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

View file

@ -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)));