mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
Can't be target/attached effects - fixed that user gets multiple warning message about prevention effect;
This commit is contained in:
parent
105062beb7
commit
8ca6fd8552
18 changed files with 91 additions and 114 deletions
|
|
@ -738,13 +738,13 @@ public class ContinuousEffects implements Serializable {
|
|||
* Checks if an event won't happen because of an rule modifying effect
|
||||
*
|
||||
* @param event
|
||||
* @param targetAbility ability the event is attached to. can be null.
|
||||
* @param targetAbility ability the event is attached to. can be null.
|
||||
* @param game
|
||||
* @param checkPlayableMode true if the event does not really happen but
|
||||
* it's checked if the event would be replaced
|
||||
* @param silentMode true if the event does not really happen but
|
||||
* it's checked if the event would be replaced
|
||||
* @return
|
||||
*/
|
||||
public boolean preventedByRuleModification(GameEvent event, Ability targetAbility, Game game, boolean checkPlayableMode) {
|
||||
public boolean preventedByRuleModification(GameEvent event, Ability targetAbility, Game game, boolean silentMode) {
|
||||
for (ContinuousRuleModifyingEffect effect : continuousRuleModifyingEffects) {
|
||||
if (!effect.checksEventType(event, game)) {
|
||||
continue;
|
||||
|
|
@ -755,7 +755,7 @@ public class ContinuousEffects implements Serializable {
|
|||
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
|
||||
effect.setValue("targetAbility", targetAbility);
|
||||
if (effect.applies(event, sourceAbility, game)) {
|
||||
if (!game.inCheckPlayableState()) {
|
||||
if (!game.inCheckPlayableState() && !silentMode) {
|
||||
String message = effect.getInfoMessage(sourceAbility, event, game);
|
||||
if (message != null && !message.isEmpty()) {
|
||||
if (effect.sendMessageToUser()) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.filter.predicate.permanent;
|
||||
|
||||
import mage.MageObject;
|
||||
|
|
@ -13,13 +12,13 @@ public class CanBeEnchantedByPredicate implements Predicate<Permanent> {
|
|||
|
||||
private final MageObject auraEnchantment;
|
||||
|
||||
public CanBeEnchantedByPredicate(MageObject auraEnchantment){
|
||||
public CanBeEnchantedByPredicate(MageObject auraEnchantment) {
|
||||
this.auraEnchantment = auraEnchantment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Permanent input, Game game) {
|
||||
return !input.cantBeAttachedBy(auraEnchantment, game);
|
||||
return !input.cantBeAttachedBy(auraEnchantment, game, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1971,12 +1971,12 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
Filter auraFilter = spellAbility.getTargets().get(0).getFilter();
|
||||
if (auraFilter instanceof FilterControlledPermanent) {
|
||||
if (!((FilterControlledPermanent) auraFilter).match(attachedTo, perm.getId(), perm.getControllerId(), this)
|
||||
|| attachedTo.cantBeAttachedBy(perm, this)) {
|
||||
|| attachedTo.cantBeAttachedBy(perm, this, true)) {
|
||||
if (movePermanentToGraveyardWithInfo(perm)) {
|
||||
somethingHappened = true;
|
||||
}
|
||||
}
|
||||
} else if (!auraFilter.match(attachedTo, this) || attachedTo.cantBeAttachedBy(perm, this)) {
|
||||
} else if (!auraFilter.match(attachedTo, this) || attachedTo.cantBeAttachedBy(perm, this, true)) {
|
||||
// handle bestow unattachment
|
||||
Card card = this.getCard(perm.getId());
|
||||
if (card != null && card.isCreature()) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.game.permanent;
|
||||
|
||||
import mage.MageObject;
|
||||
|
|
@ -94,14 +93,20 @@ public interface Permanent extends Card, Controllable {
|
|||
|
||||
void unattach(Game game);
|
||||
|
||||
// boolean addAttachment(UUID permanentId, Game game);
|
||||
// boolean addAttachment(UUID permanentId, Game game);
|
||||
//
|
||||
// boolean removeAttachment(UUID permanentId, Game game);
|
||||
boolean canBeTargetedBy(MageObject source, UUID controllerId, Game game);
|
||||
|
||||
boolean hasProtectionFrom(MageObject source, Game game);
|
||||
|
||||
boolean cantBeAttachedBy(MageObject source, Game game);
|
||||
/**
|
||||
* @param source
|
||||
* @param game
|
||||
* @param silentMode - use it to ignore warning message for users (e.g. for checking only)
|
||||
* @return
|
||||
*/
|
||||
boolean cantBeAttachedBy(MageObject source, Game game, boolean silentMode);
|
||||
|
||||
boolean wasControlledFromStartOfControllerTurn();
|
||||
|
||||
|
|
@ -210,9 +215,8 @@ public interface Permanent extends Card, Controllable {
|
|||
void setMaxBlockedBy(int maxBlockedBy);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param defenderId id of planeswalker or player to attack - can be empty
|
||||
* to check generally
|
||||
* to check generally
|
||||
* @param game
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -282,7 +286,7 @@ public interface Permanent extends Card, Controllable {
|
|||
|
||||
/**
|
||||
* Get card that was imprinted on this one.
|
||||
*
|
||||
* <p>
|
||||
* Can be null if no card was imprinted.
|
||||
*
|
||||
* @return Imprinted card UUID.
|
||||
|
|
@ -358,8 +362,8 @@ public interface Permanent extends Card, Controllable {
|
|||
|
||||
void setCreateOrder(int createOrder);
|
||||
|
||||
default boolean isAttachedTo(UUID otherId){
|
||||
if(getAttachedTo() == null){
|
||||
default boolean isAttachedTo(UUID otherId) {
|
||||
if (getAttachedTo() == null) {
|
||||
return false;
|
||||
}
|
||||
return getAttachedTo().equals(otherId);
|
||||
|
|
|
|||
|
|
@ -1076,7 +1076,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean cantBeAttachedBy(MageObject source, Game game) {
|
||||
public boolean cantBeAttachedBy(MageObject source, Game game, boolean silentMode) {
|
||||
for (ProtectionAbility ability : this.getAbilities(game).getProtectionAbilities()) {
|
||||
if (!(source.hasSubtype(SubType.AURA, game)
|
||||
&& !ability.removesAuras())
|
||||
|
|
@ -1085,7 +1085,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
return game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(EventType.STAY_ATTACHED, objectId, source.getId(), null), null, game, false);
|
||||
return game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(EventType.STAY_ATTACHED, objectId, source.getId(), null), null, game, silentMode);
|
||||
}
|
||||
|
||||
protected boolean canDamage(MageObject source, Game game) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue