| | |
| | | @Override |
| | | public void checkRate(TGame game, Integer userid, CompleteGameDTO completeStudy, List<TStudy> studyList) { |
| | | String answerRate = game.getAnswerRate(); |
| | | String rate = game.getRate().split(",")[Constants.TWO]; |
| | | // 校验是否完成超级听力 |
| | | List<TGameRecord> gameRecordList = gameRecordService.lambdaQuery().eq(TGameRecord::getGameId, game.getId()) |
| | | .eq(TGameRecord::getGameDifficulty, Constants.TWO) |
| | | .ge(TGameRecord::getAccuracy, rate).list(); |
| | | // 下一周目逻辑 |
| | | int quarterItem = 1; |
| | | Map<Integer, List<TStudy>> studyMap = new HashMap<>(8); |
| | |
| | | // 获取当前季度所有周目 |
| | | List<TStudy> studyList1 = studyMap.get(quarterItem); |
| | | // 正确率达到通关率 |
| | | if (completeStudy.getAccuracy() >= Integer.parseInt(answerRate)) { |
| | | if (completeStudy.getAccuracy() >= Integer.parseInt(answerRate) |
| | | && !gameRecordList.isEmpty()) { |
| | | // 获取用户超级记忆游戏记录 |
| | | TUserStudy userStudy = this.lambdaQuery().eq(TUserStudy::getUserId, userid).one(); |
| | | for (int i = 0; i < studyList1.size(); i++) { |
| | | TStudy tStudy = studyList1.get(i); |
| | | if (tStudy.getWeek().equals(userStudy.getWeek())) { |
| | | if (studyList1.size() == 1 || i + 1 == studyList1.size() - 1) { |
| | | if (studyList1.size() == 1 || i + 1 == studyList1.size()) { |
| | | // 是否为当前季度最后一周目 |
| | | List<TStudy> studyList2 = studyMap.get(quarterItem + 1); |
| | | // 下一季度数据为空 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void gameHearing(TGame game, Integer userid, CompleteGameDTO completeStudy) { |
| | | public void gameHearing(TGame game, Integer userid, CompleteGameDTO completeStudy, List<TStudy> studyList) { |
| | | // 超级听力通关率 |
| | | String answerRate = game.getRate().split(",")[completeStudy.getDifficulty()]; |
| | | if (completeStudy.getAccuracy() >= Integer.parseInt(answerRate)) { |
| | |
| | | .ge(TGameRecord::getAccuracy, answerRate) |
| | | .eq(TGameRecord::getGameDifficulty, completeStudy.getDifficulty()).list(); |
| | | if (!list.isEmpty()) { |
| | | userStudy.setGameDifficulty(GAME_DIFFICULTY_MAP.get(completeStudy.getDifficulty())); |
| | | Integer integer = GAME_DIFFICULTY_MAP.get(completeStudy.getDifficulty()); |
| | | userStudy.setGameDifficulty(integer); |
| | | } |
| | | } else { |
| | | // 游戏难度为2,进入下一周目学习 |
| | | List<TGameRecord> gameRecordList = gameRecordService.lambdaQuery().eq(TGameRecord::getGameId, game.getId()) |
| | | .eq(TGameRecord::getGameName, Constants.MEMORY) |
| | | .ge(TGameRecord::getAccuracy, game.getAnswerRate()).list(); |
| | | // 判断是否完成超级记忆 |
| | | if (!gameRecordList.isEmpty()) { |
| | | int quarterItem = 1; |
| | | Map<Integer, List<TStudy>> studyMap = new HashMap<>(8); |
| | | for (TStudy study : studyList) { |
| | | Integer quarter = study.getQuarter(); |
| | | List<TStudy> itemList = studyMap.get(quarter); |
| | | if (null == itemList) { |
| | | itemList = new ArrayList<>(); |
| | | } |
| | | itemList.add(study); |
| | | studyMap.put(quarter, itemList); |
| | | // 记录学习季度 |
| | | if (study.getId().equals(game.getStudyId())) { |
| | | quarterItem = quarter; |
| | | } |
| | | } |
| | | // 获取当前季度所有周目 |
| | | List<TStudy> studyList1 = studyMap.get(quarterItem); |
| | | // 获取用户超级记忆游戏记录 |
| | | for (int i = 0; i < studyList1.size(); i++) { |
| | | TStudy tStudy = studyList1.get(i); |
| | | if (tStudy.getWeek().equals(userStudy.getWeek())) { |
| | | if (studyList1.size() == 1 || i + 1 == studyList1.size()) { |
| | | // 是否为当前季度最后一周目 |
| | | List<TStudy> studyList2 = studyMap.get(quarterItem + 1); |
| | | // 下一季度数据为空 |
| | | if (null != studyList2 && !studyList2.isEmpty()) { |
| | | TStudy tStudy1 = studyList2.get(Constants.ZERO); |
| | | userStudy.setWeek(tStudy1.getWeek()); |
| | | } |
| | | } else { |
| | | TStudy tStudy1 = studyList1.get(i + 1); |
| | | userStudy.setWeek(tStudy1.getWeek()); |
| | | } |
| | | } |
| | | } |
| | | userStudy.setDay(DAY_MAP.get(String.valueOf(userStudy.getDay()))); |
| | | userStudy.setLook(Constants.BURDEN_ONE); |
| | | userStudy.setPair(Constants.BURDEN_ONE); |
| | | userStudy.setInduction(Constants.BURDEN_ONE); |
| | | userStudy.setListen(Constants.BURDEN_ONE); |
| | | userStudy.setAnswer(Constants.BURDEN_ONE); |
| | | userStudy.setGameDifficulty(Constants.ZERO); |
| | | } |
| | | } |
| | | this.updateById(userStudy); |