* 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

@ -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);