장비 장착 시스템 작업 완료
This commit is contained in:
parent
3094199674
commit
ef61fca26d
|
|
@ -1,8 +1,5 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL;
|
|
||||||
using SkiaSharp;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
||||||
|
|
||||||
namespace Server.SQL
|
namespace Server.SQL
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,7 @@ namespace Server.SQL
|
||||||
|
|
||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
logger.Info("동작1");
|
|
||||||
Statics.equipmentData = new Dictionary<long, EquipmentData>();
|
Statics.equipmentData = new Dictionary<long, EquipmentData>();
|
||||||
logger.Info("동작2");
|
|
||||||
List<EquipmentData> equipmentDatas = table.ToList();
|
List<EquipmentData> equipmentDatas = table.ToList();
|
||||||
for(int n = 0; n < equipmentDatas.Count; n++)
|
for(int n = 0; n < equipmentDatas.Count; n++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -7,51 +7,116 @@ namespace Server.Service
|
||||||
public class EquipChange : AbstractService
|
public class EquipChange : AbstractService
|
||||||
{
|
{
|
||||||
private EquipChangeReq req;
|
private EquipChangeReq req;
|
||||||
|
|
||||||
|
public void SaveSQL()
|
||||||
|
{
|
||||||
|
Statics.equipmentrSQL.SaveChanges();
|
||||||
|
Statics.deckUnitInfoSQL.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
public override string Process()
|
public override string Process()
|
||||||
{
|
{
|
||||||
//문제 1 장비 장착 저장이 안됨.
|
User user = Statics.userSQL.SelectUuid(req.uuid);
|
||||||
//문제 2 기존에 장비가 있다면 신규 장비로 교체가 되야함.
|
Equipment equipment = Statics.equipmentrSQL.SelectItem(user.id, req.equipment_id);
|
||||||
UserSQL userSQL = new UserSQL();
|
DeckUnitInfo deckUnitInfo = Statics.deckUnitInfoSQL.SelectItem(user.id, req.unit_id);
|
||||||
EquipmentrSQL equipmentrSQL = new EquipmentrSQL();
|
Equipment equipitem = null;
|
||||||
DeckUnitInfoSQL deckUnitInfoSQL = new DeckUnitInfoSQL();
|
|
||||||
User user = userSQL.SelectUuid(req.uuid);
|
|
||||||
Equipment equipment = equipmentrSQL.SelectItem(user.id, req.equipment_id);
|
|
||||||
DeckUnitInfo deckUnitInfo = deckUnitInfoSQL.SelectItem(user.id, req.unit_id);
|
|
||||||
|
|
||||||
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.equipmentData[equipment.equipment_data_id];
|
EquipmentData equipmentData = Statics.equipmentData[equipment.equipment_data_id];
|
||||||
|
if (req.is_equipment)
|
||||||
switch (equipmentData.part)
|
|
||||||
{
|
{
|
||||||
case 0:
|
switch (equipmentData.part)
|
||||||
deckUnitInfo.equip0_id = equipment.id;
|
{
|
||||||
break;
|
case 0:
|
||||||
case 1:
|
if (deckUnitInfo.equip0_id != 0)
|
||||||
deckUnitInfo.equip1_id = equipment.id;
|
{
|
||||||
break;
|
equipitem = Statics.equipmentrSQL.SelectItem(user.id, deckUnitInfo.equip0_id);
|
||||||
case 2:
|
equipitem.equip_unit = 0;
|
||||||
deckUnitInfo.equip2_id = equipment.id;
|
Statics.equipmentrSQL.Update(equipitem);
|
||||||
break;
|
}
|
||||||
case 3:
|
deckUnitInfo.equip0_id = equipment.id;
|
||||||
deckUnitInfo.equip3_id = equipment.id;
|
break;
|
||||||
break;
|
case 1:
|
||||||
case 4:
|
if (deckUnitInfo.equip1_id != 0)
|
||||||
deckUnitInfo.equip4_id = equipment.id;
|
{
|
||||||
break;
|
equipitem = Statics.equipmentrSQL.SelectItem(user.id, deckUnitInfo.equip1_id);
|
||||||
case 5:
|
equipitem.equip_unit = 0;
|
||||||
deckUnitInfo.equip5_id = equipment.id;
|
Statics.equipmentrSQL.Update(equipitem);
|
||||||
break;
|
}
|
||||||
|
deckUnitInfo.equip1_id = equipment.id;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (deckUnitInfo.equip2_id != 0)
|
||||||
|
{
|
||||||
|
equipitem = Statics.equipmentrSQL.SelectItem(user.id, deckUnitInfo.equip2_id);
|
||||||
|
equipitem.equip_unit = 0;
|
||||||
|
Statics.equipmentrSQL.Update(equipitem);
|
||||||
|
}
|
||||||
|
deckUnitInfo.equip2_id = equipment.id;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (deckUnitInfo.equip3_id != 0)
|
||||||
|
{
|
||||||
|
equipitem = Statics.equipmentrSQL.SelectItem(user.id, deckUnitInfo.equip3_id);
|
||||||
|
equipitem.equip_unit = 0;
|
||||||
|
Statics.equipmentrSQL.Update(equipitem);
|
||||||
|
}
|
||||||
|
deckUnitInfo.equip3_id = equipment.id;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if (deckUnitInfo.equip4_id != 0)
|
||||||
|
{
|
||||||
|
equipitem = Statics.equipmentrSQL.SelectItem(user.id, deckUnitInfo.equip4_id);
|
||||||
|
equipitem.equip_unit = 0;
|
||||||
|
Statics.equipmentrSQL.Update(equipitem);
|
||||||
|
}
|
||||||
|
deckUnitInfo.equip4_id = equipment.id;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
if (deckUnitInfo.equip5_id != 0)
|
||||||
|
{
|
||||||
|
equipitem = Statics.equipmentrSQL.SelectItem(user.id, deckUnitInfo.equip5_id);
|
||||||
|
equipitem.equip_unit = 0;
|
||||||
|
Statics.equipmentrSQL.Update(equipitem);
|
||||||
|
}
|
||||||
|
deckUnitInfo.equip5_id = equipment.id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
equipment.equip_unit = deckUnitInfo.id;
|
||||||
}
|
}
|
||||||
equipment.equip_unit = deckUnitInfo.id;
|
else
|
||||||
|
{
|
||||||
|
equipment.equip_unit = 0;
|
||||||
|
switch (equipmentData.part)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
deckUnitInfo.equip0_id = 0;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
deckUnitInfo.equip1_id = 0;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
deckUnitInfo.equip2_id = 0;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
deckUnitInfo.equip3_id = 0;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
deckUnitInfo.equip4_id = 0;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
deckUnitInfo.equip5_id = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Statics.equipmentrSQL.Update(equipment);
|
||||||
|
Statics.deckUnitInfoSQL.Update(deckUnitInfo);
|
||||||
|
|
||||||
equipmentrSQL.Update(equipment);
|
return makeResp(equipment, deckUnitInfo, equipitem);
|
||||||
deckUnitInfoSQL.Update(deckUnitInfo);
|
|
||||||
|
|
||||||
return makeResp(equipment, deckUnitInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Protocol ProtocolValue() => Protocol.EquipChange;
|
public override Protocol ProtocolValue() => Protocol.EquipChange;
|
||||||
|
|
@ -62,12 +127,14 @@ namespace Server.Service
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string makeResp(Equipment equipment, DeckUnitInfo deck_unit_info)
|
private string makeResp(Equipment equipment, DeckUnitInfo deck_unit_info, Equipment change_equipment)
|
||||||
{
|
{
|
||||||
|
SaveSQL();
|
||||||
EquipChangeResp resp = new EquipChangeResp();
|
EquipChangeResp resp = new EquipChangeResp();
|
||||||
resp.status = 200;
|
resp.status = 200;
|
||||||
resp.equipment = equipment;
|
resp.equipment = equipment;
|
||||||
resp.deck_unit_info = deck_unit_info;
|
resp.deck_unit_info = deck_unit_info;
|
||||||
|
resp.change_equipment = change_equipment;
|
||||||
return resp.ToJson();
|
return resp.ToJson();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -77,8 +144,11 @@ namespace Server.Service
|
||||||
public string uuid;
|
public string uuid;
|
||||||
public long unit_id;
|
public long unit_id;
|
||||||
public long equipment_id;
|
public long equipment_id;
|
||||||
|
public bool is_equipment;
|
||||||
public override bool IsReceivedAllField()
|
public override bool IsReceivedAllField()
|
||||||
{
|
{
|
||||||
|
if(uuid == "" || unit_id == 0 || equipment_id == 0)
|
||||||
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -86,6 +156,7 @@ namespace Server.Service
|
||||||
public class EquipChangeResp : Resp
|
public class EquipChangeResp : Resp
|
||||||
{
|
{
|
||||||
public Equipment equipment;
|
public Equipment equipment;
|
||||||
|
public Equipment change_equipment;
|
||||||
public DeckUnitInfo deck_unit_info;
|
public DeckUnitInfo deck_unit_info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,15 +7,12 @@ namespace Server.Service
|
||||||
public class Login : AbstractService
|
public class Login : AbstractService
|
||||||
{
|
{
|
||||||
private LoginReq req;
|
private LoginReq req;
|
||||||
|
|
||||||
public override string Process()
|
public override string Process()
|
||||||
{
|
{
|
||||||
UserSQL userSql = new UserSQL();
|
|
||||||
DynamicDataSQL dynamicDataSQL = new DynamicDataSQL();
|
|
||||||
DeckUnitInfoSQL deckUnitInfoSQL = new DeckUnitInfoSQL();
|
|
||||||
DeckInfoSQL deckInfoSQL = new DeckInfoSQL();
|
|
||||||
EquipmentrSQL equipmentrSQL = new EquipmentrSQL();
|
|
||||||
User user;
|
User user;
|
||||||
List<DynamicData> dynamicDataList = dynamicDataSQL.Select();
|
List<DynamicData> dynamicDataList = Statics.dynamicDataSQL.Select();
|
||||||
List<DeckUnitInfo> deckUnitInfoList = null;
|
List<DeckUnitInfo> deckUnitInfoList = null;
|
||||||
List<DeckInfo> deckInfoList = null;
|
List<DeckInfo> deckInfoList = null;
|
||||||
List<Equipment> equipmentList = null;
|
List<Equipment> equipmentList = null;
|
||||||
|
|
@ -24,23 +21,23 @@ namespace Server.Service
|
||||||
{
|
{
|
||||||
//최초 메일 로그인
|
//최초 메일 로그인
|
||||||
//게스트 로그인은 허용하지 않고 무조건 구글로그인 혹은 마스토돈 로그인만 가능하게 처리하기
|
//게스트 로그인은 허용하지 않고 무조건 구글로그인 혹은 마스토돈 로그인만 가능하게 처리하기
|
||||||
user = userSql.SelectMail(req.mail);
|
user = Statics.userSQL.SelectMail(req.mail);
|
||||||
|
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
deckUnitInfoList = deckUnitInfoSQL.Select();
|
deckUnitInfoList = Statics.deckUnitInfoSQL.Select();
|
||||||
deckInfoList = deckInfoSQL.Select();
|
deckInfoList = Statics.deckInfoSQL.Select();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//기존 유저 로그인
|
//기존 유저 로그인
|
||||||
user = userSql.SelectUuid(req.uuid);
|
user = Statics.userSQL.SelectUuid(req.uuid);
|
||||||
|
|
||||||
deckUnitInfoList = deckUnitInfoSQL.SelectUid(user.id);
|
deckUnitInfoList = Statics.deckUnitInfoSQL.SelectUid(user.id);
|
||||||
//추후 이것을 1개만 보낼것.
|
//추후 이것을 1개만 보낼것.
|
||||||
deckInfoList = deckInfoSQL.SelectUid(user.id);
|
deckInfoList = Statics.deckInfoSQL.SelectUid(user.id);
|
||||||
equipmentList = equipmentrSQL.SelectUid(user.id);
|
equipmentList = Statics.equipmentrSQL.SelectUid(user.id);
|
||||||
}
|
}
|
||||||
if(user == null)
|
if(user == null)
|
||||||
{
|
{
|
||||||
|
|
@ -53,7 +50,7 @@ namespace Server.Service
|
||||||
user.mail = req.mail;
|
user.mail = req.mail;
|
||||||
user.uuid = Guid.NewGuid().ToString();
|
user.uuid = Guid.NewGuid().ToString();
|
||||||
user.nickname = "NoName";
|
user.nickname = "NoName";
|
||||||
userSql.Insert(user); //저장하고 유닛의 id를 얻어오기 위함.
|
Statics.userSQL.Insert(user); //저장하고 유닛의 id를 얻어오기 위함.
|
||||||
#endregion
|
#endregion
|
||||||
#region 초기 유닛 지급
|
#region 초기 유닛 지급
|
||||||
deckUnitInfoList = new List<DeckUnitInfo>();
|
deckUnitInfoList = new List<DeckUnitInfo>();
|
||||||
|
|
@ -94,7 +91,7 @@ namespace Server.Service
|
||||||
deckUnitInfo.user_id = user.id;
|
deckUnitInfo.user_id = user.id;
|
||||||
deckUnitInfo.unit_id = 100009;
|
deckUnitInfo.unit_id = 100009;
|
||||||
deckUnitInfoList.Add(deckUnitInfo);
|
deckUnitInfoList.Add(deckUnitInfo);
|
||||||
deckUnitInfoSQL.Insert(deckUnitInfoList);
|
Statics.deckUnitInfoSQL.Insert(deckUnitInfoList);
|
||||||
#endregion
|
#endregion
|
||||||
#region 신규 덱 추가
|
#region 신규 덱 추가
|
||||||
deckInfoList = new List<DeckInfo>();
|
deckInfoList = new List<DeckInfo>();
|
||||||
|
|
@ -112,7 +109,7 @@ namespace Server.Service
|
||||||
deckInfo.deck_unit7_id = deckUnitInfoList[7].id;
|
deckInfo.deck_unit7_id = deckUnitInfoList[7].id;
|
||||||
deckInfo.deck_unit8_id = deckUnitInfoList[8].id;
|
deckInfo.deck_unit8_id = deckUnitInfoList[8].id;
|
||||||
deckInfoList.Add(deckInfo);
|
deckInfoList.Add(deckInfo);
|
||||||
deckInfoSQL.Insert(deckInfoList);
|
Statics.deckInfoSQL.Insert(deckInfoList);
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,5 +20,14 @@ namespace Server.System
|
||||||
public static readonly string PATTERN = "[^a-zA-Z0-9가-힣 ]";
|
public static readonly string PATTERN = "[^a-zA-Z0-9가-힣 ]";
|
||||||
|
|
||||||
public static Dictionary<long,EquipmentData> equipmentData = new Dictionary<long,EquipmentData>();
|
public static Dictionary<long,EquipmentData> equipmentData = new Dictionary<long,EquipmentData>();
|
||||||
|
|
||||||
|
|
||||||
|
//SQL
|
||||||
|
public static DeckInfoSQL deckInfoSQL = new DeckInfoSQL();
|
||||||
|
public static DeckUnitInfoSQL deckUnitInfoSQL = new DeckUnitInfoSQL();
|
||||||
|
public static DynamicDataSQL dynamicDataSQL = new DynamicDataSQL();
|
||||||
|
public static EquipmentrSQL equipmentrSQL = new EquipmentrSQL();
|
||||||
|
public static EquipmentDataSQL equipmentDataSQL = new EquipmentDataSQL();
|
||||||
|
public static UserSQL userSQL = new UserSQL();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue