신규 유저의 경우, 클라이언트에서 데이터를 만든 뒤, 서버에 저장하는 로직을 제거하고 서버에서 만들기

This commit is contained in:
Ino 2025-08-04 15:58:27 +09:00
parent 30f1bdb316
commit 57798d75a9
4 changed files with 231 additions and 69 deletions

View File

@ -134,55 +134,32 @@ handlers.Get_UserInfo = function (args)
if (sec > 0)
{
for (var i = 0; i < urod.Farm.Slot.length; i++)
{
if (urod.Farm.Slot[i].Time > 0)
{
urod.Farm.Slot[i].Time -= sec;
if (urod.Farm.Slot[i].Time < 0) urod.Farm.Slot[i].Time = 0;
}
}
for (var i = 0; i < urod.Farm.Shop.length; i++)
{
if (urod.Farm.Shop[i][2] > 0)
{
urod.Farm.Shop[i][2] -= sec;
if (urod.Farm.Shop[i][2] < 0) urod.Farm.Shop[i][2] = 0;
}
}
for (var key in urod.Shop)
{
if (urod.Shop.hasOwnProperty(key))
{
if (urod.Shop[key][2] > 0)
{
urod.Shop[key][2] -= sec;
if (urod.Shop[key][2] < 0) urod.Shop[key][2] = 0;
}
}
}
for (var i = 0; i < urod.Buff.Time.length; i++)
{
if (urod.Buff.Time[i] > 0)
{
urod.Buff.Time[i] -= sec;
if (urod.Buff.Time[i] < 0) urod.Buff.Time[i] = 0;
}
}
savedata = true;
// 오프라인 보상
}
}
else
{
savedata = true;
var table = Get_MissionTable();
var itemtable = Get_ItemTable();
urod = Create_NewUserData();
// 최초 클래스 및 스킬 추가
var classid = urod.Equip.Equip.PC;
Add_Item(table, itemtable, urod, classid, 1);
var skilllst = Get_SkillTable().filter(f=>f.e_SkillType != "JobPassive" && f.n_SkillClassID == classid);
for (var i = 0; i < skilllst.length; ++i)
Add_Item(table, itemtable, urod, skilllst[i].n_SkillID, 1);
// 코스튬, 펫, 짐꾼 추가
Add_Item(table, itemtable, urod, 110001, 1);
Add_Item(table, itemtable, urod, Get_GlobalValue_nValue("n_FirstEquipPet"), 1);
Add_Item(table, itemtable, urod, 70001, 1);
Make_EqiupmentEnchantOption(urod);
}
if (savedata) Set_JsonUserData(urod);
// 테스트 완료 후 주석 제거
//if (savedata) Set_JsonUserData(urod);
return Get_Return(
Get_Error(readonlydata, args.Token),
@ -194,6 +171,203 @@ handlers.Get_UserInfo = function (args)
}
);
}
function Create_NewUserData() {
var data = {};
data.LastTime = Get_CurKoreaTime();
data.Common = Array.from({ length: eCommon.Max }, () => 0);
data.MapData = {};
data.Buff = Init_Buff();
data.Equip = Init_Equip();
data.Equipment = {};
data.Slot = Init_Slot();
data.Item = {};
data.Enchant = Init_Enchant();
data.Skill = {};
data.Ability = {};
data.PC = Init_PC();
data.Awaken = Init_Awaken();
data.LimitSlot = Init_LimitSlot();
data.Pet = {};
data.PetData = { GachaLv: 1, GachaExp : 0, PetGachaADTime : Get_CurKoreaTime() };
data.Relic = {};
data.Collection = {};
data.MobKill = {};
data.Farm = Init_Farm();
data.Dungeon = {};
data.Mission = {};
data.Gacha = {};
data.Shop = {};
return data;
}
const eCommon = {
Agree: 0,
Noti: 1,
NightNoti: 2,
DOY_Day: 3,
DOY_Week: 4,
DOY_Month: 5,
PlayTime: 6,
Auto: 7,
FirstStatInit: 8,
ADRemove: 9,
GuideStep: 10,
GuideCount: 11,
NickChange: 12,
X2: 13,
CloverShopResetTime: 14,
CloverShopID_Weapon: 15,
CloverShopID_Ring: 16,
CloverShopID_Neck: 17,
CloverShopID_Boots: 18,
CloverShopID_Fairy: 19,
CloverShopID_Magic: 20,
CloverShopID_Pet: 21,
InAppBuyCount: 22,
FieldFirstFree: 23,
Roullette_Ticket: 24,
Roullette_Count: 25,
Roullette_ADCount: 26,
Roullette_LuckyCount: 27,
AttendanceStep: 28,
AttendanceDOY: 29,
Max: 30
};
function Init_Buff() {
return {
Infinity: 0,
Time: [new Date(), new Date(), new Date()]
};
}
function Init_Equip() {
const equip = {};
var classid = Get_GlobalValue_nValue("n_FirstClassID");
equip.Equip = {
PC: classid,
PCCostume: 110001,
Weapon: 0,
WeaponCostume: 0,
Armor: 0,
Helmet: 0,
Extra: 0,
Necklace: 0,
Ring: 0,
Pet: Get_GlobalValue_nValue("n_FirstEquipPet"),
Farmer: 0,
Worker: 70001
};
equip.Preset = 1;
equip.LimitPreset = 1;
var skilllst = Get_SkillTable().filter(f=>f.e_SkillType != "JobPassive" && f.n_SkillClassID == classid);
const equipSkillValues = [
skilllst[0].n_SkillID,
skilllst[1].n_SkillID,
skilllst[2].n_SkillID,
0, 0, 0
];
equip.Skill = {
1: [],
2: [],
3: []
};
for (const preset in equip.Skill) {
equip.Skill[preset] = [...equipSkillValues];
}
return equip;
}
function Init_Slot() {
const dic_EquipmentKey = {
Weapon: { id: 0, key: "Weapon" },
Armor: { id: 1, key: "Armor" },
Helmet: { id: 2, key: "Helmet" },
Extra: { id: 3, key: "Extra" },
Necklace: { id: 4, key: "Necklace" },
Ring: { id: 5, key: "Ring" }
};
const slotList = [];
for (const parts in dic_EquipmentKey) {
slotList.push({
Parts: parts, // key string 사용
Lv: 0,
Use: 0,
Enchant: [
{ ID : 0, EXTRA : 0, Lv : 0 },
{ ID : 0, EXTRA : 0, Lv : 0 },
{ ID : 0, EXTRA : 0, Lv : 0 }
]
});
}
return slotList;
}
function Init_Enchant() {
var enchant = {};
var list = Get_EnchantListTable();
for (var i = 0; i < list.length; i++)
enchant[list[i].n_EnchantID] = [0, 1, 0, 0];
return enchant;
}
function Init_Awaken() {
return {
STR: { LV : 1, Exp : 0 },
DEX: { LV : 1, Exp : 0 },
INT: { LV : 1, Exp : 0 },
LUK: { LV : 1, Exp : 0 }
};
}
function Init_PC() {
return {
Lv: 1,
LLv: 1,
ALv: 1,
Exp: 0,
AExp: 0,
Stat: [0, 0, 0, 0],
Obtain: []
};
}
function Init_LimitSlot() {
var result = { "1": [], "2": [], "3": [] };
for (var key in result) {
for (var i = 0; i < 6; i++) {
result[key].push({ ID: 0, Lock: 0 });
}
}
return result;
}
function Init_FarmSlot(slotIndex) {
return {
Slot: slotIndex,
Grade: 0,
EnchantID: 0,
Time: new Date()
};
}
function Init_Farm() {
const farmSlotList = [];
for (let i = 0; i < 8; i++) {
farmSlotList.push(Init_FarmSlot(i));
}
return {
MaxSlot: 0,
Slot: farmSlotList,
Eat: {},
Shop: {}
};
}
handlers.Get_OtherUserInfo = function (args)
{
var urod = server.GetUserReadOnlyData({ PlayFabId: args.ID }).Data;

View File

@ -334,29 +334,26 @@ public class ServerData_Read
temp.LimitBreakOption = LimitBreakOption;
temp.EnchantOption = EnchantOption;
temp.Book = new List<ServerData_Book>();
for (int i = 0; i < Book.Count; i++)
temp.Book.Add(Book[i].Get());
//temp.Book = new List<ServerData_Book>();
//for (int i = 0; i < Book.Count; i++)
// temp.Book.Add(Book[i].Get());
temp.ChapterQuest = new List<ServerData_ChapterQuest>();
for (int i = 0; i < ChapterQuest.Count; i++)
temp.ChapterQuest.Add(ChapterQuest[i].Get());
//temp.ChapterQuest = new List<ServerData_ChapterQuest>();
//for (int i = 0; i < ChapterQuest.Count; i++)
// temp.ChapterQuest.Add(ChapterQuest[i].Get());
temp.Title = DSUtil.Get_T_List(Title);
temp.Pass = DSUtil.Get_T_List(Pass);
//temp.Title = DSUtil.Get_T_List(Title);
//temp.Pass = DSUtil.Get_T_List(Pass);
foreach (var item in Inven)
temp.Inven.Add(item.Key, item.Value);
//foreach (var item in Inven)
// temp.Inven.Add(item.Key, item.Value);
temp.Potion = DSUtil.Get_T_Dic(Potion);
if (Event != null) temp.Event = DSUtil.Get_T_Dic(Event);
//temp.Potion = DSUtil.Get_T_Dic(Potion);
//if (Event != null) temp.Event = DSUtil.Get_T_Dic(Event);
//temp.TotalAdd = TotalAdd;
//temp.TotalUse = TotalUse;
#region
DataCheck(Common, temp.Common, (int)eCommon.Max);
#endregion
return temp;
}

View File

@ -321,23 +321,14 @@ public class ServerInfo : MyCoroutine
var str_result = urod.FunctionResult.ToString();
var error = MyErrorCheck(str_result);
var json = JsonConvert.DeserializeObject<SC_GetUserInfoResult>(str_result);
m_ServerData = json.UserInfo.Get_ServerData(false);
OffLineReward.m_Sec = json.ReconnectSec;
Get_MailList(json.Mail, null);
if (!json.isNewUser)
{ // 기존 유저
m_ServerData = json.UserInfo.Get_ServerData(false);
}
else
{ // 신규 유저
m_ServerData = new ServerData();
}
OptionInfo.Ins.Set_UI();
// 서버 데이터 가져오기 완료
if (json.isNewUser) // 기본 데이터 서버에 저장하고 닉네임 만들기
Write(() => { SetFirstName(_servercomplete, true); });
if (json.isNewUser) // 닉네임 만들기
SetFirstName(_servercomplete, true);
else
_servercomplete(false);
}

View File

@ -38,7 +38,7 @@ public class LimitSlotChangeData
Price = TotalPrice;
Count = MissionCount;
SelectPreset = sdata.Equip.LimitPreset;
Preset = sdata.LimitBreakOption.Preset;
Preset = sdata.LimitBreakOption != null ? sdata.LimitBreakOption.Preset : null;
Copy_ServerLimitSlot();
return this;
}