Skip to content

Commit

Permalink
1.修改评分为sgp战绩计算并优化计算方式
Browse files Browse the repository at this point in the history
2.新增胜率和评分场次数量自定义
3.修复选择英雄战绩窗口胜场不显示bug
4.修复战绩查询bug
5.优化和胜率改为组队房间获取模式取消手动筛选模式
6.修复战绩查询跨区bug
  • Loading branch information
WuYi5451 committed Nov 26, 2024
1 parent 3477240 commit ed8b0b6
Show file tree
Hide file tree
Showing 35 changed files with 570 additions and 352 deletions.
22 changes: 7 additions & 15 deletions src/main/java/helper/ClientStarter.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import helper.bo.LeagueClientBO;
import helper.cache.AppCache;
import helper.cache.FrameInnerCache;
import helper.cache.GameDataCache;
import helper.enums.GameStatusEnum;
import helper.exception.NoLcuApiException;
import helper.exception.NoProcessException;
import helper.http.RequestLcuUtil;
import helper.http.RequestSgpUtil;
import helper.services.lcu.*;
import helper.services.lcu.LinkLeagueClientApi;
import helper.services.lcu.strategy.*;
import helper.services.sgp.RegionSgpApi;
import helper.utils.ProcessUtil;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -24,7 +24,7 @@
@Slf4j
public class ClientStarter {
private LinkLeagueClientApi api;
private RegionSgpApi localSgpApi;
private RegionSgpApi sgpApi;

public void initLcu() throws Exception {
LeagueClientBO leagueClientBO = ProcessUtil.getClientProcess();
Expand All @@ -45,7 +45,7 @@ public void initSgp() throws Exception {
}
if (leagueClientBO.getRegion() != null) {
RequestSgpUtil requestUtil = new RequestSgpUtil(AppCache.api.getSgpAccessToken(), leagueClientBO.getRegion().toLowerCase());
localSgpApi = new RegionSgpApi(requestUtil);
sgpApi = new RegionSgpApi(requestUtil);
} else {
log.error("未识别到国服大区");
}
Expand All @@ -60,7 +60,6 @@ public void listenGameStatus() throws InterruptedException, IOException {
continue;
}
GameStatusContext gameStatusContext = new GameStatusContext();
CalculateScore calculateScore = new CalculateScore(api);
//监听游戏状态
GameStatusEnum gameStatus = api.getGameStatus();
if (!gameStatus.equals(GameStatusEnum.ChampSelect)) {
Expand All @@ -69,22 +68,20 @@ public void listenGameStatus() throws InterruptedException, IOException {
}
}
switch (gameStatus) {
case None:
case Lobby: {
gameStatusContext.setStrategy(new LobbyStrategy(api));
gameStatusContext.setStrategy(new LobbyStrategy(api, sgpApi));
break;
}
case Matchmaking:
case ReadyCheck: {
gameStatusContext.setStrategy(new ReadyCheckStrategy(api));
break;
}
case ChampSelect: {
gameStatusContext.setStrategy(new ChampSelectStrategy(api, localSgpApi, calculateScore));
gameStatusContext.setStrategy(new ChampSelectStrategy(api, sgpApi));
break;
}
case InProgress: {
gameStatusContext.setStrategy(new InProgressStrategy(api, calculateScore));
gameStatusContext.setStrategy(new InProgressStrategy(api, sgpApi));
break;
}
case PreEndOfGame: {
Expand All @@ -95,11 +92,6 @@ public void listenGameStatus() throws InterruptedException, IOException {
gameStatusContext.setStrategy(new EndOfGameStrategy(api));
break;
}
case WaitingForStats: {
gameStatusContext.setStrategy(new OtherStatusStrategy());
GameDataCache.reset();
break;
}
case Reconnect: {
gameStatusContext.setStrategy(new ReconnectStrategy(api));
break;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/helper/bo/GameMatchHistoryBO.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package helper.bo;

import helper.enums.GameQueueEnum;
import helper.frame.constant.GameConstant;
import lombok.Data;

Expand All @@ -26,7 +27,7 @@ public class GameMatchHistoryBO {
private List<Participants> participants;
/**
* 游戏类型ID 使用该类型区分游戏类型
* 在{@link GameConstant#GAME_TYPE}和{@link helper.enums.GameTypeEnum}
* 在{@link GameConstant#GAME_TYPE}和{@link GameQueueEnum}
* 进行映射和判断是否能进行对局详情展示
*/
private Integer queueId;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/helper/bo/SpgParticipants.java
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ public class SpgParticipants {
private String summonerName;

/**
* 团队是否早早投降
* 是否是本队伍发起的重开
*/
private boolean teamEarlySurrendered;

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/helper/bo/TencentChampion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package helper.bo;

import lombok.Data;

/**
* @author WuYi
*/
@Data
public class TencentChampion {
private Integer heroId;
private String name;
private String keywords;
}
1 change: 0 additions & 1 deletion src/main/java/helper/cache/FrameInnerCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ public class FrameInnerCache {
public static JFrame blackListFrame;
public static KeyTextPane keyTextPane;
public static MyTeamMatchHistoryPanel myTeamMatchHistoryPanel;
public static GameModeBox gameModeBox;

}
12 changes: 12 additions & 0 deletions src/main/java/helper/cache/FrameUserSetting.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,16 @@ public class FrameUserSetting {
*/
@JSONField(serialize = false)
private RankBO currentRankBO = new RankBO("RANKED_SOLO_5x5", "UNRANKED", "I");
/**
* 评分和胜率的筛选数量
*/
private Integer HistoryCount = 20;
/**
* 评分标记
*/
private String[] playerTags = new String[]{"内鬼", "下等马", "中等马", "上等马"};
/**
* 评分分割数
*/
private double[] playerBetween = new double[]{7, 8, 10};
}
33 changes: 28 additions & 5 deletions src/main/java/helper/cache/GameDataCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,22 @@
public class GameDataCache {

public static MePlayer me;
public static ArrayList<String> otherTeamScore = new ArrayList<>();
/**
* 敌人战绩
*/
public static ArrayList<String> enemyTeamScore = new ArrayList<>();
/**
* 我方评分
*/
public static ArrayList<String> myTeamScore = new ArrayList<>();
/**
* 所有英雄
*/
public static ArrayList<ChampionBO> allChampion = new ArrayList<>();
/**
* 所有英雄的绰号
*/
public static List<TencentChampion> allChampionName = new ArrayList<>();
/**
* 召唤师技能信息
*/
Expand All @@ -46,20 +59,32 @@ public class GameDataCache {
* 队友战绩缓存
*/
public static List<TeamSummonerBO> myTeamMatchHistory = new ArrayList<>();
/**
* 敌人战绩缓存
*/
public static List<TeamSummonerBO> enemyTeamMatchHistory = new ArrayList<>();

public static Map<Integer, GameQueue> selectGameQueueList = new LinkedHashMap<>();

public static Integer queueId = null;

public static LeagueClientBO leagueClient;

public static void reset() {
resetScore();
resetHistory();
}

public static void resetScore() {
otherTeamScore = new ArrayList<>();
enemyTeamScore = new ArrayList<>();
myTeamScore = new ArrayList<>();
}

public static void resetHistory() {
myTeamMatchHistory = new ArrayList<>();
enemyTeamMatchHistory = new ArrayList<>();
}

public static void cacheLcuMe() {
// 缓存登录人的信息
if (AppCache.api != null) {
Expand All @@ -76,6 +101,7 @@ public static void cacheLcuChampion() {
//缓存所有英雄
try {
allChampion = AppCache.api.getAllChampion();
allChampionName = AppCache.api.getChampionNameList();
} catch (Exception e) {
log.error("获取所有英雄错误");
}
Expand Down Expand Up @@ -111,9 +137,6 @@ public static void cacheSelectGameMode() {
}
}
}
if (FrameInnerCache.gameModeBox != null) {
FrameInnerCache.gameModeBox.setItems();
}
}

public static void cacheLeagueClient() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* @author WuYi
*/
public enum GameTypeEnum {
public enum GameQueueEnum {
CUSTOM(0, "自定义"),
RANK_SOLO(420, "单双排位"),
NORMAL(430, "匹配模式"),
Expand All @@ -22,20 +22,20 @@ public enum GameTypeEnum {
private final int queueId;
private final String typeName;

GameTypeEnum(int queueId, String typeName) {
GameQueueEnum(int queueId, String typeName) {
this.queueId = queueId;
this.typeName = typeName;
}

private static final Map<Integer, GameTypeEnum> BY_ID = new HashMap<>();
private static final Map<Integer, GameQueueEnum> BY_ID = new HashMap<>();

static {
for (GameTypeEnum e : values()) {
for (GameQueueEnum e : values()) {
BY_ID.put(e.getQueueId(), e);
}
}

public static GameTypeEnum valueOf(int id) {
public static GameQueueEnum valueOf(int id) {
return BY_ID.get(id);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package helper.frame.panel.client;

import ch.qos.logback.core.util.StringUtil;
import helper.bo.ChampionBO;
import helper.bo.TencentChampion;
import helper.cache.FrameSetting;
import helper.cache.GameDataCache;
import helper.frame.panel.base.SearchTextField;
Expand Down Expand Up @@ -57,9 +57,9 @@ public void createButtons(String filter) {
//创建按钮组
ButtonGroup group = new ButtonGroup();

for (ChampionBO championBO : GameDataCache.allChampion) {
for (TencentChampion championBO : GameDataCache.allChampionName) {
String name = championBO.getName();
if (StringUtil.isNullOrEmpty(filter) || name.contains(filter)) {
if (StringUtil.isNullOrEmpty(filter) || championBO.getKeywords().contains(filter)) {
JRadioButton button = new JRadioButton(name);
if (callBack != null) {
button.addActionListener(e -> {
Expand Down
46 changes: 0 additions & 46 deletions src/main/java/helper/frame/panel/history/GameModeBox.java

This file was deleted.

55 changes: 55 additions & 0 deletions src/main/java/helper/frame/panel/history/HistoryCountBox.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package helper.frame.panel.history;

import helper.cache.AppCache;
import helper.frame.bo.ItemBO;
import helper.frame.panel.base.BaseComboBox;
import helper.frame.utils.FrameConfigUtil;
import lombok.extern.slf4j.Slf4j;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

/**
* @author WuYi
*/
@Slf4j
public class HistoryCountBox extends BaseComboBox<ItemBO> {

public HistoryCountBox() {
this.setItems();
this.addItemListener(listener());
}

public void setItems() {
this.addItem(new ItemBO("-1", "评分胜率战绩数量(默认20)"));
this.addItem(new ItemBO("5", "5"));
this.addItem(new ItemBO("10", "10"));
this.addItem(new ItemBO("20", "20"));
this.addItem(new ItemBO("30", "30"));
this.addItem(new ItemBO("40", "40"));
this.addItem(new ItemBO("50", "50"));
this.addItem(new ItemBO("100", "100"));
this.addItem(new ItemBO("200", "200"));
Integer historyCount = AppCache.settingPersistence.getHistoryCount();
if (!historyCount.equals(20)) {
this.setSelectedItem(new ItemBO(historyCount.toString(), historyCount.toString()));
}
}

private ItemListener listener() {
return e -> {
if (e.getStateChange() == ItemEvent.SELECTED) {
ItemBO item = (ItemBO) e.getItem();
int count = Integer.parseInt(item.getValue());
if (count >= 5) {
AppCache.settingPersistence.setHistoryCount(count);
} else {
AppCache.settingPersistence.setHistoryCount(20);
}
FrameConfigUtil.save();
}
};

}

}
Loading

0 comments on commit ed8b0b6

Please sign in to comment.