/*
文件名:PartyClass.nut
路径:BaseClass/PartyClass/PartyClass.nut
创建日期:2024-04-09	20:28
文件用途:Party类
*/
class Party extends Base_C_Object {

    constructor(CObject) {
        base.constructor(CObject);
    }


    //创建队伍
    function Create(SUser) {
        Sq_Party_CreateParty(C_Object, SUser.C_Object);
    }

    //给队伍加入玩家
    function Join(SUser) {
        Sq_Party_JoinParty(C_Object, SUser.C_Object);
    }

    //获取队长
    function GetMaster() {
        local Ret = Sq_CallFunc(S_Ptr("0x8145780"), "pointer", ["pointer"], this.C_Object);
        if (Ret) {
            local SUser = User(Ret);
            if (SUser) return SUser;
        }
        return null;
    }

    //发送每个玩家的IP广播 因为组队时p2p
    function SendIpInfo() {
        Sq_Party_SendPartyIpInfo(C_Object);
    }

    //获取战斗对象
    function GetBattleField() {
        return BattleField(Sq_Party_GetBattle_Field(C_Object));
    }

    //获取玩家
    function GetUser(Pos) {
        local C_User = Sq_CallFunc(S_Ptr("0x08145764"), "pointer", ["pointer", "int"], this.C_Object, Pos);
        if (C_User) {
            return User(C_User);
        }
        return null;
    }

    //踢出玩家
    function LeaveUser(SUser) {
        Sq_CallFunc(S_Ptr("0x0859C114"), "int", ["pointer", "pointer", "int"], this.C_Object, SUser.C_Object, 2);
    }

    //从副本踢出玩家
    function LeaveUserOnDgn(SUser) {
        Sq_CallFunc(S_Ptr("0x085B2BAA"), "void", ["pointer", "pointer", "int", "int", "int"], this.C_Object, SUser.C_Object, 1, 0, 0);
    }

    //设置队伍可用复活币数量
    function SetPartyMemberCoinLimit(Count) {
        Sq_CallFunc(S_Ptr("0x085BE55A"), "pointer", ["pointer", "int"], this.C_Object, Count);
    }

    //遍历玩家并执行函数
    function ForeachMember(Func) {
        for (local i = 0; i< 4; i++) {
            local SUser = GetUser(i);
            if (SUser) {
                Func(SUser, i);
            }
        }
    }

    //获取地下城清除状态
    function Get_Dgn_Clear_State() {
        return Sq_CallFunc(S_Ptr("0x0822D89C"), "int", ["pointer"], this.C_Object);
    }
}