diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml index b19e18101..f5bfdf351 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release-dev.yml @@ -36,7 +36,7 @@ jobs: path: 'version.properties' properties: 'version shortVersion tag branch' - name: Delete previous tag and release - uses: unkies/action-gh-delete-release@v0.2.4 + uses: ClementTsang/delete-tag-and-release@v0.3.1 with: delete_release: true tag_name: ${{ steps.read_version_properties.outputs.tag }} diff --git a/src/main/java/core/file/hrf/HRFStringBuilder.java b/src/main/java/core/file/hrf/HRFStringBuilder.java index 211fee84d..e0a834857 100644 --- a/src/main/java/core/file/hrf/HRFStringBuilder.java +++ b/src/main/java/core/file/hrf/HRFStringBuilder.java @@ -203,7 +203,7 @@ public void createEconomy(Map economyDataMap) { private static String getPlayerIdByPositionValue(MatchLineupTeam team, int position){ var matchLineupPosition = team.getPlayerByPosition(position); if ( matchLineupPosition != null){ - return ""+matchLineupPosition.getPlayerId(); + return String.valueOf(matchLineupPosition.getPlayerId()); } return "0"; } @@ -211,7 +211,7 @@ private static String getPlayerIdByPositionValue(MatchLineupTeam team, int posit private static String getBehaviourByPositionValue(MatchLineupTeam team, int position){ var matchLineupPosition = team.getPlayerByPosition(position); if ( matchLineupPosition != null){ - return ""+ matchLineupPosition.getBehaviour(); + return String.valueOf(matchLineupPosition.getBehaviour()); } return "0"; } @@ -314,7 +314,7 @@ public void createLeague(Map ligaDataMap) { public void createLineUp(String trainerId, int teamId, Map nextLineup) { lineupStringBuilder = new StringBuilder("[lineup]\n"); if (nextLineup != null) { - var matchId = NumberUtils.toInt(nextLineup.get("MatchId"),0); + var matchId = NumberUtils.toInt(nextLineup.get("MatchID"),0); var matchtype = NumberUtils.toInt(nextLineup.get("MatchType"), MatchType.NONE.getMatchTypeId()); try { @@ -542,9 +542,7 @@ public void appendYouthPlayers(List playersData) { appendHRFLine(youthPlayersStringBuilder, player, "ScoutName"); appendHRFLine(youthPlayersStringBuilder, player, "ScoutingRegionID"); - for (int i = 0; appendScoutComment(youthPlayersStringBuilder, player, i); i++) { - ; - } + for (int i = 0; appendScoutComment(youthPlayersStringBuilder, player, i); i++) {} appendHRFLine(youthPlayersStringBuilder, player, "YouthMatchID"); appendHRFLine(youthPlayersStringBuilder, player, "YouthMatchDate"); diff --git a/src/main/java/core/gui/DebugMode.java b/src/main/java/core/gui/DebugMode.java index 346ce8a2c..f097e1c07 100644 --- a/src/main/java/core/gui/DebugMode.java +++ b/src/main/java/core/gui/DebugMode.java @@ -1,14 +1,8 @@ package core.gui; import core.db.frontend.SQLDialog; -//import core.gui.language.LanguageEditorDialog; import core.net.MyConnector; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; - import javax.swing.JCheckBoxMenuItem; import javax.swing.JMenu; import javax.swing.JMenuItem; @@ -20,81 +14,24 @@ public static JMenu getDeveloperMenu() { menu.add(getSQLDialogMenuItem()); menu.add(getLookAndFeelDialogMenuItem()); menu.add(getSaveXMLMenuItem()); -// menu.add(getPlayerHistoryMenuItem()); -// menu.add(getMatchStatisticsMenuItem()); - //menu.add(getLanguageMenuItem()); return menu; } - -// private static JMenuItem getLanguageMenuItem() { -// JMenuItem newItem = new JMenuItem("Language File Editor"); -// newItem.addActionListener(new ActionListener() { -// -// @Override -// public void actionPerformed(ActionEvent e) { -// new LanguageEditorDialog().setVisible(true); -// } -// }); -// return newItem; -// } private static JMenuItem getLookAndFeelDialogMenuItem() { JMenuItem newItem = new JMenuItem("Look and Feel"); - newItem.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - new LookAndFeelDialog().setVisible(true); - } - }); + newItem.addActionListener(e -> new LookAndFeelDialog().setVisible(true)); return newItem; } private static JMenuItem getSQLDialogMenuItem() { JMenuItem newItem = new JMenuItem("SQL Editor"); - newItem.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - new SQLDialog().setVisible(true); - } - }); + newItem.addActionListener(e -> new SQLDialog().setVisible(true)); return newItem; } private static JMenuItem getSaveXMLMenuItem() { JMenuItem newItem = new JCheckBoxMenuItem("Save downloaded XML"); - newItem.addItemListener(new ItemListener() { - - @Override - public void itemStateChanged(ItemEvent e) { - MyConnector.setDebugSave(e.getStateChange() == ItemEvent.SELECTED); - } - }); + newItem.addItemListener(e -> MyConnector.setDebugSave(e.getStateChange() == ItemEvent.SELECTED)); return newItem; } - -// private static JMenuItem getPlayerHistoryMenuItem() { -// JMenuItem newItem = new JMenuItem("Player History"); -// newItem.addActionListener(new ActionListener() { -// @Override -// public void actionPerformed(ActionEvent arg0) { -// new core.training.SkillDropTestFrame().setVisible(true); -// } -// }); -// return newItem; -// } -// -// private static JMenuItem getMatchStatisticsMenuItem() { -// JMenuItem newItem = new JMenuItem("Match Minutes"); -// newItem.addActionListener(new ActionListener() { -// @Override -// public void actionPerformed(ActionEvent arg0) { -// new core.model.match.StatisticsTestFrame().setVisible(true); -// } -// }); -// return newItem; -// } - - -} +} \ No newline at end of file diff --git a/src/main/java/core/gui/model/UserColumnFactory.java b/src/main/java/core/gui/model/UserColumnFactory.java index 7cc101228..d0e2bbe16 100644 --- a/src/main/java/core/gui/model/UserColumnFactory.java +++ b/src/main/java/core/gui/model/UserColumnFactory.java @@ -19,6 +19,7 @@ import core.model.player.PlayerCategory; import core.util.HODateTime; import core.util.Helper; +import core.util.StringUtils; import module.playerOverview.PlayerStatusLabelEntry; import javax.swing.*; @@ -253,7 +254,7 @@ public boolean isEditable() { @Override public IHOTableEntry getTableEntry(Player player, Player playerCompare) { return new ColorLabelEntry(player.getPlayerID(), - player.getPlayerID() + "", + String.valueOf(player.getPlayerID()), ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD, SwingConstants.RIGHT); } @@ -364,7 +365,7 @@ public IHOTableEntry getTableEntry(MatchKurzInfo match) { @Override public IHOTableEntry getTableEntry(PlayerMatchCBItem spielerCBItem) { // final Color background = MatchesColumnModel.getColor4Matchtyp(spielerCBItem.getMatchTyp()); - ColorLabelEntry entry = new ColorLabelEntry(spielerCBItem.getHomeTeamName() + "", + ColorLabelEntry entry = new ColorLabelEntry(spielerCBItem.getHomeTeamName(), ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD, SwingConstants.LEFT); entry.setFGColor((spielerCBItem.getHeimID() == HOVerwaltung.instance().getModel().getBasics() @@ -400,7 +401,7 @@ public IHOTableEntry getTableEntry(MatchKurzInfo match) { @Override public IHOTableEntry getTableEntry(PlayerMatchCBItem spielerCBItem) { // final Color background = MatchesColumnModel.getColor4Matchtyp(spielerCBItem.getMatchTyp()); - ColorLabelEntry entry = new ColorLabelEntry(spielerCBItem.getGuestTeamName() + "", + ColorLabelEntry entry = new ColorLabelEntry(spielerCBItem.getGuestTeamName(), ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD, SwingConstants.LEFT); entry.setFGColor((spielerCBItem.getGastID() == HOVerwaltung.instance().getModel().getBasics() @@ -485,7 +486,7 @@ public IHOTableEntry getTableEntry(PlayerMatchCBItem spielerCBItem) { @Override public IHOTableEntry getTableEntry(MatchKurzInfo match) { // final Color background = MatchesColumnModel.getColor4Matchtyp(match.getMatchType()); - return new ColorLabelEntry(match.getMatchID(), match.getMatchID() + "", + return new ColorLabelEntry(match.getMatchID(), String.valueOf(match.getMatchID()), ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD, SwingConstants.RIGHT); } @@ -493,7 +494,7 @@ public IHOTableEntry getTableEntry(MatchKurzInfo match) { @Override public IHOTableEntry getTableEntry(PlayerMatchCBItem spielerCBItem) { // final Color background = MatchesColumnModel.getColor4Matchtyp(spielerCBItem.getMatchTyp()); - return new ColorLabelEntry(spielerCBItem.getMatchID() + "", + return new ColorLabelEntry(String.valueOf(spielerCBItem.getMatchID()), ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD, SwingConstants.CENTER); } @@ -735,10 +736,17 @@ public IHOTableEntry getTableEntry(Player player, Player playerCompare) { @Override public IHOTableEntry getTableEntry(Player player, Player playerCompare) { var matchId = player.getLastMatchId(); - if ( matchId != null ) { + if (matchId != null && matchId > 0) { MatchKurzInfo info = DBManager.instance().getMatchesKurzInfoByMatchID(matchId, null); if (info != null) { return new MatchDateTableEntry(info.getMatchSchedule(), info.getMatchTypeExtended()); + } else { + var dateAsString = player.getLastMatchDate(); + if (!StringUtils.isEmpty(dateAsString)) { + var date = HODateTime.fromHT(dateAsString); + var matchType = player.getLastMatchType(); + return new MatchDateTableEntry(date, matchType); + } } } return new MatchDateTableEntry(null, MatchType.NONE); diff --git a/src/main/java/core/net/MyConnector.java b/src/main/java/core/net/MyConnector.java index 1e04feab6..12c3d5aa1 100644 --- a/src/main/java/core/net/MyConnector.java +++ b/src/main/java/core/net/MyConnector.java @@ -23,7 +23,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; -import java.net.URLConnection; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; @@ -90,18 +89,6 @@ public static MyConnector instance() { return m_clInstance; } - public static boolean hasInternetAccess(){ - try { - URL url = new URL("http://www.hattrick.org"); - URLConnection connection = url.openConnection(); - connection.connect(); - return true; - } - catch (IOException e) { - return false; - } - } - /** * Sets the DEBUGSAVE flag. Setting the flag to true will save downloaded * CHPP files. @@ -113,15 +100,6 @@ public static void setDebugSave(boolean debugSave) { DEBUGSAVE = debugSave; } - public static String getHOSite() { - return "http://ho1.sourceforge.net/"; - } - - public static String getPluginSite() { - return getHOSite() + "onlinefiles"; - } - - /** * Fetch a specific arena * @@ -364,7 +342,7 @@ public String uploadMatchOrder(int matchId, int teamId, MatchType matchType, Str } /** - * lädt die Aufstellungsbewertung zu einem Spiel + * Download match details, including match events */ public String downloadMatchdetails(int matchId, MatchType matchType) { String url = htUrl + "?file=matchdetails&version=" + VERSION_MATCHDETAILS; @@ -451,7 +429,7 @@ public String downloadPlayers(int teamId) { return getCHPPWebFile(url); } public String downloadPlayerDetails(String playerID) { - return getCHPPWebFile(htUrl+"?file=playerdetails&version=2.9&playerID=" + playerID); + return getCHPPWebFile(htUrl+"?file=playerdetails&version=2.9&includeMatchInfo=true&playerID=" + playerID); } public String downloadYouthPlayers(int youthteamId) { diff --git a/src/main/java/core/net/OnlineWorker.java b/src/main/java/core/net/OnlineWorker.java index 5732a8123..edd8fc799 100644 --- a/src/main/java/core/net/OnlineWorker.java +++ b/src/main/java/core/net/OnlineWorker.java @@ -1213,9 +1213,10 @@ public static void downloadTeamLogo(Map team) { public static MatchLineupTeam downloadLastLineup(List matches, int teamId){ MatchLineupTeam matchLineupTeam = null; MatchLineup matchLineup = null; - var finishedMatchesAvailable = matches.stream().anyMatch(f->f.getMatchStatus()==MatchKurzInfo.FINISHED); - if ( finishedMatchesAvailable) { - var matchLineupString = MyConnector.instance().downloadMatchLineup(-1, teamId, MatchType.LEAGUE); + var lastFinishedMatch = matches.stream().filter(f->f.getMatchStatus()==MatchKurzInfo.FINISHED).max(MatchKurzInfo::compareTo); + if ( lastFinishedMatch.isPresent()) { + var match = lastFinishedMatch.get(); + var matchLineupString = MyConnector.instance().downloadMatchLineup(match.getMatchID(), teamId, match.getMatchType()); if (!matchLineupString.isEmpty()) { matchLineup = XMLMatchLineupParser.parseMatchLineupFromString(matchLineupString); } @@ -1253,11 +1254,12 @@ public static MatchLineupTeam downloadLastLineup(List matches, in public static Map downloadNextMatchOrder(List matches, int teamId) { try { // next upcoming match - var match = matches.stream().filter(f -> f.getMatchStatus() == MatchKurzInfo.UPCOMING).min(MatchKurzInfo::compareTo).get(); - // Match is always from the normal system, and league will do - // the trick as the type. - return XMLMatchOrderParser.parseMatchOrderFromString(MyConnector.instance().downloadMatchOrder( - match.getMatchID(), match.getMatchType(), teamId)); + var nextMatch = matches.stream().filter(f -> f.getMatchStatus() == MatchKurzInfo.UPCOMING).min(MatchKurzInfo::compareTo); + if ( nextMatch.isPresent()){ + var match = nextMatch.get(); + return XMLMatchOrderParser.parseMatchOrderFromString(MyConnector.instance().downloadMatchOrder( + match.getMatchID(), match.getMatchType(), teamId)); + } } catch (Exception ignore) { } diff --git a/src/main/java/core/training/TrainingPreviewPlayers.java b/src/main/java/core/training/TrainingPreviewPlayers.java index e6d96ee93..b6a2fb8c7 100644 --- a/src/main/java/core/training/TrainingPreviewPlayers.java +++ b/src/main/java/core/training/TrainingPreviewPlayers.java @@ -27,7 +27,7 @@ public class TrainingPreviewPlayers implements Refreshable { private final HashMap players = new HashMap<>(); private int nextWeekTraining = -1; - private boolean isFuturMatchInit =false; + private boolean isFutureMatchInit =false; private WeeklyTrainingType weekTrainTyp = null; private List lMatchStats = null; private List lineups = null; @@ -83,15 +83,14 @@ public void reInit() { * refresh object */ public void refresh() { - if (players != null) - players.clear(); + players.clear(); if (lMatchStats != null) lMatchStats.clear(); if (lineups != null) lineups.clear(); nextWeekTraining = -1; weekTrainTyp = null; - isFuturMatchInit = false; + isFutureMatchInit = false; } /** @@ -195,12 +194,12 @@ private void calculateWeeklyTrainingForPlayer(Player player) { */ private List getMatchesForTraining() { - if (!isFuturMatchInit) { + if (!isFutureMatchInit) { var lastTraining = TrainingManager.instance().getNextWeekTraining(); this.lMatchStats = new ArrayList<>(); this.lineups = new ArrayList<>(); - this.isFuturMatchInit = true; + this.isFutureMatchInit = true; if (lastTraining != null) { weekTrainTyp = WeeklyTrainingType.instance(lastTraining.getTrainingType()); diff --git a/src/main/java/module/lineup/lineup/MatchAndLineupSelectionPanel.java b/src/main/java/module/lineup/lineup/MatchAndLineupSelectionPanel.java index dc6b55f8d..db0e0b74b 100644 --- a/src/main/java/module/lineup/lineup/MatchAndLineupSelectionPanel.java +++ b/src/main/java/module/lineup/lineup/MatchAndLineupSelectionPanel.java @@ -433,7 +433,6 @@ public void reInit() { @Override public void refresh() { -// HOLogger.instance().log(getClass(), " refresh() has been called"); removeListeners(); updateComponents(); addListeners(); @@ -441,38 +440,32 @@ public void refresh() { // each time updateStyleOfPlayBox gets called we need to add all elements back so that we can load stored lineups // so we need addAllStyleOfPlayItems() after every updateStyleOfPlayBox() - private void updateStyleOfPlayComboBox() - { + private void updateStyleOfPlayComboBox() { var lineup = HOVerwaltung.instance().getModel().getLineupWithoutRatingRecalc(); var oldValue = StyleOfPlay.fromInt(lineup.getStyleOfPlay()); - // NT Team can select whatever Style of Play they like - if (!UserManager.instance().getCurrentUser().isNtTeam()) { - - // remove all combo box items and add new ones. - List legalValues = getValidStyleOfPlayValues(); - m_jcbStyleOfPlay.removeAllItems(); - - for (int value : legalValues) { - CBItem cbItem; - if (value == 0) { - cbItem = new CBItem(neutral_sop, value); - } else if (value > 0) { - cbItem = new CBItem((value * 10) + "% " + offensive_sop, value); - } else { - cbItem = new CBItem((Math.abs(value) * 10) + "% " + defensive_sop, value); - } - m_jcbStyleOfPlay.addItem(cbItem); + // remove all combo box items and add new ones. + List legalValues = getValidStyleOfPlayValues(); + m_jcbStyleOfPlay.removeAllItems(); + for (int value : legalValues) { + CBItem cbItem; + if (value == 0) { + cbItem = new CBItem(neutral_sop, value); + } else if (value > 0) { + cbItem = new CBItem((value * 10) + "% " + offensive_sop, value); + } else { + cbItem = new CBItem((Math.abs(value) * 10) + "% " + defensive_sop, value); } - - // Set trainer default value - setStyleOfPlay(getDefaultTrainerStyleOfPlay()); - // Attempt to set the old value. If it is not possible it will do nothing. - setStyleOfPlay(oldValue); + m_jcbStyleOfPlay.addItem(cbItem); } - var item = (CBItem)(m_jcbStyleOfPlay.getSelectedItem()); + + // Set trainer default value + setStyleOfPlay(getDefaultTrainerStyleOfPlay()); + // Attempt to set the old value. If it is not possible it will do nothing. + setStyleOfPlay(oldValue); + var item = (CBItem) (m_jcbStyleOfPlay.getSelectedItem()); var ret = 0; - if ( item != null) ret = item.getId(); + if (item != null) ret = item.getId(); lineup.setStyleOfPlay(ret); } @@ -493,16 +486,18 @@ private List getValidStyleOfPlayValues() int min=-10, max=10; - switch (trainer) { - case Defensive -> max = -10 + 2 * tacticalAssistants; // Defensive - case Offensive -> min = 10 - 2 * tacticalAssistants; // Offensive - case Balanced -> { // Neutral - min = - tacticalAssistants; - max = tacticalAssistants; + // NT Team can select whatever Style of Play they like + if (!UserManager.instance().getCurrentUser().isNtTeam()) { + switch (trainer) { + case Defensive -> max = -10 + 2 * tacticalAssistants; // Defensive + case Offensive -> min = 10 - 2 * tacticalAssistants; // Offensive + case Balanced -> { // Neutral + min = -tacticalAssistants; + max = tacticalAssistants; + } + default -> HOLogger.instance().error(getClass(), "Illegal trainer type found: " + trainer); } - default -> HOLogger.instance().error(getClass(), "Illegal trainer type found: " + trainer); } - return IntStream.rangeClosed(min, max).boxed().collect(Collectors.toList()); } diff --git a/src/main/java/module/lineup/substitution/LanguageStringLookup.java b/src/main/java/module/lineup/substitution/LanguageStringLookup.java index 56eeb25af..07382428f 100644 --- a/src/main/java/module/lineup/substitution/LanguageStringLookup.java +++ b/src/main/java/module/lineup/substitution/LanguageStringLookup.java @@ -70,6 +70,10 @@ public static String getStanding(GoalDiffCriteria standing) { case IN_THE_LEAD_BY_MORE_THAN_TWO -> HOVerwaltung.instance().getLanguageString("subs.GoalLeadMT2"); case DOWN_BY_MORE_THAN_TWO -> HOVerwaltung.instance().getLanguageString("subs.GoalDownMT2"); case MATCH_IS_NOT_TIED -> HOVerwaltung.instance().getLanguageString("subs.MatchIsNotTied"); + case NOT_IN_THE_LEAD_BY_MORE_THAN_ONE -> HOVerwaltung.instance().getLanguageString("subs.GoalNotLeadMT1"); + case NOT_DOWN_BY_MORE_THAN_ONE -> HOVerwaltung.instance().getLanguageString("subs.GoalNotDownMT1"); + case NOT_IN_THE_LEAD_BY_MORE_THAN_TWO -> HOVerwaltung.instance().getLanguageString("subs.GoalNotLeadMT2"); + case NOT_DOWN_BY_MORE_THAN_TWO -> HOVerwaltung.instance().getLanguageString("subs.GoalNotDownMT2"); default -> ""; }; } diff --git a/src/main/java/module/lineup/substitution/SubstitutionDataProvider.java b/src/main/java/module/lineup/substitution/SubstitutionDataProvider.java index 1735146b3..6d98f1427 100644 --- a/src/main/java/module/lineup/substitution/SubstitutionDataProvider.java +++ b/src/main/java/module/lineup/substitution/SubstitutionDataProvider.java @@ -2,10 +2,8 @@ import core.datatype.CBItem; import core.model.HOVerwaltung; -import core.model.player.IMatchRoleID; -import core.model.player.Player; import module.lineup.Lineup; -import module.lineup.substitution.model.Substitution; +import module.lineup.substitution.model.GoalDiffCriteria; import module.teamAnalyzer.SystemManager; import module.teamAnalyzer.ht.HattrickManager; import module.teamAnalyzer.vo.PlayerInfo; @@ -16,23 +14,17 @@ import java.util.Map; import static core.model.player.IMatchRoleID.aFieldAndSubsMatchRoleID; -import static core.model.player.IMatchRoleID.aFieldMatchRoleID; public class SubstitutionDataProvider { - public static void getSubstitutions() { - List subs = HOVerwaltung.instance().getModel().getLineupWithoutRatingRecalc() - .getSubstitutionList(); - } - public static Map getFieldAndSubPlayerPosition() { LinkedHashMap positionMap = new LinkedHashMap<>(); Lineup lineup = HOVerwaltung.instance().getModel().getLineupWithoutRatingRecalc(); for (Integer i : aFieldAndSubsMatchRoleID) { - Player player = lineup.getPlayerByPositionID(i); + var player = lineup.getPlayerByPositionID(i); if (player != null) { - positionMap.put(i, new PlayerPositionItem(Integer.valueOf(i), lineup.getPlayerByPositionID(i))); + positionMap.put(i, new PlayerPositionItem(i, lineup.getPlayerByPositionID(i))); } } return positionMap; @@ -40,26 +32,26 @@ public static Map getFieldAndSubPlayerPosition() { public static List getFieldPositions(List aMatchRoleID , boolean includeEmptyPositions) { - List playerItems = new ArrayList(); + List playerItems = new ArrayList<>(); Lineup lineup = HOVerwaltung.instance().getModel().getLineupWithoutRatingRecalc(); for (Integer i : aMatchRoleID) { - Player player = lineup.getPlayerByPositionID(i); + var player = lineup.getPlayerByPositionID(i); if (player != null || includeEmptyPositions) { - playerItems.add(new PlayerPositionItem(Integer.valueOf(i), player)); + playerItems.add(new PlayerPositionItem(i, player)); } } return playerItems; } public static List getFieldPositions(int start, int end, boolean includeEmptyPositions) { - List playerItems = new ArrayList(); + List playerItems = new ArrayList<>(); Lineup lineup = HOVerwaltung.instance().getModel().getLineupWithoutRatingRecalc(); for (int i = start; i <= end; i++) { - Player player = lineup.getPlayerByPositionID(i); + var player = lineup.getPlayerByPositionID(i); if (player != null || includeEmptyPositions) { - playerItems.add(new PlayerPositionItem(Integer.valueOf(i), player)); + playerItems.add(new PlayerPositionItem(i, player)); } } return playerItems; @@ -72,19 +64,13 @@ public static List getFieldPositions(int start, int end, boo * @return an array with standing items */ public static CBItem[] getStandingItems() { - CBItem[] standingValues = { - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalAny"), -1), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalTied"), 0), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalLead"), 1), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalDown"), 2), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalLeadMT1"), 3), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalDownMT1"), 4), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalNotDown"), 5), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalNotLead"), 6), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalLeadMT2"), 7), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalDownMT2"), 8), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.MatchIsNotTied"), 9)}; - return standingValues; + var values = GoalDiffCriteria.values(); + CBItem[] ret = new CBItem[values.length]; + int i = 0; + for (var goalDifferenceCriteria : GoalDiffCriteria.values()){ + ret[i++] = new CBItem(LanguageStringLookup.getStanding(goalDifferenceCriteria), goalDifferenceCriteria.getId()); + } + return ret; } /** @@ -94,7 +80,7 @@ public static CBItem[] getStandingItems() { * @return an array with red card items */ public static CBItem[] getRedCardItems() { - CBItem[] redcardValues = { + return new CBItem[]{ new CBItem(HOVerwaltung.instance().getLanguageString("subs.RedIgnore"), -1), new CBItem(HOVerwaltung.instance().getLanguageString("subs.RedMy"), 1), new CBItem(HOVerwaltung.instance().getLanguageString("subs.RedOpp"), 2), @@ -108,14 +94,13 @@ public static CBItem[] getRedCardItems() { new CBItem(HOVerwaltung.instance().getLanguageString("subs.RedOppFW"), 23), new CBItem(HOVerwaltung.instance().getLanguageString("subs.RedOppWB"), 24), new CBItem(HOVerwaltung.instance().getLanguageString("subs.RedOppWi"), 25), }; - return redcardValues; } /** * Returns an {@link CBItem} array with all behaviours which can be chosen * for a substitution. * - * @return an array with behaviour items + * @return a list of behaviour items */ public static List getBehaviourItems(boolean withInheritItem) { List behaviourValues = new ArrayList<>(); diff --git a/src/main/java/module/lineup/substitution/model/GoalDiffCriteria.java b/src/main/java/module/lineup/substitution/model/GoalDiffCriteria.java index 1fbc2a905..fd40f698b 100644 --- a/src/main/java/module/lineup/substitution/model/GoalDiffCriteria.java +++ b/src/main/java/module/lineup/substitution/model/GoalDiffCriteria.java @@ -32,7 +32,15 @@ public enum GoalDiffCriteria { @SerializedName("8") DOWN_BY_MORE_THAN_TWO((byte) 8), @SerializedName("9") - MATCH_IS_NOT_TIED((byte) 9); + MATCH_IS_NOT_TIED((byte) 9), + @SerializedName("10") + NOT_IN_THE_LEAD_BY_MORE_THAN_ONE((byte) 10), + @SerializedName("11") + NOT_DOWN_BY_MORE_THAN_ONE((byte) 11), + @SerializedName("12") + NOT_IN_THE_LEAD_BY_MORE_THAN_TWO((byte) 12), + @SerializedName("13") + NOT_DOWN_BY_MORE_THAN_TWO((byte) 13); private final byte id; diff --git a/src/main/resources/sprache/English.properties b/src/main/resources/sprache/English.properties index 7455d0744..426fafdc5 100644 --- a/src/main/resources/sprache/English.properties +++ b/src/main/resources/sprache/English.properties @@ -1599,6 +1599,10 @@ subs.GoalNotLead=Not in the lead subs.GoalLeadMT2=In the lead by more than two subs.GoalDownMT2=Down by more than two subs.MatchIsNotTied=Match is not tied +subs.GoalNotLeadMT1=Not in lead by more than one +subs.GoalNotDownMT1=Not down by more than one +subs.GoalNotLeadMT2=Not in lead by more than two +subs.GoalNotDownMT2=Not down by more than two #The red card statuses subs.RedIgnore=Ignore red status