diff --git a/src/main/java/core/gui/model/UserColumnFactory.java b/src/main/java/core/gui/model/UserColumnFactory.java index e22e1dc1e..0780de73b 100644 --- a/src/main/java/core/gui/model/UserColumnFactory.java +++ b/src/main/java/core/gui/model/UserColumnFactory.java @@ -581,14 +581,14 @@ public IHOTableEntry getTableEntry(Player player, Player playerCompare) { byte idealPosition = player.getIdealPosition(); String posValue = String.format("%s (%.2f)", MatchRoleID.getNameForPosition(idealPosition), - player.getIdealPositionRating()); + player.getPositionRating(idealPosition)); if ( player.isAnAlternativeBestPosition(idealPosition) ) { posValue += " *"; } ColorLabelEntry tmp = new ColorLabelEntry( -MatchRoleID.getSortId(idealPosition, false) - + (player.getIdealPositionRating() / 100.0f), + + (player.getPositionRating(idealPosition) / 100.0f), posValue, ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD, SwingConstants.LEFT); diff --git a/src/main/java/core/model/player/Player.java b/src/main/java/core/model/player/Player.java index 2636a4f8a..52aa4d033 100644 --- a/src/main/java/core/model/player/Player.java +++ b/src/main/java/core/model/player/Player.java @@ -22,6 +22,7 @@ import java.util.*; import static core.constants.player.PlayerSkill.*; +import static core.model.player.IMatchRoleID.aPositionBehaviours; import static core.model.player.MatchRoleID.getPosition; import static core.model.player.MatchRoleID.isFieldMatchRoleId; import static java.lang.Integer.MAX_VALUE; @@ -33,7 +34,7 @@ public class Player extends AbstractTable.Storable { - private byte idealPos = IMatchRoleID.UNKNOWN; + private byte calculatedBestPosition = IMatchRoleID.UNKNOWN; private static final PlayerSkill[] trainingSkills = {STAMINA, KEEPER, SETPIECES, DEFENDING, SCORING, WINGER, PASSING, PLAYMAKING}; private static final String BREAK = "[br]"; @@ -845,21 +846,26 @@ public MatchLineupPosition getIdealMatchLineupPosition() { public byte getIdealPosition() { //in case player best position is forced by user final int flag = getUserPosFlag(); - if (flag == IMatchRoleID.UNKNOWN) { - if (idealPos == IMatchRoleID.UNKNOWN) { - var matchLineupPosition = getIdealMatchLineupPosition(); - idealPos = getPosition(matchLineupPosition.getRoleId(), matchLineupPosition.getBehaviour()); - } - return idealPos; + return getCalculatedBestPosition(); } - return (byte) flag; } + public byte getCalculatedBestPosition() { + if (calculatedBestPosition == IMatchRoleID.UNKNOWN) { + var matchLineupPosition = getIdealMatchLineupPosition(); + calculatedBestPosition = getPosition(matchLineupPosition.getRoleId(), matchLineupPosition.getBehaviour()); + } + return calculatedBestPosition; + } + public double getPositionRating(byte position) { - var ratingPredictionModel = HOVerwaltung.instance().getModel().getRatingPredictionModel(); - return ratingPredictionModel.getPlayerMatchAverageRating(this, position); + if ( aPositionBehaviours.contains((int)position)) { + var ratingPredictionModel = HOVerwaltung.instance().getModel().getRatingPredictionModel(); + return ratingPredictionModel.getPlayerMatchAverageRating(this, position); + } + return 0; } private Map wagesHistory = null; // age->wage diff --git a/src/main/java/module/playerOverview/PlayerDetailsPanel.java b/src/main/java/module/playerOverview/PlayerDetailsPanel.java index c13928a9e..6a97bf70f 100644 --- a/src/main/java/module/playerOverview/PlayerDetailsPanel.java +++ b/src/main/java/module/playerOverview/PlayerDetailsPanel.java @@ -289,7 +289,7 @@ private void setLabels() { m_jlSeasonSeriesGoals.setText(String.valueOf(m_clPlayer.getLeagueGoals())); m_jlSeasonCupGoals.setText(String.valueOf(m_clPlayer.getCupGameGoals())); - var bestPosition = m_clPlayer.getIdealPosition(); + var bestPosition = m_clPlayer.getCalculatedBestPosition(); m_jlBestPosition.setText(MatchRoleID.getNameForPosition(bestPosition) + " (" + Helper.getNumberFormat(false, core.model.UserParameter.instance().nbDecimals).format( diff --git a/src/main/resources/release_notes.md b/src/main/resources/release_notes.md index 8dff49c3f..9c8cc4a74 100644 --- a/src/main/resources/release_notes.md +++ b/src/main/resources/release_notes.md @@ -14,6 +14,7 @@ ### Squad * Calculation of the tsi sub by approximating the tsi formula (#235) +* Fix display of best position rating (#2166) ### Team Analyzer * Fix illegal argument exception in team rating panel (#2155)