/*
文件名:History_Log.nut
路径:CallBack/History_Log.nut
创建日期:2024-04-27	15:52
文件用途:游戏Log事件HOOK
*/
if (!("Cb_History_Log_Func" in getroottable())) Cb_History_Log_Func <- {};

function Cb_History_Log(Data) {
    // print(Data[0]);
    local UID = Data[1].tointeger();
    local Time = Data[3];
    local CharacName = Data[4];
    local CID = Data[5].tointeger();
    local CharacLevel = Data[6];
    local CharacJob = Data[7];
    local CharacGrowType = Data[8];
    local ClientWebAddress = Data[9];
    local ClientPeerIp = Data[10];
    local ClientPort = Data[11];
    local ChannelId = Data[12].tointeger(); //当前频道id

    local Game_Event = Data[13].slice(1); //游戏事件
    // print("活动事件:" + Game_Event + ":end");
    if (Game_Event in Cb_History_Log_Func) {
        local SUser = World.GetUserByUidCid(UID, CID);
        if (SUser)
            Cb_History_Log_Func[Game_Event](SUser, Data);
        else {
            if (Game_Event == "IP+" || Game_Event == "IP-")
                Cb_History_Log_Func[Game_Event](UID, CID, Data);
        }
    }
}

//进入副本
if (!("Cb_History_DungeonEnter_Func" in getroottable())) Cb_History_DungeonEnter_Func <- {};
Cb_History_Log_Func["DungeonEnter"] <- function(SUser, Data) {
    foreach(_Index, Func in Cb_History_DungeonEnter_Func) {
        Func(SUser, Data);
    }
}

//离开副本
if (!("Cb_History_DungeonLeave_Func" in getroottable())) Cb_History_DungeonLeave_Func <- {};
Cb_History_Log_Func["DungeonLeave"] <- function(SUser, Data) {
    foreach(_Index, Func in Cb_History_DungeonLeave_Func) {
        Func(SUser, Data);
    }
}

//获得金币
if (!("Cb_History_MoneyUp_Func" in getroottable())) Cb_History_MoneyUp_Func <- {};
Cb_History_Log_Func["Money+"] <- function(SUser, Data) {
    foreach(_Index, Func in Cb_History_MoneyUp_Func) {
        Func(SUser, Data);
    }
}

//获得道具
if (!("Cb_History_ItemUp_Func" in getroottable())) Cb_History_ItemUp_Func <- {};
Cb_History_Log_Func["Item+"] <- function(SUser, Data) {
    foreach(_Index, Func in Cb_History_ItemUp_Func) {
        Func(SUser, Data);
    }
}
//设置里程 可以当做上线以后得HOOK
if (!("Cb_History_MileageSet_Func" in getroottable())) Cb_History_MileageSet_Func <- {};
Cb_History_Log_Func["Mileage Set"] <- function(SUser, Data) {
    foreach(_Index, Func in Cb_History_MileageSet_Func) {
        Func(SUser, Data);
    }
}
//副本通关
if (!("Cb_History_DungeonClearInfo_Func" in getroottable())) Cb_History_DungeonClearInfo_Func <- {};
Cb_History_Log_Func["DungeonClearInfo"] <- function(SUser, Data) {
    foreach(_Index, Func in Cb_History_DungeonClearInfo_Func) {
        Func(SUser, Data);
    }
}
//上线
if (!("Cb_History_IPUp_Func" in getroottable())) Cb_History_IPUp_Func <- {};
Cb_History_Log_Func["IP+"] <- function(UID, CID, Data) {
    foreach(_Index, Func in Cb_History_IPUp_Func) {
        Func(UID, CID, Data);
    }
}
//上线
if (!("Cb_History_IPDown_Func" in getroottable())) Cb_History_IPDown_Func <- {};
Cb_History_Log_Func["IP-"] <- function(UID, CID, Data) {
    foreach(_Index, Func in Cb_History_IPDown_Func) {
        Func(UID, CID, Data);
    }
}
//使用复活币事件
if (!("Cb_History_PCoinDown_Func" in getroottable())) Cb_History_PCoinDown_Func <- {};
Cb_History_Log_Func["PCoin-"] <- function(SUser, Data) {
    foreach(_Index, Func in Cb_History_PCoinDown_Func) {
        Func(SUser, Data);
    }
}
//使用复活币事件
if (!("Cb_History_ItemLock_Func" in getroottable())) Cb_History_ItemLock_Func <- {};
Cb_History_Log_Func["ItemLock"] <- function(SUser, Data) {
    foreach(_Index, Func in Cb_History_ItemLock_Func) {
        Func(SUser, Data);
    }
}