From bfb498b257da1e53e4c6ff06d200fabc6eb15ae0 Mon Sep 17 00:00:00 2001 From: lodici Date: Sun, 5 Apr 2015 14:50:40 +0100 Subject: [PATCH] rename HumanPlayer to HumanProfile. --- src/magic/game/state/GameLoader.java | 6 +++--- .../player/{HumanPlayer.java => HumanProfile.java} | 6 +++--- src/magic/model/player/PlayerProfile.java | 4 ++-- src/magic/model/player/PlayerProfiles.java | 4 ++-- src/magic/model/player/PlayerStatistics.java | 2 +- src/magic/test/TestGameBuilder.java | 4 ++-- src/magic/ui/DuelDecksPanel.java | 4 ++-- src/magic/ui/player/HumanPlayerJList.java | 12 ++++++------ src/magic/ui/screen/NewDuelSettingsScreen.java | 10 +++++----- src/magic/ui/screen/SelectHumanPlayerScreen.java | 10 +++++----- src/magic/ui/screen/SelectPlayerScreen.java | 2 +- 11 files changed, 32 insertions(+), 32 deletions(-) rename src/magic/model/player/{HumanPlayer.java => HumanProfile.java} (85%) diff --git a/src/magic/game/state/GameLoader.java b/src/magic/game/state/GameLoader.java index 89042ad2d7..d1a0bc58f9 100644 --- a/src/magic/game/state/GameLoader.java +++ b/src/magic/game/state/GameLoader.java @@ -10,7 +10,7 @@ import magic.model.MagicPlayer; import magic.model.MagicPlayerDefinition; import magic.model.phase.MagicMainPhase; import magic.model.player.AiProfile; -import magic.model.player.HumanPlayer; +import magic.model.player.HumanProfile; import magic.model.player.PlayerProfile; import magic.test.TestGameBuilder; @@ -44,7 +44,7 @@ public final class GameLoader { ap.setAiLevel(gameState.getDifficulty()); pp1 = ap; } else { - final HumanPlayer hp = new HumanPlayer(); + final HumanProfile hp = new HumanProfile(); hp.setPlayerName(gameState.getPlayer(0).getName()); pp1 = hp; } @@ -61,7 +61,7 @@ public final class GameLoader { ap.setAiLevel(gameState.getDifficulty()); pp2 = ap; } else { - final HumanPlayer hp = new HumanPlayer(); + final HumanProfile hp = new HumanProfile(); hp.setPlayerName(gameState.getPlayer(1).getName()); pp2 = hp; } diff --git a/src/magic/model/player/HumanPlayer.java b/src/magic/model/player/HumanProfile.java similarity index 85% rename from src/magic/model/player/HumanPlayer.java rename to src/magic/model/player/HumanProfile.java index ed8ec0ba53..4baddbe932 100644 --- a/src/magic/model/player/HumanPlayer.java +++ b/src/magic/model/player/HumanProfile.java @@ -3,16 +3,16 @@ package magic.model.player; import java.util.Properties; import java.util.Map; -public class HumanPlayer extends PlayerProfile { +public class HumanProfile extends PlayerProfile { private static final String PLAYER_TYPE = "human"; - public HumanPlayer(final String profileId) { + public HumanProfile(final String profileId) { super(profileId); loadProperties(); } - public HumanPlayer() { + public HumanProfile() { super(); loadProperties(); } diff --git a/src/magic/model/player/PlayerProfile.java b/src/magic/model/player/PlayerProfile.java index 020748f899..b3fc48fa1f 100644 --- a/src/magic/model/player/PlayerProfile.java +++ b/src/magic/model/player/PlayerProfile.java @@ -27,7 +27,7 @@ public abstract class PlayerProfile { } public boolean isHuman() { - return this instanceof HumanPlayer; + return this instanceof HumanProfile; } protected PlayerProfile() { @@ -103,7 +103,7 @@ public abstract class PlayerProfile { public static PlayerProfile getHumanPlayer(final String playerId) { if (playerId != null && PlayerProfiles.getPlayerProfile(playerId) != null) { - return new HumanPlayer(playerId); + return new HumanProfile(playerId); } else { return PlayerProfiles.getDefaultHumanPlayer(); } diff --git a/src/magic/model/player/PlayerProfiles.java b/src/magic/model/player/PlayerProfiles.java index db868aa03a..1c1b1ab9f3 100644 --- a/src/magic/model/player/PlayerProfiles.java +++ b/src/magic/model/player/PlayerProfiles.java @@ -35,7 +35,7 @@ public final class PlayerProfiles { // Humans for (Path path : getProfilePaths("human")) { final String profileId = path.getFileName().toString(); - final HumanPlayer player = new HumanPlayer(profileId); + final HumanProfile player = new HumanProfile(profileId); profilesMap.put(profileId, player); } // AIs @@ -85,7 +85,7 @@ public final class PlayerProfiles { } private static void createDefaultHumanPlayerProfiles() throws IOException { - final HumanPlayer profile = new HumanPlayer(); + final HumanProfile profile = new HumanProfile(); profile.setPlayerName(getDefaultPlayerProfileName()); profile.save(); } diff --git a/src/magic/model/player/PlayerStatistics.java b/src/magic/model/player/PlayerStatistics.java index f930be00f0..0ca142075d 100644 --- a/src/magic/model/player/PlayerStatistics.java +++ b/src/magic/model/player/PlayerStatistics.java @@ -202,7 +202,7 @@ public class PlayerStatistics { sb.append(f.getStatLine("\nDuels won / lost:\t", duelsWon, " / ", duelsLost, " (", duelsWinPercentage, "%)")); sb.append(f.getStatLine("\nGames played:\t", gamesPlayed)); sb.append(f.getStatLine("\nGames won / lost\t", gamesWon, " / ", gamesLost, " (", gamesWinPercentage, "%)")); - sb.append(f.getStatLine("\nGames conceded:\t", playerProfile instanceof HumanPlayer ? gamesConceded : StatsFormatter.NO_VALUE)); + sb.append(f.getStatLine("\nGames conceded:\t", playerProfile instanceof HumanProfile ? gamesConceded : StatsFormatter.NO_VALUE)); sb.append(f.getStatLine("\nTurns played:\t", turnsPlayed)); sb.append(f.getStatLine("\nAverage turns per game:\t", averageTurns)); sb.append(f.getStatLine("\nMost used color:\t", mostColor.getName())); diff --git a/src/magic/test/TestGameBuilder.java b/src/magic/test/TestGameBuilder.java index 529ac3c778..1a63fc17aa 100644 --- a/src/magic/test/TestGameBuilder.java +++ b/src/magic/test/TestGameBuilder.java @@ -13,7 +13,7 @@ import magic.model.MagicPayedCost; import magic.model.MagicDuel; import magic.model.MagicDeckProfile; import magic.model.player.AiProfile; -import magic.model.player.HumanPlayer; +import magic.model.player.HumanProfile; import magic.model.stack.MagicCardOnStack; import magic.model.action.MagicPlayTokenAction; import magic.model.action.MagicPlayCardFromStackAction; @@ -112,7 +112,7 @@ public abstract class TestGameBuilder { final MagicDeckProfile profile=new MagicDeckProfile("bgruw"); - final HumanPlayer hp = new HumanPlayer(); + final HumanProfile hp = new HumanProfile(); hp.setPlayerName("Player"); final MagicPlayerDefinition player1=new MagicPlayerDefinition(hp,profile); diff --git a/src/magic/ui/DuelDecksPanel.java b/src/magic/ui/DuelDecksPanel.java index 7f3f646dc3..cebc69f0d2 100644 --- a/src/magic/ui/DuelDecksPanel.java +++ b/src/magic/ui/DuelDecksPanel.java @@ -6,7 +6,7 @@ import magic.model.MagicCardDefinition; import magic.model.MagicDeck; import magic.model.MagicDuel; import magic.model.MagicPlayerDefinition; -import magic.model.player.HumanPlayer; +import magic.model.player.HumanProfile; import magic.model.player.PlayerProfile; import magic.ui.duel.viewer.CardViewer; import magic.ui.duel.viewer.DeckDescriptionViewer; @@ -266,7 +266,7 @@ public class DuelDecksPanel extends TexturedPanel { } private int getScore(final PlayerProfile profile) { - if (profile instanceof HumanPlayer) { + if (profile instanceof HumanProfile) { return duel.getGamesWon(); } else { return duel.getGamesPlayed() - duel.getGamesWon(); diff --git a/src/magic/ui/player/HumanPlayerJList.java b/src/magic/ui/player/HumanPlayerJList.java index 4c04d19651..c71da6da5b 100644 --- a/src/magic/ui/player/HumanPlayerJList.java +++ b/src/magic/ui/player/HumanPlayerJList.java @@ -1,6 +1,6 @@ package magic.ui.player; -import magic.model.player.HumanPlayer; +import magic.model.player.HumanProfile; import magic.ui.widget.FontsAndBorders; import magic.ui.MagicStyle; import net.miginfocom.swing.MigLayout; @@ -19,17 +19,17 @@ import magic.ui.IconImages; @SuppressWarnings("serial") public class HumanPlayerJList - extends JList { + extends JList { public HumanPlayerJList() { setOpaque(false); setCellRenderer(new HumanPlayerListRenderer()); } - private class HumanPlayerListRenderer extends JPanel implements ListCellRenderer { + private class HumanPlayerListRenderer extends JPanel implements ListCellRenderer { private Color foreColor; - private HumanPlayer profile; + private HumanProfile profile; public HumanPlayerListRenderer() { setOpaque(false); @@ -37,8 +37,8 @@ public class HumanPlayerJList @Override public Component getListCellRendererComponent( - JList list, - HumanPlayer profile, + JList list, + HumanProfile profile, int index, boolean isSelected, boolean cellHasFocus) { diff --git a/src/magic/ui/screen/NewDuelSettingsScreen.java b/src/magic/ui/screen/NewDuelSettingsScreen.java index b065e3cda1..37bb6d0356 100644 --- a/src/magic/ui/screen/NewDuelSettingsScreen.java +++ b/src/magic/ui/screen/NewDuelSettingsScreen.java @@ -12,7 +12,7 @@ import magic.data.DeckUtils; import magic.data.DuelConfig; import magic.exception.InvalidDeckException; import magic.model.MagicDeck; -import magic.model.player.HumanPlayer; +import magic.model.player.HumanProfile; import magic.model.player.IPlayerProfileListener; import magic.model.player.PlayerProfile; import magic.model.player.PlayerProfiles; @@ -197,7 +197,7 @@ public class NewDuelSettingsScreen } private void selectNewProfile(final PlayerProfile playerProfile) { - if (playerProfile instanceof HumanPlayer) { + if (playerProfile instanceof HumanProfile) { ScreenController.showSelectHumanPlayerScreen(this, playerProfile); } else { ScreenController.showSelectAiProfileScreen(this, playerProfile); @@ -232,7 +232,7 @@ public class NewDuelSettingsScreen } private DuelPlayerPanel getDuelPlayerPanel(final PlayerProfile player) { - if (player instanceof HumanPlayer) { + if (player instanceof HumanProfile) { return playerPanels[0]; } else { return playerPanels[1]; @@ -252,7 +252,7 @@ public class NewDuelSettingsScreen */ @Override public void PlayerProfileDeleted(PlayerProfile deletedPlayer) { - if (deletedPlayer instanceof HumanPlayer) { + if (deletedPlayer instanceof HumanProfile) { final PlayerProfile playerProfile = PlayerProfiles.getDefaultHumanPlayer(); DuelConfig.getInstance().setPlayerProfile(0, playerProfile); getDuelPlayerPanel(playerProfile).setPlayer(playerProfile); @@ -274,7 +274,7 @@ public class NewDuelSettingsScreen } private void saveSelectedPlayerProfile(final PlayerProfile player) { - if (player instanceof HumanPlayer) { + if (player instanceof HumanProfile) { DuelConfig.getInstance().setPlayerProfile(0, player); } else { DuelConfig.getInstance().setPlayerProfile(1, player); diff --git a/src/magic/ui/screen/SelectHumanPlayerScreen.java b/src/magic/ui/screen/SelectHumanPlayerScreen.java index cbf52c9783..0a3c6465ad 100644 --- a/src/magic/ui/screen/SelectHumanPlayerScreen.java +++ b/src/magic/ui/screen/SelectHumanPlayerScreen.java @@ -1,6 +1,6 @@ package magic.ui.screen; -import magic.model.player.HumanPlayer; +import magic.model.player.HumanProfile; import magic.model.player.IPlayerProfileListener; import magic.model.player.PlayerProfile; import magic.model.player.PlayerProfiles; @@ -28,9 +28,9 @@ public class SelectHumanPlayerScreen refreshProfilesJList(playerProfile); } - private HumanPlayer[] getPlayerProfilesArray() { + private HumanProfile[] getPlayerProfilesArray() { final List sortedPlayersList = getSortedPlayersList(); - return sortedPlayersList.toArray(new HumanPlayer[sortedPlayersList.size()]); + return sortedPlayersList.toArray(new HumanProfile[sortedPlayersList.size()]); } /* (non-Javadoc) @@ -38,7 +38,7 @@ public class SelectHumanPlayerScreen */ @Override protected void createDefaultPlayerProfiles() throws IOException { - final HumanPlayer profile = new HumanPlayer(); + final HumanProfile profile = new HumanProfile(); profile.setPlayerName(getDefaultPlayerProfileName()); profile.save(); } @@ -95,7 +95,7 @@ public class SelectHumanPlayerScreen JOptionPane.PLAIN_MESSAGE, null, null, null); if (newName != null && !newName.trim().isEmpty()) { - final PlayerProfile newProfile = new HumanPlayer(); + final PlayerProfile newProfile = new HumanProfile(); newProfile.setPlayerName(newName); newProfile.save(); PlayerProfiles.getPlayerProfiles().put(newProfile.getId(), newProfile); diff --git a/src/magic/ui/screen/SelectPlayerScreen.java b/src/magic/ui/screen/SelectPlayerScreen.java index 91d5f123e5..ba00e57078 100644 --- a/src/magic/ui/screen/SelectPlayerScreen.java +++ b/src/magic/ui/screen/SelectPlayerScreen.java @@ -24,7 +24,7 @@ import javax.swing.JScrollPane; import javax.swing.KeyStroke; import javax.swing.SwingUtilities; import magic.model.player.AiProfile; -import magic.model.player.HumanPlayer; +import magic.model.player.HumanProfile; import magic.model.player.IPlayerProfileListener; import magic.model.player.PlayerProfile; import magic.model.player.PlayerProfiles;