c1_lua/lua/app/module/equip/equip_manager.lua
xiekaidong 42ad5ec9fa Merge branch 'dev_20230809' into dev_20230815
# Conflicts:
#	lua/app/config/const.lua
#	lua/app/config/item.lua
#	lua/app/config/skill_rogue.lua
#	lua/app/config/strings/cn/buff.lua
#	lua/app/config/strings/cn/item.lua
#	lua/app/config/strings/de/item.lua
#	lua/app/config/strings/en/item.lua
#	lua/app/config/strings/es/item.lua
#	lua/app/config/strings/fr/item.lua
#	lua/app/config/strings/id/item.lua
#	lua/app/config/strings/ja/item.lua
#	lua/app/config/strings/ja/skill.lua
#	lua/app/config/strings/ko/item.lua
#	lua/app/config/strings/pt/item.lua
#	lua/app/config/strings/ru/item.lua
#	lua/app/config/strings/th/item.lua
#	lua/app/config/strings/vi/item.lua
#	lua/app/config/strings/zh/item.lua
#	lua/app/config/strings/zh/skill.lua
2023-08-08 15:58:56 +08:00

52 lines
1.8 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
local itemGetType = BIReport.ITEM_GET_TYPE.EQUIP_UPGRADE
if part ~= GConst.EquipConst.PART_TYPE.WEAPON then
itemGetType = BIReport.ITEM_GET_TYPE.ARMOR_UPGRADE
end
self:sendMessage(ProtoMsgType.FromMsgEnum.EquipUpgradeReq, {hero_id = id, position = part}, {}, self.rspUpgrade, itemGetType)
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