Save_Farm_ShopBuy
This commit is contained in:
parent
d63fbbf635
commit
8083bb196e
|
|
@ -316,31 +316,62 @@ function Use_Item(table, urod, itemid, amount)
|
||||||
{
|
{
|
||||||
var success = false;
|
var success = false;
|
||||||
|
|
||||||
// 아이템 루트별 처리
|
if (urod.Item[itemid])
|
||||||
const tryUse = (dict, useIndex, totalIndex = null) => {
|
{
|
||||||
if (!dict[itemid]) return false;
|
if (urod.Item[itemid][0] >= amount)
|
||||||
if (dict[itemid][useIndex] < amount) return false;
|
{
|
||||||
|
urod.Item[itemid][0] -= amount;
|
||||||
dict[itemid][useIndex] -= amount;
|
urod.Item[itemid][2] = Add_Amount(urod.Item[itemid][2], amount);
|
||||||
if (totalIndex !== null)
|
success = true;
|
||||||
dict[itemid][totalIndex] = Add_Amount(dict[itemid][totalIndex], amount);
|
}
|
||||||
return true;
|
}
|
||||||
};
|
else if (urod.Equipment[itemid])
|
||||||
|
{
|
||||||
if (urod.Item && tryUse(urod.Item, 0, 2)) success = true;
|
if (urod.Equipment[itemid][0] >= amount)
|
||||||
else if (urod.Equipment && tryUse(urod.Equipment, 0)) success = true;
|
{
|
||||||
else if (urod.Skill && tryUse(urod.Skill, 0)) success = true;
|
urod.Equipment[itemid][0] -= amount;
|
||||||
else if (urod.Pet && tryUse(urod.Pet, 0)) success = true;
|
success = true;
|
||||||
else if (urod.Enchant && tryUse(urod.Enchant, 0, 3)) success = true;
|
}
|
||||||
else if (urod.Relic && tryUse(urod.Relic, 0)) success = true;
|
}
|
||||||
|
else if (urod.Skill[itemid])
|
||||||
|
{
|
||||||
|
if (urod.Skill[itemid][0] >= amount)
|
||||||
|
{
|
||||||
|
urod.Skill[itemid][0] -= amount;
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (urod.Pet[itemid])
|
||||||
|
{
|
||||||
|
if (urod.Pet[itemid][0] >= amount)
|
||||||
|
{
|
||||||
|
urod.Pet[itemid][0] -= amount;
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (urod.Enchant[itemid])
|
||||||
|
{
|
||||||
|
if (urod.Enchant[itemid][0] >= amount)
|
||||||
|
{
|
||||||
|
urod.Enchant[itemid][0] -= amount;
|
||||||
|
urod.Enchant[itemid][3] = Add_Amount(urod.Enchant[itemid][3], amount);
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (urod.Relic[itemid])
|
||||||
|
{
|
||||||
|
if (urod.Relic[itemid][0] >= amount)
|
||||||
|
{
|
||||||
|
urod.Relic[itemid][0] -= amount;
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
Add_MissionCount(table, urod, "CONSUME_GOODS", itemid, amount, false);
|
Add_MissionCount(table, urod, "CONSUME_GOODS", itemid, amount, false);
|
||||||
Add_MissionCount(table, urod, "CONSUME_GOODS_ACC", itemid, amount, false);
|
Add_MissionCount(table, urod, "CONSUME_GOODS_ACC", itemid, amount, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//log.info('use ' + itemid + ', ' + amount + ', result : ' + success);
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
function Get_ItemAmount(urod, itemid)
|
function Get_ItemAmount(urod, itemid)
|
||||||
|
|
@ -845,7 +876,7 @@ handlers.Save_PC_AbilityInit = function(args)
|
||||||
var abilitytable = Get_AbilityConfigTable();
|
var abilitytable = Get_AbilityConfigTable();
|
||||||
var global = Get_GlobalValueTable();
|
var global = Get_GlobalValueTable();
|
||||||
|
|
||||||
if (Use_Item(itemtable, urod, 1, Gem))
|
if (Use_Item(table, urod, 1, Gem))
|
||||||
{
|
{
|
||||||
var matdata = global.find(f => f.s_ID == "n_AbilityMaterialID");
|
var matdata = global.find(f => f.s_ID == "n_AbilityMaterialID");
|
||||||
if (!matdata) return Get_Return(1); // 설정 누락
|
if (!matdata) return Get_Return(1); // 설정 누락
|
||||||
|
|
@ -924,10 +955,10 @@ handlers.Save_PC_BuyJob = function(args)
|
||||||
return Get_Return(6);
|
return Get_Return(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
var itemtable = Get_ItemTable();
|
|
||||||
if (Use_Item(itemtable, urod, matdata.n_Value, m_Data.n_NeedGoodsCount))
|
|
||||||
{
|
|
||||||
var table = Get_MissionTable();
|
var table = Get_MissionTable();
|
||||||
|
if (Use_Item(table, urod, materialId, m_Data.n_NeedGoodsCount))
|
||||||
|
{
|
||||||
|
var itemtable = Get_ItemTable();
|
||||||
Add_Item(table, itemtable, urod, args.JobID, 1);
|
Add_Item(table, itemtable, urod, args.JobID, 1);
|
||||||
|
|
||||||
// 고유 스킬 지급
|
// 고유 스킬 지급
|
||||||
|
|
@ -2612,6 +2643,32 @@ handlers.Save_Farm_FarmerChange = function(args)
|
||||||
}
|
}
|
||||||
return Get_Return(1);
|
return Get_Return(1);
|
||||||
}
|
}
|
||||||
|
handlers.Save_Farm_ShopBuy = 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 id = args.FarmShopID;
|
||||||
|
var shop = urod.Farm.Shop[id];
|
||||||
|
if (!shop) return Get_Return(4);
|
||||||
|
var farmshopdata = Get_FarmShopTable().find(f=>f.n_FarmShopID == id);
|
||||||
|
if (shop.Buy >= farmshopdata.n_DayLimit) return Get_Return(3);
|
||||||
|
if (new Date(shop.Time) - Get_CurKoreaTime() > 0) return Get_Return(2);
|
||||||
|
|
||||||
|
if (farmshopdata.n_PayItemID == 0 || Use_Item(table, urod, farmshopdata.n_PayItemID, farmshopdata.n_PayItemAmount))
|
||||||
|
{
|
||||||
|
Add_Item(table, Get_ItemTable(), urod, farmshopdata.n_ItemID, farmshopdata.n_ItemAmount);
|
||||||
|
shop.Time = Get_TimeAddSec(farmshopdata.n_GapTime);
|
||||||
|
++shop.Buy;
|
||||||
|
|
||||||
|
Set_JsonUserData(urod);
|
||||||
|
return Get_Return(0);
|
||||||
|
}
|
||||||
|
return Get_Return(1);
|
||||||
|
}
|
||||||
/////////////////////////////////// 서버 처리
|
/////////////////////////////////// 서버 처리
|
||||||
|
|
||||||
handlers.Write_UnityInApp = function(args)
|
handlers.Write_UnityInApp = function(args)
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
|
@ -2520,6 +2520,44 @@ public class ServerInfo : MyCoroutine
|
||||||
Set_Coroutine(() => { Save_Farm_FarmerChange(id, _act); }, 2f);
|
Set_Coroutine(() => { Save_Farm_FarmerChange(id, _act); }, 2f);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
public void Save_Farm_ShopBuy(int id, Action _act)
|
||||||
|
{
|
||||||
|
NetWait.Ins.Set(true);
|
||||||
|
PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest
|
||||||
|
{
|
||||||
|
FunctionName = MethodBase.GetCurrentMethod().Name,
|
||||||
|
GeneratePlayStreamEvent = true,
|
||||||
|
FunctionParameter = new
|
||||||
|
{
|
||||||
|
Token = m_LoginInfo.EntityToken.EntityToken,
|
||||||
|
FarmShopID = id,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
result =>
|
||||||
|
{
|
||||||
|
if (result.Error == null)
|
||||||
|
{
|
||||||
|
NetWait.Ins.Set(false);
|
||||||
|
var str_result = result.FunctionResult.ToString();
|
||||||
|
var error = MyErrorCheck(str_result);
|
||||||
|
// (0 성공, 1 실패 (재화 부족), 2 실패 (시간 남음), 3 실패 (오늘 구매 완료), 4 실패 (없는 상점 아이템))
|
||||||
|
switch (error)
|
||||||
|
{
|
||||||
|
case 0: _act?.Invoke(); break;
|
||||||
|
case 1: ToastUI.Ins.Set(388); break;
|
||||||
|
case 2: ToastUI.Ins.Set(999900043); break;
|
||||||
|
case 3: ToastUI.Ins.Set(999900044); break;
|
||||||
|
case 4: ToastUI.Ins.Set(999900002); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Set_Coroutine(() => { Save_Farm_ShopBuy(id, _act); }, 2f);
|
||||||
|
},
|
||||||
|
fail =>
|
||||||
|
{
|
||||||
|
Set_Coroutine(() => { Save_Farm_ShopBuy(id, _act); }, 2f);
|
||||||
|
});
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 우편
|
#region 우편
|
||||||
|
|
|
||||||
|
|
@ -74,11 +74,14 @@ public class FarmShopCard : CardBase
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuySuccess()
|
void BuySuccess()
|
||||||
|
{
|
||||||
|
ServerInfo.Ins.Save_Farm_ShopBuy(m_Tdata.n_FarmShopID, () =>
|
||||||
{
|
{
|
||||||
var sdata = ServerInfo.Ins.m_ServerData;
|
var sdata = ServerInfo.Ins.m_ServerData;
|
||||||
sdata.Add_Item(m_Tdata.n_ItemID, m_Tdata.n_ItemAmount);
|
sdata.Add_Item(m_Tdata.n_ItemID, m_Tdata.n_ItemAmount);
|
||||||
sdata.Buy_FarmShopItem(m_FarmShopID, m_Tdata.n_GapTime);
|
sdata.Buy_FarmShopItem(m_FarmShopID, m_Tdata.n_GapTime);
|
||||||
ObtainItemUI.Ins.Set(new ItemSimpleData { itemid = m_Tdata.n_ItemID, amount = m_Tdata.n_ItemAmount });
|
ObtainItemUI.Ins.Set(new ItemSimpleData { itemid = m_Tdata.n_ItemID, amount = m_Tdata.n_ItemAmount });
|
||||||
FarmShopUI.Ins.Set();
|
FarmShopUI.Ins.Set();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue