local monsterConfig = require("excel.monster")
local RoleAttr = require("role.RoleAttr")
local RoleDefine = require("role.RoleDefine")
local BattleMonsterExcel = require("excel.battlemonster")
local BattleMonsterExcel2 = require("excel.battlemonster2")

-- 创建一个怪物grid
function createMonsterObj(monsterId, attrId, refreshData, deleteData)
	local monsterCfg = monsterConfig.monster[monsterId] or BattleMonsterExcel.monster[monsterId] or BattleMonsterExcel2.monster[monsterId]
	if not monsterCfg then 
		--assert(nil, "not monster id "..id)
		return
	end
	local Obj = {}

    --暂时加这些，后续有需要再加
	Obj.id = monsterId
	Obj.lv = 1
    Obj.quality = 0
    Obj.power = 0
    Obj.star = monsterCfg.star or 0
	Obj.icon = monsterCfg.head or 0
	Obj.camp = monsterCfg.camp or 0
	Obj.body = monsterCfg.body or 0
    Obj.head = monsterCfg.head or 0


    for k, v in pairs(refreshData or {}) do
        Obj[k] = v
    end

    for key in pairs(deleteData or {}) do
        Obj[key] = nil
    end

    local attrs = RoleAttr.calcMonsterConf(monsterId, attrId)
    Obj.power = attrs[RoleDefine.ZHANDOULI]

	return Obj
end

-- 根据monsterOutID创建怪物obj List
function createMonsterObjListByMonsterOutID(monsterOutID)
    if not monsterOutID then return end

    local singleCfg = monsterConfig.monsterOut[monsterOutID] or BattleMonsterExcel.monsterOut[monsterOutID] or BattleMonsterExcel2.monsterOut[monsterOutID]
    local member = singleCfg.member
    local attrIds = singleCfg.attrID

    local objList = {}
    for k, v in ipairs(member) do
        local monsterID = v[1]
        local monsterLv = v[2]
        local attrId = attrIds[k]
        local refreshData = {lv = monsterLv}
        local obj = createMonsterObj(monsterID, attrId, refreshData)
        objList[k] = obj
    end
    return objList
end