thewar_client/Client/Assets/1_Script/System/Http/Protocol.cs

222 lines
6.0 KiB
C#

using BestHTTP;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
public enum Protocol
{
//0~100 임시 프로토콜
Test = 0,
AddUser = 1,
Downlode = 100,//기획 데이터 다운로드
Login = 101,//유저 로그인
EquipChange = 200,//장비 변경
DeckChange = 201,//장비 변경
NicknameChange = 202,//닉네임 변경
}
#region 100 : Downlode
public class DownlodeReq
{
public string version { get; set; }
public DownlodeReq()
{
version = Statics.version;
}
}
public class DownlodeResp : Request<DownlodeResp>
{
private Protocol protocol = Protocol.Downlode;
public string data { get; set; }
public string version { get; set; }
public void Request(Action<DownlodeResp> onRequestFinished)
{
CreateRequest(protocol, onRequestFinished, new DownlodeReq(), HTTPMethods.Post, null);
}
}
#endregion
#region 101 : Login
public class LoginReq
{
public string mail { get; set; }
public string uuid { get; set; }
public LoginReq(string mail, string uuid)
{
this.mail = mail;
this.uuid = uuid;
}
}
public class LoginResp : Request<LoginResp>
{
private Protocol protocol = Protocol.Login;
public string uuid { get; set; }
public string nickname { get; set; }
public ulong gold { get; set; }
public ulong cash { get; set; }
public List<DynamicData> dynamic_data { get; set; }
public List<DeckUnitInfo> deck_unit { get; set; }
public List<DeckInfo> deck_info { get; set; }
public List<Equipment> equipment { get; set; }
public void Request(LoginReq loginReq, Action<LoginResp> onRequestFinished, Action errorRequestFinished)
{
CreateRequest(protocol, onRequestFinished, loginReq, HTTPMethods.Post, errorRequestFinished);
}
}
public class DynamicData
{
public int id { get; set; }
public string name { get; set; }
public string value { get; set; }
}
public class DeckUnitInfo
{
public long id { get; set; }
public long unit_id { get; set; }
public long equip0_id { get; set; }
public long equip1_id { get; set; }
public long equip2_id { get; set; }
public long equip3_id { get; set; }
public long equip4_id { get; set; }
public long equip5_id { get; set; }
public int level { get; set; }
public long exp { get; set; }
}
public class Equipment
{
public long id { get; set; }
public long equip_unit { get; set; }
public int rand_stats { get; set; }
public long equipment_data_id { get; set; }
}
public class DeckInfo
{
public long id { get; set; }
public int deck_type { get; set; }
public long deck_unit0_id { get; set; }
public long deck_unit1_id { get; set; }
public long deck_unit2_id { get; set; }
public long deck_unit3_id { get; set; }
public long deck_unit4_id { get; set; }
public long deck_unit5_id { get; set; }
public long deck_unit6_id { get; set; }
public long deck_unit7_id { get; set; }
public long deck_unit8_id { get; set; }
public void newDataSet(DeckInfo newData)
{
this.id = newData.id;
this.deck_type = newData.deck_type;
this.deck_unit0_id = newData.deck_unit0_id;
this.deck_unit1_id = newData.deck_unit1_id;
this.deck_unit2_id = newData.deck_unit2_id;
this.deck_unit3_id = newData.deck_unit3_id;
this.deck_unit4_id = newData.deck_unit4_id;
this.deck_unit5_id = newData.deck_unit5_id;
this.deck_unit6_id = newData.deck_unit6_id;
this.deck_unit7_id = newData.deck_unit7_id;
this.deck_unit8_id = newData.deck_unit8_id;
}
}
#endregion
#region 200 : EquipChange
public class EquipChangeReq
{
public string uuid { get; set; }
public long unit_id { get; set; }
public long equipment_id { get; set; }
public bool is_equipment { get; set; }
public EquipChangeReq(long unit_id, long equipment_id, bool is_equipment)
{
this.uuid = Statics.uuid;
this.unit_id = unit_id;
this.equipment_id = equipment_id;
this.is_equipment = is_equipment;
}
}
public class EquipChangeResp : Request<EquipChangeResp>
{
private Protocol protocol = Protocol.EquipChange;
public Equipment equipment { get; set; }
public DeckUnitInfo deck_unit_info { get; set; }
public Equipment change_equipment { get; set; }
public void Request(Action<EquipChangeResp> onRequestFinished, long unit_id, long equipment_id, bool is_equipment)
{
CreateRequest(protocol, onRequestFinished, new EquipChangeReq(unit_id, equipment_id, is_equipment), HTTPMethods.Post, null);
}
}
#endregion
#region 201 : DeckChange
public class DeckChangeReq
{
public string uuid { get; set; }
public long deck_id { get; set; }
public long[] deck_unit { get; set; }
public DeckChangeReq(long deck_id, long[] deck_unit)
{
this.uuid = Statics.uuid;
this.deck_id = deck_id;
this.deck_unit = deck_unit;
}
}
public class DeckChangeResp : Request<DeckChangeResp>
{
private Protocol protocol = Protocol.DeckChange;
public DeckInfo deck_info { get; set; }
public void Request(Action<DeckChangeResp> onRequestFinished, long deck_id, long[] deck_unit)
{
CreateRequest(protocol, onRequestFinished, new DeckChangeReq(deck_id, deck_unit), HTTPMethods.Post, null);
}
}
#endregion
#region 202 : NicknameChange
public class NicknameChangeReq
{
public string uuid { get; set; }
public string newNickname { get; set; }
public NicknameChangeReq(string newNickname)
{
this.uuid = Statics.uuid;
this.newNickname = newNickname;
}
}
public class NicknameChangeResp : Request<NicknameChangeResp>
{
private Protocol protocol = Protocol.NicknameChange;
public string nickname { get; set; }
public ulong cash { get; set; }
public void Request(Action<NicknameChangeResp> onRequestFinished, string newNickname)
{
CreateRequest(protocol, onRequestFinished, new NicknameChangeReq(newNickname), HTTPMethods.Post, null);
}
}
#endregion