Skip to content

Commit

Permalink
皮肤设置完成后,重新加载皮肤
Browse files Browse the repository at this point in the history
  • Loading branch information
4379711 committed May 9, 2024
1 parent dd4fa41 commit 932f0ff
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 44 deletions.
11 changes: 7 additions & 4 deletions src/main/java/yalong/site/cache/GameDataCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ public class GameDataCache {
public static ArrayList<String> myTeamScore = new ArrayList<>();

public static void reset() {
skinId = null;
currentChampionSkins = new ArrayList<>();
otherTeamScore = new ArrayList<>();
myTeamScore = new ArrayList<>();
resetScore();
resetPickSkinBoxData();
}

public static void resetScore() {
otherTeamScore = new ArrayList<>();
myTeamScore = new ArrayList<>();
}
public static void resetPickSkinBoxData() {
skinId = null;
currentChampionSkins = new ArrayList<>();
for (int i = 1; i < FrameInnerCache.pickSkinBox.getItemCount(); i++) {
FrameInnerCache.pickSkinBox.removeItemAt(i);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import yalong.site.cache.GameDataCache;
import yalong.site.utils.KeyEventUtil;

import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;

Expand All @@ -13,24 +12,19 @@
*/
public class SendMyTeamScoreConsumer implements HotKeyConsumer {

@Override
public Consumer<Integer> build() {
return i -> {
if (FrameCache.sendScore) {
ArrayList<String> myTeamScore = GameDataCache.myTeamScore;
for (int j = 0; j < myTeamScore.size(); j++) {
String s = myTeamScore.get(j);
if (j == 0) {
s = "我方" + s;
}
KeyEventUtil.sendMsg(s);
try {
TimeUnit.MILLISECONDS.sleep(500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
};
}
@Override
public Consumer<Integer> build() {
return i -> {
if (FrameCache.sendScore) {
for (String s : GameDataCache.myTeamScore) {
KeyEventUtil.sendMsg("我方" + s);
try {
TimeUnit.MILLISECONDS.sleep(500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
};
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package yalong.site.services.hotkey;

import yalong.site.cache.FrameCache;
import yalong.site.cache.GameDataCache;
import yalong.site.utils.KeyEventUtil;

import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;

Expand All @@ -15,17 +15,14 @@ public class SendOtherTeamScoreConsumer implements HotKeyConsumer {
@Override
public Consumer<Integer> build() {
return i -> {
ArrayList<String> otherTeamScore = GameDataCache.otherTeamScore;
for (int j = 0; j < otherTeamScore.size(); j++) {
String s = otherTeamScore.get(j);
if (j == 0) {
s = "对方" + s;
}
KeyEventUtil.sendMsg(s);
try {
TimeUnit.MILLISECONDS.sleep(500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
if (FrameCache.sendScore) {
for (String s : GameDataCache.otherTeamScore) {
KeyEventUtil.sendMsg("对方"+s);
try {
TimeUnit.MILLISECONDS.sleep(500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
};
Expand Down
21 changes: 14 additions & 7 deletions src/main/java/yalong/site/services/lcu/CalculateScore.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ public ArrayList<String> entry2String(Map.Entry<Float, SummonerScoreBO> entry, S
stringBuilder.append(type);
stringBuilder.append("是:【");
stringBuilder.append(stupid.getSummonerInfo().getDisplayName());
stringBuilder.append("】,得分");
stringBuilder.append(String.format("%.2f", entry.getKey() / gameNum));
result.add(stringBuilder.toString());
stringBuilder = new StringBuilder();
stringBuilder.append(String.format("】,KDA: 【%.2f】 ", entry.getKey() / gameNum));
stringBuilder.append("近");
stringBuilder.append(gameNum);
stringBuilder.append("场战绩为:");
Expand All @@ -87,7 +84,9 @@ public ArrayList<String> entry2String(Map.Entry<Float, SummonerScoreBO> entry, S
stringBuilder.append(scoreBO.getDeaths());
stringBuilder.append("-");
stringBuilder.append(scoreBO.getAssists());
stringBuilder.append(" ");
stringBuilder.append("(");
stringBuilder.append(scoreBO.getWin() ? "赢" : "输");
stringBuilder.append(") ");
}
result.add(stringBuilder.toString());
return result;
Expand All @@ -97,13 +96,20 @@ public ArrayList<String> entry2String(Map.Entry<Float, SummonerScoreBO> entry, S
* 查询战绩,格式化为要发送的消息
*/
public ArrayList<String> dealScore2Msg(List<String> puuidList) {
ArrayList<String> result = new ArrayList<>();
if(puuidList.isEmpty()){
return result;
}
int gameNum = 3;
ArrayList<SummonerScoreBO> scoreByPuuidList = new ArrayList<>();
try {
scoreByPuuidList = getScoreByPuuidList(puuidList, gameNum);
} catch (Exception e) {
log.error("查询战绩错误", e);
}
if(scoreByPuuidList.isEmpty()){
return result;
}
TreeMap<Float, SummonerScoreBO> treeMap = calcScore2treeMap(scoreByPuuidList);
Map.Entry<Float, SummonerScoreBO> firstEntry = treeMap.firstEntry();
Map.Entry<Float, SummonerScoreBO> lastEntry = treeMap.lastEntry();
Expand All @@ -116,8 +122,9 @@ public ArrayList<String> dealScore2Msg(List<String> puuidList) {

ArrayList<String> stupidList = entry2String(firstEntry, "傻鸟");
ArrayList<String> smartList = entry2String(lastEntry, "大神");
smartList.addAll(stupidList);
return smartList;
result.addAll(stupidList);
result.addAll(smartList);
return result;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ private void setSkin() throws IOException {
}
if(GameDataCache.skinId!=null){
api.setCurrentChampionSkins(GameDataCache.skinId);
//设置皮肤完成后,清空缓存
GameDataCache.resetPickSkinBoxData();
}
}

Expand Down

0 comments on commit 932f0ff

Please sign in to comment.