Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* some cleanup

* #1881 add undocumented goal difference criteria

* #1881 add undocumented goal difference criteria release_notes.md
  • Loading branch information
wsbrenk authored Jun 8, 2023
1 parent 8a0b71c commit ffa3ced
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 135 deletions.
10 changes: 4 additions & 6 deletions src/main/java/core/file/hrf/HRFStringBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,15 @@ public void createEconomy(Map<String, String> 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";
}

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";
}
Expand Down Expand Up @@ -314,7 +314,7 @@ public void createLeague(Map<String, String> ligaDataMap) {
public void createLineUp(String trainerId, int teamId, Map<String, String> 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 {
Expand Down Expand Up @@ -542,9 +542,7 @@ public void appendYouthPlayers(List<MyHashtable> 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");
Expand Down
71 changes: 4 additions & 67 deletions src/main/java/core/gui/DebugMode.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
// }


}
}
22 changes: 0 additions & 22 deletions src/main/java/core/net/MyConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand All @@ -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
*
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/core/training/TrainingPreviewPlayers.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class TrainingPreviewPlayers implements Refreshable {

private final HashMap<Player, TrainingPreviewPlayer> players = new HashMap<>();
private int nextWeekTraining = -1;
private boolean isFuturMatchInit =false;
private boolean isFutureMatchInit =false;
private WeeklyTrainingType weekTrainTyp = null;
private List<MatchStatistics> lMatchStats = null;
private List<Lineup> lineups = null;
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -195,12 +194,12 @@ private void calculateWeeklyTrainingForPlayer(Player player) {
*/
private List<MatchStatistics> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> "";
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,50 +14,44 @@
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<Substitution> subs = HOVerwaltung.instance().getModel().getLineupWithoutRatingRecalc()
.getSubstitutionList();
}

public static Map<Integer, PlayerPositionItem> getFieldAndSubPlayerPosition() {
LinkedHashMap<Integer, PlayerPositionItem> 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;
}


public static List<PlayerPositionItem> getFieldPositions(List<Integer> aMatchRoleID , boolean includeEmptyPositions) {
List<PlayerPositionItem> playerItems = new ArrayList<PlayerPositionItem>();
List<PlayerPositionItem> 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<PlayerPositionItem> getFieldPositions(int start, int end, boolean includeEmptyPositions) {
List<PlayerPositionItem> playerItems = new ArrayList<PlayerPositionItem>();
List<PlayerPositionItem> 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;
Expand All @@ -72,19 +64,13 @@ public static List<PlayerPositionItem> 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;
}

/**
Expand All @@ -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),
Expand All @@ -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<CBItem> getBehaviourItems(boolean withInheritItem) {
List<CBItem> behaviourValues = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ bug fixes

### Lineup
* fix nt team selection options of style of play combo box (#1873)
* fix download error of substitutions with undocumented goal difference criteria (#1881)

### Statistics
* fix currency of secondary teams (#1856)
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/sprache/English.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ffa3ced

Please sign in to comment.