赛事预测. @author junzhou
| 22 | * @author junzhou |
| 23 | */ |
| 24 | @Slf4j |
| 25 | public class MatchGame implements Task { |
| 26 | |
| 27 | @Override |
| 28 | public void run() { |
| 29 | |
| 30 | if (!ConfigLoader.helperConfig.getTaskConfig().getMatchGame()) { |
| 31 | log.info("赛事预测未开启"); |
| 32 | return; |
| 33 | } |
| 34 | |
| 35 | double currentCoin = OftenApi.getCoinBalance(); |
| 36 | |
| 37 | if (currentCoin < ConfigLoader.helperConfig.getTaskConfig().getMinimumNumberOfCoins()) { |
| 38 | log.info("{}个硬币都没有,参加什么预测呢?任务结束", ConfigLoader.helperConfig.getTaskConfig().getMinimumNumberOfCoins()); |
| 39 | return; |
| 40 | } |
| 41 | JsonObject resultJson = queryContestQuestion(getTime(), 1, 50); |
| 42 | JsonObject jsonObject = resultJson.get("data").getAsJsonObject(); |
| 43 | if (resultJson.get("code").getAsInt() == 0) { |
| 44 | JsonArray list = jsonObject.get("list").getAsJsonArray(); |
| 45 | JsonObject pageinfo = jsonObject.get("page").getAsJsonObject(); |
| 46 | if (pageinfo.get("total").getAsInt() == 0) { |
| 47 | log.info("今日无赛事或者本日赛事已经截止预测"); |
| 48 | return; |
| 49 | } |
| 50 | if (list != null) { |
| 51 | int coinNumber = ConfigLoader.helperConfig.getTaskConfig().getPredictNumberOfCoins(); |
| 52 | int contestId; |
| 53 | String contestName; |
| 54 | int questionId; |
| 55 | String questionTitle; |
| 56 | int teamId; |
| 57 | String teamName; |
| 58 | // int seasonId; |
| 59 | String seasonName; |
| 60 | for (JsonElement listinfo : list) { |
| 61 | log.info("-----预测开始-----"); |
| 62 | |
| 63 | if (currentCoin < ConfigLoader.helperConfig.getTaskConfig().getMinimumNumberOfCoins()) { |
| 64 | log.info("仅剩{}个硬币,低于最低保留硬币数量,后续预测不再执行", currentCoin); |
| 65 | break; |
| 66 | } |
| 67 | |
| 68 | JsonObject contestJson = listinfo.getAsJsonObject().getAsJsonObject("contest"); |
| 69 | JsonObject questionJson = listinfo.getAsJsonObject().getAsJsonArray("questions").get(0).getAsJsonObject(); |
| 70 | contestId = contestJson.get("id").getAsInt(); |
| 71 | contestName = contestJson.get("game_stage").getAsString(); |
| 72 | questionId = questionJson.get("id").getAsInt(); |
| 73 | questionTitle = questionJson.get("title").getAsString(); |
| 74 | //seasonId = contestJson.get("season").getAsJsonObject().get("id").getAsInt(); |
| 75 | seasonName = contestJson.get("season").getAsJsonObject().get("title").getAsString(); |
| 76 | |
| 77 | log.info("{} {}:{}", seasonName, contestName, questionTitle); |
| 78 | |
| 79 | if (questionJson.get("is_guess").getAsInt() == 1) { |
| 80 | log.info("此问题已经参与过预测了,无需再次预测"); |
| 81 | continue; |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…