Skip to content

Commit

Permalink
Merge7.1 (#1884)
Browse files Browse the repository at this point in the history
* Release/7 (#1859)

* start HO7.1

* #1856 fix currency of secondary teams

* #1856 fix currency of secondary teams

---------

Co-authored-by: wsbrenk <zissener-weg-brenk.de>

* #1857 fix playername getter in MatchHighlightsTable (#1860)

Co-authored-by: wsbrenk <zissener-weg-brenk.de>

* #1861 fix exception in GoalDiffCriteria (#1864)

Co-authored-by: wsbrenk <zissener-weg-brenk.de>

* Fix click on “Last Match” column when it has been moved. (#1863)

The “Last Match” column is clickable, and opens:
- The match in Hattrick when shift-clicking,
- The match in HO when double-clicking.

This commit also adds some comment to clarify the behaviour.

* Minor UI improvement in teamAnalyzer. (#1867)

This adds a bit of padding around the check boxes on the teamAnalyser panel,
and centers the automatic / manual radio buttons.

It also cleans up code a bit, in particular in lineup assistant.  Probably more
effort to come on that front.

* #1858 (#1869)

* #1858 debug date time parsing

* #1858 debug currency parsing

* #1858 using Helper.formatCurrency

* #1858 Player.baseWage reset setter getter (not used for now, but senseful for the future)

* #1858 Player.baseWage reset setter getter (not used for now, but senseful for the future)

* #1858 translate comments in Helper.java

* #1858 remove  unused imports in HODateTime.java (add some comments)

* #1858 fix Player.setExpiryDate, use localized DateTimeFormatter

* #1858 fix PlayerConverter add comment explaining offsSpecialty

* #1858 fix PlayerConverter remove old commented methods

* #1858 fix PlayerConverter.parseLocalDateTime

* #1858 PlayerConverter scan wage

* #1858 PlayerConverter scan skill refactored

* #1858 PlayerConverter scan wage
fix indexRowWarning

* Fixes deadline date parsing in Transfer Scout.

---------

Co-authored-by: Sébastien Le Callonnec <[email protected]>

* #1873 (#1874)

* #1873 fix MatchAndLineupSelectionPanel.updateStyleOfPlayComboBox nt team selection

* #1873 release_notes.md

* #1878 (#1879)

* fix OnlineWorker.downloadLastLineup

* MyConnector.downloadPlayerDetails include match info

* #1878 release_notes.md

* #1878 show last match date of nt team players

* #1881 (#1882)

* some cleanup

* #1881 add undocumented goal difference criteria

* #1881 add undocumented goal difference criteria release_notes.md

* #1881 debug worlflow (#1883)

* some cleanup

* #1881 add undocumented goal difference criteria

* #1881 add undocumented goal difference criteria release_notes.md

* #1881 fix workflow

---------

Co-authored-by: Sébastien Le Callonnec <[email protected]>
  • Loading branch information
wsbrenk and tychobrailleur authored Jun 8, 2023
1 parent 51edf67 commit fecf829
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 187 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
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;
// }


}
}
20 changes: 14 additions & 6 deletions src/main/java/core/gui/model/UserColumnFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -485,15 +486,15 @@ 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);
}

@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);
}
Expand Down Expand Up @@ -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);
Expand Down
26 changes: 2 additions & 24 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 Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/core/net/OnlineWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -1213,9 +1213,10 @@ public static void downloadTeamLogo(Map<String, String> team) {
public static MatchLineupTeam downloadLastLineup(List<MatchKurzInfo> 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);
}
Expand Down Expand Up @@ -1253,11 +1254,12 @@ public static MatchLineupTeam downloadLastLineup(List<MatchKurzInfo> matches, in
public static Map<String, String> downloadNextMatchOrder(List<MatchKurzInfo> 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) {
}
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
Loading

0 comments on commit fecf829

Please sign in to comment.