export const MESSAGETYPES = {
  ShootSyncMeArrowID: parseInt("0x789b6b0d"), // 2023451405
  ShootSyncMePracticeID: parseInt("0xD88AE05E"), // 3632980062
  ShootSyncBattleCreateMatchLinkID: parseInt("0xF86FF466"), // 2538869862
  WaitForAllReady: parseInt("0x615C13BE"), // 1633424318
  AllReady: parseInt("0x1CCB49FD"), // 483084797
  MeleeAllReady: parseInt("0x37132BD5"), // 924003285
  ShootResult: parseInt("0xAA0795E2"), // 2852623842
  CurrentRoundEnded: parseInt("0x3E2CE041"), // 1043128385
  ToSomeoneShoot: parseInt("0x077ACD1A"), // 125488410
  SomeGuyIsReady: parseInt("0xAEE8C236"), // 2934489654
  MatchOver: parseInt("0xB7815EEF"), // 3078708975
  StartCount: parseInt("0xD7B0DD2F"), // 3618692399
  FinalShoot: parseInt("0x5953C8A1"), // 1498663073
  RoundPoint: 4061248646,
  UserEnterRoom: 2133805521,
  UserExitRoom: 3896523333,
  RoomDestroy: 3617539277,
  SomeoneComplete: 2921416944,
  HalfTimeOver: 388606440,
  BackToGame: 1899960424,
  FinalShootResult: 3813452544,
  PaySuccess: 3793388244,
  RankUpdate: 1121669910,
  LvlUpdate: 3958625354,
  TeamUpdate: 4168086616,
  InvalidShot: 4168086617,
  Calibration: 4168086625,
  DeviceOnline: 4168086626,
  DeviceOffline: 4168086627,
  SomeoneIsReady: 4168086628,
};

export const MESSAGETYPESV2 = {
  AboutToStart: 1,
  BattleStart: 2,
  ToSomeoneShoot: 3,
  ShootResult: 4,
  NewRound: 5,
  BattleEnd: 6,
  HalfRest: 7,
  TestDistance: 8,
  MatchSuccess: 9,
  InvalidShot: 10,
};

export const topThreeColors = ["#FFD947", "#D2D2D2", "#FFA515"];

export const getMessageTypeName = (id) => {
  for (let key in MESSAGETYPES) {
    if (MESSAGETYPES[key] === id) return key;
  }
  for (let key in MESSAGETYPESV2) {
    if (MESSAGETYPESV2[key] === id) return key;
  }
  return id;
};

export const roundsName = {
  0: "一",
  1: "一",
  2: "二",
  3: "三",
  4: "四",
  5: "五",
};

export const meleeAvatarColors = [
  "#364469",
  "#692735",
  "#934B4B",
  "#A98B69",
  "#8268A2",
  "#9C538F",
  "#6870BB",
  "#4B8593",
  "#9BA969",
  "#DCCE6D",
];

export const orderStatusNames = {
  1: "待付款",
  2: "已付款",
  3: "已发货",
  4: "已完成",
  5: "已关闭",
  6: "申请退款",
  7: "退款中",
  8: "已退款",
  9: "拒绝退款",
};

export const getStatusColor = (status) => {
  switch (status) {
    case 1:
      return "#EF4848";
    case 4:
      return "#35CD67";
    default:
      return "#999999";
  }
};

export const directionAdjusts = {
  AdjustLowerRight: "向右下方调瞄",
  AdjustDown: "向下方调瞄",
  AdjustLowerLeft: "向左下方调瞄",
  AdjustLeft: "向左侧调瞄",
  AdjustUpperLeft: "向左上侧调瞄",
  AdjustUp: "向上方调瞄",
  AdjustUpperRight: "向右上方调瞄",
  AdjustRight: "向右侧调瞄",
};

export const getBattleResultTips = (
  gameMode,
  mode,
  { rank = 0, score = 0, win = false }
) => {
  const getRandomIndex = (len) => Math.floor(Math.random() * len);
  if (gameMode === 1) {
    if (mode <= 3) {
      if (win) {
        const tests = [
          "https://static.shelingxingqiu.com/attachment/2025-08-01/dbqq1fglywucyoh9zn.png",
          "https://static.shelingxingqiu.com/attachment/2025-08-01/dbqq1fgls1trzqneeh.png",
          "https://static.shelingxingqiu.com/attachment/2025-08-01/dbqq1fgm4fmv0tqico.png",
          // "你是朋友中的佼佼者哟!",
          // "你成功击败好友，成为大赢家!",
          // "你将好友“一举拿下”，超神无疑!",
        ];
        return tests[getRandomIndex(3)];
      } else {
        const tests = [
          "https://static.shelingxingqiu.com/attachment/2025-08-01/dbqq0gmb12vjkonvzm.png",
          "https://static.shelingxingqiu.com/attachment/2025-08-01/dbqq0gmo5gpiecqqgu.png",
          "https://static.shelingxingqiu.com/attachment/2025-08-01/dbqq0gmtk8hjwqoecz.png",
          // "失误啦失误啦，再多来几局吧~",
          // "惜败好友，下次再战定能反超!",
          // "友谊第一，下场胜利属于你!",
        ];
        return tests[getRandomIndex(3)];
      }
    } else {
      if (rank <= 3) {
        const tests = [
          "好成绩!全国排位赛等着你!",
          "持续练习，就会迎来更多高光时刻!",
        ];
        return tests[getRandomIndex(2)];
      } else {
        return "每日练习打卡，争取下次脱颖而出!";
      }
    }
  } else if (gameMode === 2) {
    if (mode <= 3) {
      if (win) {
        const tests = [
          "https://static.shelingxingqiu.com/attachment/2025-08-01/dbqq1fgtb29jbdus4g.png",
          "https://static.shelingxingqiu.com/attachment/2025-08-01/dbqq1fgtbu8fzpbh3z.png",
          "https://static.shelingxingqiu.com/attachment/2025-08-01/dbqq1fgtbu8fzpbh3z.png",
          // "你已经奔跑在通向王者的路上了!",
          // "射灵星球最闪耀的前进者!",
          // "赞!你真是越战越勇",
        ];
        return tests[getRandomIndex(3)];
      } else {
        const tests = [
          "https://static.shelingxingqiu.com/attachment/2025-08-01/dbqq0gmovnd33hz5yj.png",
          "https://static.shelingxingqiu.com/attachment/2025-08-01/dbqq0gmtu558juplj9.png",
          "https://static.shelingxingqiu.com/attachment/2025-08-01/dbqq0gmuhb5aofghg4.png",
          // "失败是成功之母，儿子在等你!",
          // "人生得意须尽欢，不过此关心不甘!",
          // "这回一定是打开方式不对。再来!",
        ];
        return tests[getRandomIndex(3)];
      }
    } else {
      if (score > 0) {
        const tests = [
          "王者一定属于你!",
          "高光时刻!继续保持!",
          "射灵世界的佼佼者!",
        ];
        return tests[getRandomIndex(3)];
      } else {
        const tests = [
          "再来一次，定能脱颖而出!",
          "加强练习，争取越战越勇",
          "人生走过的每一步都算数",
        ];
        return tests[getRandomIndex(3)];
      }
    }
  }
  return "";
};

export const RoundImages = {
  round1:
    "https://static.shelingxingqiu.com/attachment/2025-08-13/dc12slggifbnw9snvs.png",
  round2:
    "https://static.shelingxingqiu.com/attachment/2025-08-13/dc12slgf0swue5xzpd.png",
  round3:
    "https://static.shelingxingqiu.com/attachment/2025-08-13/dc12slglkylhmq8beb.png",
  round4:
    "https://static.shelingxingqiu.com/attachment/2025-08-13/dc12slggc88nasmxf5.png",
  round5:
    "https://static.shelingxingqiu.com/attachment/2025-08-13/dc12slgeloitb8mixf.png",
  gold1:
    "https://static.shelingxingqiu.com/attachment/2025-08-13/dc12slgsjbyyuu1des.png",
  gold2:
    "https://static.shelingxingqiu.com/attachment/2025-08-13/dc12slgdysd1wqulj5.png",
  gold3:
    "https://static.shelingxingqiu.com/attachment/2025-08-13/dc12slgm82ny3qjd8m.png",
};

export const RoundGoldImages = {
  round1:
    "https://static.shelingxingqiu.com/attachment/2025-08-13/dc12slg7kfzzwwiwcb.png",
  round2:
    "https://static.shelingxingqiu.com/attachment/2025-08-13/dc12slgs5htghfh3a9.png",
  round3:
    "https://static.shelingxingqiu.com/attachment/2025-08-13/dc12slgc9ge3paqkba.png",
  round4:
    "https://static.shelingxingqiu.com/attachment/2025-08-13/dc12slgehduk96yurp.png",
  round5:
    "https://static.shelingxingqiu.com/attachment/2025-08-13/dc12slgefz3hdmwbnz.png",
  gold1:
    "https://static.shelingxingqiu.com/attachment/2025-08-13/dc12slgeyb4cqwezgc.png",
  gold2:
    "https://static.shelingxingqiu.com/attachment/2025-08-13/dc12slggu3tlh97v5p.png",
  gold3:
    "https://static.shelingxingqiu.com/attachment/2025-08-13/dc12slgszmdtmaotch.png",
};
