[fix] 沒滿21分bug

This commit is contained in:
建喵 2024-06-06 16:03:12 +08:00
parent 4279c449b5
commit 8f169badee

View File

@ -49,13 +49,19 @@ export default function Play() {
useEffect(() => {
if (data) {
const score: number[] = JSON.parse(data.score);
const win: number = score.indexOf(data.winScore);
const win: number = score.indexOf(data.winScore) === -1
? score.indexOf(score[0] > score[1] ? score[0] : score[1])
: score.indexOf(data.winScore);
const team: string[] = JSON.parse(data.team).flat();
const winTeam: string[] = JSON.parse(data.team)[win];
const scoreList: number[] = JSON.parse(data.scoreList);
setTime(dayjs(data.time * 1000).format("YYYY-MM-DD HH:mm:ss"));
setTeam(team);
setWinTeam(winTeam[0] + "、" + winTeam[1]);
if (win === -1) {
setWinTeam("不明");
} else {
setWinTeam(winTeam[0] + "、" + winTeam[1]);
}
setScore(score[0] + "" + score[1]);
setScoreList(scoreList);
}