- Fix Crawlspace in multiplayer

- Move a method using getOpponent() to AI (only place it's used, to group the methods using this deprecated function in the AI code)
This commit is contained in:
elcnesh
2014-07-29 22:22:14 +00:00
parent ed496dbc10
commit ecc4620dda
7 changed files with 54 additions and 41 deletions

View File

@@ -731,7 +731,7 @@ public class CombatUtil {
* @return a boolean.
*/
public static boolean canAttack(final Card c, final GameEntity def, final Combat combat) {
int cntAttackers = combat.getAttackers().size();
final int cntAttackers = combat.getAttackers().size();
final Game game = c.getGame();
if (cntAttackers > 0) {
@@ -741,10 +741,6 @@ public class CombatUtil {
if (keyword.equals("No more than two creatures can attack each combat.")) {
return false;
}
if (keyword.equals("No more than two creatures can attack you each combat.") &&
card.getController().getOpponent().equals(c.getController())) {
return false;
}
}
if (keyword.equals("CARDNAME can only attack alone.") && combat.isAttacking(card)) {
return false;
@@ -761,6 +757,18 @@ public class CombatUtil {
}
}
final int cntAttackersToDef = combat.getAttackersOf(def).size();
if (cntAttackersToDef > 1) {
for (final Card card : game.getCardsIn(ZoneType.Battlefield)) {
for (final String keyword : card.getKeyword()) {
if (keyword.equals("No more than two creatures can attack you each combat.") &&
card.getController().equals(def)) {
return false;
}
}
}
}
if ((c.hasKeyword("CARDNAME can't attack or block alone.") || c.hasKeyword("CARDNAME can't attack alone."))
&& c.getController().getCreaturesInPlay().size() < 2) {
return false;
@@ -832,20 +840,8 @@ public class CombatUtil {
*
* @param c
* a {@link forge.game.card.Card} object.
* @return a boolean.
*/
public static boolean canAttackNextTurn(final Card c) {
return canAttackNextTurn(c, c.getController().getOpponent());
}
// can a creature attack if untapped and without summoning sickness?
/**
* <p>
* canAttackNextTurn.
* </p>
*
* @param c
* a {@link forge.game.card.Card} object.
* @param def
* the defending {@link GameEntity}.
* @return a boolean.
*/
public static boolean canAttackNextTurn(final Card c, final GameEntity defender) {