import {ResGetList} from "../protocols/hero/PtlGetList";
import {ResLogin} from "../protocols/user/PtlLogin";
import {Player} from "./Player";
import {Role} from "./Role";
import {SkillBase} from "./skill/skillBase";


export type joinFightData = {
    player: Partial<ResLogin['gud']> & {
        buff?: { [id: string]: number | any; };
        side?: string;
        pos?: string | number;
        attr?: { [id: string]: number | any; };
        dead?: boolean;
    },
    roles: { [k: string]: roleDataType; };
    star?: number
};

export type roleDataType = Partial<ResGetList['list']['']> & {
    attr: { [k: string]: any; };
    side?: string;
    pos?: string | number;
    dead?: boolean;
    lockHp?: boolean;
    maxhp?: number;
} & { [k: string]: any; };

export type FightObj = Role | Player;

export type modifyHpType = {
    skillType: string,
    skillId: string | number;
};

export type dpsinfoType = { num: number, dps: number, miss: boolean, baoji: boolean, fromRole: FightObj, toRole: FightObj; };

export type afterSkillType = { fromRole: FightObj, toRole: FightObj, fromSkill: SkillBase, skillConf: { [k: string]: any; }, targetCount: number; emitData?: EmitDataType; };

export type buffDataType =
    { fromRole: FightObj, toRole: FightObj, fromSkill: SkillBase, skillConf: { [k: string]: any; }, targetCount: number; }
    & { buffid?: string; };

export type EmitDataType = { skillId: string | number, fromRole: FightObj, toRole: FightObj; } & { [k: string]: any; };


export type chkDataType = { when: string; } & { [k: string]: any; };
/**
 * toRole : 被动的持有者
 */
export type passiveChkType = {
    chkdata: chkDataType,
    emitData: EmitDataType,
    toRole: Role;
};

export type actType = 'addPassive' | 'delpassive';

export type atkRoleInfo_Type = { ov: number, nv: number, miss: boolean, baoji: boolean; };

export type turn_Type = { act: 'trun', roundNums: number; };
export type atk_Type = { act: 'atk', fromRole: string, targets: string[], skillId: string | number, rolesInfo: { [k: string]: atkRoleInfo_Type; }; };
export type addBuff_type = { act: 'addBuff', toRole: string, fromRole: string, skillId: string | number, buffType: string, buffId: string; };
export type delBuff_type = { act: 'delBuff', fromRole: string, skillId: string | number, buffId: string, buffType: string, why?: string; };
export type startAct_Type = { act: 'startAct', fromRole: string; };
export type stopAct_Type = { act: 'stopAct', fromRole: string; };
export type fightEnd_Type = { act: 'fightEnd', winSide: number; };
export type roleDead_Type = { act: 'roleDead', isFuhou: boolean, fromRole: string; };
export type addHp_Type = { act: 'addHp', fromRole: string, why: string, buffId: string, nv: number, ov: number; };
export type downHp_Type = { act: 'downHp', fromRole: string, why: string, buffId: string, nv: number, ov: number; };
export type fanji_Type = { act: 'fanji', fromRole: string, targets: string[], skillId: string | number, rolesInfo: { [k: string]: atkRoleInfo_Type; }; };
export type fuhuo_Type = { act: 'fuhuo', fromRole: string, target: string, nv: number; };
export type chongsheng_Type = { act: 'chongsheng', fromRole: string, target: string, nv: number; };
export type playerNuqi_Type = { act: 'playerNuqi', fromRole: string, maxnuqi: number, nuqi: number; };

export type recordDataType =
    turn_Type
    | atk_Type
    | addBuff_type
    | delBuff_type
    | startAct_Type
    | stopAct_Type
    | fightEnd_Type
    | roleDead_Type
    | addHp_Type
    | downHp_Type
    | fanji_Type
    | fuhuo_Type
    | chongsheng_Type
    | playerNuqi_Type;

export type fightResult = {
    winSide: number;
    fightLog: recordDataType[];
    initData: joinFightData[];
    fightData: joinFightData[];
    totalDamage: { "0": number, "1": number; };
    fightStatistics?: { [k: string]: { [k: string]: number; }; };
    otherData?: {
        [k: string]: any;
    };
};