mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 21:42:07 -08:00
[CMR] Implemented Benevolent Blessing
This commit is contained in:
parent
b8feae7f3a
commit
319775c0b4
5 changed files with 104 additions and 7 deletions
|
|
@ -15,14 +15,14 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ProtectionChosenColorAttachedEffect extends ContinuousEffectImpl {
|
||||
|
||||
protected ObjectColor chosenColor;
|
||||
protected ProtectionAbility protectionAbility;
|
||||
protected boolean notRemoveItself;
|
||||
protected final boolean notRemoveItself;
|
||||
protected boolean notRemoveControlled;
|
||||
|
||||
public ProtectionChosenColorAttachedEffect(boolean notRemoveItself) {
|
||||
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
|
|
@ -59,6 +59,11 @@ public class ProtectionChosenColorAttachedEffect extends ContinuousEffectImpl {
|
|||
if (notRemoveItself) {
|
||||
protectionAbility.setAuraIdNotToBeRemoved(source.getSourceId());
|
||||
}
|
||||
if (notRemoveControlled) {
|
||||
protectionAbility.setDoesntRemoveControlled(true);
|
||||
protectionAbility.setRemoveEquipment(false);
|
||||
protectionAbility.setRemovesAuras(false);
|
||||
}
|
||||
}
|
||||
if (protectionAbility != null) {
|
||||
Permanent attachedTo = game.getPermanent(attachement.getAttachedTo());
|
||||
|
|
@ -70,4 +75,9 @@ public class ProtectionChosenColorAttachedEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ProtectionChosenColorAttachedEffect setNotRemoveControlled(boolean notRemoveControlled) {
|
||||
this.notRemoveControlled = notRemoveControlled;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ public class ProtectionAbility extends StaticAbility {
|
|||
|
||||
protected Filter filter;
|
||||
protected boolean removeAuras;
|
||||
protected boolean removeEquipment;
|
||||
protected boolean doesntRemoveControlled;
|
||||
protected static List<ObjectColor> colors = new ArrayList<>();
|
||||
protected UUID auraIdNotToBeRemoved; // defines an Aura objectId that will not be removed from this protection ability
|
||||
|
||||
|
|
@ -32,6 +34,8 @@ public class ProtectionAbility extends StaticAbility {
|
|||
super(Zone.BATTLEFIELD, null);
|
||||
this.filter = filter;
|
||||
this.removeAuras = true;
|
||||
this.removeEquipment = true;
|
||||
this.doesntRemoveControlled = false;
|
||||
this.auraIdNotToBeRemoved = null;
|
||||
}
|
||||
|
||||
|
|
@ -39,6 +43,8 @@ public class ProtectionAbility extends StaticAbility {
|
|||
super(ability);
|
||||
this.filter = ability.filter.copy();
|
||||
this.removeAuras = ability.removeAuras;
|
||||
this.removeEquipment = ability.removeEquipment;
|
||||
this.doesntRemoveControlled = ability.doesntRemoveControlled;
|
||||
this.auraIdNotToBeRemoved = ability.auraIdNotToBeRemoved;
|
||||
}
|
||||
|
||||
|
|
@ -97,14 +103,14 @@ public class ProtectionAbility extends StaticAbility {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Emrakul, the Aeons Torn
|
||||
if (filter instanceof FilterStackObject) {
|
||||
if (filter.match(source, game)) {
|
||||
return (!source.isInstantOrSorcery());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (filter instanceof FilterObject) {
|
||||
return !filter.match(source, game);
|
||||
}
|
||||
|
|
@ -138,6 +144,22 @@ public class ProtectionAbility extends StaticAbility {
|
|||
return removeAuras;
|
||||
}
|
||||
|
||||
public void setRemoveEquipment(boolean removeEquipment) {
|
||||
this.removeEquipment = removeEquipment;
|
||||
}
|
||||
|
||||
public boolean removesEquipment() {
|
||||
return removeEquipment;
|
||||
}
|
||||
|
||||
public void setDoesntRemoveControlled(boolean doesntRemoveControlled) {
|
||||
this.doesntRemoveControlled = doesntRemoveControlled;
|
||||
}
|
||||
|
||||
public boolean getDoesntRemoveControlled() {
|
||||
return doesntRemoveControlled;
|
||||
}
|
||||
|
||||
public List<ObjectColor> getColors() {
|
||||
return colors;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1104,9 +1104,12 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
for (ProtectionAbility ability : this.getAbilities(game).getProtectionAbilities()) {
|
||||
if (!(source.hasSubtype(SubType.AURA, game)
|
||||
&& !ability.removesAuras())
|
||||
&& !source.getId().equals(ability.getAuraIdNotToBeRemoved())
|
||||
&& !ability.canTarget(source, game)) {
|
||||
return true;
|
||||
&& !(source.hasSubtype(SubType.EQUIPMENT, game)
|
||||
&& !ability.removesEquipment())) {
|
||||
if (!source.getId().equals(ability.getAuraIdNotToBeRemoved())
|
||||
&& !ability.canTarget(source, game)) {
|
||||
return !ability.getDoesntRemoveControlled() || isControlledBy(game.getControllerId(source.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(EventType.STAY_ATTACHED, objectId, source.getId(), null), null, game, silentMode);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue