Code cleanup

This commit is contained in:
drdev
2014-09-25 11:37:24 +00:00
parent 42af632ccf
commit 1b0346219d
5 changed files with 10 additions and 14 deletions

View File

@@ -608,12 +608,12 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
}
@Override
public void openView(List<Player> sortedPlayers, int humanCount) {
public void openView(List<Player> sortedPlayers) {
List<PlayerView> sortedPlayerViews = new ArrayList<PlayerView>();
for (Player p : sortedPlayers) {
sortedPlayerViews.add(MatchUtil.getGameView().getPlayerView(p));
}
CMatchUI.SINGLETON_INSTANCE.initMatch(sortedPlayerViews, humanCount != 1);
CMatchUI.SINGLETON_INSTANCE.initMatch(sortedPlayerViews, MatchUtil.getHumanCount() != 1);
actuateMatchPreferences();
@@ -622,7 +622,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
// per player observers were set in CMatchUI.SINGLETON_INSTANCE.initMatch
//Set Field shown to current player.
if (humanCount > 0) {
if (MatchUtil.getHumanCount() > 0) {
final VField nextField = CMatchUI.SINGLETON_INSTANCE.getFieldViewFor(sortedPlayerViews.get(0));
SDisplayUtil.showTab(nextField);
}

View File

@@ -124,14 +124,15 @@ public class MatchController implements IMatchController {
}
@Override
public void openView(List<Player> sortedPlayers, int humanCount) {
public void openView(List<Player> sortedPlayers) {
boolean noHumans = MatchUtil.getHumanCount() == 0;
List<VPlayerPanel> playerPanels = new ArrayList<VPlayerPanel>();
for (Player p : sortedPlayers) {
playerPanels.add(new VPlayerPanel(MatchUtil.getGameView(p).getPlayerView(p), humanCount == 0 || p.getController() instanceof PlayerControllerHuman));
playerPanels.add(new VPlayerPanel(MatchUtil.getGameView(p).getPlayerView(p), noHumans || p.getController() instanceof PlayerControllerHuman));
}
view = new MatchScreen(playerPanels);
if (humanCount == 0) {
if (noHumans) {
//add special object that pauses game if screen touched
view.add(new FDisplayObject() {
@Override

View File

@@ -16,7 +16,6 @@ import forge.game.zone.ZoneType;
import forge.match.MatchUtil;
import forge.menu.FMenuBar;
import forge.model.FModel;
import forge.player.LobbyPlayerHuman;
import forge.properties.ForgePreferences;
import forge.properties.ForgePreferences.FPref;
import forge.screens.FScreen;
@@ -66,12 +65,8 @@ public class MatchScreen extends FScreen {
scroller = add(new FieldScroller());
int humanCount = 0;
for (VPlayerPanel playerPanel : playerPanels0) {
playerPanels.put(playerPanel.getPlayer(), scroller.add(playerPanel));
if (playerPanel.getPlayer().getLobbyPlayer() instanceof LobbyPlayerHuman) {
humanCount++;
}
}
bottomPlayerPanel = playerPanels0.get(0);
topPlayerPanel = playerPanels0.get(1);
@@ -91,7 +86,7 @@ public class MatchScreen extends FScreen {
}
}));
if (humanCount > 1) { //show top prompt if multiple human players
if (MatchUtil.getHumanCount() > 1) { //show top prompt if multiple human players
topPlayerPrompt = add(new VPrompt("", "",
new FEventHandler() {
@Override

View File

@@ -22,7 +22,7 @@ import forge.view.SpellAbilityView;
public interface IMatchController {
void startNewMatch(Match match);
boolean resetForNewGame();
void openView(List<Player> sortedPlayers, int humanCount);
void openView(List<Player> sortedPlayers);
void afterGameEnd();
void showCombat(CombatView combat);
void showPromptMessage(PlayerView playerView, String message);

View File

@@ -194,7 +194,7 @@ public class MatchUtil {
}
}
controller.openView(sortedPlayers, humanCount);
controller.openView(sortedPlayers);
if (humanCount == 0) {
playbackControl = new FControlGamePlayback(GuiBase.getInterface(), getGameView());