const express = require('express'); const router = express.Router(); const matchController = require('../controllers/matchController'); const { authUser, requireLadderUser } = require('../middlewares/auth'); // === 挑战赛 === // 检查是否可以发起挑战 router.get('/challenge/check/:targetMemberCode', authUser, matchController.checkChallenge); // 发起挑战 router.post('/challenge/create', authUser, matchController.createChallenge); // 响应挑战 router.post('/challenge/respond', authUser, matchController.respondChallenge); // 提交比分 router.post('/challenge/submit-score', authUser, matchController.submitScore); // 确认比分 router.post('/challenge/confirm-score', authUser, matchController.confirmScore); // === 排位赛 === // 扫码加入排位赛 router.post('/ranking/join', authUser, matchController.joinRankingMatch); // 获取排位赛详情 router.get('/ranking/:matchCode', authUser, matchController.getRankingDetail); // 获取我的当前对局 router.get('/ranking/:matchCode/my-game', authUser, matchController.getMyCurrentGame); // 提交排位赛比分 router.post('/ranking/submit-score', authUser, matchController.submitRankingScore); // 确认排位赛比分 router.post('/ranking/confirm-score', authUser, matchController.confirmRankingScore); // === 通用 === // 获取正在进行中的比赛 router.get('/ongoing', authUser, matchController.getOngoingMatches); // 获取选手比赛记录(用于选手详情页) router.get('/history', authUser, matchController.getPlayerHistory); // 获取我的比赛记录 router.get('/my-matches', authUser, matchController.getMyMatches); // 获取待确认的比赛 router.get('/pending-confirm', authUser, matchController.getPendingConfirm); // 获取比赛详情 router.get('/:id', authUser, matchController.getMatchDetail); module.exports = router;