diff --git a/DataCollection/gamedata.json b/DataCollection/gamedata.json
index ef60e3c..2155eff 100644
--- a/DataCollection/gamedata.json
+++ b/DataCollection/gamedata.json
@@ -118,6 +118,18 @@
"back_to_map":"^M",
"long_full_line":"^L",
"fountain":"Although it's not recommended, you could drink from this fountain if you are thirsty...^T6Drink from the public fountain. ^B1D^R1^X^Z",
+ "wishing_well":{
+ "no_coins":"
Unfortunately you have no Wishing Well coins!",
+ "wish_coins":"You have %AMOUNT% Wishing Well coins!",
+ "wish_meta":"^I14^T6Toss a Coin in and wish for Money. ^BN1^R1^I14^T6Toss a Coin in and wish for Things. ^BN2^R1^I14^T6Toss a Coin in and wish for World Peace. ^BN3^R1",
+
+ "wish_things":"The Wishing Well granted you a %ITEM% and a %ITEM2%!",
+ "wish_money":"The Wishing Well granted you $%MONEY%!",
+ "wish_worldpeace":"The Wishing Well granted you $%MONEY% and a %ITEM%!",
+ "make_wish":"You tossed your wishing well coin in the well.",
+ "world_peace_message":"World Peace!! This well is only so deep.. How about a little money and an object instead!"
+
+ },
"inn":{
"buy_meal":"^LYou can buy the following meals:^R1",
"buy_rest":"^LWe also offer the following rest options:^R1",
@@ -781,7 +793,8 @@
"dorothy_shoes":260,
"pawneer_order":559,
"telescope":182,
- "pitchfork":152
+ "pitchfork":152,
+ "wishing_coin":50
},
"throwable":[
{"id":144,"message":"blanketing wet snow on "},
diff --git a/Horse Isle Server/Horse Isle Server/Game/Item.cs b/Horse Isle Server/Horse Isle Server/Game/Item.cs
index 4ce959f..41a969d 100644
--- a/Horse Isle Server/Horse Isle Server/Game/Item.cs
+++ b/Horse Isle Server/Horse Isle Server/Game/Item.cs
@@ -56,7 +56,19 @@ namespace HISP.Game
public static int PawneerOrder;
public static int Telescope;
public static int Pitchfork;
+ public static int WishingCoin;
+ public static ItemInformation[] GetAllWishableItems()
+ {
+ List itemInfo = new List();
+ foreach(ItemInformation item in Items)
+ {
+ if (item.WishingWell)
+ itemInfo.Add(item);
+ }
+ return itemInfo.ToArray();
+ }
+
public static bool ConsumeItem(User user, ItemInformation itmInfo)
{
diff --git a/Horse Isle Server/Horse Isle Server/Game/Messages.cs b/Horse Isle Server/Horse Isle Server/Game/Messages.cs
index d9612fe..2aeb1ba 100644
--- a/Horse Isle Server/Horse Isle Server/Game/Messages.cs
+++ b/Horse Isle Server/Horse Isle Server/Game/Messages.cs
@@ -188,7 +188,19 @@ namespace HISP.Game
public static string AwardHeader;
public static string NoAwards;
public static string AwardFormat;
-
+
+ // Wishing Well
+
+ public static string NoWishingCoins;
+ public static string WishingWellMeta;
+ public static string YouHaveWishingCoinsFormat;
+
+ public static string TossedCoin;
+ public static string WishItemsFormat;
+ public static string WishMoneyFormat;
+ public static string WishWorldPeaceFormat;
+ public static string WorldPeaceOnlySoDeep;
+
// Shop
public static string ThingsIAmSelling;
@@ -307,6 +319,27 @@ namespace HISP.Game
// Click
public static string NothingInterestingHere;
+
+ public static string FormatNumberOfWishingCoins(int amount)
+ {
+ return YouHaveWishingCoinsFormat.Replace("%AMOUNT%", amount.ToString("N0"));
+ }
+
+ public static string FormatWishThingsMessage(string item1, string item2)
+ {
+ return WishItemsFormat.Replace("%ITEM%", item1).Replace("%ITEM2%", item2);
+ }
+ public static string FormatWishMoneyMessage(int money)
+ {
+ return WishMoneyFormat.Replace("%MONEY%", money.ToString("N0"));
+ }
+ public static string FormatWishWorldPeaceMessage(int money, string item)
+ {
+ return WishWorldPeaceFormat.Replace("%MONEY%", money.ToString("N0")).Replace("%ITEM%", item);
+ }
+
+
+
public static string FormatInnEnjoyedServiceMessage(string item, int price)
{
return InnEnjoyedServiceFormat.Replace("%ITEM%", item).Replace("%PRICE%", price.ToString("N0"));
diff --git a/Horse Isle Server/Horse Isle Server/Game/Meta.cs b/Horse Isle Server/Horse Isle Server/Game/Meta.cs
index 85d7f30..501b04c 100644
--- a/Horse Isle Server/Horse Isle Server/Game/Meta.cs
+++ b/Horse Isle Server/Horse Isle Server/Game/Meta.cs
@@ -142,6 +142,30 @@ namespace HISP.Game
return message;
}
+
+ private static string buildWishingWell(User user)
+ {
+ string message = "";
+ bool hasCoins = user.Inventory.HasItemId(Item.WishingCoin);
+ if(!hasCoins)
+ {
+ message += Messages.NoWishingCoins;
+ }
+ else
+ {
+ InventoryItem wishingCoins = user.Inventory.GetItemByItemId(Item.WishingCoin);
+ int totalCoins = wishingCoins.ItemInstances.Count;
+ message += Messages.FormatNumberOfWishingCoins(totalCoins);
+ message += Messages.WishingWellMeta;
+ }
+
+ message += Messages.ExitThisPlace;
+ message += Messages.MetaTerminator;
+ return message;
+
+
+ }
+
private static string buildCommonInfo(int x, int y)
{
string message = "";
@@ -378,6 +402,7 @@ namespace HISP.Game
return message;
}
+
public static string BuildAwardList(User user)
{
string message = Messages.AwardHeader;
@@ -625,7 +650,10 @@ namespace HISP.Game
message += buildShopInfo(shop,user.Inventory);
}
-
+ if(TileCode == "WISHINGWELL")
+ {
+ message += Meta.buildWishingWell(user);
+ }
if(TileCode == "INN")
{
int InnID = int.Parse(TileArg);
diff --git a/Horse Isle Server/Horse Isle Server/Game/Services/Inn.cs b/Horse Isle Server/Horse Isle Server/Game/Services/Inn.cs
index 58c0414..d42805c 100644
--- a/Horse Isle Server/Horse Isle Server/Game/Services/Inn.cs
+++ b/Horse Isle Server/Horse Isle Server/Game/Services/Inn.cs
@@ -29,7 +29,7 @@ namespace HISP.Game.Services
public Item.ItemInformation GetStockedItem(int itemId)
{
- // Check if inn stock.. (pun intended)
+ // Check if inn stock..
foreach(Item.ItemInformation offering in RestsOffered)
{
if (offering.Id == itemId)
diff --git a/Horse Isle Server/Horse Isle Server/Server/GameClient.cs b/Horse Isle Server/Horse Isle Server/Server/GameClient.cs
index 837bd8c..31562dd 100644
--- a/Horse Isle Server/Horse Isle Server/Server/GameClient.cs
+++ b/Horse Isle Server/Horse Isle Server/Server/GameClient.cs
@@ -242,6 +242,9 @@ namespace HISP.Server
case PacketBuilder.PACKET_NPC:
GameServer.OnNpcInteraction(this, Packet);
break;
+ case PacketBuilder.PACKET_WISH:
+ GameServer.OnWish(this, Packet);
+ break;
default:
Logger.ErrorPrint("Unimplemented Packet: " + BitConverter.ToString(Packet).Replace('-', ' '));
break;
diff --git a/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs b/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs
index 47c4708..d81ac1c 100644
--- a/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs
+++ b/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs
@@ -444,6 +444,7 @@ namespace HISP.Server
Item.PawneerOrder = gameData.item.special.pawneer_order;
Item.Telescope = gameData.item.special.telescope;
Item.Pitchfork = gameData.item.special.pitchfork;
+ Item.WishingCoin = gameData.item.special.wishing_coin;
// New Users
Messages.NewUserMessage = gameData.new_user.starting_message;
@@ -694,6 +695,16 @@ namespace HISP.Server
Messages.NoAwards = gameData.messages.meta.awards_page.no_awards;
Messages.AwardFormat = gameData.messages.meta.awards_page.award_format;
+ // World Peace
+ Messages.NoWishingCoins = gameData.messages.meta.wishing_well.no_coins;
+ Messages.YouHaveWishingCoinsFormat = gameData.messages.meta.wishing_well.wish_coins;
+ Messages.WishItemsFormat = gameData.messages.meta.wishing_well.wish_things;
+ Messages.WishMoneyFormat = gameData.messages.meta.wishing_well.wish_money;
+ Messages.WishWorldPeaceFormat = gameData.messages.meta.wishing_well.wish_worldpeace;
+
+ Messages.TossedCoin = gameData.messages.meta.wishing_well.make_wish;
+ Messages.WorldPeaceOnlySoDeep = gameData.messages.meta.wishing_well.world_peace_message;
+ Messages.WishingWellMeta = gameData.messages.meta.wishing_well.wish_meta;
// Sec Codes
Messages.InvalidSecCodeError = gameData.messages.sec_code.invalid_sec_code;
diff --git a/Horse Isle Server/Horse Isle Server/Server/GameServer.cs b/Horse Isle Server/Horse Isle Server/Server/GameServer.cs
index d65c478..d3e2420 100644
--- a/Horse Isle Server/Horse Isle Server/Server/GameServer.cs
+++ b/Horse Isle Server/Horse Isle Server/Server/GameServer.cs
@@ -322,6 +322,78 @@ namespace HISP.Server
}
+
+ public static void OnWish(GameClient sender, byte[] packet)
+ {
+ if (!sender.LoggedIn)
+ {
+ Logger.ErrorPrint(sender.RemoteIp + " tried to wish when not logged in.");
+ return;
+ }
+
+ if(packet.Length < 4)
+ {
+ Logger.ErrorPrint(sender.LoggedinUser.Username + " Sent an invalid wish Packet");
+ return;
+ }
+
+ if (!sender.LoggedinUser.Inventory.HasItemId(Item.WishingCoin))
+ {
+ Logger.HackerPrint(sender.LoggedinUser.Username + " Tried to use a wishing well while having 0 coins.");
+ return;
+ }
+
+ InventoryItem wishingCoinInvItems = sender.LoggedinUser.Inventory.GetItemByItemId(Item.WishingCoin);
+ byte wishType = packet[1];
+ string message = "";
+
+ byte[] chatMsg = PacketBuilder.CreateChat(Messages.TossedCoin, PacketBuilder.CHAT_BOTTOM_RIGHT);
+ sender.SendPacket(chatMsg);
+
+ switch(wishType)
+ {
+ case PacketBuilder.WISH_MONEY:
+ int gainMoney = RandomNumberGenerator.Next(500, 1000);
+ sender.LoggedinUser.Money += gainMoney;
+ message = Messages.FormatWishMoneyMessage(gainMoney);
+ break;
+ case PacketBuilder.WISH_ITEMS:
+ Item.ItemInformation[] wishableItmes = Item.GetAllWishableItems();
+ int item = RandomNumberGenerator.Next(0, wishableItmes.Length);
+ Item.ItemInformation itm = wishableItmes[item];
+ item = RandomNumberGenerator.Next(0, wishableItmes.Length);
+ Item.ItemInformation itm2 = wishableItmes[item];
+
+ sender.LoggedinUser.Inventory.AddIgnoringFull(new ItemInstance(itm.Id));
+ sender.LoggedinUser.Inventory.AddIgnoringFull(new ItemInstance(itm2.Id));
+
+ message = Messages.FormatWishThingsMessage(itm.Name, itm2.Name);
+ break;
+ case PacketBuilder.WISH_WORLDPEACE:
+ byte[] tooDeep = PacketBuilder.CreateChat(Messages.WorldPeaceOnlySoDeep, PacketBuilder.CHAT_BOTTOM_RIGHT);
+ sender.SendPacket(tooDeep);
+
+ wishableItmes = Item.GetAllWishableItems();
+ item = RandomNumberGenerator.Next(0, wishableItmes.Length);
+ int earnMoney = RandomNumberGenerator.Next(0, 500);
+ itm = wishableItmes[item];
+
+
+ sender.LoggedinUser.Money += earnMoney;
+ sender.LoggedinUser.Inventory.AddIgnoringFull(new ItemInstance(itm.Id));
+
+ message = Messages.FormatWishWorldPeaceMessage(earnMoney, itm.Name);
+ break;
+ default:
+ Logger.ErrorPrint("Unknnown Wish type: " + wishType.ToString("X"));
+ break;
+ }
+ byte[] msg = PacketBuilder.CreateChat(message, PacketBuilder.CHAT_BOTTOM_RIGHT);
+ sender.SendPacket(msg);
+
+ sender.LoggedinUser.Inventory.Remove(wishingCoinInvItems.ItemInstances[0]);
+ Update(sender);
+ }
public static void OnKeepAlive(GameClient sender, byte[] packet)
{
if (!sender.LoggedIn)
diff --git a/Horse Isle Server/Horse Isle Server/Server/PacketBuilder.cs b/Horse Isle Server/Horse Isle Server/Server/PacketBuilder.cs
index aabd415..c35fe74 100644
--- a/Horse Isle Server/Horse Isle Server/Server/PacketBuilder.cs
+++ b/Horse Isle Server/Horse Isle Server/Server/PacketBuilder.cs
@@ -38,7 +38,11 @@ namespace HISP.Server
public const byte PACKET_QUIT = 0x7D;
public const byte PACKET_PLAYERINFO = 0x16;
public const byte PACKET_INFORMATION = 0x28;
+ public const byte PACKET_WISH = 0x2C;
+ public const byte WISH_MONEY = 0x31;
+ public const byte WISH_ITEMS = 0x32;
+ public const byte WISH_WORLDPEACE = 0x33;
public const byte SECCODE_QUEST = 0x32;
public const byte SECCODE_ITEM = 0x28;