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;