UNPKG

press-plus

Version:
64 lines (51 loc) 1.83 kB
import { SCHEDULE_TYPE_MAP, GROUP_TYPE_MAP } from '../config'; import { getCurScheduleType } from './cur-schedule-type'; export function mockOriginGame(resp: any, reqStage: number) { const groupType = resp?.game_info?.group_type; if (groupType >= 7) return; const pipelineCfg: Record<string, any> = {}; if (groupType == GROUP_TYPE_MAP.CYCLE) { pipelineCfg.curr_stage_num = 1; const boNum = resp?.round_info?.bo_type; pipelineCfg.game_stage_cfg_slice = [{ stage_id: 2, schedule_type: SCHEDULE_TYPE_MAP.CYCLE, bo_num: boNum, bo_type: boNum, }]; } else if (groupType == GROUP_TYPE_MAP.KNOCK_OUT) { pipelineCfg.curr_stage_num = 1; pipelineCfg.game_stage_cfg_slice = [{ stage_id: 3, schedule_type: SCHEDULE_TYPE_MAP.KNOCK_OUT, }]; } else if (groupType == GROUP_TYPE_MAP.CUP) { pipelineCfg.curr_stage_num = resp.stage == 2 ? 1 : 2; const stageCfgList = [{ stage_id: 2, stage_name: '循环赛', schedule_type: SCHEDULE_TYPE_MAP.CYCLE, }, { stage_id: 3, stage_name: '淘汰赛', schedule_type: SCHEDULE_TYPE_MAP.KNOCK_OUT, }]; pipelineCfg.game_stage_cfg_slice = stageCfgList; const curScheType = getCurScheduleType({ stageCfgList, curStageIdx: pipelineCfg.curr_stage_num - 1, reqStage, }); if (resp?.round_list?.length) { if (curScheType == SCHEDULE_TYPE_MAP.CYCLE) { resp.round_list = resp.round_list.filter((item: any) => item.round_type === 'cycle'); } else if (curScheType == SCHEDULE_TYPE_MAP.KNOCK_OUT) { resp.round_list = resp.round_list.filter((item: any) => item.round_type === 'main'); } } } resp.round_list?.forEach((item: any) => { item.start_battle_type = 1; }); resp.pipline_cfg = pipelineCfg; }