Skip to content

Commit

Permalink
Fix #237 : Propose to sell players also when recent efficiency focused
Browse files Browse the repository at this point in the history
  • Loading branch information
axel3rd committed Aug 4, 2022
1 parent db6d891 commit 948954f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/blondin/mpg/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ static void processGames(League league, ApiClients apiClients, Config config) {
ChampionshipTypeWrapper.toStats(league.getChampionship()), config, false, false);

Integer currentPlayersBuy = team.getBids().stream().map(Player::getPricePaid).collect(Collectors.summingInt(Integer::intValue));
writeTransactionsProposal(playersTeam, playersAvailable, team.getBudget() - currentPlayersBuy, apiClients.getOutPlayers(),
ChampionshipTypeWrapper.toOut(league.getChampionship()), config);
writeTransactionsProposal(cd.getDay(), playersTeam, playersAvailable, team.getBudget() - currentPlayersBuy,
apiClients.getOutPlayers(), ChampionshipTypeWrapper.toOut(league.getChampionship()), config);
}
}
} catch (NoMoreGamesException e) {
Expand Down Expand Up @@ -303,7 +303,7 @@ private static void updateTeamWithRetry(MpgClient mpgClient, Division division,
}
}

private static void writeTransactionsProposal(List<Player> playersTeam, List<Player> playersAvailable, int budget,
private static void writeTransactionsProposal(int currentDay, List<Player> playersTeam, List<Player> playersAvailable, int budget,
InjuredSuspendedWrapperClient outPlayersClient, ChampionshipOutType championship, Config config) {

// Players with bad efficiency
Expand All @@ -319,7 +319,7 @@ private static void writeTransactionsProposal(List<Player> playersTeam, List<Pla
}

int cash = budget;
if (!config.isEfficiencyRecentFocus() && !players2Sell.isEmpty()) {
if (currentDay > 2 && !players2Sell.isEmpty()) {
LOG.info("Players to sell (initial cash: {}):", budget);
AsciiTable at = getTable(TABLE_POSITION, TABLE_PLAYER_NAME, TABLE_EFFICIENCY, TABLE_QUOTE);
for (Player player : players2Sell) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/blondin/mpg/stats/model/CurrentDay.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public class CurrentDay {
@JsonProperty("lD")
private int lastDayReached;

public int getDay() {
return day;
}

public int getDayReached() {
return lastDayReached;
}
Expand Down
4 changes: 3 additions & 1 deletion src/test/java/org/blondin/mpg/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,10 @@ public void testProcessFromEmptyCoach() throws Exception {
Assert.assertTrue(getLogOut(), getLogOut().contains("Ligue 2 Fous"));
Assert.assertTrue(getLogOut(), getLogOut().contains("Ba"));
Assert.assertTrue(getLogOut(), getLogOut().contains("Updating team"));
Assert.assertTrue(getLogOut(), getLogOut().contains("Transactions proposal"));
Assert.assertTrue(getLogOut(), getLogOut().contains("| G | Prevot Maxence (mpg_championship_player_220359) | 4.00 |"));
Assert.assertTrue(getLogOut(), getLogOut().contains("Transactions proposal"));
// currentGameWeek is 2 => selling players should not be displayed
Assert.assertFalse(getLogOut(), getLogOut().contains("Players to sell (initial cash"));
}

private void executeMainProcess(Config config) {
Expand Down

0 comments on commit 948954f

Please sign in to comment.