48 lines
1.6 KiB
Lua
48 lines
1.6 KiB
Lua
local EquipManager = class("EquipManager", BaseModule)
|
|
|
|
-- 升级装备
|
|
function EquipManager:reqUpgrade(id, part)
|
|
local entity = DataManager.EquipData:getEquip(id, part)
|
|
if not entity then
|
|
return
|
|
end
|
|
|
|
local heroEntity = DataManager.HeroData:getHeroById(id)
|
|
if heroEntity == nil or not heroEntity:isUnlock() then
|
|
return
|
|
end
|
|
|
|
for index, cost in ipairs(entity:getUpgradeMaterials()) do
|
|
if cost.num > DataManager.BagData.ItemData:getItemNumById(cost.id) then
|
|
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_8))
|
|
UIManager:showUI("app/ui/dungeon/item_get_ui", {id = cost.id, value = cost.num})
|
|
return
|
|
end
|
|
end
|
|
|
|
if not entity:isEnoughGold() then
|
|
if not ModuleManager.ShopManager:tryTriggerCoinGift() then
|
|
GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_GOLD)
|
|
end
|
|
return
|
|
end
|
|
|
|
if entity:isMaxLevel() then
|
|
if entity:getPart() == GConst.EquipConst.PART_TYPE.WEAPON then
|
|
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_7, DataManager.PlayerData:getLv() + 1))
|
|
else
|
|
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_9, entity:getLevel() + 1))
|
|
end
|
|
return
|
|
end
|
|
|
|
self:sendMessage(ProtoMsgType.FromMsgEnum.EquipUpgradeReq, {hero_id = id, position = part}, {}, self.rspUpgrade, BIReport.ITEM_GET_TYPE.EQUIP_UPGRADE)
|
|
end
|
|
|
|
function EquipManager:rspUpgrade(result)
|
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
|
DataManager.EquipData:onUpgradeEquip(result.reqData.hero_id, result.reqData.position)
|
|
end
|
|
end
|
|
|
|
return EquipManager |