mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- Remove keyword "CARDNAME can't attack if defending player controls an untapped"
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
package forge.game.combat;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Lists;
|
||||
import forge.card.CardType;
|
||||
import forge.card.MagicColor;
|
||||
@@ -854,51 +853,6 @@ public class CombatUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
Player defendingPlayer = null;
|
||||
if (defender instanceof Card) {
|
||||
defendingPlayer = ((Card) defender).getController();
|
||||
} else {
|
||||
defendingPlayer = (Player) defender;
|
||||
}
|
||||
|
||||
// CARDNAME can't attack if defending player controls an untapped
|
||||
// creature with power ...
|
||||
final int[] powerLimit = { 0 };
|
||||
String cantAttackKw = null;
|
||||
|
||||
for( String kw : c.getKeyword()) {
|
||||
if (kw.startsWith("CARDNAME can't attack if defending player controls an untapped creature with power")) {
|
||||
cantAttackKw = kw;
|
||||
}
|
||||
}
|
||||
|
||||
// The keyword
|
||||
// "CARDNAME can't attack if defending player controls an untapped creature with power"
|
||||
// ... is present
|
||||
if (cantAttackKw != null) {
|
||||
final String[] asSeparateWords = cantAttackKw.trim().split(" ");
|
||||
|
||||
if (asSeparateWords.length >= 15) {
|
||||
if (StringUtils.isNumeric(asSeparateWords[12])) {
|
||||
powerLimit[0] = Integer.parseInt((asSeparateWords[12]).trim());
|
||||
|
||||
List<Card> list = defendingPlayer.getCreaturesInPlay();
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card ct) {
|
||||
return (ct.isUntapped()
|
||||
&& ((ct.getNetAttack() >= powerLimit[0] && asSeparateWords[14].contains("greater"))
|
||||
|| (ct.getNetAttack() <= powerLimit[0] && asSeparateWords[14].contains("less"))));
|
||||
}
|
||||
});
|
||||
if (!list.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // hasKeyword = CARDNAME can't attack if defending player controls an
|
||||
// untapped creature with power ...
|
||||
|
||||
for (String keyword : c.getKeyword()) {
|
||||
if (keyword.equals("CARDNAME can't attack.") || keyword.equals("CARDNAME can't attack or block.")) {
|
||||
return false;
|
||||
|
||||
@@ -13,7 +13,6 @@ import forge.card.mana.ManaCostShard;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardFactoryUtil;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.player.Player;
|
||||
|
||||
@@ -58,14 +58,22 @@ public class StaticAbilityCantAttackBlock {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Player defender = target instanceof Card ? ((Card) target).getController() : (Player) target;
|
||||
|
||||
if (params.containsKey("UnlessDefenderControls")) {
|
||||
String type = params.get("UnlessDefenderControls");
|
||||
Player defender = target instanceof Card ? ((Card) target).getController() : (Player) target;
|
||||
List<Card> list = defender.getCardsIn(ZoneType.Battlefield);
|
||||
if (Iterables.any(list, CardPredicates.restriction(type.split(","), hostCard.getController(), hostCard))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (params.containsKey("IfDefenderControls")) {
|
||||
String type = params.get("IfDefenderControls");
|
||||
List<Card> list = defender.getCardsIn(ZoneType.Battlefield);
|
||||
if (!Iterables.any(list, CardPredicates.restriction(type.split(","), hostCard.getController(), hostCard))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user