From 87635241161832936a70e551d0de10be3179b0ec Mon Sep 17 00:00:00 2001 From: SilicaAndPina Date: Fri, 6 Nov 2020 13:32:46 +1300 Subject: [PATCH] Add shop inventory (0/1) --- DataCollection/gamedata.json | 100 +++++++++++++++- .../Horse Isle Server/Game/IInventory.cs | 10 -- .../Horse Isle Server/Game/InventoryItem.cs | 20 ++++ .../Horse Isle Server/Game/Item.cs | 6 +- .../Horse Isle Server/Game/Messages.cs | 4 + .../Horse Isle Server/Game/Meta.cs | 30 ++++- .../Horse Isle Server/Game/Shop.cs | 42 +++++++ .../Horse Isle Server/Game/ShopInventory.cs | 93 ++++++++++++++ .../Horse Isle Server.csproj | 3 + .../Horse Isle Server/Server/Database.cs | 113 ++++++++++++++---- .../Horse Isle Server/Server/GameServer.cs | 1 + .../Horse Isle Server/Server/Gamedata.cs | 4 + 12 files changed, 383 insertions(+), 43 deletions(-) create mode 100644 Horse Isle Server/Horse Isle Server/Game/InventoryItem.cs create mode 100644 Horse Isle Server/Horse Isle Server/Game/Shop.cs create mode 100644 Horse Isle Server/Horse Isle Server/Game/ShopInventory.cs diff --git a/DataCollection/gamedata.json b/DataCollection/gamedata.json index 36325f6..8256df9 100644 --- a/DataCollection/gamedata.json +++ b/DataCollection/gamedata.json @@ -53,7 +53,11 @@ "exit_this_place":"^X", "end_of_meta":"^Z", "back_to_map":"^M", - "long_full_line":"^L", + "long_full_line":"^L", + "hay_pile":{ + "no_pitchfork":"Unfortunately you do not have a pitchfork to gather hay!", + "pitchfork":"You have a pitchfork, would you like to gather some hay?^I267^T6Get to work Gathering Hay ^BMpitchfork^R1" + }, "npc":{ "start_chat_format":"^I%ICONID%^T8%NAME%, %DESCRIPTION%", "chatpoint_format":" Conversation with %NAME%, %DESCRIPTION%

%NAME%: %TEXT%", @@ -530189,5 +530193,97 @@ "chained_questid": null, "minigame": false } + ], + "shop_list":[ + {"buys_item_types":["ROCK","JEWELRY"],"buy_percent":75,"sell_percent":127,"stocks_itemids":[]}, + {"buys_item_types":["PLAYERFOOD"],"buy_percent":75,"sell_percent":127,"stocks_itemids":[9,4,11,44]}, + {"buys_item_types":["PLAYERFOOD"],"buy_percent":75,"sell_percent":127,"stocks_itemids":[137,9,4,69,6,138]}, + {"buys_item_types":["CLOTHES"],"buy_percent":75,"sell_percent":127,"stocks_itemids":[15,405,409,14,407,418]}, + {"buys_item_types":["TACK"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[35,36,37,288,289,290,1342,1344,1343]}, + {"buys_item_types":["FLOWER"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[42]}, + {"buys_item_types":["FISHING"],"buy_percent":100,"sell_percent":100,"stocks_itemids":[]}, + {"buys_item_types":["PLAYERFOOD","CLOTHES","MISC","FLOWER"],"buy_percent":50,"sell_percent":200,"stocks_itemids":[9,70,4,152]}, + {"buys_item_types":["FISHING"],"buy_percent":100,"sell_percent":100,"stocks_itemids":[]}, + {"buys_item_types":["FLOWER"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[188,80]}, + {"buys_item_types":["HORSEFOOD","TACK"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[32,33,34,35,36,37,285,286,287,120,113,104,93,95,108,1327,1329,1328,1650,1652,1651]}, + {"buys_item_types":["ROCK","JEWELRY"],"buy_percent":75,"sell_percent":127,"stocks_itemids":[]}, + {"buys_item_types":["PLAYERFOOD","CLOTHES","MISC"],"buy_percent":75,"sell_percent":130,"stocks_itemids":[438,439]}, + {"buys_item_types":["FLOWER"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[187,80,81]}, + {"buys_item_types":["HORSEFOOD"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[32,33,34,202,205]}, + {"buys_item_types":["TACK"],"buy_percent":98,"sell_percent":102,"stocks_itemids":[277,278,279,282,283,284,1324,1325,1326,1506,1507,1508]}, + {"buys_item_types":["ROCK","JEWELRY"],"buy_percent":80,"sell_percent":127,"stocks_itemids":[]}, + {"buys_item_types":["CLOTHES"],"buy_percent":75,"sell_percent":127,"stocks_itemids":[433,434,435,436,422,427,429,432]}, + {"buys_item_types":["PLAYERFOOD","CLOTHES","MISC"],"buy_percent":80,"sell_percent":110,"stocks_itemids":[4,9,11,439]}, + {"buys_item_types":["HORSEFOOD"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[32,33,34,203,206,1569]}, + {"buys_item_types":["PLAYERFOOD","CLOTHES","MISC"],"buy_percent":80,"sell_percent":125,"stocks_itemids":[182,439]}, + {"buys_item_types":["FLOWER"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[42,81]}, + {"buys_item_types":["FLOWER"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[189,43]}, + {"buys_item_types":["PLAYERFOOD","CLOTHES","MISC"],"buy_percent":80,"sell_percent":125,"stocks_itemids":[4,9]}, + {"buys_item_types":["PLAYERFOOD","CLOTHES","MISC"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[438]}, + {"buys_item_types":["FISHING"],"buy_percent":100,"sell_percent":100,"stocks_itemids":[]}, + {"buys_item_types":["HORSEFOOD"],"buy_percent":80,"sell_percent":120,"stocks_itemids":[32,33,34,203,203]}, + {"buys_item_types":["TACK"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[272,273,274,291,292,293,718,719,720,1348,1349,1350]}, + {"buys_item_types":["PLAYERFOOD"],"buy_percent":85,"sell_percent":115,"stocks_itemids":[4,9,8,7,69]}, + {"buys_item_types":["ROCK","JEWELRY"],"buy_percent":80,"sell_percent":120,"stocks_itemids":[]}, + {"buys_item_types":["CLOTHES"],"buy_percent":80,"sell_percent":120,"stocks_itemids":[15,410,408,404,411,414,406,412,417]}, + {"buys_item_types":["CLOTHES"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[426,421,428,430,416,413,431,422,432]}, + {"buys_item_types":["TACK"],"buy_percent":98,"sell_percent":102,"stocks_itemids":[297,298,299,303,304,305,543,544,545,1345,1346,1347,1516,1517,1518]}, + {"buys_item_types":["HORSEFOOD"],"buy_percent":80,"sell_percent":120,"stocks_itemids":[32,33,34,205,202,1569]}, + {"buys_item_types":["ROCK","JEWELRY"],"buy_percent":75,"sell_percent":130,"stocks_itemids":[]}, + {"buys_item_types":["FISHING"],"buy_percent":100,"sell_percent":100,"stocks_itemids":[]}, + {"buys_item_types":["CLOTHES"],"buy_percent":75,"sell_percent":130,"stocks_itemids":[420,423,424,425,419,406,415]}, + {"buys_item_types":["PLAYERFOOD","CLOTHES","MISC"],"buy_percent":75,"sell_percent":130,"stocks_itemids":[4,9,438]}, + {"buys_item_types":["HORSEFOOD"],"buy_percent":75,"sell_percent":130,"stocks_itemids":[32,33,202,204,1569]}, + {"buys_item_types":["PLAYERFOOD"],"buy_percent":75,"sell_percent":130,"stocks_itemids":[4,9,7,11]}, + {"buys_item_types":["FLOWER"],"buy_percent":75,"sell_percent":130,"stocks_itemids":[189]}, + {"buys_item_types":["ROCK","JEWELRY"],"buy_percent":75,"sell_percent":130,"stocks_itemids":[]}, + {"buys_item_types":["TACK"],"buy_percent":98,"sell_percent":102,"stocks_itemids":[294,295,296,300,301,302,1333,1334,1335,1488,1489,1490,1611,1612,1613]}, + {"buys_item_types":["COMPANION"],"buy_percent":75,"sell_percent":130,"stocks_itemids":[235,314,226,590,681,229,239,1173,1220,247,242,1672]}, + {"buys_item_types":["COMPANION"],"buy_percent":80,"sell_percent":120,"stocks_itemids":[216,276,237,227,255,248,913,1081,1276,244,1341,1578,1610,1666]}, + {"buys_item_types":["COMPANION"],"buy_percent":75,"sell_percent":130,"stocks_itemids":[350,218,236,246,250,838,1011,1217,1221,1409,1477,1645,1667]}, + {"buys_item_types":["COMPANION"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[313,220,219,541,540,865,1004,1012,1600,1590,1528,1149,1080,1177,1424,1509,1657]}, + {"buys_item_types":["COMPANION"],"buy_percent":80,"sell_percent":120,"stocks_itemids":[222,225,1152,252,527,238,231,956,1312,1392,1401,1442,1505,1576]}, + {"buys_item_types":["COMPANION"],"buy_percent":75,"sell_percent":130,"stocks_itemids":[208,224,315,542,591,1008,1164,1166,1243,1308,1363,1555,1635]}, + {"buys_item_types":["COMPANION"],"buy_percent":70,"sell_percent":120,"stocks_itemids":[207,234,254,592,748,228,221,1239,1279,1307,1316,1418]}, + {"buys_item_types":["PLAYERFOOD","CLOTHES","MISC"],"buy_percent":70,"sell_percent":125,"stocks_itemids":[4,9,137,109,117,125]}, + {"buys_item_types":["PLAYERFOOD"],"buy_percent":80,"sell_percent":120,"stocks_itemids":[4,9,140,155,139]}, + {"buys_item_types":["ROCK","JEWELRY"],"buy_percent":85,"sell_percent":120,"stocks_itemids":[]}, + {"buys_item_types":["PLAYERFOOD","CLOTHES","MISC"],"buy_percent":70,"sell_percent":120,"stocks_itemids":[4,9,438]}, + {"buys_item_types":["HORSEFOOD"],"buy_percent":70,"sell_percent":120,"stocks_itemids":[32,33,34]}, + {"buys_item_types":["ROCK","JEWELRY"],"buy_percent":75,"sell_percent":125,"stocks_itemids":[]}, + {"buys_item_types":["PLAYERFOOD","CLOTHES","MISC"],"buy_percent":75,"sell_percent":125,"stocks_itemids":[4,9,137,109,117]}, + {"buys_item_types":["PLAYERFOOD","CLOTHES","MISC"],"buy_percent":70,"sell_percent":120,"stocks_itemids":[4,9,439]}, + {"buys_item_types":["ROCK","JEWELRY"],"buy_percent":95,"sell_percent":105,"stocks_itemids":[]}, + {"buys_item_types":["PLAYERFOOD","CLOTHES","MISC"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[4,9]}, + {"buys_item_types":["PLAYERFOOD","CLOTHES","MISC","JEWELRY"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[4,9]}, + {"buys_item_types":["HORSEFOOD","TACK"],"buy_percent":98,"sell_percent":102,"stocks_itemids":[35,36,37,272,273,274,549,550,551,1351,1352,1353]}, + {"buys_item_types":["PLAYERFOOD","CLOTHES","MISC","JEWELRY"],"buy_percent":85,"sell_percent":115,"stocks_itemids":[4,9]}, + {"buys_item_types":["PLAYERFOOD","CLOTHES"],"buy_percent":85,"sell_percent":115,"stocks_itemids":[4,9]}, + {"buys_item_types":["ROCK","JEWELRY"],"buy_percent":85,"sell_percent":115,"stocks_itemids":[]}, + {"buys_item_types":["TACK"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[524,525,526,1415,1416,1417]}, + {"buys_item_types":["TACK"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[531,532,533,1425,1426,1427]}, + {"buys_item_types":["PLAYERFOOD","MISC"],"buy_percent":70,"sell_percent":130,"stocks_itemids":[4,9,182]}, + {"buys_item_types":["PLAYERFOOD"],"buy_percent":70,"sell_percent":130,"stocks_itemids":[11,70,69]}, + {"buys_item_types":["HORSEFOOD"],"buy_percent":70,"sell_percent":130,"stocks_itemids":[33,206,203]}, + {"buys_item_types":["ROCK","JEWELRY"],"buy_percent":70,"sell_percent":130,"stocks_itemids":[]}, + {"buys_item_types":["TACK"],"buy_percent":98,"sell_percent":102,"stocks_itemids":[546,547,548,718,719,720,1330,1331,1332,1485,1486,1487]}, + {"buys_item_types":["COMPANION"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[700,703,704,705,739,920,975,982,1188,1318,1319,1571,1573,1624,1625]}, + {"buys_item_types":["COMPANION"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[872,702,801,701,976,981,1176,1189,1251,1314,1317,1321,1393,1570,1572,1626]}, + {"buys_item_types":["PLAYERFOOD","ROCK","MISC","HORSEFOOD","JEWELRY"],"buy_percent":75,"sell_percent":125,"stocks_itemids":[4,9,32,33]}, + {"buys_item_types":["COMPANION"],"buy_percent":99,"sell_percent":101,"stocks_itemids":[823,1083,1197,1215,1372,1407,1408,1414,1413,1549,1550,1551,1552]}, + {"buys_item_types":["COMPANION"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[799,800,793,752,840,864,921,983,1151,1203,1202,1320,1575,1574,1623]}, + {"buys_item_types":["PLAYERFOOD","ROCK","MISC","HORSEFOOD","FLOWER","FISHING","COMPANION","JEWELRY"],"buy_percent":95,"sell_percent":105,"stocks_itemids":[5,7,11,155,182,438,439,33,32]}, + {"buys_item_types":["PLAYERFOOD"],"buy_percent":75,"sell_percent":125,"stocks_itemids":[138,12,6]}, + {"buys_item_types":["ROCK","MISC","JEWELRY"],"buy_percent":75,"sell_percent":125,"stocks_itemids":[]}, + {"buys_item_types":["PLAYERFOOD","ROCK","MISC","HORSEFOOD","FLOWER","FISHING","COMPANION","JEWELRY"],"buy_percent":92,"sell_percent":108,"stocks_itemids":[5,11,12]}, + {"buys_item_types":["HORSEFOOD"],"buy_percent":90,"sell_percent":100,"stocks_itemids":[1198,1199,1566,1567]}, + {"buys_item_types":["COMPANION"],"buy_percent":99,"sell_percent":101,"stocks_itemids":[1358,1359,1360,1361,1362]}, + {"buys_item_types":["COMPANION"],"buy_percent":99,"sell_percent":101,"stocks_itemids":[1373]}, + {"buys_item_types":["ROCK","FISHING"],"buy_percent":90,"sell_percent":110,"stocks_itemids":[]}, + {"buys_item_types":["PLAYERFOOD"],"buy_percent":75,"sell_percent":125,"stocks_itemids":[7,8,9,11,140]}, + {"buys_item_types":["PLAYERFOOD","ROCK","MISC","FISHING"],"buy_percent":75,"sell_percent":125,"stocks_itemids":[7,8,9]}, + {"buys_item_types":["CLOTHES","ROCK","MISC","JEWELRY"],"buy_percent":75,"sell_percent":125,"stocks_itemids":[79,357,182]}, + {"buys_item_types":["PLAYERFOOD"],"buy_percent":75,"sell_percent":125,"stocks_itemids":[129,126,132,140,537,348]}, + {"buys_item_types":["PLAYERFOOD"],"buy_percent":75,"sell_percent":125,"stocks_itemids":[11,44,139,8,7]} ] - } \ No newline at end of file +} \ No newline at end of file diff --git a/Horse Isle Server/Horse Isle Server/Game/IInventory.cs b/Horse Isle Server/Horse Isle Server/Game/IInventory.cs index df4b633..2aa84ed 100644 --- a/Horse Isle Server/Horse Isle Server/Game/IInventory.cs +++ b/Horse Isle Server/Horse Isle Server/Game/IInventory.cs @@ -4,16 +4,6 @@ using System.Collections.Generic; namespace HISP.Game { - class InventoryItem - { - public InventoryItem() - { - ItemInstances = new List(); - } - - public int ItemId; - public List ItemInstances; - } interface IInventory { diff --git a/Horse Isle Server/Horse Isle Server/Game/InventoryItem.cs b/Horse Isle Server/Horse Isle Server/Game/InventoryItem.cs new file mode 100644 index 0000000..2e7e132 --- /dev/null +++ b/Horse Isle Server/Horse Isle Server/Game/InventoryItem.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; + +namespace HISP.Game +{ + class InventoryItem + { + public InventoryItem() + { + ItemInstances = new List(); + Infinite = false; + ItemId = 0; + } + + public int ItemId; + public bool Infinite; + public List ItemInstances; + } + +} diff --git a/Horse Isle Server/Horse Isle Server/Game/Item.cs b/Horse Isle Server/Horse Isle Server/Game/Item.cs index c39cb04..e47455f 100644 --- a/Horse Isle Server/Horse Isle Server/Game/Item.cs +++ b/Horse Isle Server/Horse Isle Server/Game/Item.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace HISP.Game { diff --git a/Horse Isle Server/Horse Isle Server/Game/Messages.cs b/Horse Isle Server/Horse Isle Server/Game/Messages.cs index f6b55c4..0930c1f 100644 --- a/Horse Isle Server/Horse Isle Server/Game/Messages.cs +++ b/Horse Isle Server/Horse Isle Server/Game/Messages.cs @@ -24,6 +24,10 @@ namespace HISP.Game // Records public static string ProfileSavedMessage; + // Hay Pile + public static string HasPitchforkMeta; + public static string NoPitchforkMeta; + // Chat public static string GlobalChatFormat; public static string AdsChatFormat; diff --git a/Horse Isle Server/Horse Isle Server/Game/Meta.cs b/Horse Isle Server/Horse Isle Server/Game/Meta.cs index ab831e0..1613c0c 100644 --- a/Horse Isle Server/Horse Isle Server/Game/Meta.cs +++ b/Horse Isle Server/Horse Isle Server/Game/Meta.cs @@ -173,14 +173,37 @@ namespace HISP.Game if (specialTile.Code == null) message += buildCommonInfo(specialTile.X, specialTile.Y); - if (specialTile.Code == "TRANSPORT") + else + user.MetaPriority = true; + + string TileCode = specialTile.Code; + string TileArg = ""; + if (TileCode.Contains("-")) + { + + TileCode = TileCode.Split('-')[0]; + TileArg = TileCode.Split('-')[1]; + } + + if (TileCode == "TRANSPORT") { Transport.TransportPoint point = Transport.GetTransportPoint(specialTile.X, specialTile.Y); message += Meta.BuildTransportInfo(point)+ "^R1"; } - if (specialTile.ExitX != 0 && specialTile.ExitY != 0) - message += Messages.ExitThisPlace + Messages.MetaTerminator; + if (TileCode == "STRAWPILE") + { + if (user.Inventory.HasItemId(Item.Pitchfork)) + message += Messages.HasPitchforkMeta; + else + message += Messages.NoPitchforkMeta; + } + + if(TileCode == "STORE") + { + + } + return message; @@ -233,6 +256,7 @@ namespace HISP.Game Quest.QuestEntry quest = Quest.GetQuestById(chatpoint.ActivateQuestId); if (Quest.ActivateQuest(user, quest, true)) { + user.MetaPriority = true; if(quest.GotoNpcChatpoint != -1) chatpoint = Npc.GetNpcChatpoint(npc,quest.GotoNpcChatpoint); if (quest.SuccessNpcChat != null) diff --git a/Horse Isle Server/Horse Isle Server/Game/Shop.cs b/Horse Isle Server/Horse Isle Server/Game/Shop.cs new file mode 100644 index 0000000..2603137 --- /dev/null +++ b/Horse Isle Server/Horse Isle Server/Game/Shop.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; + +namespace HISP.Game +{ + class Shop + { + public int Id; + + public string[] BuysItemTypes; + public int BuyPricePercentage; + public int SellPricePercentage; + public int[] InfniteStocks; + ShopInventory Inventory; + + public Shop() + { + Id = shopList.Count; + Inventory = new ShopInventory(this); + shopList.Add(this); + } + + public int CalculateBuyCost(Item.ItemInformation item) + { + return Math.Abs(item.SellPrice * (100 / BuyPricePercentage)); + } + public int CalculateSellCost(Item.ItemInformation item) + { + return Math.Abs(item.SellPrice * (100 / SellPricePercentage)); + } + + + + // Static Functions + private static List shopList = new List(); + public static Shop GetShopById(int id) + { + return shopList[id]; + } + + } +} diff --git a/Horse Isle Server/Horse Isle Server/Game/ShopInventory.cs b/Horse Isle Server/Horse Isle Server/Game/ShopInventory.cs new file mode 100644 index 0000000..7fd10be --- /dev/null +++ b/Horse Isle Server/Horse Isle Server/Game/ShopInventory.cs @@ -0,0 +1,93 @@ +using HISP.Server; +using System; +using System.Collections.Generic; + +namespace HISP.Game +{ + class ShopInventory : IInventory + { + private Shop baseShop; + private List inventoryItems; + public int Count + { + get + { + return inventoryItems.Count; + } + } + public ShopInventory(Shop shopkeeper) + { + baseShop = shopkeeper; + + ItemInstance[] instances = Database.GetShopInventory(baseShop.Id).ToArray(); + foreach (ItemInstance instance in instances) + { + addItem(instance, false); + } + } + + private void addItem(ItemInstance item, bool addToDatabase) + { + if (addToDatabase) + Database.AddItemToInventory(baseShop.Id, item); + + foreach (InventoryItem invetoryItem in inventoryItems) + { + if (invetoryItem.ItemId == item.ItemId) + { + invetoryItem.ItemInstances.Add(item); + return; + } + } + + InventoryItem inventoryItem = new InventoryItem(); + + inventoryItem.ItemId = item.ItemId; + inventoryItem.ItemInstances.Add(item); + inventoryItems.Add(inventoryItem); + } + + public void AddInfinity(Item.ItemInformation itemInfo) + { + InventoryItem inventoryItem = new InventoryItem(); + inventoryItem.ItemId = itemInfo.Id; + inventoryItem.Infinite = true; + for(int i = 0; i < 25; i++) // add 25 + inventoryItem.ItemInstances.Add(new ItemInstance(inventoryItem.ItemId)); + } + public void Add(ItemInstance item) + { + addItem(item, true); + } + + public InventoryItem GetItemByItemId(int itemId) + { + throw new NotImplementedException(); + } + + public InventoryItem GetItemByRandomid(int randomId) + { + throw new NotImplementedException(); + } + + public InventoryItem[] GetItemList() + { + throw new NotImplementedException(); + } + + public bool HasItem(int randomId) + { + throw new NotImplementedException(); + } + + public bool HasItemId(int itemId) + { + throw new NotImplementedException(); + } + + public void Remove(ItemInstance item) + { + throw new NotImplementedException(); + } + } +} diff --git a/Horse Isle Server/Horse Isle Server/Horse Isle Server.csproj b/Horse Isle Server/Horse Isle Server/Horse Isle Server.csproj index ab15020..cc8fe85 100644 --- a/Horse Isle Server/Horse Isle Server/Horse Isle Server.csproj +++ b/Horse Isle Server/Horse Isle Server/Horse Isle Server.csproj @@ -72,7 +72,10 @@ + + + True True diff --git a/Horse Isle Server/Horse Isle Server/Server/Database.cs b/Horse Isle Server/Horse Isle Server/Server/Database.cs index f05ff61..ac408d3 100644 --- a/Horse Isle Server/Horse Isle Server/Server/Database.cs +++ b/Horse Isle Server/Horse Isle Server/Server/Database.cs @@ -21,6 +21,7 @@ namespace HISP.Server string BuddyTable = "CREATE TABLE BuddyList(Id INT, IdFriend INT, Pending BOOL)"; string WorldTable = "CREATE TABLE World(Time INT,Day INT, Year INT, Weather TEXT(64))"; string InventoryTable = "CREATE TABLE Inventory(PlayerID INT, RandomID INT, ItemID INT)"; + string ShopInventory = "CREATE TABLE ShopInventroy(ShopID INT, RandomID INT, ItemID INT)"; string DroppedItems = "CREATE TABLE DroppedItems(X INT, Y INT, RandomID INT, ItemID INT, DespawnTimer INT)"; string TrackedQuest = "CREATE TABLE TrackedQuest(playerId INT, questId INT, timesCompleted INT)"; @@ -102,10 +103,21 @@ namespace HISP.Server Logger.WarnPrint(e.Message); }; - try { + MySqlCommand sqlCommand = db.CreateCommand(); + sqlCommand.CommandText = ShopInventory; + sqlCommand.ExecuteNonQuery(); + sqlCommand.Dispose(); + } + catch (Exception e) + { + Logger.WarnPrint(e.Message); + }; + + try + { MySqlCommand sqlCommand = db.CreateCommand(); sqlCommand.CommandText = TrackedQuest; sqlCommand.ExecuteNonQuery(); @@ -259,28 +271,6 @@ namespace HISP.Server } } - public static List GetPlayerInventory(int playerId) - { - using (MySqlConnection db = new MySqlConnection(ConnectionString)) - { - db.Open(); - MySqlCommand sqlCommand = db.CreateCommand(); - - sqlCommand.CommandText = "SELECT ItemId,RandomId FROM Inventory WHERE PlayerId=@playerId"; - sqlCommand.Parameters.AddWithValue("@playerId", playerId); - sqlCommand.Prepare(); - MySqlDataReader reader = sqlCommand.ExecuteReader(); - List instances = new List(); - - while(reader.Read()) - { - instances.Add(new ItemInstance(reader.GetInt32(0), reader.GetInt32(1))); - } - sqlCommand.Dispose(); - return instances; - } - } - public static int GetTrackedQuestCompletedCount(int playerId, int questId) { if(CheckTrackeQuestExists(playerId,questId)) @@ -389,6 +379,83 @@ namespace HISP.Server sqlCommand.Dispose(); } } + public static List GetShopInventory(int shopId) + { + using (MySqlConnection db = new MySqlConnection(ConnectionString)) + { + db.Open(); + MySqlCommand sqlCommand = db.CreateCommand(); + + sqlCommand.CommandText = "SELECT ItemId,RandomId FROM ShopInventory WHERE ShopID=@shopId"; + sqlCommand.Parameters.AddWithValue("@shopId", shopId); + sqlCommand.Prepare(); + MySqlDataReader reader = sqlCommand.ExecuteReader(); + List instances = new List(); + + while (reader.Read()) + { + instances.Add(new ItemInstance(reader.GetInt32(0), reader.GetInt32(1))); + } + sqlCommand.Dispose(); + return instances; + } + } + + public static void AddItemToShopInventory(int shopId, ItemInstance instance) + { + using (MySqlConnection db = new MySqlConnection(ConnectionString)) + { + db.Open(); + MySqlCommand sqlCommand = db.CreateCommand(); + + sqlCommand.CommandText = "INSERT INTO ShopInventory VALUES(@shopId,@randomId,@itemId)"; + sqlCommand.Parameters.AddWithValue("@shopId", shopId); + sqlCommand.Parameters.AddWithValue("@randomId", instance.RandomId); + sqlCommand.Parameters.AddWithValue("@itemId", instance.ItemId); + sqlCommand.Prepare(); + sqlCommand.ExecuteNonQuery(); + sqlCommand.Dispose(); + } + } + + public static void RemoveItemFromShopInventory(int shopId, ItemInstance instance) + { + using (MySqlConnection db = new MySqlConnection(ConnectionString)) + { + db.Open(); + MySqlCommand sqlCommand = db.CreateCommand(); + + sqlCommand.CommandText = "DELETE FROM ShopInventory WHERE (ShopID=@shopId AND RandomId=@randomId)"; + sqlCommand.Parameters.AddWithValue("@shopId", shopId); + sqlCommand.Parameters.AddWithValue("@randomId", instance.RandomId); + sqlCommand.Prepare(); + sqlCommand.ExecuteNonQuery(); + sqlCommand.Dispose(); + } + } + + public static List GetPlayerInventory(int playerId) + { + using (MySqlConnection db = new MySqlConnection(ConnectionString)) + { + db.Open(); + MySqlCommand sqlCommand = db.CreateCommand(); + + sqlCommand.CommandText = "SELECT ItemId,RandomId FROM Inventory WHERE PlayerId=@playerId"; + sqlCommand.Parameters.AddWithValue("@playerId", playerId); + sqlCommand.Prepare(); + MySqlDataReader reader = sqlCommand.ExecuteReader(); + List instances = new List(); + + while (reader.Read()) + { + instances.Add(new ItemInstance(reader.GetInt32(0), reader.GetInt32(1))); + } + sqlCommand.Dispose(); + return instances; + } + } + public static void AddItemToInventory(int playerId, ItemInstance instance) { using (MySqlConnection db = new MySqlConnection(ConnectionString)) diff --git a/Horse Isle Server/Horse Isle Server/Server/GameServer.cs b/Horse Isle Server/Horse Isle Server/Server/GameServer.cs index 53cdd29..87c135b 100644 --- a/Horse Isle Server/Horse Isle Server/Server/GameServer.cs +++ b/Horse Isle Server/Horse Isle Server/Server/GameServer.cs @@ -204,6 +204,7 @@ namespace HISP.Server return; } } + } diff --git a/Horse Isle Server/Horse Isle Server/Server/Gamedata.cs b/Horse Isle Server/Horse Isle Server/Server/Gamedata.cs index ed5b1bb..f29cb25 100644 --- a/Horse Isle Server/Horse Isle Server/Server/Gamedata.cs +++ b/Horse Isle Server/Horse Isle Server/Server/Gamedata.cs @@ -437,6 +437,10 @@ namespace HISP.Server Messages.South = gameData.messages.meta.nearby.south; Messages.West = gameData.messages.meta.nearby.west; + Messages.NoPitchforkMeta = gameData.messages.meta.hay_pile.no_pitchfork; + Messages.HasPitchforkMeta = gameData.messages.meta.hay_pile.pitchfork; + + // Inventory Messages.InventoryHeaderFormat = gameData.messages.meta.inventory.header_format;