player.isHostileTo() renamed to more correct 'isOpponentOf()'

This commit is contained in:
Maxmtg
2013-02-06 06:41:51 +00:00
parent 9cd0afa0d8
commit cb1793eddf
16 changed files with 29 additions and 30 deletions

View File

@@ -62,7 +62,7 @@ public class AddTurnAi extends SpellAiLogic {
} else {
final List<Player> tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa);
for (final Player p : tgtPlayers) {
if (p.isHostileTo(ai) && !mandatory) {
if (p.isOpponentOf(ai) && !mandatory) {
return false;
}
}

View File

@@ -275,7 +275,7 @@ public class AttachAi extends SpellAiLogic {
} else {
// then try any other opponent
for (final Player curseChoice : targetable) {
if (curseChoice.isHostileTo(aiPlayer)) {
if (curseChoice.isOpponentOf(aiPlayer)) {
return curseChoice;
}
}
@@ -294,7 +294,7 @@ public class AttachAi extends SpellAiLogic {
} else {
// then try allies
for (final Player boonChoice : targetable) {
if (!boonChoice.isHostileTo(aiPlayer)) {
if (!boonChoice.isOpponentOf(aiPlayer)) {
return boonChoice;
}
}
@@ -595,7 +595,7 @@ public class AttachAi extends SpellAiLogic {
if (!mandatory && card.isEquipment() && !targets.isEmpty()) {
Card newTarget = (Card) targets.get(0);
//don't equip human creatures
if (newTarget.getController().isHostileTo(ai)) {
if (newTarget.getController().isOpponentOf(ai)) {
return false;
}

View File

@@ -813,7 +813,7 @@ public class ChangeZoneAi extends SpellAiLogic {
@Override
public boolean apply(final Card c) {
for (Card aura : c.getEnchantedBy()) {
if (c.getOwner().isHostileTo(ai) && aura.getController().equals(ai)) {
if (c.getOwner().isOpponentOf(ai) && aura.getController().equals(ai)) {
return false;
}
}
@@ -1037,7 +1037,7 @@ public class ChangeZoneAi extends SpellAiLogic {
if (!list.isEmpty()) {
final Card attachedTo = list.get(0);
// This code is for the Dragon auras
if (attachedTo.getController().isHostileTo(ai)) {
if (attachedTo.getController().isOpponentOf(ai)) {
return false;
}
}
@@ -1148,7 +1148,7 @@ public class ChangeZoneAi extends SpellAiLogic {
return true;
}
});
if (player.isHostileTo(ai) && sa.hasParam("GainControl") && activator.equals(ai)) {
if (player.isOpponentOf(ai) && sa.hasParam("GainControl") && activator.equals(ai)) {
fetchList = CardLists.filter(fetchList, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
@@ -1162,7 +1162,7 @@ public class ChangeZoneAi extends SpellAiLogic {
}
if (ZoneType.Exile.equals(destination) || origin.contains(ZoneType.Battlefield)) {
// Exiling or bouncing stuff
if (player.isHostileTo(ai)) {
if (player.isOpponentOf(ai)) {
c = CardFactoryUtil.getBestAI(fetchList);
} else {
c = CardFactoryUtil.getWorstAI(fetchList);

View File

@@ -26,7 +26,7 @@ public class ChooseTypeAi extends SpellAiLogic {
sa.getTarget().addTarget(ai);
} else {
for (final Player p : AbilityFactory.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa)) {
if (p.isHostileTo(ai) && !mandatory) {
if (p.isOpponentOf(ai) && !mandatory) {
return false;
}
}

View File

@@ -162,7 +162,7 @@ public class DamageDealAi extends DamageAiBase {
});
Card targetCard;
if (pl.isHostileTo(ai) && (killables.size() > 0)) {
if (pl.isOpponentOf(ai) && (killables.size() > 0)) {
targetCard = CardFactoryUtil.getBestCreatureAI(killables);
return targetCard;
@@ -173,7 +173,7 @@ public class DamageDealAi extends DamageAiBase {
}
if (hPlay.size() > 0) {
if (pl.isHostileTo(ai)) {
if (pl.isOpponentOf(ai)) {
targetCard = CardFactoryUtil.getBestCreatureAI(hPlay);
} else {
targetCard = CardFactoryUtil.getWorstCreatureAI(hPlay);
@@ -327,7 +327,7 @@ public class DamageDealAi extends DamageAiBase {
// from this spell will kill me
return false;
}
if (p.isHostileTo(ai) && !p.canLoseLife()) {
if (p.isOpponentOf(ai) && !p.canLoseLife()) {
return false;
}
}

View File

@@ -98,7 +98,7 @@ public class DrawAi extends SpellAiLogic {
if (tgt != null) {
final ArrayList<Player> players = tgt.getTargetPlayers();
if ((players.size() > 0) && players.get(0).isHostileTo(ai)) {
if ((players.size() > 0) && players.get(0).isOpponentOf(ai)) {
return true;
}
}

View File

@@ -43,7 +43,7 @@ public class FogAi extends SpellAiLogic {
boolean chance;
// should really check if other player is attacking this player
if (ai.isHostileTo(Singletons.getModel().getGame().getPhaseHandler().getPlayerTurn())) {
if (ai.isOpponentOf(Singletons.getModel().getGame().getPhaseHandler().getPlayerTurn())) {
chance = Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE);
} else {
chance = Singletons.getModel().getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DAMAGE);

View File

@@ -139,7 +139,7 @@ public class PumpAi extends PumpAiBase {
// everything?
for (final Card card : cards) {
if (sa.isCurse()) {
if (!card.getController().isHostileTo(ai)) {
if (!card.getController().isOpponentOf(ai)) {
return false;
}
@@ -149,7 +149,7 @@ public class PumpAi extends PumpAiBase {
return true;
}
if (!card.getController().isHostileTo(ai) && shouldPumpCard(ai, sa, card, defense, attack, keywords)) {
if (!card.getController().isOpponentOf(ai) && shouldPumpCard(ai, sa, card, defense, attack, keywords)) {
return true;
}
}

View File

@@ -26,7 +26,7 @@ public class TapAi extends TapAiBase {
final PhaseHandler phase = Singletons.getModel().getGame().getPhaseHandler();
final Player turn = phase.getPlayerTurn();
if (turn.isHostileTo(ai) && phase.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
if (turn.isOpponentOf(ai) && phase.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
// Tap things down if it's Human's turn
} else if (turn == ai && phase.getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
// Tap creatures down if in combat -- handled in tapPrefTargeting().

View File

@@ -132,13 +132,13 @@ public class TapAllAi extends SpellAiLogic {
final int human = Iterables.size(Iterables.filter(validTappables, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
return c.getController().isHostileTo(ai);
return c.getController().isOpponentOf(ai);
}
}));
final int compy = Iterables.size(Iterables.filter(validTappables, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
return !c.getController().isHostileTo(ai);
return !c.getController().isOpponentOf(ai);
}
}));
if (human > compy) {

View File

@@ -609,7 +609,7 @@ public class ChangeZoneEffect extends SpellEffect {
}
// Look at opponents hand before moving onto choosing a card
if (origin.contains(ZoneType.Hand) && player.isHostileTo(player)) {
if (origin.contains(ZoneType.Hand) && player.isOpponentOf(player)) {
GuiChoose.oneOrNone(sa.getSourceCard().getName() + " - Looking at Opponent's Hand", player
.getCardsIn(ZoneType.Hand));
}

View File

@@ -56,7 +56,7 @@ public class ChoosePlayerEffect extends SpellEffect {
if (sa.hasParam("AILogic")) {
if (sa.getParam("AILogic").equals("Curse")) {
for (int curseChoice = 0; curseChoice < choices.size(); curseChoice++) {
if (choices.get(curseChoice).isHostileTo(p)) {
if (choices.get(curseChoice).isOpponentOf(p)) {
card.setChosenPlayer(choices.get(curseChoice));
break;
}

View File

@@ -53,7 +53,7 @@ public class SacrificeEffect extends SpellEffect {
if (sa.hasParam("Random")) {
sacList = sacrificeRandom(p, amount, valid, sa, destroy);
} else if (p.isComputer()) {
if (sa.hasParam("Optional") && sa.getActivatingPlayer().isHostileTo(p)) {
if (sa.hasParam("Optional") && sa.getActivatingPlayer().isOpponentOf(p)) {
continue;
}
sacList = sacrificeAI(p, amount, valid, sa, destroy);

View File

@@ -1196,7 +1196,7 @@ public class ComputerUtil {
// don't bounce or blink a permanent that the human
// player owns or is a token
if (saviourApi == ApiType.ChangeZone && (c.getOwner().isHuman() || c.isToken())) {
if (saviourApi == ApiType.ChangeZone && (c.getOwner().isOpponentOf(aiPlayer) || c.isToken())) {
continue;
}

View File

@@ -1678,7 +1678,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
boolean hasPutIntoPlayWith2xP1P1InsteadOfDiscard = c.hasKeyword("If a spell or ability an opponent controls causes you to discard CARDNAME, put it onto the battlefield with two +1/+1 counters on it instead of putting it into your graveyard.");
if ((hasPutIntoPlayInsteadOfDiscard || hasPutIntoPlayWith2xP1P1InsteadOfDiscard)
&& null != sa && sa.getSourceCard().getController().isHostileTo(c.getController())) {
&& null != sa && sa.getSourceCard().getController().isOpponentOf(c.getController())) {
game.getAction().moveToPlay(c);
if (hasPutIntoPlayWith2xP1P1InsteadOfDiscard) {
@@ -2477,7 +2477,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
final String[] incR = restriction.split("\\.");
if (incR[0].equals("Opponent")) {
if (this.equals(sourceController) || !this.isHostileTo(sourceController)) {
if (this.equals(sourceController) || !this.isOpponentOf(sourceController)) {
return false;
}
} else if (incR[0].equals("You")) {
@@ -2526,7 +2526,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
return false;
}
} else if (property.equals("Opponent")) {
if (this.equals(sourceController) || !this.isHostileTo(sourceController)) {
if (this.equals(sourceController) || !this.isOpponentOf(sourceController)) {
return false;
}
} else if (property.equals("Other")) {
@@ -3114,7 +3114,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
* @param playerTurn
* @return
*/
public boolean isHostileTo(Player other) {
public boolean isOpponentOf(Player other) {
if (other.equals(getOpponent())) {
return true;
}

View File

@@ -17,6 +17,7 @@ import forge.game.GameState;
import forge.game.GameType;
import forge.game.phase.PhaseType;
import forge.gui.GuiChoose;
import forge.gui.GuiDialog;
import forge.gui.match.CMatchUI;
import forge.item.CardPrinted;
@@ -106,10 +107,8 @@ public class PlayerControllerHuman extends PlayerController {
question.append("Cast ").append(cascadedCard.getName());
question.append(" without paying its mana cost?");
final int answer = JOptionPane.showConfirmDialog(null, question.toString(),
title.toString(), JOptionPane.YES_NO_OPTION);
boolean result = answer == JOptionPane.YES_OPTION;
boolean result = GuiDialog.confirm(cascadedCard, question.toString());
if ( result )
game.getAction().playCardWithoutManaCost(cascadedCard, getPlayer());
return result;