import { getLabelSymbol, getLabelName } from '../common/gp-match/label/label';
import { getRewardList } from '../common/gp-match/reward/game-reward';


// const getChildMatchType = (childInfo: Record<string, any>) => {
//   if (childInfo?.match_rule_cfg?.pubg_rule_cfg) {
//     const func = childInfo?.match_rule_cfg.pubg_rule_cfg.join_func;
//     if (func == 1) {
//       return '团体赛';
//     } if (func == 2) {
//       return '个人赛';
//     }
//   }
//   return '';
// };

const getTagList = (childInfo: Record<string, any>) => {
  // const matchTypeDesc = getChildMatchType(childInfo);
  const joinNum = childInfo.join_num || 0;
  const isMobileJoin = childInfo.match_rule_cfg?.pubg_rule_cfg?.device_cfg == 1;
  return [
    // matchTypeDesc,
    joinNum ? `报名人数 ${joinNum}` : '',
    isMobileJoin ? '手机参赛' : '',
  ].filter(Boolean);
};


export function parseMatchItem(item: Record<string, any> = {}) {
  const childInfo = item.child_info || {};
  const labelName = getLabelName(item);
  const labelSymbol = getLabelSymbol(labelName) || 'isLabelUnknown';
  const normalTagList = getTagList(childInfo);
  const prizeList = getRewardList(childInfo.general_reward_desc || '');

  return {
    ...item,
    labelName,
    [labelSymbol]: true,
    normalTagList,
    prizeList,

    childPic: childInfo.child_pic || '',
    childName: childInfo.child_name || '',
    isMobileJoin: childInfo.match_rule_cfg?.pubg_rule_cfg?.device_cfg == 1,
  };
}
