From 6199d1ac78c323582af865e68968ecc28bbb1f54 Mon Sep 17 00:00:00 2001 From: Ino Date: Sun, 27 Jul 2025 02:58:53 +0900 Subject: [PATCH] Save_Farm_EatFruit --- .../Editor/Resources/.CloudScript.js | 22 +++++++++++ Assets/Script/Server/ServerInfo.cs | 37 +++++++++++++++++++ Assets/Script/UI/Farm/FarmInvenUI.cs | 17 ++++++--- 3 files changed, 71 insertions(+), 5 deletions(-) diff --git a/Assets/PlayFabEditorExtensions/Editor/Resources/.CloudScript.js b/Assets/PlayFabEditorExtensions/Editor/Resources/.CloudScript.js index 395ea8d7c..5c17470ea 100644 --- a/Assets/PlayFabEditorExtensions/Editor/Resources/.CloudScript.js +++ b/Assets/PlayFabEditorExtensions/Editor/Resources/.CloudScript.js @@ -2570,6 +2570,28 @@ function Get_FarmHarvestitems(urod, curSlot) return items; } +handlers.Save_Farm_EatFruit = function(args) +{ + var readonlydata = Get_UserReadOnlyData(); + var error = Get_Error(readonlydata, args.Token); + if (error < 0) return Get_Return(error); + + var urod = Get_JsonUserData(readonlydata); + var table = Get_MissionTable(); + var key = args.FruitID; + var amount = args.Amount; + if (Use_Item(table, urod, key, amount)) + { + if (!urod.Farm.Eat[key]) + urod.Farm.Eat[key] = amount; + else + urod.Farm.Eat[key] = Add_Amount(urod.Farm.Eat[key], amount); + + Set_JsonUserData(urod); + return Get_Return(0); + } + return Get_Return(1); +} /////////////////////////////////// 서버 처리 handlers.Write_UnityInApp = function(args) diff --git a/Assets/Script/Server/ServerInfo.cs b/Assets/Script/Server/ServerInfo.cs index 82aaa3554..99b201780 100644 --- a/Assets/Script/Server/ServerInfo.cs +++ b/Assets/Script/Server/ServerInfo.cs @@ -2337,6 +2337,7 @@ public class ServerInfo : MyCoroutine Set_Coroutine(() => { Save_Buff(index, _act); }, 2f); }); } + public void Save_Farm_PlantSeed(int slot, int enchantid, Action _act) { NetWait.Ins.Set(true); @@ -2448,6 +2449,42 @@ public class ServerInfo : MyCoroutine Set_Coroutine(() => { Save_Farm_HarvestImm(slot, _act); }, 2f); }); } + public void Save_Farm_EatFruit(int id, int amount, Action _act) + { + NetWait.Ins.Set(true); + PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest + { + FunctionName = MethodBase.GetCurrentMethod().Name, + GeneratePlayStreamEvent = true, + FunctionParameter = new + { + Token = m_LoginInfo.EntityToken.EntityToken, + FruitID = id, + Amount = amount + } + }, + result => + { + if (result.Error == null) + { + NetWait.Ins.Set(false); + var str_result = result.FunctionResult.ToString(); + var error = MyErrorCheck(str_result); + // (0 성공, 1 실패 (갯수 부족)) + switch (error) + { + case 0: _act?.Invoke(); break; + case 1: ToastUI.Ins.Set(388); break; + } + } + else + Set_Coroutine(() => { Save_Farm_EatFruit(id, amount, _act); }, 2f); + }, + fail => + { + Set_Coroutine(() => { Save_Farm_EatFruit(id, amount, _act); }, 2f); + }); + } #endregion #region 우편 diff --git a/Assets/Script/UI/Farm/FarmInvenUI.cs b/Assets/Script/UI/Farm/FarmInvenUI.cs index 0c799cd11..369607728 100644 --- a/Assets/Script/UI/Farm/FarmInvenUI.cs +++ b/Assets/Script/UI/Farm/FarmInvenUI.cs @@ -46,7 +46,10 @@ public class FarmInvenUI : BotMenuBase texts[0].text = table_itemlist.Ins.Get_ItemName(itemData.n_ItemID); texts[1].text = table_itemlist.Ins.Get_ItemDesc(itemData.n_ItemID); texts[2].text = table_fruit.Ins.Get_Data_orNull(id).Get_Desc(); + texts[3].text = ""; +#if UNITY_EDITOR texts[3].text = $"(확인용)먹은 갯수 : {sdata.Get_EatFruitCount(id)}"; +#endif m_ArrowUI.Set(totalcount => { }, amount); } @@ -55,12 +58,16 @@ public class FarmInvenUI : BotMenuBase { if (m_ArrowUI.Get_TotalCount() > 0) { - var sdata = ServerInfo.Ins.m_ServerData; var id = SelectCard.Get_FruitID(); - sdata.Use_Item(id, m_ArrowUI.Get_TotalCount()); - sdata.Add_EatFruitCount(id, m_ArrowUI.Get_TotalCount()); - Set(); - MyValue.Get_ActorStatInfoorNull(eRole.PC); + var amount = m_ArrowUI.Get_TotalCount(); + ServerInfo.Ins.Save_Farm_EatFruit(id, amount, () => + { + var sdata = ServerInfo.Ins.m_ServerData; + sdata.Use_Item(id, amount); + sdata.Add_EatFruitCount(id, amount); + Set(); + MyValue.Get_ActorStatInfoorNull(eRole.PC); + }); } } } \ No newline at end of file