// 军团建筑
export enum GUILD_STRUCTURE {
    START = 1,
    ARMY_CENTER = 1,      // 中军大帐
    EQUIP_PRODUCE = 2,    // 炼器堂
    BOSS = 3,             // 演武台
    TRAIN = 4,            // 练兵场
    WISH_POOL = 5,        // 许愿池
    STORE = 6,             // 商店
    DONATE = 7,           // 捐献所
    END
}

// 建筑名
export const GUILD_STRUCTURE_NAME = new Map([
    [ GUILD_STRUCTURE.ARMY_CENTER, '中军大帐'],
    [ GUILD_STRUCTURE.EQUIP_PRODUCE, '炼器堂'],
    [ GUILD_STRUCTURE.BOSS, '演武台'],
    [ GUILD_STRUCTURE.TRAIN, '练兵场'],
    [ GUILD_STRUCTURE.DONATE, '捐献所'],
    [ GUILD_STRUCTURE.WISH_POOL, '许愿池'],
    [ GUILD_STRUCTURE.STORE, '商店']
])

// 权限
export enum GUILD_AUTH {
    LEADER = 1,           // 团长
    MANAGER = 2,          // 管理员
    MEMBER = 3,           // 成员
    OTHERS = 4            // 未加入公会的其他人
}

// 职位
export enum GUILD_JOB {
    DAJIANGJUN = 1,
    JIANGJUN = 2,
    XIAOWEI = 3,
    SHIZHANG = 4,
    WUZHANG = 5,
    SHIBING = 6
}

// 操作
export enum GUILD_OPERATE {
    CREATE_GUILD = 1,               // 创建公会
    GET_GUILD_LIST = 2,             // 显示所有军团列表
    APPLY_GUILD = 3,                // 申请加入军团
    GET_GUILD_INFO = 4,             // 查看军团详细
    GET_MY_GUILD_INFO = 5,          // 查看自己军团详情
    GET_INVITATION_LIST = 6,        // 查看自己被邀请的军团
    RECEIVE_INVITAION = 7,          // 接受邀请
    GET_MEMBER_LIST_MAIN = 8,       // 查看成员主要信息
    GET_MEMBER_LIST_DETAIL = 9,     // 查看团内成员信息
    SET_AUTH = 10,                  // 设置权限
    SET_INFO = 11,                  // 修改军团信息
    GET_APPLY_LIST = 12,            // 查看申请列表
    RECEIVE_APPLY = 13,             // 接受申请
    GET_INIVATION_MEMBER_LIST = 14, // 获取可邀请列表
    INVATE_MEMBER = 15,             // 邀请某人
    SEND_MAIL = 16,                 // 发送邮件
    RECRUIT = 17,                   // 招募
    KICK = 18,                      // 踢人
    DISMISS = 19,                   // 解散军团
    QUIT = 20,                      // 退出军团
    IMPEACH = 21,                   // 弹劾团长
    UP_STRUCTURE = 22,              // 建筑物升级
    GET_REC = 23,                   // 获得动态
    OPEN_BOSS = 24,                 // 开启演武台
    EQUIP_PRODUCE = 25,             // 炼器堂研发
    BE_KICKED = 26,                 // 被踢出军团
    BE_SET_AUTH = 27,               // 被授权头衔
    BE_IMPEACH = 28,                // 被弹劾
    RECEIVE_ACTIVE = 29,            // 领取每日活跃宝箱
    GET_ACTIVE_RANK = 30,           // 查看活跃排行榜
    BOSS_BATTLE = 31,               // 挑战演舞台
    DONATE = 32,                    // 捐献所操作
    REFINE = 33,                    // 炼器
    ASSIST_REFINE = 34,             // 助力研发
    TRAIN = 35,                     // 练兵
    WISH_POOL = 36,                 // 许愿池
    GATE_ACTIVITY = 37,             // 蛮夷入侵挑战
    CITY_ACTIVITY_DECLARE = 38,     // 诸侯混战宣战
    CITY_ACTIVITY = 39,             // 诸侯混战挑战
    RACE_ACTIVITY = 40,             // 粮草先行挑战
}

export enum GUILD_AUTH_CHECK_TYPE {
    CHECK_SELF = 1,                 // 查询自己的权限，传递自己的userGuild数据
    CHECK_OTHERS = 2,               // 自己的权限和对方的权限，两者的userGuild数据都传递
    CHECK_SELF_IF_EXIST = 3,        // 如果加入了军团会判断权限，如果没有加入则会进入接口内
    CHECK_SELF_WITH_SESSION = 4,    // 不查询userGuild，只靠session中的auth判断
}

export const GUILD_ROUTE_OPERATE = [
    { route: 'guild.guildHandler.createGuild', operate: GUILD_OPERATE.CREATE_GUILD, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.getGuildList', operate: GUILD_OPERATE.GET_GUILD_LIST, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.setGuildInfo', operate: GUILD_OPERATE.SET_INFO, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.getGuildInfo', operate: GUILD_OPERATE.GET_GUILD_INFO, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.setAuth', operate: GUILD_OPERATE.SET_AUTH, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.setAuth', operate: GUILD_OPERATE.BE_SET_AUTH, type: GUILD_AUTH_CHECK_TYPE.CHECK_OTHERS },
    { route: 'guild.guildHandler.getMyGuildInfo', operate: GUILD_OPERATE.GET_MY_GUILD_INFO, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF_IF_EXIST },
    { route: 'guild.guildHandler.applyGuild', operate: GUILD_OPERATE.APPLY_GUILD, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.getApplyList', operate: GUILD_OPERATE.GET_APPLY_LIST, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.receiveApply', operate: GUILD_OPERATE.RECEIVE_APPLY, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.getInviteMemberList', operate: GUILD_OPERATE.GET_INIVATION_MEMBER_LIST, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.inviteMember', operate: GUILD_OPERATE.INVATE_MEMBER, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.getInvitationList', operate: GUILD_OPERATE.GET_INVITATION_LIST, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.receiveInvitation', operate: GUILD_OPERATE.RECEIVE_INVITAION, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.getGuildMember', operate: GUILD_OPERATE.GET_MEMBER_LIST_MAIN, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.dismiss', operate: GUILD_OPERATE.DISMISS, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.quit', operate: GUILD_OPERATE.QUIT, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.kick', operate: GUILD_OPERATE.KICK, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.kick', operate: GUILD_OPERATE.BE_KICKED, type: GUILD_AUTH_CHECK_TYPE.CHECK_OTHERS },
    { route: 'guild.guildHandler.impeach', operate: GUILD_OPERATE.IMPEACH, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.impeach', operate: GUILD_OPERATE.BE_IMPEACH, type: GUILD_AUTH_CHECK_TYPE.CHECK_OTHERS },
    { route: 'guild.guildHandler.upStructure', operate: GUILD_OPERATE.UP_STRUCTURE, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.getRec', operate: GUILD_OPERATE.GET_REC, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.sendMail', operate: GUILD_OPERATE.SEND_MAIL, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.recruit', operate: GUILD_OPERATE.RECRUIT, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.receiveActiveBox', operate: GUILD_OPERATE.RECEIVE_ACTIVE, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildHandler.getActiveRank', operate: GUILD_OPERATE.GET_ACTIVE_RANK, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildBossHandler.openBossInstance', operate: GUILD_OPERATE.OPEN_BOSS, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildRefineHandler.lightUpTree', operate: GUILD_OPERATE.EQUIP_PRODUCE, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildBossHandler.openBossInstance', operate: GUILD_OPERATE.OPEN_BOSS, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildRefineHandler.lightUpTree', operate: GUILD_OPERATE.EQUIP_PRODUCE, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildBossHandler.getBossInstance', operate: GUILD_OPERATE.BOSS_BATTLE, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildBossHandler.battleBoss', operate: GUILD_OPERATE.BOSS_BATTLE, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildBossHandler.action', operate: GUILD_OPERATE.BOSS_BATTLE, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildBossHandler.battleBossEnd', operate: GUILD_OPERATE.BOSS_BATTLE, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.donateHandler.getDonation', operate: GUILD_OPERATE.DONATE, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.donateHandler.donate', operate: GUILD_OPERATE.DONATE, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.donateHandler.receiveBox', operate: GUILD_OPERATE.DONATE, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildRefineHandler.getRefine', operate: GUILD_OPERATE.REFINE, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildRefineHandler.refine', operate: GUILD_OPERATE.REFINE, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildRefineHandler.assistRefine', operate: GUILD_OPERATE.ASSIST_REFINE, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildTrainHandler.getTrainInstance', operate: GUILD_OPERATE.TRAIN, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildTrainHandler.getTrainReports', operate: GUILD_OPERATE.TRAIN, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildTrainHandler.getTrainBoxs', operate: GUILD_OPERATE.TRAIN, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildTrainHandler.trainBattleStart', operate: GUILD_OPERATE.TRAIN, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildTrainHandler.trainBattleEnd', operate: GUILD_OPERATE.TRAIN, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildTrainHandler.getTrainInstanceBox', operate: GUILD_OPERATE.TRAIN, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildTrainHandler.getTrainLvUpRewards', operate: GUILD_OPERATE.TRAIN, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildTrainHandler.purchaseTrainCount', operate: GUILD_OPERATE.TRAIN, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.wishPoolHandler.getWishPool', operate: GUILD_OPERATE.WISH_POOL, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.wishPoolHandler.wishGoods', operate: GUILD_OPERATE.WISH_POOL, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.wishPoolHandler.donateGoods', operate: GUILD_OPERATE.WISH_POOL, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.wishPoolHandler.receiveGoods', operate: GUILD_OPERATE.WISH_POOL, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.wishPoolHandler.getReports', operate: GUILD_OPERATE.WISH_POOL, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.gateActivityHandler.getGateActivity', operate: GUILD_OPERATE.GATE_ACTIVITY, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF_WITH_SESSION },
    { route: 'guild.gateActivityHandler.checkBattle', operate: GUILD_OPERATE.GATE_ACTIVITY, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.gateActivityHandler.action', operate: GUILD_OPERATE.GATE_ACTIVITY, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF_WITH_SESSION },
    { route: 'guild.gateActivityHandler.hitGate', operate: GUILD_OPERATE.GATE_ACTIVITY, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF_WITH_SESSION },
    { route: 'guild.gateActivityHandler.battleEnd', operate: GUILD_OPERATE.GATE_ACTIVITY, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF_WITH_SESSION },
    { route: 'guild.cityActivityHandler.getCityActivity', operate: GUILD_OPERATE.CITY_ACTIVITY, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.cityActivityHandler.getCityStatus', operate: GUILD_OPERATE.CITY_ACTIVITY, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF_WITH_SESSION },
    { route: 'guild.cityActivityHandler.declareCity', operate: GUILD_OPERATE.CITY_ACTIVITY_DECLARE, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.cityActivityHandler.checkBattle', operate: GUILD_OPERATE.CITY_ACTIVITY, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.cityActivityHandler.hitGate', operate: GUILD_OPERATE.CITY_ACTIVITY, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF_WITH_SESSION },
    { route: 'guild.cityActivityHandler.battleEnd', operate: GUILD_OPERATE.CITY_ACTIVITY, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF_WITH_SESSION },
    { route: 'guild.raceActivityHandler.getRaceActivity', operate: GUILD_OPERATE.RACE_ACTIVITY, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF_WITH_SESSION },
    { route: 'guild.raceActivityHandler.join', operate: GUILD_OPERATE.RACE_ACTIVITY, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF_WITH_SESSION },
    { route: 'guild.raceActivityHandler.getRace', operate: GUILD_OPERATE.RACE_ACTIVITY, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF_WITH_SESSION },
    { route: 'guild.raceActivityHandler.useItem', operate: GUILD_OPERATE.RACE_ACTIVITY, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF_WITH_SESSION },
    { route: 'guild.raceActivityHandler.battleEnd', operate: GUILD_OPERATE.RACE_ACTIVITY, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF_WITH_SESSION },
    { route: 'guild.guildBossHandler.encourage', operate: GUILD_OPERATE.BOSS_BATTLE, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },
    { route: 'guild.guildBossHandler.getBossInstanceByBattleCode', operate: GUILD_OPERATE.BOSS_BATTLE, type: GUILD_AUTH_CHECK_TYPE.CHECK_SELF },

];

export const GUILD_ROUTE_TO_OPERATE = new Map<string, { operate: GUILD_OPERATE, type: number }[]>();
for(let {route, operate, type} of GUILD_ROUTE_OPERATE) {
    if(!GUILD_ROUTE_TO_OPERATE.has(route)) {
        GUILD_ROUTE_TO_OPERATE.set(route, []);
    }
    GUILD_ROUTE_TO_OPERATE.get(route).push({ operate, type});
}

// 军团状态
export enum GUILD_STATUS {
    RUNNING = 1,              // 运转中
    DISMISSED = 2             // 解散
}

// 成员状态
export enum USER_GUILD_STATUS {
    ON = 1,              // 成员
    QUIT = 2,            // 退出
    DISMISSED = 3        // 解散
}

// 查询每页显示
export const GUILD_PER_PAGE = 30;

// 公会申请状态
export enum GUILD_APPLY_STATUS {
    WAITING = 1,           // 等待操作
    AGREE = 2,             // 同意
    REFUSE = 3             // 拒绝
}

// 公会申请类型
export enum GUILD_APPLY_TYPE {
    APPLY = 1,              // 申请
    INVITE = 2              // 邀请
}

// 公会动态id
export enum GUILD_REC_TYPE {
    JOIN_GUILD = 1,          // 加入军团 roleName
    QUIT_GUILD = 2,          // 离开军团 roleName
    SET_MANAGER = 3,         // 提升管理 roleName
    STRUCTURE_UP = 4,        // 建筑物升级 structureName lv
    EQUIP_PRODUCE = 5,       // 装备碎片研发 lvmin lvmax quality
    BOSS_END = 6,            // 演武台击杀boss bossName
    BOSS_START = 7,           // 演武台boss 开启 bossName
    TRAIN_END = 8,           // 练兵场压制 warName
    TRAIN_START = 9,         // 练兵场开启 warName
    SET_LEADER = 10,          // 转让团长 guildName roleName
    IMPEACH = 11,             // 弹劾 roleName roleName
}

export enum GUILD_BOSS_STATUS {
    WAIT_OPEN = 0,            // 等待开启
    OPEN = 1,                 // 开启中
    CLEAR = 2                 // 已挑战完成
}

export const GUILD_REPORT_NUM = 40;

// 获得活跃值途径id
export enum GUILD_POINT_WAYS {
    DONATE = 1,            // 捐赠
    WISH_POOL = 2,         // 许愿池 
    TRAIN = 3,             // 训练场
    BOSS_WAR = 4,          // 演武台
    ACTIVITY = 5,          // 军团活动 
}

// 军团活动id
export enum GUILD_ACTIVITY_TYPE {
    GATE_ACTIVITY = 1,      // 蛮夷入侵
    CITY_ACTIVITY = 2,      // 诸侯混战
    RACE_ACTIVITY = 3       // 粮草先行
}

// 军团活动状态
export enum GUILD_ACTIVITY_STATUS {
    WAITING = 0,
    START = 1,
    END = 2
}

// 积分获取类型
export enum GET_POINT_WAYS {
    ROUND_START = 1,
    ENEMY = 2,          // 小兵
    LITTLE_BOSS = 3,    // 小boss
    BOSS = 4,           // 大boss
    DEFENSE_SUCCESS = 5, // 防守成功
    ELITE_ENEMY = 6,    // 精英怪
}

// 敌军类型，和上面的相对应
export enum ENEMIES_TYPE {
    ENEMY = 2,          // 小兵
    LITTLE_BOSS = 3,    // 小boss
    BOSS = 4,           // 大boss
    ELITE_ENEMY = 6,    // 精英怪
}

// 城池对于我的军团的状态
export enum CITY_STATUS {
    NOT_OPEN = 0,       // 未开放
    CAN_DECLARE = 1,    // 可宣战
    DECLARED = 2,       // 已宣战
    GUARD = 3           // 已占领
}

// 粮草先行事件表
export enum RACE_EVENT {
    LIANNU = 1,            // 连弩
    GUISHOUYINFU = 2,      // 鬼手阴符
    FENGCHE = 3,           // 风车
    WUGUIBANYUNFU = 4,     // 五鬼搬运符
    LUDUN = 5,             // 橹盾
    TIANSHIDUNFU = 6,      // 天师盾符
    JIASU_1 = 7,           // 加速事件
    JIASU_2 = 8,           // 加速事件
    HUIFU_1 = 9,           // 恢复事件
    JIANSU_1 = 10,         // 减速事件
    JIANSU_2 = 11,         // 减速事件
    SHANGHAI_1 = 12,        // 伤害事件
    ITEM = 13,              // 将获得道具
}

// 粮草先行事件类型
export enum RACE_EVENT_TYPE {
    DEFAULT = 0,
    ITEM = 1,          // 发道具
    EVENT = 2,         // 事件
}

// 粮草先行事件效果类型
export enum RACE_EVENT_EFFECT_TYPE {
    GOOD = 1,           // 好事件
    BAD = 2,            // 坏事件
}

// 粮草先行状态
export enum RACE_ACTIVITY_STATUS {
    WAITING = 0, // 未开始
    START = 1, // 已开始
    END = 2, // 已结束
    BREAK = 3,  // 爆破
}

export const CITY_ACTIVITY_DOOR = 1047;

export enum WISH_POOL_TYPE {
    SOUL = 1,   // 将魂
}