* Fixed cards with skip untap optional ability that cause game freezes (#5606)

This commit is contained in:
Oleg Agafonov 2019-03-01 18:10:32 +04:00
parent 4a14940414
commit 6846db75f4
169 changed files with 754 additions and 1172 deletions

View file

@ -1,4 +1,3 @@
package mage.abilities.decorator;
import mage.abilities.Ability;
@ -11,7 +10,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class ConditionalRestrictionEffect extends RestrictionEffect {
@ -86,51 +84,51 @@ public class ConditionalRestrictionEffect extends RestrictionEffect {
}
@Override
public boolean canAttack(Game game) {
public boolean canAttack(Game game, boolean canUseChooseDialogs) {
if (conditionState) {
return effect.canAttack(game);
return effect.canAttack(game, canUseChooseDialogs);
} else if (otherwiseEffect != null) {
return otherwiseEffect.canAttack(game);
return otherwiseEffect.canAttack(game, canUseChooseDialogs);
}
return true;
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
if (conditionState) {
return effect.canBlock(attacker, blocker, source, game);
return effect.canBlock(attacker, blocker, source, game, canUseChooseDialogs);
} else if (otherwiseEffect != null) {
return otherwiseEffect.canBlock(attacker, blocker, source, game);
return otherwiseEffect.canBlock(attacker, blocker, source, game, canUseChooseDialogs);
}
return true;
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
if (conditionState) {
return effect.canBeBlocked(attacker, blocker, source, game);
return effect.canBeBlocked(attacker, blocker, source, game, canUseChooseDialogs);
} else if (otherwiseEffect != null) {
return otherwiseEffect.canBeBlocked(attacker, blocker, source, game);
return otherwiseEffect.canBeBlocked(attacker, blocker, source, game, canUseChooseDialogs);
}
return true;
}
@Override
public boolean canBeUntapped(Permanent permanent, Ability source, Game game) {
public boolean canBeUntapped(Permanent permanent, Ability source, Game game, boolean canUseChooseDialogs) {
if (conditionState) {
return effect.canBeUntapped(permanent, source, game);
return effect.canBeUntapped(permanent, source, game, canUseChooseDialogs);
} else if (otherwiseEffect != null) {
return otherwiseEffect.canBeUntapped(permanent, source, game);
return otherwiseEffect.canBeUntapped(permanent, source, game, canUseChooseDialogs);
}
return true;
}
@Override
public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) {
public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game, boolean canUseChooseDialogs) {
if (conditionState) {
return effect.canUseActivatedAbilities(permanent, source, game);
return effect.canUseActivatedAbilities(permanent, source, game, canUseChooseDialogs);
} else if (otherwiseEffect != null) {
return otherwiseEffect.canUseActivatedAbilities(permanent, source, game);
return otherwiseEffect.canUseActivatedAbilities(permanent, source, game, canUseChooseDialogs);
}
return true;
}

View file

@ -34,7 +34,10 @@ public abstract class RestrictionEffect extends ContinuousEffectImpl {
public abstract boolean applies(Permanent permanent, Ability source, Game game);
public boolean canAttack(Game game) {
// canUseChooseDialogs -- restrict checks can be called by rules engine and by card info engine,
// last one uses for info only and can't use dialogs, e.g. canUseChooseDialogs = false
public boolean canAttack(Game game, boolean canUseChooseDialogs) {
return true;
}
@ -45,11 +48,11 @@ public abstract class RestrictionEffect extends ContinuousEffectImpl {
* @param game
* @return
*/
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game) {
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game, boolean canUseChooseDialogs) {
return true;
}
public boolean canAttackCheckAfter(int numberOfAttackers, Ability source, Game game) {
public boolean canAttackCheckAfter(int numberOfAttackers, Ability source, Game game, boolean canUseChooseDialogs) {
return true;
}
@ -60,15 +63,15 @@ public abstract class RestrictionEffect extends ContinuousEffectImpl {
* @param game
* @return
*/
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return true;
}
public boolean canBlockCheckAfter(Ability source, Game game) {
public boolean canBlockCheckAfter(Ability source, Game game, boolean canUseChooseDialogs) {
return true;
}
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return true;
}
@ -81,19 +84,19 @@ public abstract class RestrictionEffect extends ContinuousEffectImpl {
* @return true = block is ok false = block is not valid (human: back to
* defining blockers, AI: remove blocker)
*/
public boolean canBeBlockedCheckAfter(Permanent attacker, Ability source, Game game) {
public boolean canBeBlockedCheckAfter(Permanent attacker, Ability source, Game game, boolean canUseChooseDialogs) {
return true;
}
public boolean canBeUntapped(Permanent permanent, Ability source, Game game) {
public boolean canBeUntapped(Permanent permanent, Ability source, Game game, boolean canUseChooseDialogs) {
return true;
}
public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) {
public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game, boolean canUseChooseDialogs) {
return true;
}
public boolean canTransform(Permanent permanent, Ability source, Game game) {
public boolean canTransform(Permanent permanent, Ability source, Game game, boolean canUseChooseDialogs) {
return true;
}

View file

@ -12,7 +12,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author halljared
*/
public class CantAttackBlockTransformAttachedEffect extends RestrictionEffect {
@ -30,25 +29,23 @@ public class CantAttackBlockTransformAttachedEffect extends RestrictionEffect {
public boolean applies(Permanent permanent, Ability source, Game game) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) {
if (permanent.getId().equals(enchantment.getAttachedTo())) {
return true;
}
return permanent.getId().equals(enchantment.getAttachedTo());
}
return false;
}
@Override
public boolean canAttack(Game game) {
public boolean canAttack(Game game, boolean canUseChooseDialogs) {
return false;
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}
@Override
public boolean canTransform(Permanent permanent, Ability source, Game game) {
public boolean canTransform(Permanent permanent, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -1,9 +1,5 @@
package mage.abilities.effects.common;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.RestrictionEffect;
@ -16,8 +12,11 @@ import mage.game.permanent.Permanent;
import mage.game.turn.Step;
import mage.target.targetpointer.FixedTarget;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public class DetainAllEffect extends OneShotEffect {
@ -110,17 +109,17 @@ class DetainAllRestrictionEffect extends RestrictionEffect {
}
@Override
public boolean canAttack(Game game) {
public boolean canAttack(Game game, boolean canUseChooseDialogs) {
return false;
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}
@Override
public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) {
public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -1,7 +1,5 @@
package mage.abilities.effects.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
@ -16,8 +14,9 @@ import mage.target.Target;
import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author LevelX2
*/
//
@ -137,17 +136,17 @@ class DetainRestrictionEffect extends RestrictionEffect {
}
@Override
public boolean canAttack(Game game) {
public boolean canAttack(Game game, boolean canUseChooseDialogs) {
return false;
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}
@Override
public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) {
public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common;
import mage.abilities.Ability;
@ -10,7 +9,6 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
/**
*
* @author LevelX2
*/
public class SkipUntapOptionalSourceEffect extends RestrictionEffect {
@ -32,9 +30,15 @@ public class SkipUntapOptionalSourceEffect extends RestrictionEffect {
}
@Override
public boolean canBeUntapped(Permanent permanent, Ability source, Game game) {
public boolean canBeUntapped(Permanent permanent, Ability source, Game game, boolean canUseChooseDialogs) {
Player player = game.getPlayer(permanent.getControllerId());
return player != null && player.chooseUse(Outcome.Benefit, "Untap " + permanent.getLogName() + '?', source, game);
if (canUseChooseDialogs) {
// calls on untap step
return player != null && player.chooseUse(Outcome.Benefit, "Untap " + permanent.getLogName() + '?', source, game);
} else {
// calcs on get cards info
return true;
}
}
@Override

View file

@ -12,7 +12,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class CanAttackOnlyAloneEffect extends RestrictionEffect {
@ -32,7 +31,7 @@ public class CanAttackOnlyAloneEffect extends RestrictionEffect {
}
@Override
public boolean canAttackCheckAfter(int numberOfAttackers, Ability source, Game game) {
public boolean canAttackCheckAfter(int numberOfAttackers, Ability source, Game game, boolean canUseChooseDialogs) {
return numberOfAttackers == 1;
}

View file

@ -29,7 +29,7 @@ public class CanBlockOnlyFlyingAttachedEffect extends RestrictionEffect {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
if (attacker == null) {
return true;
}

View file

@ -29,7 +29,7 @@ public class CanBlockOnlyFlyingEffect extends RestrictionEffect {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
if (attacker == null) {
return true;
}

View file

@ -13,7 +13,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class CantAttackAloneAttachedEffect extends RestrictionEffect {
@ -33,7 +32,7 @@ public class CantAttackAloneAttachedEffect extends RestrictionEffect {
}
@Override
public boolean canAttackCheckAfter(int numberOfAttackers, Ability source, Game game) {
public boolean canAttackCheckAfter(int numberOfAttackers, Ability source, Game game, boolean canUseChooseDialogs) {
return numberOfAttackers > 1;
}

View file

@ -12,7 +12,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class CantAttackAloneSourceEffect extends RestrictionEffect {
@ -32,7 +31,7 @@ public class CantAttackAloneSourceEffect extends RestrictionEffect {
}
@Override
public boolean canAttackCheckAfter(int numberOfAttackers, Ability source, Game game) {
public boolean canAttackCheckAfter(int numberOfAttackers, Ability source, Game game, boolean canUseChooseDialogs) {
return numberOfAttackers > 1;
}

View file

@ -1,5 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -30,7 +28,7 @@ public class CantAttackAnyPlayerAllEffect extends RestrictionEffect {
sb.append(' ').append(duration.toString());
}
}
staticText = sb.toString();
staticText = sb.toString();
}
public CantAttackAnyPlayerAllEffect(final CantAttackAnyPlayerAllEffect effect) {
@ -44,7 +42,7 @@ public class CantAttackAnyPlayerAllEffect extends RestrictionEffect {
}
@Override
public boolean canAttack(Game game) {
public boolean canAttack(Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -1,5 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -10,7 +8,7 @@ import mage.game.permanent.Permanent;
/**
* The source of this effect can't attack any opponent
*
*
* @author BetaSteward_at_googlemail.com
*/
public class CantAttackAnyPlayerSourceEffect extends RestrictionEffect {
@ -29,7 +27,7 @@ public class CantAttackAnyPlayerSourceEffect extends RestrictionEffect {
}
@Override
public boolean canAttack(Game game) {
public boolean canAttack(Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -1,5 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -10,7 +8,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
@ -31,7 +28,7 @@ public class CantAttackAttachedEffect extends RestrictionEffect {
}
@Override
public boolean canAttack(Game game) {
public boolean canAttack(Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -9,7 +8,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class CantAttackBlockAllEffect extends RestrictionEffect {
@ -42,12 +40,12 @@ public class CantAttackBlockAllEffect extends RestrictionEffect {
}
@Override
public boolean canAttack(Game game) {
public boolean canAttack(Game game, boolean canUseChooseDialogs) {
return false;
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -1,10 +1,9 @@
package mage.abilities.effects.common.combat;
import mage.constants.AttachmentType;
import mage.constants.Duration;
import mage.abilities.Ability;
import mage.abilities.effects.RestrictionEffect;
import mage.constants.AttachmentType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -31,12 +30,12 @@ public class CantAttackBlockAttachedEffect extends RestrictionEffect {
}
@Override
public boolean canAttack(Game game) {
public boolean canAttack(Game game, boolean canUseChooseDialogs) {
return false;
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -1,5 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -9,7 +7,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
@ -30,12 +27,12 @@ public class CantAttackBlockTargetEffect extends RestrictionEffect {
}
@Override
public boolean canAttack(Game game) {
public boolean canAttack(Game game, boolean canUseChooseDialogs) {
return false;
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -9,7 +8,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class CantAttackBlockUnlessConditionSourceEffect extends RestrictionEffect {
@ -33,12 +31,12 @@ public class CantAttackBlockUnlessConditionSourceEffect extends RestrictionEffec
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}
@Override
public boolean canAttack(Game game) {
public boolean canAttack(Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -31,7 +31,7 @@ public class CantAttackControllerAttachedEffect extends RestrictionEffect {
}
@Override
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game) {
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game, boolean canUseChooseDialogs) {
if (defenderId == null) {
return true;
}

View file

@ -35,7 +35,7 @@ public class CantAttackIfDefenderControlsPermanent extends RestrictionEffect {
}
@Override
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game) {
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game, boolean canUseChooseDialogs) {
if (defenderId == null) {
return true;
}

View file

@ -1,15 +1,12 @@
package mage.abilities.effects.common.combat;
import mage.constants.Duration;
import mage.abilities.Ability;
import mage.abilities.effects.RestrictionEffect;
import mage.constants.Duration;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author BetaSteward_at_googlemail.com & L_J
*/
public class CantAttackSourceEffect extends RestrictionEffect {
@ -29,7 +26,7 @@ public class CantAttackSourceEffect extends RestrictionEffect {
}
@Override
public boolean canAttack(Game game) {
public boolean canAttack(Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -1,5 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -10,7 +8,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class CantAttackTargetEffect extends RestrictionEffect {
@ -29,7 +26,7 @@ public class CantAttackTargetEffect extends RestrictionEffect {
}
@Override
public boolean canAttack(Game game) {
public boolean canAttack(Game game, boolean canUseChooseDialogs) {
return false;
}
@ -40,11 +37,11 @@ public class CantAttackTargetEffect extends RestrictionEffect {
@Override
public String getText(Mode mode) {
if(staticText != null && !staticText.isEmpty()) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
String text = "target " + mode.getTargets().get(0).getTargetName() + " can't attack";
if(this.duration == Duration.EndOfTurn) {
if (this.duration == Duration.EndOfTurn) {
text += " this turn";
}
return text;

View file

@ -35,7 +35,7 @@ public class CantAttackUnlessDefenderControllsPermanent extends RestrictionEffec
}
@Override
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game) {
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game, boolean canUseChooseDialogs) {
if (defenderId == null) {
return true;
}

View file

@ -48,7 +48,7 @@ public class CantAttackYouAllEffect extends RestrictionEffect {
}
@Override
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game) {
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game, boolean canUseChooseDialogs) {
if (defenderId == null) {
return true;
}

View file

@ -32,7 +32,7 @@ public class CantAttackYouEffect extends RestrictionEffect {
}
@Override
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game) {
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game, boolean canUseChooseDialogs) {
if (defenderId == null) {
return true;
}

View file

@ -38,7 +38,7 @@ public class CantAttackYouOrPlaneswalkerAllEffect extends RestrictionEffect {
}
@Override
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game) {
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game, boolean canUseChooseDialogs) {
if (defenderId == null) {
return true;
}

View file

@ -1,15 +1,13 @@
package mage.abilities.effects.common.combat;
import mage.constants.Duration;
import mage.abilities.Ability;
import mage.abilities.effects.RestrictionEffect;
import mage.constants.Duration;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author North
*/
public class CantBeBlockedAllEffect extends RestrictionEffect {
@ -37,7 +35,7 @@ public class CantBeBlockedAllEffect extends RestrictionEffect {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -9,7 +8,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author North
*/
public class CantBeBlockedAttachedEffect extends RestrictionEffect {
@ -29,7 +27,7 @@ public class CantBeBlockedAttachedEffect extends RestrictionEffect {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -9,7 +8,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class CantBeBlockedByAllSourceEffect extends RestrictionEffect {
@ -36,7 +34,7 @@ public class CantBeBlockedByAllSourceEffect extends RestrictionEffect {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return !filterBlockedBy.match(blocker, source.getSourceId(), source.getControllerId(), game);
}

View file

@ -1,16 +1,15 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
import mage.abilities.effects.RestrictionEffect;
import mage.constants.Duration;
import static mage.constants.Duration.EndOfTurn;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import static mage.constants.Duration.EndOfTurn;
/**
*
* @author LevelX2
*/
public class CantBeBlockedByAllTargetEffect extends RestrictionEffect {
@ -38,7 +37,7 @@ public class CantBeBlockedByAllTargetEffect extends RestrictionEffect {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return !filterBlockedBy.match(blocker, source.getSourceId(), source.getControllerId(), game);
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -9,7 +8,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
@ -23,7 +21,7 @@ public class CantBeBlockedByCreaturesAllEffect extends RestrictionEffect {
this.filterCreatures = filterCreatures;
this.filterBlockedBy = filterBlockedBy;
staticText = new StringBuilder(filterCreatures.getMessage()).append(" can't be blocked ")
.append(filterBlockedBy.getMessage().startsWith("except by") ? "":"by ").append(filterBlockedBy.getMessage()).toString();
.append(filterBlockedBy.getMessage().startsWith("except by") ? "" : "by ").append(filterBlockedBy.getMessage()).toString();
}
public CantBeBlockedByCreaturesAllEffect(final CantBeBlockedByCreaturesAllEffect effect) {
@ -38,7 +36,7 @@ public class CantBeBlockedByCreaturesAllEffect extends RestrictionEffect {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return !filterBlockedBy.match(blocker, source.getSourceId(), source.getControllerId(), game);
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -36,7 +35,7 @@ public class CantBeBlockedByCreaturesAttachedEffect extends RestrictionEffect {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return !filter.match(blocker, source.getSourceId(), source.getControllerId(), game);
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -33,7 +32,7 @@ public class CantBeBlockedByCreaturesSourceEffect extends RestrictionEffect {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return !filter.match(blocker, source.getSourceId(), source.getControllerId(), game);
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -8,7 +7,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class CantBeBlockedByCreaturesWithGreaterPowerEffect extends RestrictionEffect {
@ -28,7 +26,7 @@ public class CantBeBlockedByCreaturesWithGreaterPowerEffect extends RestrictionE
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return blocker.getPower().getValue() <= attacker.getPower().getValue();
}

View file

@ -1,14 +1,12 @@
package mage.abilities.effects.common.combat;
import mage.constants.Duration;
import mage.abilities.Ability;
import mage.abilities.effects.RestrictionEffect;
import mage.constants.Duration;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author North
*/
public class CantBeBlockedByCreaturesWithLessPowerEffect extends RestrictionEffect {
@ -28,7 +26,7 @@ public class CantBeBlockedByCreaturesWithLessPowerEffect extends RestrictionEffe
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return (blocker.getPower().getValue() >= attacker.getPower().getValue());
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -10,7 +9,6 @@ import mage.game.permanent.Permanent;
import mage.target.Target;
/**
*
* @author LevelX2
*/
@ -18,7 +16,7 @@ public class CantBeBlockedByTargetSourceEffect extends RestrictionEffect {
/**
* Target creature(s) cant block the source creature
*
*
* @param duration
*/
@ -36,7 +34,7 @@ public class CantBeBlockedByTargetSourceEffect extends RestrictionEffect {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return !this.getTargetPointer().getTargets(game, source).contains(blocker.getId());
}
@ -52,7 +50,7 @@ public class CantBeBlockedByTargetSourceEffect extends RestrictionEffect {
}
StringBuilder sb = new StringBuilder();
Target target = mode.getTargets().get(0);
if(target.getNumberOfTargets() > 1){
if (target.getNumberOfTargets() > 1) {
if (target.getNumberOfTargets() < target.getMaxNumberOfTargets()) {
sb.append("Up to");
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -8,7 +7,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author North
*/
public class CantBeBlockedSourceEffect extends RestrictionEffect {
@ -16,6 +14,7 @@ public class CantBeBlockedSourceEffect extends RestrictionEffect {
public CantBeBlockedSourceEffect() {
this(Duration.WhileOnBattlefield);
}
public CantBeBlockedSourceEffect(Duration duration) {
super(duration);
this.staticText = "{this} can't be blocked";
@ -34,7 +33,7 @@ public class CantBeBlockedSourceEffect extends RestrictionEffect {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -13,7 +13,6 @@ import mage.target.Target;
import mage.util.CardUtil;
/**
*
* @author North
*/
public class CantBeBlockedTargetEffect extends RestrictionEffect {
@ -47,7 +46,7 @@ public class CantBeBlockedTargetEffect extends RestrictionEffect {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return !filter.match(blocker, source.getSourceId(), source.getControllerId(), game);
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -8,7 +7,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author escplan9 (Derek Monturo - dmontur1 at gmail dot com)
*/
public class CantBlockActivateAttachedEffect extends RestrictionEffect {
@ -26,20 +24,18 @@ public class CantBlockActivateAttachedEffect extends RestrictionEffect {
public boolean applies(Permanent permanent, Ability source, Game game) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) {
if (permanent.getId().equals(enchantment.getAttachedTo())) {
return true;
}
return permanent.getId().equals(enchantment.getAttachedTo());
}
return false;
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}
@Override
public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) {
public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -10,7 +9,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class CantBlockAllEffect extends RestrictionEffect {
@ -33,7 +31,7 @@ public class CantBlockAllEffect extends RestrictionEffect {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -68,7 +68,7 @@ public class CantBlockAttachedEffect extends RestrictionEffect {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
if (attacker == null) {
return true;
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -8,7 +7,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class CantBlockAttackActivateAttachedEffect extends RestrictionEffect {
@ -26,25 +24,23 @@ public class CantBlockAttackActivateAttachedEffect extends RestrictionEffect {
public boolean applies(Permanent permanent, Ability source, Game game) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) {
if (permanent.getId().equals(enchantment.getAttachedTo())) {
return true;
}
return permanent.getId().equals(enchantment.getAttachedTo());
}
return false;
}
@Override
public boolean canAttack(Game game) {
public boolean canAttack(Game game, boolean canUseChooseDialogs) {
return false;
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}
@Override
public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) {
public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -36,7 +36,7 @@ public class CantBlockCreaturesSourceEffect extends RestrictionEffect {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
if (attacker == null) {
return true;
}

View file

@ -1,15 +1,12 @@
package mage.abilities.effects.common.combat;
import mage.constants.Duration;
import mage.abilities.Ability;
import mage.abilities.effects.RestrictionEffect;
import mage.constants.Duration;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class CantBlockSourceEffect extends RestrictionEffect {
@ -32,7 +29,7 @@ public class CantBlockSourceEffect extends RestrictionEffect {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -11,7 +10,6 @@ import mage.target.Target;
import mage.util.CardUtil;
/**
*
* @author North
*/
public class CantBlockTargetEffect extends RestrictionEffect {
@ -30,7 +28,7 @@ public class CantBlockTargetEffect extends RestrictionEffect {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -9,7 +8,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class CantBlockUnlessYouControlSourceEffect extends RestrictionEffect {
@ -33,7 +31,7 @@ public class CantBlockUnlessYouControlSourceEffect extends RestrictionEffect {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -1,20 +1,14 @@
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.RestrictionEffect;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.PhaseStep;
import mage.constants.SubLayer;
import mage.constants.*;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class UntapAllDuringEachOtherPlayersUntapStepEffect extends ContinuousEffectImpl {
@ -49,7 +43,7 @@ public class UntapAllDuringEachOtherPlayersUntapStepEffect extends ContinuousEff
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
boolean untap = true;
for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(permanent, game).keySet()) {
untap &= effect.canBeUntapped(permanent, source, game);
untap &= effect.canBeUntapped(permanent, source, game, true);
}
if (untap) {
permanent.untap(game);

View file

@ -1,19 +1,13 @@
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.RestrictionEffect;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.PhaseStep;
import mage.constants.SubLayer;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author fireshoes
*/
public class UntapSourceDuringEachOtherPlayersUntapStepEffect extends ContinuousEffectImpl {
@ -43,11 +37,11 @@ public class UntapSourceDuringEachOtherPlayersUntapStepEffect extends Continuous
&& game.getStep() != null
&& game.getStep().getType() == PhaseStep.UNTAP) {
game.getState().setValue(source.getSourceId() + "applied", true);
Permanent permanent = (Permanent) game.getPermanent(source.getSourceId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
boolean untap = true;
for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(permanent, game).keySet()) {
untap &= effect.canBeUntapped(permanent, source, game);
untap &= effect.canBeUntapped(permanent, source, game, true);
}
if (untap) {
permanent.untap(game);

View file

@ -1,18 +1,16 @@
package mage.abilities.keyword;
import mage.constants.Duration;
import mage.abilities.Ability;
import mage.abilities.EvasionAbility;
import mage.abilities.MageSingleton;
import mage.abilities.effects.RestrictionEffect;
import mage.constants.Duration;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.io.ObjectStreamException;
/**
*
* @author Loki
*/
public class FearAbility extends EvasionAbility implements MageSingleton {
@ -59,7 +57,7 @@ class FearEffect extends RestrictionEffect implements MageSingleton {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return blocker.isArtifact() || blocker.getColor(game).isBlack();
}

View file

@ -1,7 +1,5 @@
package mage.abilities.keyword;
import java.io.ObjectStreamException;
import mage.abilities.Ability;
import mage.abilities.EvasionAbility;
import mage.abilities.MageSingleton;
@ -12,8 +10,9 @@ import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.io.ObjectStreamException;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class FlyingAbility extends EvasionAbility implements MageSingleton {
@ -60,7 +59,7 @@ class FlyingEffect extends RestrictionEffect implements MageSingleton {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return blocker.getAbilities().containsKey(FlyingAbility.getInstance().getId())
|| blocker.getAbilities().containsKey(ReachAbility.getInstance().getId())
|| (null != game.getContinuousEffects().asThough(blocker.getId(), AsThoughEffectType.BLOCK_DRAGON, source, blocker.getControllerId(), game)

View file

@ -1,8 +1,5 @@
package mage.abilities.keyword;
import java.io.ObjectStreamException;
import mage.abilities.Ability;
import mage.abilities.EvasionAbility;
import mage.abilities.MageSingleton;
@ -11,13 +8,14 @@ import mage.constants.Duration;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.io.ObjectStreamException;
/**
*
* @author LevelX2
*/
public class HorsemanshipAbility extends EvasionAbility implements MageSingleton {
private static final HorsemanshipAbility instance = new HorsemanshipAbility();
private static final HorsemanshipAbility instance = new HorsemanshipAbility();
private Object readResolve() throws ObjectStreamException {
return instance;
@ -59,7 +57,7 @@ class Horsemanship extends RestrictionEffect implements MageSingleton {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return blocker.getAbilities().containsKey(HorsemanshipAbility.getInstance().getId());
}

View file

@ -10,18 +10,15 @@ import mage.game.permanent.Permanent;
/**
* 702.13. Intimidate #
*
* 702.13a Intimidate is an evasion ability.
*
* 702.13b A creature with intimidate can't be blocked except by artifact creatures
* and/or creatures that share a color with it. (See rule 509, "Declare Blockers Step.") #
*
* 702.13c Multiple instances of intimidate on the same creature are redundant.
*
*
*
* <p>
* 702.13a Intimidate is an evasion ability.
* <p>
* 702.13b A creature with intimidate can't be blocked except by artifact creatures
* and/or creatures that share a color with it. (See rule 509, "Declare Blockers Step.") #
* <p>
* 702.13c Multiple instances of intimidate on the same creature are redundant.
*/
public class IntimidateAbility extends EvasionAbility implements MageSingleton {
public class IntimidateAbility extends EvasionAbility implements MageSingleton {
private static final IntimidateAbility instance = new IntimidateAbility();
public static IntimidateAbility getInstance() {
@ -58,7 +55,7 @@ class IntimidateEffect extends RestrictionEffect implements MageSingleton {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
boolean result = false;
if (blocker.isArtifact() && (blocker.isCreature())) {
result = true;

View file

@ -1,4 +1,3 @@
package mage.abilities.keyword;
import mage.abilities.Ability;
@ -11,7 +10,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class LandwalkAbility extends EvasionAbility {
@ -60,7 +58,7 @@ class LandwalkEffect extends RestrictionEffect {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
if (game.getBattlefield().contains(filter, blocker.getControllerId(), 1, game)
&& null == game.getContinuousEffects().asThough(blocker.getId(), AsThoughEffectType.BLOCK_LANDWALK, source, blocker.getControllerId(), game)) {
switch (filter.getMessage()) {

View file

@ -60,7 +60,7 @@ class ShadowEffect extends RestrictionEffect implements MageSingleton {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
if (attacker == null) {
return true;
}
@ -68,7 +68,7 @@ class ShadowEffect extends RestrictionEffect implements MageSingleton {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return blocker.getAbilities().containsKey(ShadowAbility.getInstance().getId())
|| null != game.getContinuousEffects().asThough(blocker.getId(), AsThoughEffectType.BLOCK_SHADOW, source, blocker.getControllerId(), game);
}

View file

@ -14,7 +14,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class SkulkAbility extends StaticAbility {
@ -56,7 +55,7 @@ class SkulkEffect extends RestrictionEffect {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return blocker.getPower().getValue() <= attacker.getPower().getValue();
}

View file

@ -57,7 +57,7 @@ class SpaceFlightEffect extends RestrictionEffect implements MageSingleton {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
if (attacker == null) {
return true;
}
@ -65,7 +65,7 @@ class SpaceFlightEffect extends RestrictionEffect implements MageSingleton {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return blocker.getAbilities().containsKey(SpaceflightAbility.getInstance().getId())
|| blocker.getAbilities().containsKey(CanBlockSpaceflightAbility.getInstance().getId());
}

View file

@ -1,4 +1,3 @@
package mage.abilities.keyword;
import mage.abilities.Ability;
@ -110,15 +109,13 @@ class UnleashRestrictionEffect extends RestrictionEffect {
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
if (permanent != null && permanent.getId().equals(source.getSourceId())) {
if (permanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
return true;
}
return permanent.getCounters(game).getCount(CounterType.P1P1) > 0;
}
return false;
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -520,7 +520,7 @@ public class Combat implements Serializable, Copyable<Combat> {
for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(attackingCreature, game).entrySet()) {
RestrictionEffect effect = entry.getKey();
for (Ability ability : entry.getValue()) {
if (!effect.canAttackCheckAfter(numberAttackers, ability, game)) {
if (!effect.canAttackCheckAfter(numberAttackers, ability, game, true)) {
MageObject sourceObject = ability.getSourceObject(game);
if (attackingPlayer.isHuman()) {
game.informPlayer(attackingPlayer, attackingCreature.getIdName() + " can't attack this way (" + (sourceObject == null ? "null" : sourceObject.getIdName()) + ')');
@ -1178,7 +1178,7 @@ public class Combat implements Serializable, Copyable<Combat> {
for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(blockingCreature, game).entrySet()) {
RestrictionEffect effect = entry.getKey();
for (Ability ability : entry.getValue()) {
if (!effect.canBlockCheckAfter(ability, game)) {
if (!effect.canBlockCheckAfter(ability, game, true)) {
if (controller.isHuman()) {
game.informPlayer(controller, blockingCreature.getLogName() + " can't block this way.");
return false;
@ -1198,7 +1198,7 @@ public class Combat implements Serializable, Copyable<Combat> {
for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(attackingCreature, game).entrySet()) {
RestrictionEffect effect = entry.getKey();
for (Ability ability : entry.getValue()) {
if (!effect.canBeBlockedCheckAfter(attackingCreature, ability, game)) {
if (!effect.canBeBlockedCheckAfter(attackingCreature, ability, game, true)) {
if (controller.isHuman()) {
game.informPlayer(controller, attackingCreature.getLogName() + " can't be blocked this way.");
return false;

View file

@ -150,7 +150,7 @@ class AgyremRestrictionEffect extends RestrictionEffect {
}
@Override
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game) {
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game, boolean canUseChooseDialogs) {
if (defenderId == null) {
return true;
}

View file

@ -1,9 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -24,8 +20,11 @@ import mage.target.Target;
import mage.watchers.common.AttackedThisTurnWatcher;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author spjspj
*/
public class AstralArenaPlane extends Plane {
@ -81,15 +80,11 @@ class AstralArenaAttackRestrictionEffect extends RestrictionEffect {
if (cPlane == null) {
return false;
}
if (!cPlane.getName().equalsIgnoreCase("Plane - Astral Arena")) {
return false;
}
return true;
return cPlane.getName().equalsIgnoreCase("Plane - Astral Arena");
}
@Override
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game) {
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game, boolean canUseChooseDialogs) {
return game.getCombat().getAttackers().isEmpty();
}
}
@ -116,14 +111,11 @@ class AstralArenaBlockRestrictionEffect extends RestrictionEffect {
if (cPlane == null) {
return false;
}
if (!cPlane.getName().equalsIgnoreCase("Plane - Astral Arena")) {
return false;
}
return true;
return cPlane.getName().equalsIgnoreCase("Plane - Astral Arena");
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return game.getCombat().getBlockers().isEmpty();
}
}

View file

@ -1,8 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import mage.abilities.Ability;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -21,12 +18,14 @@ import mage.filter.predicate.mageobject.PowerPredicate;
import mage.game.Game;
import mage.game.command.Plane;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.EldraziAnnihilatorToken;
import mage.target.Target;
import mage.watchers.common.PlanarRollWatcher;
import mage.game.permanent.token.EldraziAnnihilatorToken;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author spjspj
*/
public class HedronFieldsOfAgadeemPlane extends Plane {
@ -80,12 +79,12 @@ class HedronFieldsOfAgadeemRestrictionEffect extends RestrictionEffect {
}
@Override
public boolean canAttack(Game game) {
public boolean canAttack(Game game, boolean canUseChooseDialogs) {
return false;
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -1,8 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
@ -25,8 +22,10 @@ import mage.game.permanent.Permanent;
import mage.target.Target;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author spjspj
*/
public class TazeemPlane extends Plane {
@ -83,7 +82,7 @@ class TazeemCantBlockAllEffect extends RestrictionEffect {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}

View file

@ -268,23 +268,23 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
continue;
}
if (!entry.getKey().canAttack(game) || !entry.getKey().canAttack(this, null, ability, game)) {
if (!entry.getKey().canAttack(game, false) || !entry.getKey().canAttack(this, null, ability, game, false)) {
restrictHints.add(HintUtils.prepareText("Can't attack" + addSourceObjectName(game, ability), null, HintUtils.HINT_ICON_RESTRICT));
}
if (!entry.getKey().canBlock(null, this, ability, game)) {
if (!entry.getKey().canBlock(null, this, ability, game, false)) {
restrictHints.add(HintUtils.prepareText("Can't block" + addSourceObjectName(game, ability), null, HintUtils.HINT_ICON_RESTRICT));
}
if (!entry.getKey().canBeUntapped(this, ability, game)) {
if (!entry.getKey().canBeUntapped(this, ability, game, false)) {
restrictHints.add(HintUtils.prepareText("Can't untapped" + addSourceObjectName(game, ability), null, HintUtils.HINT_ICON_RESTRICT));
}
if (!entry.getKey().canUseActivatedAbilities(this, ability, game)) {
if (!entry.getKey().canUseActivatedAbilities(this, ability, game, false)) {
restrictHints.add(HintUtils.prepareText("Can't use activated abilities" + addSourceObjectName(game, ability), null, HintUtils.HINT_ICON_RESTRICT));
}
if (!entry.getKey().canTransform(this, ability, game)) {
if (!entry.getKey().canTransform(this, ability, game, false)) {
restrictHints.add(HintUtils.prepareText("Can't transform" + addSourceObjectName(game, ability), null, HintUtils.HINT_ICON_RESTRICT));
}
}
@ -1190,11 +1190,11 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
private boolean canAttackCheckRestrictionEffects(UUID defenderId, Game game) {
//20101001 - 508.1c
for (Map.Entry<RestrictionEffect, Set<Ability>> effectEntry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) {
if (!effectEntry.getKey().canAttack(game)) {
if (!effectEntry.getKey().canAttack(game, true)) {
return false;
}
for (Ability ability : effectEntry.getValue()) {
if (!effectEntry.getKey().canAttack(this, defenderId, ability, game)) {
if (!effectEntry.getKey().canAttack(this, defenderId, ability, game, true)) {
return false;
}
}
@ -1219,7 +1219,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
// check blocker restrictions
for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) {
for (Ability ability : entry.getValue()) {
if (!entry.getKey().canBlock(attacker, this, ability, game)) {
if (!entry.getKey().canBlock(attacker, this, ability, game, true)) {
return false;
}
}
@ -1227,7 +1227,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
// check also attacker's restriction effects
for (Map.Entry<RestrictionEffect, Set<Ability>> restrictionEntry : game.getContinuousEffects().getApplicableRestrictionEffects(attacker, game).entrySet()) {
for (Ability ability : restrictionEntry.getValue()) {
if (!restrictionEntry.getKey().canBeBlocked(attacker, this, ability, game)) {
if (!restrictionEntry.getKey().canBeBlocked(attacker, this, ability, game, true)) {
return false;
}
}
@ -1245,7 +1245,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) {
RestrictionEffect effect = entry.getKey();
for (Ability ability : entry.getValue()) {
if (!effect.canBlock(null, this, ability, game)) {
if (!effect.canBlock(null, this, ability, game, true)) {
return false;
}
}
@ -1266,7 +1266,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) {
RestrictionEffect effect = entry.getKey();
for (Ability ability : entry.getValue()) {
if (!effect.canUseActivatedAbilities(this, ability, game)) {
if (!effect.canUseActivatedAbilities(this, ability, game, true)) {
return false;
}
}
@ -1280,7 +1280,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) {
RestrictionEffect effect = entry.getKey();
for (Ability ability : entry.getValue()) {
if (!effect.canTransform(this, ability, game)) {
if (!effect.canTransform(this, ability, game, true)) {
return false;
}
}

View file

@ -1645,7 +1645,7 @@ public abstract class PlayerImpl implements Player, Serializable {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) {
boolean untap = true;
for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(permanent, game).keySet()) {
untap &= effect.canBeUntapped(permanent, null, game);
untap &= effect.canBeUntapped(permanent, null, game, true);
}
if (untap) {
canBeUntapped.add(permanent);
@ -1752,7 +1752,7 @@ public abstract class PlayerImpl implements Player, Serializable {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) {
boolean untap = true;
for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(permanent, game).keySet()) {
untap &= effect.canBeUntapped(permanent, null, game);
untap &= effect.canBeUntapped(permanent, null, game, true);
}
if (untap) {
permanent.untap(game);