Skip to content

Commit

Permalink
#1889 download new trainer info from player details (#1890)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsbrenk committed Jul 8, 2023
1 parent 2954735 commit 92310ce
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 32 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ test {
// Version ============================================================
// Development_stage (DEV:0 BETA:1 STABLE:2)
def major = '7'
def minor = '1'
def development_stage = 2
def minor = '2'
def development_stage = 1
def releaseArtefacts = true
def development_tag = ["dev", "beta", "tag_stable"]
def version_type = ["-DEV", "-BETA", ""]
Expand Down Expand Up @@ -309,9 +309,9 @@ task pushmd(dependsOn: preparingBuild) {
// list the contributors that don't want to be mentioned in release notes
def contributorFilter = ["Che"]

def commitCount = callGit('git rev-list 7.0..HEAD --count')
def diff = callGit('git diff --shortstat 7.0..HEAD')
def contributors = filter(callGit('git shortlog -s -n 7.0..HEAD'), contributorFilter)
def commitCount = callGit('git rev-list 7.1..HEAD --count')
def diff = callGit('git diff --shortstat 7.1..HEAD')
def contributors = filter(callGit('git shortlog -s -n 7.1..HEAD'), contributorFilter)
def latestCommit = callGit('git log -1 --pretty=format:"%s"')

println("create release-notes")
Expand Down
18 changes: 15 additions & 3 deletions src/main/java/core/file/xml/ConvertXml2Hrf.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import java.util.List;
import java.util.Map;

import static core.net.OnlineWorker.downloadLastLineup;
import static core.net.OnlineWorker.downloadNextMatchOrder;
import static core.net.OnlineWorker.*;

/**
* Convert the necessary xml data into a HRF file.
Expand Down Expand Up @@ -127,6 +126,20 @@ private ConvertXml2Hrf() {

HOMainFrame.instance().setInformation(Helper.getTranslation("ls.update_status.players_information"), progressIncrement);
List<MyHashtable> playersData = new XMLPlayersParser().parsePlayersFromString(mc.downloadPlayers(teamId));
var trainerId = String.valueOf(teamdetailsDataMap.get("TrainerID"));
// If trainer is not in players data, download trainer info from player details
var found = false;
for ( var p : playersData){
if ( p.get("PlayerID").equals(trainerId)){
found=true;
break;
}
}
if ( !found){
var xml = MyConnector.instance().downloadPlayerDetails(trainerId);
playersData.add(new XMLPlayersParser().parsePlayerDetails(xml));
}


// Download players' avatar
HOMainFrame.instance().setInformation(Helper.getTranslation("ls.update_status.players_avatars"), progressIncrement);
Expand Down Expand Up @@ -187,7 +200,6 @@ private ConvertXml2Hrf() {
hrfSgtringBuilder.createTeam(trainingDataMap);

// lineup
var trainerId = String.valueOf(teamdetailsDataMap.get("TrainerID"));
HOMainFrame.instance().setInformation(Helper.getTranslation("ls.update_status.create_lineups"), progressIncrement);
hrfSgtringBuilder.createLineUp(trainerId, teamId, nextLineupDataMap);

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/core/file/xml/XMLPlayersParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ public final Vector<MyHashtable> parsePlayersFromString(String inputStream) {
return createListe(doc);
}

public final MyHashtable parsePlayerDetails(String inputStream){
Document doc = XMLManager.parseString(inputStream);
Element root = doc.getDocumentElement();
Element ele = (Element) root.getElementsByTagName("Player").item(0);
return createPlayerDetails(ele);
}

/////////////////////////////////////////////////////////////////////////////////
//Parser Helper private
////////////////////////////////////////////////////////////////////////////////
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/core/model/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,13 @@ public Player(java.util.Properties properties, HODateTime hrfdate, int hrf_id) {
m_iTransferlisted = Boolean.parseBoolean(properties.getProperty("transferlisted", "False")) ? 1 : 0;
m_iLaenderspiele = Integer.parseInt(properties.getProperty("caps", "0"));
m_iU20Laenderspiele = Integer.parseInt(properties.getProperty("capsu20", "0"));
nationalTeamId = Integer.parseInt(properties.getProperty("nationalteamid", "0"));
var ntTeamId = properties.getProperty("nationalteamid", "0");
if ( ntTeamId.isEmpty()){
nationalTeamId=0;
}
else {
nationalTeamId = Integer.parseInt(ntTeamId);
}

// #461-lastmatch
m_lastMatchDate = properties.getProperty("lastmatch_date");
Expand Down Expand Up @@ -489,8 +495,8 @@ private void downloadMotherclubInfoIfMissing() {
var isSilentDownload = connection.isSilentDownload();
try {
connection.setSilentDownload(true);
// try to download missing motherclub info
var playerDetails = OnlineWorker.downloadPlayerDetails(""+this.getPlayerID());
// try to download missing mother club info
var playerDetails = OnlineWorker.downloadPlayerDetails(String.valueOf(this.getPlayerID()));
if (playerDetails != null) {
motherclubId = playerDetails.getMotherclubId();
motherclubName = playerDetails.getMotherclubName();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/core/net/MyConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ public String downloadYouthPlayers(int youthteamId) {
*/

public String getStaff(int teamId) {
String url = htUrl + "?file=stafflist&version=1.0&teamId=" + teamId;
String url = htUrl + "?file=stafflist&version=1.1&teamId=" + teamId;
return getCHPPWebFile(url);
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/module/training/ui/model/TrainingModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ private boolean isOsmosisTrainingAvailable(TrainingPerWeek t) {
}

private List<TrainingPerWeek> adjustFutureTrainingsVector(List<TrainingPerWeek> _futureTrainings, int requiredNBentries) {
List<TrainingPerWeek> newfutureTrainings = new ArrayList<>();
List<TrainingPerWeek> newFutureTrainings = new ArrayList<>();
TrainingPerWeek previousTraining = TrainingManager.instance().getNextWeekTraining();
HOLogger.instance().debug(TrainingModel.class, "Previous training date: " + previousTraining);

if ( previousTraining != null) {
TrainingPerWeek futureTraining;
while (newfutureTrainings.size() < requiredNBentries) {
while (newFutureTrainings.size() < requiredNBentries) {
//first iteration equals to nextWeek training then increase per one week per iteration
var futureTrainingDate = previousTraining.getTrainingDate().plusDaysAtSameLocalTime(7);
var storedFutureTrainings = _futureTrainings.stream().filter(t -> futureTrainingDate.equals(t.getTrainingDate())).toList();
Expand All @@ -180,10 +180,10 @@ private List<TrainingPerWeek> adjustFutureTrainingsVector(List<TrainingPerWeek>
futureTraining = new TrainingPerWeek(futureTrainingDate, previousTraining.getTrainingType(), previousTraining.getTrainingIntensity(),
previousTraining.getStaminaShare(), previousTraining.getTrainingAssistantsLevel(), previousTraining.getCoachLevel(), DBDataSource.GUESS);
}
newfutureTrainings.add(futureTraining);
newFutureTrainings.add(futureTraining);
previousTraining = futureTraining;
}
}
return newfutureTrainings;
return newFutureTrainings;
}
}
44 changes: 43 additions & 1 deletion src/main/resources/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
# Changelist HO! 7.1

## Some numbers
* 11 commits
* 34 files changed, 1085 insertions(+), 1213 deletions(-)
* Contributors:
* 9 wsbrenk
* 2 Sébastien Le Callonnec

## Highlights
* bug fixes

## [Detailed Changelog](https://github.com/akasolace/HO/issues?q=milestone%3A7.1)

### Squad
* fix click on “Last Match” column when the column has been moved.
* fix last match info of nt teams (#1878)

### Matches
* fix missing player names in match highlights panel (#1857)

### 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)

### Transfer
* fix bugs in transfer scout panel (#1858)

## Translations

Reports by Contributors - April 22, 2023 - June 24, 2023

* Achilles 272
* sich 4
* Lidegand 4
* wsbrenk 4

Total 288

# Changelist HO! 7.0

## Some numbers
Expand Down Expand Up @@ -98,7 +140,7 @@ Total 234
* 11 commits
* 22 files changed, 469 insertions(+), 493 deletions(-)
* Contributors:
11 wsbrenk
* 11 wsbrenk

## Highlights
* bug fixes
Expand Down
20 changes: 5 additions & 15 deletions src/main/resources/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,26 @@

bug fixes

## [Detailed Changelog](https://github.com/akasolace/HO/issues?q=milestone%3A8.0)
## [Detailed Changelog](https://github.com/akasolace/HO/issues?q=milestone%3A7.2)

### Database

### Squad
* fix click on “Last Match” column when the column has been moved.
* fix last match info of nt teams (#1878)

### Team Analyzer

### Rating

### Matches
* fix missing player names in match highlights panel (#1857)

### 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)

### Transfer
* fix bugs in transfer scout panel (#1858)

### Training
* handle new trainer types which are no longer listed as player (#1889)

### League

Expand All @@ -39,11 +33,7 @@ bug fixes

## Translations

Reports by Contributors - April 22, 2023 - June 24, 2023
Reports by Contributors - June 24, 2023 - July 08, 2023
* Miccoli17 1

* Achilles 272
* sich 4
* Lidegand 4
* wsbrenk 4

Total 288
Total 1

0 comments on commit 92310ce

Please sign in to comment.