press-next
Version:
Vue3 组件库,支持 Composition API
88 lines (67 loc) • 1.69 kB
text/typescript
import { getGpBattleState } from '../parser-tree/battle-status';
import { getMiddleButtonTitle } from '../parser-tree/middle-button';
import { getCardTeams } from './knockout-team';
// 解析 游客状态的赛程列表
export function parseGpScheListView(card: Record<string, any> = {}, {
isAdmin = false,
isManualStart = false,
openAILive = false,
}) {
const {
card_state: cardState = {},
stime,
round_name: roundName = '',
battle_id: battleId,
schedule_id: schId,
} = card;
const { teamA, teamB } = getCardTeams(card);
const isAtLeastOneTeamEmpty = teamA.isSpecial || teamB.isSpecial;
const buttonInfo = getMiddleButtonTitle({
isAdmin,
isAtLeastOneTeamEmpty,
state: cardState.sch_state,
curBattle: {
battle_state: cardState.battle_state,
},
openAILive,
});
const curBo = card.cur_bo || 1;
const boNum = card.bo_type || 1;
const {
timeDesc,
statusDesc,
playingDesc,
listViewStatusDesc,
battleDesc,
} = getGpBattleState({
state: cardState.sch_state,
battleState: cardState.battle_state,
curBo,
isManualStart,
time: stime,
});
return {
roundInfo: {
round_name: roundName,
},
battleId,
sche: {
upTeamInfo: teamA,
downTeamInfo: teamB,
schId,
battleId,
state: cardState.sch_state,
timeDesc,
statusDesc,
playingDesc,
listViewStatusDesc,
battleDesc,
showVS: listViewStatusDesc === '未开始',
curBo: `${curBo}`,
boType: boNum,
middleButtonTitle: buttonInfo.title,
middleButtonClass: buttonInfo.class,
isAtLeastOneTeamEmpty,
},
};
}