상점 처리 시스템 수정
This commit is contained in:
parent
5d97bbfd55
commit
92b0e9d212
|
|
@ -80,7 +80,7 @@ namespace Server.Manager
|
|||
throw new RuntimeException("Unknown Error [box.Add(etcItem)]", Error.RuntimeException);
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Not case", Error.nodata);
|
||||
throw new RuntimeException("Not case", Error.NoData);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ namespace Server.Manager
|
|||
throw new RuntimeException("Unknown Error [box.Add(etcItem)]", Error.RuntimeException);
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Not case", Error.nodata);
|
||||
throw new RuntimeException("Not case", Error.NoData);
|
||||
}
|
||||
//지급된 보상은 가챠에서 제외
|
||||
randomRewardDatas.RemoveAt(n);
|
||||
|
|
@ -255,7 +255,7 @@ namespace Server.Manager
|
|||
throw new RuntimeException("Unknown Error [box.Add(etcItem)]", Error.RuntimeException);
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Not case", Error.nodata);
|
||||
throw new RuntimeException("Not case", Error.NoData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ namespace Server.SQL
|
|||
|
||||
public override List<ResetShopItem> SelectUid(long user_id)
|
||||
{
|
||||
//현재 시간도 비교해서 이전날자가 들어가지 않게 하기
|
||||
return table.Where(data => data.user_id == user_id && data.end_date > DateTime.UtcNow).ToList();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,38 +14,78 @@ namespace Server.Service
|
|||
private void SaveSQL(ItemManager item)
|
||||
{
|
||||
Statics.userSQL.SaveChanges();
|
||||
Statics.resetShopItemSQL.SaveChanges();
|
||||
item.box.SaveSQL();
|
||||
}
|
||||
|
||||
public override string Process()
|
||||
{
|
||||
User user = Statics.userSQL.SelectUuid(req.uuid);
|
||||
eBuyType buy_type;
|
||||
int buy;
|
||||
long reward;
|
||||
long id;
|
||||
ResetShopItem resetShopItem = null;
|
||||
if (req.reset_id == 0)
|
||||
{
|
||||
ShopItemData shopItemData = Statics.shopItemExcel.getShopItemData(req.shopItemIndex);
|
||||
buy_type = shopItemData.buy_type;
|
||||
buy = shopItemData.buy;
|
||||
reward = shopItemData.reward;
|
||||
id = shopItemData.index;
|
||||
}
|
||||
else
|
||||
{
|
||||
resetShopItem = Statics.resetShopItemSQL.SelectUid(user.id).Find(n => n.id == req.reset_id);
|
||||
buy_type = resetShopItem.buy_type;
|
||||
buy = resetShopItem.buy;
|
||||
reward = resetShopItem.reward;
|
||||
id = resetShopItem.id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//획득 가능한 아이템인지 확인
|
||||
switch (shopItemData.buy_type)
|
||||
switch (buy_type)
|
||||
{
|
||||
case eBuyType.gold:
|
||||
if (user.gold < shopItemData.buy)
|
||||
throw new RuntimeException("Not gold", Error.nogold);
|
||||
user.gold -= shopItemData.buy;
|
||||
if (user.gold < buy)
|
||||
throw new RuntimeException("Not gold", Error.NoGold);
|
||||
user.gold -= buy;
|
||||
break;
|
||||
case eBuyType.cash:
|
||||
if (!user.buyCash(shopItemData.buy))
|
||||
throw new RuntimeException("Not cash", Error.nogold);
|
||||
if (!user.buyCash(buy))
|
||||
throw new RuntimeException("Not cash", Error.NoGold);
|
||||
break;
|
||||
case eBuyType.money://현금결제 현재로서는 무조건 결제완료가 나오도록 처리할것
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Not case", Error.nodata);
|
||||
throw new RuntimeException("Not case", Error.NoData);
|
||||
}
|
||||
|
||||
ItemManager item = new ItemManager(user);
|
||||
|
||||
if (shopItemData.reward != 0)
|
||||
item.addReward(shopItemData.reward);
|
||||
if (reward != 0)
|
||||
{
|
||||
item.addReward(reward);
|
||||
ShopItem shopItem = new ShopItem();
|
||||
if(resetShopItem == null)
|
||||
{
|
||||
shopItem.user_id = user.id;
|
||||
shopItem.shop_item_data_id = id;
|
||||
Statics.shopItemSQL.Insert(shopItem);
|
||||
}
|
||||
else
|
||||
logger.Error("처리 필요");
|
||||
{
|
||||
resetShopItem.count--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RuntimeException("ServerError", Error.RuntimeException);
|
||||
}
|
||||
|
||||
|
||||
SaveSQL(item);
|
||||
return makeResp(user, item);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Server.Service
|
|||
continue;
|
||||
long unit_id = req.deck_unit[n];
|
||||
if( deckUnitInfo.FindIndex(data => data.id == unit_id) == -1)
|
||||
throw new RuntimeException("Not Unit", Error.nodata);
|
||||
throw new RuntimeException("Not Unit", Error.NoData);
|
||||
}
|
||||
|
||||
//존재하는 덱인지 검사
|
||||
|
|
@ -42,7 +42,7 @@ namespace Server.Service
|
|||
}
|
||||
|
||||
if(deckindex == -1)
|
||||
throw new RuntimeException("Not Deck", Error.nodata);
|
||||
throw new RuntimeException("Not Deck", Error.NoData);
|
||||
|
||||
//덱 검사
|
||||
if (deckInfo[deckindex].deck_unit0_id == req.deck_unit[0] &&
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace Server.Service
|
|||
|
||||
if (equipment == null || deckUnitInfo == null)
|
||||
{
|
||||
throw new RuntimeException("Not Data", Error.nodata);
|
||||
throw new RuntimeException("Not Data", Error.NoData);
|
||||
}
|
||||
EquipmentData equipmentData = Statics.equipmentExcel.getEquipmentData(equipment.equipment_data_id);
|
||||
if (req.is_equipment)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace Server.Service
|
|||
user = Statics.userSQL.SelectUuid(req.uuid);
|
||||
if (user == null)
|
||||
{
|
||||
throw new RuntimeException("Not User", Error.nodata);
|
||||
throw new RuntimeException("Not User", Error.NoData);
|
||||
}
|
||||
deckInfoList = Statics.deckInfoSQL.SelectUid(user.id);
|
||||
itemManager = new ItemManager(user);
|
||||
|
|
@ -49,7 +49,7 @@ namespace Server.Service
|
|||
{
|
||||
if (req.mail == "")
|
||||
{
|
||||
throw new RuntimeException("Not User", Error.nodata);
|
||||
throw new RuntimeException("Not User", Error.NoData);
|
||||
}
|
||||
#region 신규유저 생성
|
||||
newUser = true;
|
||||
|
|
|
|||
|
|
@ -24,14 +24,14 @@ namespace Server.Service
|
|||
//만약 시스템 설정과 같은 닉네임이 온다면 중복 처리
|
||||
if (newNickname == defaultNick)
|
||||
{
|
||||
throw new RuntimeException("Duplicate nickname", Error.errordata);
|
||||
throw new RuntimeException("Duplicate nickname", Error.ErrorData);
|
||||
}
|
||||
|
||||
//닉네임 체크
|
||||
if (!Regex.IsMatch(newNickname, regular) || (newNickname.Length < 2 || newNickname.Length > 16) || user.nickname == newNickname)
|
||||
{
|
||||
//해당 데이터가 들어온다면 유저 정보와 같이 로그를 남기게 만들것
|
||||
throw new RuntimeException("Nickname not allowed", Error.errordata);
|
||||
throw new RuntimeException("Nickname not allowed", Error.ErrorData);
|
||||
}
|
||||
|
||||
//가격 체크
|
||||
|
|
@ -43,7 +43,7 @@ namespace Server.Service
|
|||
//현재 충분한 제화가 있는지 확인
|
||||
if (!user.buyCash(buy))
|
||||
{
|
||||
throw new RuntimeException("Cache shortage", Error.nogold);
|
||||
throw new RuntimeException("Cache shortage", Error.NoGold);
|
||||
}
|
||||
|
||||
//닉네임 중복 검사
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@ public enum Error
|
|||
{
|
||||
RuntimeException = -1,//서버 오류
|
||||
None = 0,//사용안함
|
||||
success = 200,//성공
|
||||
notFound = 404,//프로토콜 없음
|
||||
unknown = 500,//파라미터 오류
|
||||
errordata = 501,//잘못된 데이터
|
||||
crypto = 800,//암복호화 에러
|
||||
nodata = 900,//데이터가 없음
|
||||
nogold = 901,//소모재화가 없음
|
||||
Success = 200,//성공
|
||||
NotFound = 404,//프로토콜 없음
|
||||
Unknown = 500,//파라미터 오류
|
||||
ErrorData = 501,//잘못된 데이터
|
||||
Crypto = 800,//암복호화 에러
|
||||
NoData = 900,//데이터가 없음
|
||||
NoGold = 901,//소모재화가 없음
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ namespace Server.System {
|
|||
Protocol cmd = (Protocol)int.Parse(context.Request.Headers["cmd"]);
|
||||
SERVICE_DIC.TryGetValue(cmd, out abstractService);
|
||||
if (abstractService == null)
|
||||
throw new RuntimeException("Not Found", Error.notFound);
|
||||
throw new RuntimeException("Not Found", Error.NotFound);
|
||||
|
||||
string body = Request(context.Request).GetAwaiter().GetResult();
|
||||
|
||||
|
|
@ -49,9 +49,9 @@ namespace Server.System {
|
|||
Req req = abstractService.Requst(body);
|
||||
|
||||
if (req == null)
|
||||
throw new RuntimeException("", Error.nodata);
|
||||
throw new RuntimeException("", Error.NoData);
|
||||
else if (!req.IsReceivedAllField())
|
||||
throw new RuntimeException("Internal Server Error", Error.unknown);
|
||||
throw new RuntimeException("Internal Server Error", Error.Unknown);
|
||||
|
||||
Response = abstractService.Process();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue