removed global calls to getPlayer (for human player at gui) where member/local variables could provide data needed

This commit is contained in:
Maxmtg
2013-05-22 21:40:11 +00:00
parent 58aa4aef55
commit c0b8c4cf21
6 changed files with 15 additions and 12 deletions

View File

@@ -105,7 +105,7 @@ public class InputBlock extends InputBase {
if (isMetaDown) { if (isMetaDown) {
if (card.getController() == Singletons.getControl().getPlayer() ) { if (card.getController() == player ) {
game.getCombat().removeFromCombat(card); game.getCombat().removeFromCombat(card);
} }
removeFromAllBlocking(card); removeFromAllBlocking(card);

View File

@@ -73,8 +73,7 @@ public class InputCleanup extends InputBase {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void selectCard(final Card card, boolean isMetaDown) { public final void selectCard(final Card card, boolean isMetaDown) {
Zone zone = game.getZoneOf(card); if (!player.getZone(ZoneType.Hand).contains(card))
if (!zone.is(ZoneType.Hand, Singletons.getControl().getPlayer()))
return; return;
game.getInputQueue().LockAndInvokeGameAction(new Runnable() { game.getInputQueue().LockAndInvokeGameAction(new Runnable() {

View File

@@ -20,6 +20,7 @@ import forge.game.player.LobbyPlayer;
import forge.game.player.LobbyPlayerHuman; import forge.game.player.LobbyPlayerHuman;
import forge.game.player.Player; import forge.game.player.Player;
import forge.game.player.PlayerStatistics; import forge.game.player.PlayerStatistics;
import forge.game.player.PlayerType;
import forge.gui.GuiDialog; import forge.gui.GuiDialog;
import forge.gui.framework.EDocID; import forge.gui.framework.EDocID;
import forge.gui.framework.SDisplayUtil; import forge.gui.framework.SDisplayUtil;
@@ -374,7 +375,7 @@ public class MatchController {
} }
boolean willPlay = goesFirst.getController().getWillPlayOnFirstTurn(message); boolean willPlay = goesFirst.getController().getWillPlayOnFirstTurn(message);
if ( goesFirst != FControl.SINGLETON_INSTANCE.getPlayer() ) { if ( goesFirst.getLobbyPlayer().getType() == PlayerType.COMPUTER ) {
GuiDialog.message(message + "\nComputer Going First"); GuiDialog.message(message + "\nComputer Going First");
} }
goesFirst = willPlay ? goesFirst : goesFirst.getOpponent(); goesFirst = willPlay ? goesFirst : goesFirst.getOpponent();

View File

@@ -387,7 +387,7 @@ public class CombatUtil {
*/ */
public static boolean finishedMandatoryBlocks(final Combat combat, final Player defending) { public static boolean finishedMandatoryBlocks(final Combat combat, final Player defending) {
final List<Card> blockers = Singletons.getControl().getPlayer().getCreaturesInPlay(); final List<Card> blockers = defending.getCreaturesInPlay();
final List<Card> attackers = combat.getAttackers(); final List<Card> attackers = combat.getAttackers();
// if a creature does not block but should, return false // if a creature does not block but should, return false

View File

@@ -1811,7 +1811,7 @@ public class Player extends GameEntity implements Comparable<Player> {
} }
// Dev Mode // Dev Mode
if (this == FControl.SINGLETON_INSTANCE.getPlayer() && Preferences.DEV_MODE && if (this.getLobbyPlayer().getType() == PlayerType.HUMAN && Preferences.DEV_MODE &&
Singletons.getModel().getPreferences().getPrefBoolean(FPref.DEV_UNLIMITED_LAND)) { Singletons.getModel().getPreferences().getPrefBoolean(FPref.DEV_UNLIMITED_LAND)) {
return true; return true;
} }

View File

@@ -120,8 +120,7 @@ public final class GuiDisplayUtil {
public static void devModeGenerateMana() { public static void devModeGenerateMana() {
final Card dummy = new Card(); final Card dummy = new Card();
final Player human = Singletons.getControl().getPlayer(); dummy.setOwner(getPlayer());
dummy.setOwner(human);
Map<String, String> produced = new HashMap<String, String>(); Map<String, String> produced = new HashMap<String, String>();
produced.put("Produced", "W W W W W W W U U U U U U U B B B B B B B G G G G G G G R R R R R R R 7"); produced.put("Produced", "W W W W W W W U U U U U U U B B B B B B B G G G G G G G R R R R R R R 7");
final AbilityManaPart abMana = new AbilityManaPart(dummy, produced); final AbilityManaPart abMana = new AbilityManaPart(dummy, produced);
@@ -287,7 +286,7 @@ public final class GuiDisplayUtil {
List<Card> humanDevExileSetup = new ArrayList<Card>(); List<Card> humanDevExileSetup = new ArrayList<Card>();
List<Card> computerDevExileSetup = new ArrayList<Card>(); List<Card> computerDevExileSetup = new ArrayList<Card>();
final Player human = Singletons.getControl().getPlayer(); final Player human = getPlayer();
final Player ai = human.getOpponents().get(0); final Player ai = human.getOpponents().get(0);
if (!tChangePlayer.trim().toLowerCase().equals("none")) { if (!tChangePlayer.trim().toLowerCase().equals("none")) {
@@ -455,7 +454,7 @@ public final class GuiDisplayUtil {
* @since 1.0.15 * @since 1.0.15
*/ */
public static void devModeTutor() { public static void devModeTutor() {
final List<Card> lib = Singletons.getControl().getPlayer().getCardsIn(ZoneType.Library); final List<Card> lib = getPlayer().getCardsIn(ZoneType.Library);
final Object o = GuiChoose.oneOrNone("Choose a card", lib); final Object o = GuiChoose.oneOrNone("Choose a card", lib);
if (null == o) { if (null == o) {
return; return;
@@ -540,7 +539,7 @@ public final class GuiDisplayUtil {
* @since 1.0.16 * @since 1.0.16
*/ */
public static void devModeUnlimitedLand() { public static void devModeUnlimitedLand() {
Singletons.getControl().getPlayer().addMaxLandsToPlay(100); getPlayer().addMaxLandsToPlay(100);
} }
/** /**
@@ -637,7 +636,7 @@ public final class GuiDisplayUtil {
game.getAction().moveToHand(forgeCard); // this is really needed (for rollbacks at least) game.getAction().moveToHand(forgeCard); // this is really needed (for rollbacks at least)
// Human player is choosing targets for an ability controlled by chosen player. // Human player is choosing targets for an ability controlled by chosen player.
sa.setActivatingPlayer(p); sa.setActivatingPlayer(p);
HumanPlay.playSaWithoutPayingManaCost(Singletons.getControl().getPlayer(), sa); HumanPlay.playSaWithoutPayingManaCost(getPlayer(), sa);
} }
}); });
} }
@@ -706,4 +705,8 @@ public final class GuiDisplayUtil {
return Singletons.getControl().getMatch().getCurrentGame(); return Singletons.getControl().getMatch().getCurrentGame();
} }
private static Player getPlayer() {
return Singletons.getControl().getPlayer();
}
} // end class GuiDisplayUtil } // end class GuiDisplayUtil