| | |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.exception.GlobalException; |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.study.domain.*; |
| | | import com.ruoyi.study.dto.CompleteGameDTO; |
| | | import com.ruoyi.study.dto.StudyWeekDTO; |
| | | import com.ruoyi.study.mapper.TStudyMapper; |
| | | import com.ruoyi.study.service.*; |
| | |
| | | private ITSubjectService subjectService; |
| | | @Resource |
| | | private ITGameRecordService gameRecordService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private ITStudyAnswerService studyAnswerService; |
| | | @Resource |
| | |
| | | // 有问有答 |
| | | List<TStudyAnswer> answerList = studyAnswerService.lambdaQuery().eq(TStudyAnswer::getStudyId, id) |
| | | .eq(TStudyAnswer::getDisabled, 0).list(); |
| | | total += answerList.stream().map(TStudyAnswer::getIntegral).mapToInt(Integer::intValue).sum(); |
| | | Optional<TStudyAnswer> answerOptional = answerList.stream().findAny(); |
| | | if (answerOptional.isPresent()) { |
| | | total += answerOptional.get().getIntegral(); |
| | | } |
| | | // 归纳判断 |
| | | List<TStudyInduction> inductionList = studyInductionService.lambdaQuery().eq(TStudyInduction::getStudyId, id) |
| | | .eq(TStudyInduction::getDisabled, 0).list(); |
| | | total += inductionList.stream().map(TStudyInduction::getIntegral).mapToInt(Integer::intValue).sum(); |
| | | Optional<TStudyInduction> inductionOptional = inductionList.stream().findAny(); |
| | | if (inductionOptional.isPresent()) { |
| | | total += inductionOptional.get().getIntegral(); |
| | | } |
| | | // 看图选音 |
| | | List<TStudyLook> lookList = studyLookService.lambdaQuery().eq(TStudyLook::getStudyId, id) |
| | | .eq(TStudyLook::getDisabled, 0).list(); |
| | | total += lookList.stream().map(TStudyLook::getIntegral).mapToInt(Integer::intValue).sum(); |
| | | Optional<TStudyLook> lookOptional = lookList.stream().findAny(); |
| | | if (lookOptional.isPresent()) { |
| | | total += lookOptional.get().getIntegral(); |
| | | } |
| | | // 听音选图 |
| | | List<TStudyListen> listenList = studyListenService.lambdaQuery().eq(TStudyListen::getStudyId, id) |
| | | .eq(TStudyListen::getDisabled, 0).list(); |
| | | total += listenList.stream().map(TStudyListen::getIntegral).mapToInt(Integer::intValue).sum(); |
| | | Optional<TStudyListen> listenOptional = listenList.stream().findAny(); |
| | | if (listenOptional.isPresent()) { |
| | | total += listenOptional.get().getIntegral(); |
| | | } |
| | | // 音图相配 |
| | | List<TStudyPair> pairList = studyPairService.lambdaQuery().eq(TStudyPair::getStudyId, id) |
| | | .eq(TStudyPair::getDisabled, 0).list(); |
| | | total += pairList.stream().map(TStudyPair::getIntegral).mapToInt(Integer::intValue).sum(); |
| | | Optional<TStudyPair> pairOptional = pairList.stream().findAny(); |
| | | if (pairOptional.isPresent()) { |
| | | total += pairOptional.get().getIntegral(); |
| | | } |
| | | // 自主游戏 |
| | | List<TGame> gameList = gameService.lambdaQuery().eq(TGame::getStudyId, id) |
| | | .eq(TGame::getDisabled, 0).list(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public TUserStudy studySchedule(String userId, Integer week) { |
| | | return userStudyService.studySchedule(userId, week); |
| | | public TUserStudy studySchedule(String userId) { |
| | | return userStudyService.studySchedule(userId); |
| | | } |
| | | |
| | | @Override |
| | | public void checkDifficulty(Integer difficulty, Integer week, TGame game) { |
| | | public void checkDifficulty(Integer difficulty, Integer week, TGame game, Integer userid) { |
| | | // 判断用户是否完成上一个等级 |
| | | if (!Constants.ZERO.equals(difficulty)) { |
| | | Integer level = GAME_DIFFICULTY_MAP.get(difficulty); |
| | | if (null == level) { |
| | | throw new GlobalException("游戏等级异常,请重试!"); |
| | | } |
| | | // 游戏通关率 |
| | | String clearanceRate = game.getRate().split(",")[level]; |
| | | // 获取用户游戏进度 |
| | | Integer userId = tokenService.getLoginUserStudy().getUserid(); |
| | | List<TGameRecord> list = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userId) |
| | | List<TGameRecord> list = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userid) |
| | | .eq(TGameRecord::getGameId, game.getId()) |
| | | .eq(TGameRecord::getAccuracy, 100) |
| | | .ge(TGameRecord::getAccuracy, clearanceRate) |
| | | .eq(TGameRecord::getGameDifficulty, level).list(); |
| | | if (list.isEmpty()) { |
| | | throw new GlobalException("请先完成上一难度再挑战当前难度!"); |
| | |
| | | return (int) (sum * ((double) accuracy / 100)); |
| | | } |
| | | |
| | | @Override |
| | | public void checkRate(TGame game, Integer userid, CompleteGameDTO completeStudy) { |
| | | |
| | | } |
| | | |
| | | } |