From 3fc1e5a870997a461d728b7e8f6907714b2b2977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=8C=90=EB=8F=8C?= Date: Sat, 23 Mar 2024 19:38:11 +0900 Subject: [PATCH] =?UTF-8?q?=EC=83=81=EC=A0=90=20=EA=B5=AC=EB=A7=A4?= =?UTF-8?q?=EC=8B=9C=20=EB=82=A8=EC=9D=80=20=EA=B5=AC=EB=A7=A4=ED=9A=9F?= =?UTF-8?q?=EC=88=98=20=ED=99=95=EC=9D=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Server/SQL/ShopItem.cs | 5 +++++ Server/SQL/ShopItemData.cs | 2 ++ Server/Service/BuyShopItem.cs | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/Server/SQL/ShopItem.cs b/Server/SQL/ShopItem.cs index dcedd39..0457a32 100644 --- a/Server/SQL/ShopItem.cs +++ b/Server/SQL/ShopItem.cs @@ -27,5 +27,10 @@ namespace Server.SQL { return table.Where(data => data.user_id == user_id).ToList(); } + + public List SelectUid(long user_id, long shop_item_data_id) + { + return table.Where(data => data.user_id == user_id && data.shop_item_data_id == shop_item_data_id).ToList(); + } } } diff --git a/Server/SQL/ShopItemData.cs b/Server/SQL/ShopItemData.cs index f094d5d..3b50c67 100644 --- a/Server/SQL/ShopItemData.cs +++ b/Server/SQL/ShopItemData.cs @@ -10,6 +10,7 @@ namespace Server.SQL public eBuyType buy_type { get; set; } public int buy { get; set; } public long reward { get; set; } + public int buy_count { get; set; } } public enum eBuyType @@ -44,6 +45,7 @@ namespace Server.SQL shopItemData.buy_type = (eBuyType)item.Value["buy_type"]; shopItemData.buy = (int)item.Value["buy"]; shopItemData.reward = (int)item.Value["reward"]; + shopItemData.buy_count = (int)item.Value["buy_count"]; this.shopItemData.Add(item.Key, shopItemData); } } diff --git a/Server/Service/BuyShopItem.cs b/Server/Service/BuyShopItem.cs index 8bbc270..da9131d 100644 --- a/Server/Service/BuyShopItem.cs +++ b/Server/Service/BuyShopItem.cs @@ -31,6 +31,17 @@ namespace Server.Service if (req.reset_id == -1) { ShopItemData shopItemData = Statics.shopItemExcel.getShopItemData(req.shopItemIndex); + + //구매 가능한지 검사 + if(shopItemData.buy_count != -1) + { + List shopItems = Statics.shopItemSQL.SelectUid(user.id, shopItemData.index); + Console.WriteLine(shopItems.Count); + if(shopItems.Count >= shopItemData.buy_count) + { + throw new RuntimeException("Not Buy Count", Error.ErrorData); + } + } buy_type = shopItemData.buy_type; buy = shopItemData.buy; reward = shopItemData.reward; @@ -39,6 +50,11 @@ namespace Server.Service else { resetShopItem = Statics.resetShopItemSQL.SelectUid(user.id).Find(n => n.id == req.reset_id); + //구매 가능한지 검사 + if (resetShopItem.count == 0) + { + throw new RuntimeException("Not Buy Count", Error.ErrorData); + } buy_type = resetShopItem.buy_type; buy = resetShopItem.buy; reward = resetShopItem.reward;