상점 처리 시스템 수정

This commit is contained in:
김판돌 2024-03-23 18:19:11 +09:00
parent 5d97bbfd55
commit 92b0e9d212
9 changed files with 72 additions and 33 deletions

View File

@ -80,7 +80,7 @@ namespace Server.Manager
throw new RuntimeException("Unknown Error [box.Add(etcItem)]", Error.RuntimeException); throw new RuntimeException("Unknown Error [box.Add(etcItem)]", Error.RuntimeException);
break; break;
default: 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); throw new RuntimeException("Unknown Error [box.Add(etcItem)]", Error.RuntimeException);
break; break;
default: default:
throw new RuntimeException("Not case", Error.nodata); throw new RuntimeException("Not case", Error.NoData);
} }
//지급된 보상은 가챠에서 제외 //지급된 보상은 가챠에서 제외
randomRewardDatas.RemoveAt(n); randomRewardDatas.RemoveAt(n);
@ -255,7 +255,7 @@ namespace Server.Manager
throw new RuntimeException("Unknown Error [box.Add(etcItem)]", Error.RuntimeException); throw new RuntimeException("Unknown Error [box.Add(etcItem)]", Error.RuntimeException);
break; break;
default: default:
throw new RuntimeException("Not case", Error.nodata); throw new RuntimeException("Not case", Error.NoData);
} }
} }
} }

View File

@ -32,7 +32,6 @@ namespace Server.SQL
public override List<ResetShopItem> SelectUid(long user_id) public override List<ResetShopItem> SelectUid(long user_id)
{ {
//현재 시간도 비교해서 이전날자가 들어가지 않게 하기
return table.Where(data => data.user_id == user_id && data.end_date > DateTime.UtcNow).ToList(); return table.Where(data => data.user_id == user_id && data.end_date > DateTime.UtcNow).ToList();
} }
} }

View File

@ -14,38 +14,78 @@ namespace Server.Service
private void SaveSQL(ItemManager item) private void SaveSQL(ItemManager item)
{ {
Statics.userSQL.SaveChanges(); Statics.userSQL.SaveChanges();
Statics.resetShopItemSQL.SaveChanges();
item.box.SaveSQL(); item.box.SaveSQL();
} }
public override string Process() public override string Process()
{ {
User user = Statics.userSQL.SelectUuid(req.uuid); 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); 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: case eBuyType.gold:
if (user.gold < shopItemData.buy) if (user.gold < buy)
throw new RuntimeException("Not gold", Error.nogold); throw new RuntimeException("Not gold", Error.NoGold);
user.gold -= shopItemData.buy; user.gold -= buy;
break; break;
case eBuyType.cash: case eBuyType.cash:
if (!user.buyCash(shopItemData.buy)) if (!user.buyCash(buy))
throw new RuntimeException("Not cash", Error.nogold); throw new RuntimeException("Not cash", Error.NoGold);
break; break;
case eBuyType.money://현금결제 현재로서는 무조건 결제완료가 나오도록 처리할것 case eBuyType.money://현금결제 현재로서는 무조건 결제완료가 나오도록 처리할것
break; break;
default: default:
throw new RuntimeException("Not case", Error.nodata); throw new RuntimeException("Not case", Error.NoData);
} }
ItemManager item = new ItemManager(user); ItemManager item = new ItemManager(user);
if (shopItemData.reward != 0) if (reward != 0)
item.addReward(shopItemData.reward); {
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 else
logger.Error("처리 필요"); {
resetShopItem.count--;
}
}
else
{
throw new RuntimeException("ServerError", Error.RuntimeException);
}
SaveSQL(item); SaveSQL(item);
return makeResp(user, item); return makeResp(user, item);

View File

@ -26,7 +26,7 @@ namespace Server.Service
continue; continue;
long unit_id = req.deck_unit[n]; long unit_id = req.deck_unit[n];
if( deckUnitInfo.FindIndex(data => data.id == unit_id) == -1) 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) 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] && if (deckInfo[deckindex].deck_unit0_id == req.deck_unit[0] &&

View File

@ -24,7 +24,7 @@ namespace Server.Service
if (equipment == null || deckUnitInfo == null) 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); EquipmentData equipmentData = Statics.equipmentExcel.getEquipmentData(equipment.equipment_data_id);
if (req.is_equipment) if (req.is_equipment)

View File

@ -40,7 +40,7 @@ namespace Server.Service
user = Statics.userSQL.SelectUuid(req.uuid); user = Statics.userSQL.SelectUuid(req.uuid);
if (user == null) if (user == null)
{ {
throw new RuntimeException("Not User", Error.nodata); throw new RuntimeException("Not User", Error.NoData);
} }
deckInfoList = Statics.deckInfoSQL.SelectUid(user.id); deckInfoList = Statics.deckInfoSQL.SelectUid(user.id);
itemManager = new ItemManager(user); itemManager = new ItemManager(user);
@ -49,7 +49,7 @@ namespace Server.Service
{ {
if (req.mail == "") if (req.mail == "")
{ {
throw new RuntimeException("Not User", Error.nodata); throw new RuntimeException("Not User", Error.NoData);
} }
#region #region
newUser = true; newUser = true;

View File

@ -24,14 +24,14 @@ namespace Server.Service
//만약 시스템 설정과 같은 닉네임이 온다면 중복 처리 //만약 시스템 설정과 같은 닉네임이 온다면 중복 처리
if (newNickname == defaultNick) 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) 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)) if (!user.buyCash(buy))
{ {
throw new RuntimeException("Cache shortage", Error.nogold); throw new RuntimeException("Cache shortage", Error.NoGold);
} }
//닉네임 중복 검사 //닉네임 중복 검사

View File

@ -25,11 +25,11 @@ public enum Error
{ {
RuntimeException = -1,//서버 오류 RuntimeException = -1,//서버 오류
None = 0,//사용안함 None = 0,//사용안함
success = 200,//성공 Success = 200,//성공
notFound = 404,//프로토콜 없음 NotFound = 404,//프로토콜 없음
unknown = 500,//파라미터 오류 Unknown = 500,//파라미터 오류
errordata = 501,//잘못된 데이터 ErrorData = 501,//잘못된 데이터
crypto = 800,//암복호화 에러 Crypto = 800,//암복호화 에러
nodata = 900,//데이터가 없음 NoData = 900,//데이터가 없음
nogold = 901,//소모재화가 없음 NoGold = 901,//소모재화가 없음
} }

View File

@ -40,7 +40,7 @@ namespace Server.System {
Protocol cmd = (Protocol)int.Parse(context.Request.Headers["cmd"]); Protocol cmd = (Protocol)int.Parse(context.Request.Headers["cmd"]);
SERVICE_DIC.TryGetValue(cmd, out abstractService); SERVICE_DIC.TryGetValue(cmd, out abstractService);
if (abstractService == null) if (abstractService == null)
throw new RuntimeException("Not Found", Error.notFound); throw new RuntimeException("Not Found", Error.NotFound);
string body = Request(context.Request).GetAwaiter().GetResult(); string body = Request(context.Request).GetAwaiter().GetResult();
@ -49,9 +49,9 @@ namespace Server.System {
Req req = abstractService.Requst(body); Req req = abstractService.Requst(body);
if (req == null) if (req == null)
throw new RuntimeException("", Error.nodata); throw new RuntimeException("", Error.NoData);
else if (!req.IsReceivedAllField()) else if (!req.IsReceivedAllField())
throw new RuntimeException("Internal Server Error", Error.unknown); throw new RuntimeException("Internal Server Error", Error.Unknown);
Response = abstractService.Process(); Response = abstractService.Process();