잘못 수정된 내용 재 업데이트
This commit is contained in:
parent
999a80e229
commit
0d04e5434b
|
|
@ -7,7 +7,7 @@ namespace Server.SQL
|
|||
{
|
||||
[Key]
|
||||
public long index { get; set; }
|
||||
public eBuyType buy_type { get; set; }
|
||||
public eRewardItemType reward_item_type { get; set; }
|
||||
public long return_item { get; set; }
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ namespace Server.SQL
|
|||
{
|
||||
RewardData rewardData = new RewardData();
|
||||
rewardData.index = item.Key;
|
||||
rewardData.buy_type = (eBuyType)item.Value["part"];
|
||||
rewardData.reward_item_type = (eBuyType)item.Value["part"];
|
||||
rewardData.return_item = (long)item.Value["return_item"];
|
||||
this.rewardData.Add(item.Key, rewardData);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,121 @@
|
|||
using Server.System;
|
||||
using Newtonsoft.Json;
|
||||
using Server.SQL;
|
||||
using LibGit2Sharp;
|
||||
|
||||
namespace Server.Service
|
||||
{
|
||||
public class BuyShopItem : AbstractService
|
||||
{
|
||||
private BuyShopItemReq req;
|
||||
|
||||
private void SaveSQL()
|
||||
{
|
||||
Statics.userSQL.SaveChanges();
|
||||
}
|
||||
|
||||
public override string Process()
|
||||
{
|
||||
User user = Statics.userSQL.SelectUuid(req.uuid);
|
||||
ShopItemData shopItemData = Statics.shopItemExcel.getShopItemData(req.index);
|
||||
RewardData rewardData;
|
||||
|
||||
//획득 가능한 아이템인지 확인
|
||||
switch (shopItemData.buy_type)
|
||||
{
|
||||
case eBuyType.gold:
|
||||
if(user.gold < shopItemData.buy)
|
||||
{
|
||||
throw new RuntimeException("Not gold", Error.nogold);
|
||||
}
|
||||
user.gold -= shopItemData.buy;
|
||||
break;
|
||||
case eBuyType.cash:
|
||||
if (!user.buyCash(shopItemData.buy))
|
||||
{
|
||||
throw new RuntimeException("Not cash", Error.nogold);
|
||||
}
|
||||
break;
|
||||
case eBuyType.money://현금결제 현재로서는 무조건 결제완료가 나오도록 처리할것
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Not case", Error.nodata);
|
||||
}
|
||||
|
||||
//아이템 획득 처리
|
||||
if(shopItemData.reward == 0)
|
||||
{
|
||||
//따로 처리가 필요함.
|
||||
}
|
||||
else
|
||||
{
|
||||
rewardData = Statics.rewardExcel.getRewardData(shopItemData.reward);
|
||||
switch (rewardData.reward_item_type)
|
||||
{
|
||||
case eRewardItemType.gold:
|
||||
user.gold += rewardData.return_item;
|
||||
break;
|
||||
case eRewardItemType.freecash:
|
||||
user.free_cash += rewardData.return_item;
|
||||
break;
|
||||
case eRewardItemType.paycash:
|
||||
user.pay_cash += rewardData.return_item;
|
||||
break;
|
||||
case eRewardItemType.character:
|
||||
|
||||
break;
|
||||
case eRewardItemType.equipment:
|
||||
|
||||
break;
|
||||
case eRewardItemType.consumable:
|
||||
|
||||
break;
|
||||
case eRewardItemType.etc:
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Not case", Error.nodata);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
SaveSQL();
|
||||
return makeResp();
|
||||
}
|
||||
|
||||
public override Protocol ProtocolValue() => Protocol.BuyShopItem;
|
||||
|
||||
public override Req Requst(string json)
|
||||
{
|
||||
req = JsonConvert.DeserializeObject<BuyShopItemReq>(json);
|
||||
return req;
|
||||
}
|
||||
|
||||
private string makeResp()
|
||||
{
|
||||
BuyShopItemResp resp = new BuyShopItemResp();
|
||||
return resp.ToJson();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class BuyShopItemReq : Req
|
||||
{
|
||||
public string uuid;
|
||||
public long index;
|
||||
public override bool IsReceivedAllField()
|
||||
{
|
||||
if (uuid == "" || index == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class BuyShopItemResp : Resp
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,8 @@
|
|||
EquipChange = 200,//장비 변경
|
||||
DeckChange = 201,//덱 유닛 변경
|
||||
NicknameChange = 202,//닉네임 변경
|
||||
|
||||
BuyShopItem = 300,//상점 아이템 구매
|
||||
}
|
||||
|
||||
public enum Error
|
||||
|
|
|
|||
Loading…
Reference in New Issue