| | |
| | | voiceList.add(new GameMemoryVoiceVO(tSubject.getId(), tSubject.getCorrect())); |
| | | } |
| | | // 校验超级听力是否通过 |
| | | studyService.checkClearance(game,userStudy.getUserid()); |
| | | // studyService.checkClearance(game,userStudy.getUserid()); |
| | | // 框架记忆数量翻倍,前端需要根据数量画格子 |
| | | game.setAnswerCount(game.getAnswerCount() * 2); |
| | | return R.ok(new StudyGameMemoryVO(game, photoList, voiceList)); |
| | |
| | | throw new GlobalException("游戏信息异常!"); |
| | | } |
| | | // 积分明细 |
| | | List<TIntegralRecord> integralRecordList = integralRecordService.lambdaQuery().eq(TIntegralRecord::getUserId, userid) |
| | | .eq(TIntegralRecord::getGameId, game.getId()).eq(TIntegralRecord::getDisabled, 0).list(); |
| | | Integer difficulty = completeStudy.getDifficulty(); |
| | | List<TIntegralRecord> integralRecordList = integralRecordService.lambdaQuery() |
| | | .eq(TIntegralRecord::getUserId, userid) |
| | | .eq(TIntegralRecord::getGameId, game.getId()) |
| | | .eq(TIntegralRecord::getDisabled, 0) |
| | | .eq(TIntegralRecord::getGameDifficulty, difficulty).list(); |
| | | // 本次游戏总共能获取的积分数量 |
| | | Integer integral; |
| | | if (completeStudy.getGameName().equals(Constants.HEARING)) { |
| | | // 本次游戏总积分 |
| | | integral = Integer.parseInt(game.getIntegral().split(",")[completeStudy.getDifficulty()]); |
| | | integral = Integer.parseInt(game.getIntegral().split(",")[difficulty]); |
| | | } else if (completeStudy.getGameName().equals(Constants.MEMORY)) { |
| | | integralRecordList = integralRecordService.lambdaQuery() |
| | | .eq(TIntegralRecord::getUserId, userid) |
| | | .eq(TIntegralRecord::getGameId, game.getId()) |
| | | .eq(TIntegralRecord::getDisabled, 0) |
| | | .eq(TIntegralRecord::getGameDifficulty, null).list(); |
| | | integral = game.getAnswerIntegral(); |
| | | } else { |
| | | throw new GlobalException("该次游戏积分计算异常!"); |
| | |
| | | // 游戏测试记录 |
| | | Boolean add = gameRecordService.add(completeStudy); |
| | | // 可获得积分不为null时,才添加积分明细记录 |
| | | if (null != availableIntegral) { |
| | | add = add && integralRecordService.add(String.valueOf(availableIntegral), Constants.COMPLETE_GAME, completeStudy.getGameId(), null); |
| | | if (null != availableIntegral && !Constants.ZERO.equals(availableIntegral)) { |
| | | add = add && integralRecordService.add(String.valueOf(availableIntegral), |
| | | Constants.COMPLETE_GAME, completeStudy.getGameId(), null, difficulty); |
| | | // 用户账户添加积分 |
| | | TUser user = userService.getById(userid); |
| | | user.setIntegral(user.getIntegral() + availableIntegral); |
| | |
| | | userStudy.setWeekStudy(userStudy.getWeekStudy() + completeStudy.getUseTime()); |
| | | userStudy.setMonthStudy(userStudy.getMonthStudy() + completeStudy.getUseTime()); |
| | | userStudyService.updateById(userStudy); |
| | | // 学习配置列表 |
| | | List<TStudy> studyList = studyService.lambdaQuery().eq(TStudy::getDisabled, 0) |
| | | .orderByAsc(TStudy::getWeek).list(); |
| | | if (studyList.isEmpty()) { |
| | | throw new GlobalException("学习配置列表未配置或数据失效!"); |
| | | } |
| | | // 超级记忆逻辑 |
| | | if (Constants.MEMORY.equals(completeStudy.getGameName())) { |
| | | // 学习配置列表 |
| | | List<TStudy> studyList = studyService.lambdaQuery().eq(TStudy::getDisabled, 0) |
| | | .orderByAsc(TStudy::getWeek).list(); |
| | | if (studyList.isEmpty()) { |
| | | throw new GlobalException("学习配置列表未配置或数据失效!"); |
| | | } |
| | | // 超级记忆正确率达到通关率标准,才能进入下一周目学习 |
| | | // 校验是否通关超级听力与超级记忆,通关则学习记录更新为下一周目 |
| | | userStudyService.checkRate(game, userid, completeStudy, studyList); |
| | | add = add && completeStudy.getAccuracy() >= Integer.parseInt(game.getAnswerRate()); |
| | | } else { |
| | | // 超级听力需根据正确率判断是否允许进入下一难度 |
| | | userStudyService.gameHearing(game, userid, completeStudy); |
| | | String rate = game.getRate().split(",")[completeStudy.getDifficulty()]; |
| | | add = add && completeStudy.getAccuracy() >= Integer.parseInt(rate); |
| | | userStudyService.gameHearing(game, userid, completeStudy, studyList); |
| | | } |
| | | return R.ok(availableIntegral); |
| | | } |
| | |
| | | if (null == integralRecord) { |
| | | // 添加积分明细记录 |
| | | result = integralRecordService.add(String.valueOf(storyListen.getIntegral()), |
| | | Constants.COMPLETE_STORY, null, storyId); |
| | | Constants.COMPLETE_STORY, null, storyId, null); |
| | | TUser user = userService.lambdaQuery().eq(TUser::getId, userId).one(); |
| | | // 添加积分 |
| | | user.setIntegral(user.getIntegral() + storyListen.getIntegral()); |