mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
Questing Beast - fixed rollback error on damage prevent (#6116);
This commit is contained in:
parent
5cb040607e
commit
9cf1ee2f42
32 changed files with 260 additions and 223 deletions
|
@ -11,7 +11,9 @@ import mage.constants.CardType;
|
||||||
import mage.constants.ColoredManaSymbol;
|
import mage.constants.ColoredManaSymbol;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.common.TargetAnyTarget;
|
import mage.target.common.TargetAnyTarget;
|
||||||
|
@ -85,7 +87,7 @@ class AcolytesRewardEffect extends PreventionEffectImpl {
|
||||||
} else {
|
} else {
|
||||||
amount = 0;
|
amount = 0;
|
||||||
}
|
}
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getControllerId(), source.getSourceId(), source.getControllerId(), toPrevent, false);
|
GameEvent preventEvent = new PreventDamageEvent(source.getControllerId(), source.getSourceId(), source.getControllerId(), toPrevent, ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
|
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
|
||||||
if (targetCreature != null) {
|
if (targetCreature != null) {
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
package mage.cards.a;
|
package mage.cards.a;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
|
@ -16,17 +13,20 @@ import mage.constants.Duration;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.target.TargetSource;
|
import mage.target.TargetSource;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public final class AuriokReplica extends CardImpl {
|
public final class AuriokReplica extends CardImpl {
|
||||||
|
|
||||||
public AuriokReplica(UUID ownerId, CardSetInfo setInfo) {
|
public AuriokReplica(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{3}");
|
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{3}");
|
||||||
this.subtype.add(SubType.CLERIC);
|
this.subtype.add(SubType.CLERIC);
|
||||||
this.power = new MageInt(2);
|
this.power = new MageInt(2);
|
||||||
this.toughness = new MageInt(2);
|
this.toughness = new MageInt(2);
|
||||||
|
@ -77,7 +77,7 @@ class AuriokReplicaEffect extends PreventionEffectImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void preventDamage(GameEvent event, Ability source, UUID target, Game game) {
|
private void preventDamage(GameEvent event, Ability source, UUID target, Game game) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, target, source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(target, source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int damage = event.getAmount();
|
int damage = event.getAmount();
|
||||||
event.setAmount(0);
|
event.setAmount(0);
|
||||||
|
@ -88,9 +88,7 @@ class AuriokReplicaEffect extends PreventionEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (super.applies(event, source, game)) {
|
if (super.applies(event, source, game)) {
|
||||||
if (event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(this.getTargetPointer().getFirst(game, source))) {
|
return event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(this.getTargetPointer().getFirst(game, source));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.b;
|
package mage.cards.b;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
@ -13,10 +10,14 @@ import mage.cards.CardSetInfo;
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.GameEvent.EventType;
|
import mage.game.events.GameEvent.EventType;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author emerald000
|
* @author emerald000
|
||||||
*/
|
*/
|
||||||
|
@ -67,7 +68,7 @@ class BattletideAlchemistEffect extends PreventionEffectImpl {
|
||||||
int numberOfClericsControlled = new PermanentsOnBattlefieldCount(new FilterControlledCreaturePermanent(SubType.CLERIC, "Clerics")).calculate(game, source, this);
|
int numberOfClericsControlled = new PermanentsOnBattlefieldCount(new FilterControlledCreaturePermanent(SubType.CLERIC, "Clerics")).calculate(game, source, this);
|
||||||
int toPrevent = Math.min(numberOfClericsControlled, event.getAmount());
|
int toPrevent = Math.min(numberOfClericsControlled, event.getAmount());
|
||||||
if (toPrevent > 0 && controller.chooseUse(Outcome.PreventDamage, "Prevent " + toPrevent + " damage to " + targetPlayer.getName() + '?', source, game)) {
|
if (toPrevent > 0 && controller.chooseUse(Outcome.PreventDamage, "Prevent " + toPrevent + " damage to " + targetPlayer.getName() + '?', source, game)) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, targetPlayer.getId(), source.getSourceId(), source.getControllerId(), toPrevent, false);
|
GameEvent preventEvent = new PreventDamageEvent(targetPlayer.getId(), source.getSourceId(), source.getControllerId(), toPrevent, ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
if (event.getAmount() >= toPrevent) {
|
if (event.getAmount() >= toPrevent) {
|
||||||
event.setAmount(event.getAmount() - toPrevent);
|
event.setAmount(event.getAmount() - toPrevent);
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.b;
|
package mage.cards.b;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.PreventionEffectImpl;
|
import mage.abilities.effects.PreventionEffectImpl;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
@ -12,12 +10,15 @@ import mage.counters.CounterType;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
import mage.filter.predicate.mageobject.MulticoloredPredicate;
|
import mage.filter.predicate.mageobject.MulticoloredPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author TheElk801
|
* @author TheElk801
|
||||||
*/
|
*/
|
||||||
public final class BraceForImpact extends CardImpl {
|
public final class BraceForImpact extends CardImpl {
|
||||||
|
@ -69,7 +70,7 @@ class BraceForImpactPreventDamageTargetEffect extends PreventionEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int prevented = 0;
|
int prevented = 0;
|
||||||
int damage = event.getAmount();
|
int damage = event.getAmount();
|
||||||
|
@ -93,9 +94,7 @@ class BraceForImpactPreventDamageTargetEffect extends PreventionEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (!this.used && super.applies(event, source, game)) {
|
if (!this.used && super.applies(event, source, game)) {
|
||||||
if (source.getTargets().getFirstTarget().equals(event.getTargetId())) {
|
return source.getTargets().getFirstTarget().equals(event.getTargetId());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package mage.cards.c;
|
package mage.cards.c;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
@ -10,20 +9,21 @@ import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.common.TargetAnyTarget;
|
import mage.target.common.TargetAnyTarget;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class CandlesGlow extends CardImpl {
|
public final class CandlesGlow extends CardImpl {
|
||||||
|
|
||||||
public CandlesGlow(UUID ownerId, CardSetInfo setInfo) {
|
public CandlesGlow(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{W}");
|
||||||
this.subtype.add(SubType.ARCANE);
|
this.subtype.add(SubType.ARCANE);
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class CandlesGlowPreventDamageTargetEffect extends PreventionEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int prevented;
|
int prevented;
|
||||||
if (event.getAmount() >= this.amount) {
|
if (event.getAmount() >= this.amount) {
|
||||||
|
@ -103,9 +103,7 @@ class CandlesGlowPreventDamageTargetEffect extends PreventionEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (!this.used && super.applies(event, source, game)) {
|
if (!this.used && super.applies(event, source, game)) {
|
||||||
if (source.getTargets().getFirstTarget().equals(event.getTargetId())) {
|
return source.getTargets().getFirstTarget().equals(event.getTargetId());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.e;
|
package mage.cards.e;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility;
|
import mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
@ -15,7 +12,12 @@ import mage.constants.Duration;
|
||||||
import mage.constants.TargetController;
|
import mage.constants.TargetController;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Plopman
|
* @author Plopman
|
||||||
|
@ -57,7 +59,7 @@ class EnergyFieldEffect extends PreventionEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int damage = event.getAmount();
|
int damage = event.getAmount();
|
||||||
event.setAmount(0);
|
event.setAmount(0);
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.g;
|
package mage.cards.g;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
@ -9,17 +7,16 @@ import mage.abilities.effects.PreventionEffect;
|
||||||
import mage.abilities.effects.ReplacementEffectImpl;
|
import mage.abilities.effects.ReplacementEffectImpl;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.*;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.GameEvent.EventType;
|
import mage.game.events.GameEvent.EventType;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class GhostsOfTheInnocent extends CardImpl {
|
public final class GhostsOfTheInnocent extends CardImpl {
|
||||||
|
@ -81,7 +78,7 @@ class GhostsOfTheInnocentPreventDamageEffect extends ReplacementEffectImpl imple
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
int amount = (int) Math.ceil(event.getAmount() / 2.0);
|
int amount = (int) Math.ceil(event.getAmount() / 2.0);
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, event.getTargetId(), source.getSourceId(), source.getControllerId(), amount, false);
|
GameEvent preventEvent = new PreventDamageEvent(event.getTargetId(), source.getSourceId(), source.getControllerId(), amount, ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
event.setAmount(event.getAmount() - amount);
|
event.setAmount(event.getAmount() - amount);
|
||||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, event.getTargetId(), source.getSourceId(), source.getControllerId(), amount));
|
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, event.getTargetId(), source.getSourceId(), source.getControllerId(), amount));
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.g;
|
package mage.cards.g;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||||
|
@ -17,12 +15,15 @@ import mage.constants.Duration;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.GameEvent.EventType;
|
import mage.game.events.GameEvent.EventType;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author spjspj
|
* @author spjspj
|
||||||
*/
|
*/
|
||||||
public final class GideonsIntervention extends CardImpl {
|
public final class GideonsIntervention extends CardImpl {
|
||||||
|
@ -88,9 +89,7 @@ class GideonsInterventionCantCastEffect extends ContinuousRuleModifyingEffectImp
|
||||||
String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
|
String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
|
||||||
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
|
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
|
||||||
MageObject object = game.getObject(event.getSourceId());
|
MageObject object = game.getObject(event.getSourceId());
|
||||||
if (object != null && object.getName().equals(cardName)) {
|
return object != null && object.getName().equals(cardName);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +118,7 @@ class GideonsInterventionPreventAllDamageEffect extends PreventionEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int damage = event.getAmount();
|
int damage = event.getAmount();
|
||||||
event.setAmount(0);
|
event.setAmount(0);
|
||||||
|
|
|
@ -1,30 +1,28 @@
|
||||||
|
|
||||||
package mage.cards.g;
|
package mage.cards.g;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.ReplacementEffectImpl;
|
import mage.abilities.effects.ReplacementEffectImpl;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.*;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.DamageCreatureEvent;
|
import mage.game.events.DamageCreatureEvent;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author noxx
|
* @author noxx
|
||||||
*/
|
*/
|
||||||
public final class GloomSurgeon extends CardImpl {
|
public final class GloomSurgeon extends CardImpl {
|
||||||
|
|
||||||
public GloomSurgeon(UUID ownerId, CardSetInfo setInfo) {
|
public GloomSurgeon(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{B}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}");
|
||||||
this.subtype.add(SubType.SPIRIT);
|
this.subtype.add(SubType.SPIRIT);
|
||||||
|
|
||||||
this.power = new MageInt(2);
|
this.power = new MageInt(2);
|
||||||
|
@ -57,7 +55,7 @@ class GloomSurgeonEffect extends ReplacementEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int preventedDamage = event.getAmount();
|
int preventedDamage = event.getAmount();
|
||||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), preventedDamage));
|
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), preventedDamage));
|
||||||
|
@ -79,9 +77,7 @@ class GloomSurgeonEffect extends ReplacementEffectImpl {
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (event.getTargetId().equals(source.getSourceId())) {
|
if (event.getTargetId().equals(source.getSourceId())) {
|
||||||
DamageCreatureEvent damageEvent = (DamageCreatureEvent) event;
|
DamageCreatureEvent damageEvent = (DamageCreatureEvent) event;
|
||||||
if (damageEvent.isCombatDamage()) {
|
return damageEvent.isCombatDamage();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.g;
|
package mage.cards.g;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
|
@ -10,19 +8,18 @@ import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.PreventionEffectImpl;
|
import mage.abilities.effects.PreventionEffectImpl;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.*;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.ComparisonType;
|
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
import mage.filter.predicate.mageobject.PowerPredicate;
|
import mage.filter.predicate.mageobject.PowerPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public final class Godtoucher extends CardImpl {
|
public final class Godtoucher extends CardImpl {
|
||||||
|
@ -34,7 +31,7 @@ public final class Godtoucher extends CardImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Godtoucher(UUID ownerId, CardSetInfo setInfo) {
|
public Godtoucher(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{G}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}");
|
||||||
this.subtype.add(SubType.ELF);
|
this.subtype.add(SubType.ELF);
|
||||||
this.subtype.add(SubType.CLERIC);
|
this.subtype.add(SubType.CLERIC);
|
||||||
|
|
||||||
|
@ -82,7 +79,7 @@ class GodtoucherEffect extends PreventionEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int damage = event.getAmount();
|
int damage = event.getAmount();
|
||||||
event.setAmount(0);
|
event.setAmount(0);
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.h;
|
package mage.cards.h;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
|
@ -10,21 +8,23 @@ import mage.abilities.keyword.FlashAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.SubType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.DamageEvent;
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author jeffwadsworth
|
* @author jeffwadsworth
|
||||||
*/
|
*/
|
||||||
public final class HazeFrog extends CardImpl {
|
public final class HazeFrog extends CardImpl {
|
||||||
|
|
||||||
public HazeFrog(UUID ownerId, CardSetInfo setInfo) {
|
public HazeFrog(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{G}{G}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{G}");
|
||||||
this.subtype.add(SubType.FROG);
|
this.subtype.add(SubType.FROG);
|
||||||
|
|
||||||
this.power = new MageInt(2);
|
this.power = new MageInt(2);
|
||||||
|
@ -70,7 +70,7 @@ class HazeFrogEffect extends PreventionEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int damage = event.getAmount();
|
int damage = event.getAmount();
|
||||||
Permanent permanent = game.getPermanent(event.getSourceId());
|
Permanent permanent = game.getPermanent(event.getSourceId());
|
||||||
|
@ -90,9 +90,7 @@ class HazeFrogEffect extends PreventionEffectImpl {
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (super.applies(event, source, game) && event instanceof DamageEvent) {
|
if (super.applies(event, source, game) && event instanceof DamageEvent) {
|
||||||
DamageEvent damageEvent = (DamageEvent) event;
|
DamageEvent damageEvent = (DamageEvent) event;
|
||||||
if (damageEvent.isCombatDamage() && !damageEvent.getSourceId().equals(source.getSourceId())) {
|
return damageEvent.isCombatDamage() && !damageEvent.getSourceId().equals(source.getSourceId());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.h;
|
package mage.cards.h;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.PreventionEffectImpl;
|
import mage.abilities.effects.PreventionEffectImpl;
|
||||||
|
@ -9,25 +7,24 @@ import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.*;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.DamageEvent;
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class HeartOfLight extends CardImpl {
|
public final class HeartOfLight extends CardImpl {
|
||||||
|
|
||||||
public HeartOfLight(UUID ownerId, CardSetInfo setInfo) {
|
public HeartOfLight(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
|
||||||
this.subtype.add(SubType.AURA);
|
this.subtype.add(SubType.AURA);
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,7 +72,7 @@ class HeartOfLightEffect extends PreventionEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int damage = event.getAmount();
|
int damage = event.getAmount();
|
||||||
event.setAmount(0);
|
event.setAmount(0);
|
||||||
|
@ -89,9 +86,7 @@ class HeartOfLightEffect extends PreventionEffectImpl {
|
||||||
if (super.applies(event, source, game) && event instanceof DamageEvent) {
|
if (super.applies(event, source, game) && event instanceof DamageEvent) {
|
||||||
Permanent aura = game.getPermanent(source.getSourceId());
|
Permanent aura = game.getPermanent(source.getSourceId());
|
||||||
if (aura != null && aura.getAttachedTo() != null) {
|
if (aura != null && aura.getAttachedTo() != null) {
|
||||||
if (event.getSourceId().equals(aura.getAttachedTo()) || event.getTargetId().equals(aura.getAttachedTo())) {
|
return event.getSourceId().equals(aura.getAttachedTo()) || event.getTargetId().equals(aura.getAttachedTo());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.i;
|
package mage.cards.i;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.StateTriggeredAbility;
|
import mage.abilities.StateTriggeredAbility;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
|
@ -21,18 +19,21 @@ import mage.constants.Outcome;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.filter.FilterCard;
|
import mage.filter.FilterCard;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.common.TargetCardInYourGraveyard;
|
import mage.target.common.TargetCardInYourGraveyard;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Plopman
|
* @author Plopman
|
||||||
*/
|
*/
|
||||||
public final class ImmortalCoil extends CardImpl {
|
public final class ImmortalCoil extends CardImpl {
|
||||||
|
|
||||||
public ImmortalCoil(UUID ownerId, CardSetInfo setInfo) {
|
public ImmortalCoil(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}{B}{B}");
|
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}{B}{B}");
|
||||||
|
|
||||||
// {tap}, Exile two cards from your graveyard: Draw a card.
|
// {tap}, Exile two cards from your graveyard: Draw a card.
|
||||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), new TapSourceCost());
|
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), new TapSourceCost());
|
||||||
|
@ -133,7 +134,7 @@ class PreventAllDamageToControllerEffect extends PreventionEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int damage = event.getAmount();
|
int damage = event.getAmount();
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
|
@ -157,9 +158,7 @@ class PreventAllDamageToControllerEffect extends PreventionEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (super.applies(event, source, game)) {
|
if (super.applies(event, source, game)) {
|
||||||
if (event.getTargetId().equals(source.getControllerId())) {
|
return event.getTargetId().equals(source.getControllerId());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.m;
|
package mage.cards.m;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.StaticAbility;
|
import mage.abilities.StaticAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
@ -13,25 +11,22 @@ import mage.abilities.keyword.EquipAbility;
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.AttachmentType;
|
import mage.constants.*;
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.DamageEvent;
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public final class MagebaneArmor extends CardImpl {
|
public final class MagebaneArmor extends CardImpl {
|
||||||
|
|
||||||
public MagebaneArmor(UUID ownerId, CardSetInfo setInfo) {
|
public MagebaneArmor(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{3}");
|
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
|
||||||
this.subtype.add(SubType.EQUIPMENT);
|
this.subtype.add(SubType.EQUIPMENT);
|
||||||
|
|
||||||
// Equipped creature gets +2/+4 and loses flying.
|
// Equipped creature gets +2/+4 and loses flying.
|
||||||
|
@ -99,7 +94,7 @@ class MagebaneArmorPreventionEffect extends PreventionEffectImpl {
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, equipment.getAttachedTo(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(equipment.getAttachedTo(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int damage = event.getAmount();
|
int damage = event.getAmount();
|
||||||
event.setAmount(0);
|
event.setAmount(0);
|
||||||
|
@ -114,10 +109,8 @@ class MagebaneArmorPreventionEffect extends PreventionEffectImpl {
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (super.applies(event, source, game) && !((DamageEvent) event).isCombatDamage()) {
|
if (super.applies(event, source, game) && !((DamageEvent) event).isCombatDamage()) {
|
||||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||||
if (equipment != null && equipment.getAttachedTo() != null
|
return equipment != null && equipment.getAttachedTo() != null
|
||||||
&& event.getTargetId().equals(equipment.getAttachedTo())) {
|
&& event.getTargetId().equals(equipment.getAttachedTo());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.p;
|
package mage.cards.p;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.PreventionEffectImpl;
|
import mage.abilities.effects.PreventionEffectImpl;
|
||||||
|
@ -11,16 +9,19 @@ import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author nantuko
|
* @author nantuko
|
||||||
*/
|
*/
|
||||||
public final class PersonalSanctuary extends CardImpl {
|
public final class PersonalSanctuary extends CardImpl {
|
||||||
|
|
||||||
public PersonalSanctuary(UUID ownerId, CardSetInfo setInfo) {
|
public PersonalSanctuary(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
|
||||||
|
|
||||||
|
|
||||||
// During your turn, prevent all damage that would be dealt to you.
|
// During your turn, prevent all damage that would be dealt to you.
|
||||||
|
@ -50,7 +51,7 @@ class PersonalSanctuaryEffect extends PreventionEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int damage = event.getAmount();
|
int damage = event.getAmount();
|
||||||
event.setAmount(0);
|
event.setAmount(0);
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
package mage.cards.p;
|
package mage.cards.p;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
@ -11,22 +8,25 @@ import mage.abilities.keyword.InfectAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.SubType;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public final class PhyrexianHydra extends CardImpl {
|
public final class PhyrexianHydra extends CardImpl {
|
||||||
|
|
||||||
public PhyrexianHydra(UUID ownerId, CardSetInfo setInfo) {
|
public PhyrexianHydra(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{G}{G}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{G}");
|
||||||
this.subtype.add(SubType.HYDRA);
|
this.subtype.add(SubType.HYDRA);
|
||||||
|
|
||||||
this.power = new MageInt(7);
|
this.power = new MageInt(7);
|
||||||
|
@ -71,7 +71,7 @@ class PhyrexianHydraEffect extends PreventionEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
boolean retValue = false;
|
boolean retValue = false;
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
int damage = event.getAmount();
|
int damage = event.getAmount();
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
event.setAmount(0);
|
event.setAmount(0);
|
||||||
|
@ -88,9 +88,7 @@ class PhyrexianHydraEffect extends PreventionEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (super.applies(event, source, game)) {
|
if (super.applies(event, source, game)) {
|
||||||
if (event.getTargetId().equals(source.getSourceId())) {
|
return event.getTargetId().equals(source.getSourceId());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.p;
|
package mage.cards.p;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
@ -12,25 +10,24 @@ import mage.abilities.effects.PreventionEffectImpl;
|
||||||
import mage.abilities.keyword.ProtectionAbility;
|
import mage.abilities.keyword.ProtectionAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.*;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.filter.FilterObject;
|
import mage.filter.FilterObject;
|
||||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.target.TargetSource;
|
import mage.target.TargetSource;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author cbt33, Plopman (Circle of Protection: Red)
|
* @author cbt33, Plopman (Circle of Protection: Red)
|
||||||
*/
|
*/
|
||||||
public final class PilgrimOfJustice extends CardImpl {
|
public final class PilgrimOfJustice extends CardImpl {
|
||||||
|
|
||||||
public PilgrimOfJustice(UUID ownerId, CardSetInfo setInfo) {
|
public PilgrimOfJustice(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}");
|
||||||
this.subtype.add(SubType.HUMAN);
|
this.subtype.add(SubType.HUMAN);
|
||||||
this.subtype.add(SubType.CLERIC);
|
this.subtype.add(SubType.CLERIC);
|
||||||
|
|
||||||
|
@ -58,15 +55,17 @@ public final class PilgrimOfJustice extends CardImpl {
|
||||||
class PilgrimOfJusticeEffect extends PreventionEffectImpl {
|
class PilgrimOfJusticeEffect extends PreventionEffectImpl {
|
||||||
|
|
||||||
private static final FilterObject filter = new FilterObject("red source");
|
private static final FilterObject filter = new FilterObject("red source");
|
||||||
static{
|
|
||||||
|
static {
|
||||||
filter.add(new ColorPredicate(ObjectColor.RED));
|
filter.add(new ColorPredicate(ObjectColor.RED));
|
||||||
}
|
}
|
||||||
|
|
||||||
private TargetSource target;
|
private TargetSource target;
|
||||||
|
|
||||||
public PilgrimOfJusticeEffect() {
|
public PilgrimOfJusticeEffect() {
|
||||||
super(Duration.EndOfTurn);
|
super(Duration.EndOfTurn);
|
||||||
target = new TargetSource(filter);
|
target = new TargetSource(filter);
|
||||||
|
|
||||||
staticText = "The next time a red source of your choice would deal damage to you this turn, prevent that damage";
|
staticText = "The next time a red source of your choice would deal damage to you this turn, prevent that damage";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +99,7 @@ class PilgrimOfJusticeEffect extends PreventionEffectImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void preventDamage(GameEvent event, Ability source, UUID target, Game game) {
|
private void preventDamage(GameEvent event, Ability source, UUID target, Game game) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, target, source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(target, source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int damage = event.getAmount();
|
int damage = event.getAmount();
|
||||||
event.setAmount(0);
|
event.setAmount(0);
|
||||||
|
@ -112,9 +111,7 @@ class PilgrimOfJusticeEffect extends PreventionEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (!this.used && super.applies(event, source, game)) {
|
if (!this.used && super.applies(event, source, game)) {
|
||||||
if (event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(target.getFirstTarget())) {
|
return event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(target.getFirstTarget());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.p;
|
package mage.cards.p;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
@ -12,25 +10,24 @@ import mage.abilities.effects.PreventionEffectImpl;
|
||||||
import mage.abilities.keyword.ProtectionAbility;
|
import mage.abilities.keyword.ProtectionAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.*;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.filter.FilterObject;
|
import mage.filter.FilterObject;
|
||||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.target.TargetSource;
|
import mage.target.TargetSource;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author cbt33, Plopman (Circle of Protection: Red)
|
* @author cbt33, Plopman (Circle of Protection: Red)
|
||||||
*/
|
*/
|
||||||
public final class PilgrimOfVirtue extends CardImpl {
|
public final class PilgrimOfVirtue extends CardImpl {
|
||||||
|
|
||||||
public PilgrimOfVirtue(UUID ownerId, CardSetInfo setInfo) {
|
public PilgrimOfVirtue(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}");
|
||||||
this.subtype.add(SubType.HUMAN);
|
this.subtype.add(SubType.HUMAN);
|
||||||
this.subtype.add(SubType.CLERIC);
|
this.subtype.add(SubType.CLERIC);
|
||||||
|
|
||||||
|
@ -62,6 +59,7 @@ class PilgrimOfVirtueEffect extends PreventionEffectImpl {
|
||||||
static {
|
static {
|
||||||
filter.add(new ColorPredicate(ObjectColor.BLACK));
|
filter.add(new ColorPredicate(ObjectColor.BLACK));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final TargetSource target;
|
private final TargetSource target;
|
||||||
|
|
||||||
public PilgrimOfVirtueEffect() {
|
public PilgrimOfVirtueEffect() {
|
||||||
|
@ -101,7 +99,7 @@ class PilgrimOfVirtueEffect extends PreventionEffectImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void preventDamage(GameEvent event, Ability source, UUID target, Game game) {
|
private void preventDamage(GameEvent event, Ability source, UUID target, Game game) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, target, source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(target, source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int damage = event.getAmount();
|
int damage = event.getAmount();
|
||||||
event.setAmount(0);
|
event.setAmount(0);
|
||||||
|
@ -113,9 +111,7 @@ class PilgrimOfVirtueEffect extends PreventionEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (!this.used && super.applies(event, source, game)) {
|
if (!this.used && super.applies(event, source, game)) {
|
||||||
if (event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(target.getFirstTarget())) {
|
return event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(target.getFirstTarget());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,9 @@ import mage.filter.common.FilterPlaneswalkerPermanent;
|
||||||
import mage.filter.predicate.mageobject.PowerPredicate;
|
import mage.filter.predicate.mageobject.PowerPredicate;
|
||||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.DamageEvent;
|
|
||||||
import mage.game.events.DamagedEvent;
|
import mage.game.events.DamagedEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
|
@ -101,7 +101,7 @@ class QuestingBeastPreventionEffect extends ContinuousRuleModifyingEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (!((DamageEvent) event).isCombatDamage()) {
|
if (!((PreventDamageEvent) event).isCombatDamage()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Permanent permanent = game.getPermanent(event.getSourceId());
|
Permanent permanent = game.getPermanent(event.getSourceId());
|
||||||
|
|
|
@ -11,7 +11,9 @@ import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -72,7 +74,7 @@ class ShieldOfTheAvatarPreventionEffect extends PreventionEffectImpl {
|
||||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||||
int numberOfCreaturesControlled = CreaturesYouControlCount.instance.calculate(game, source, this);
|
int numberOfCreaturesControlled = CreaturesYouControlCount.instance.calculate(game, source, this);
|
||||||
int toPrevent = Math.min(numberOfCreaturesControlled, event.getAmount());
|
int toPrevent = Math.min(numberOfCreaturesControlled, event.getAmount());
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, equipment.getAttachedTo(), source.getSourceId(), source.getControllerId(), toPrevent, false);
|
GameEvent preventEvent = new PreventDamageEvent(equipment.getAttachedTo(), source.getSourceId(), source.getControllerId(), toPrevent, ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
if (event.getAmount() >= toPrevent) {
|
if (event.getAmount() >= toPrevent) {
|
||||||
event.setAmount(event.getAmount() - toPrevent);
|
event.setAmount(event.getAmount() - toPrevent);
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.s;
|
package mage.cards.s;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
@ -11,21 +9,24 @@ import mage.abilities.effects.PreventionEffectImpl;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.SubType;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class StonewiseFortifier extends CardImpl {
|
public final class StonewiseFortifier extends CardImpl {
|
||||||
|
|
||||||
public StonewiseFortifier(UUID ownerId, CardSetInfo setInfo) {
|
public StonewiseFortifier(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}");
|
||||||
this.subtype.add(SubType.HUMAN);
|
this.subtype.add(SubType.HUMAN);
|
||||||
this.subtype.add(SubType.WIZARD);
|
this.subtype.add(SubType.WIZARD);
|
||||||
|
|
||||||
|
@ -71,7 +72,7 @@ class StonewiseFortifierPreventAllDamageToEffect extends PreventionEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, event.getTargetId(), event.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(event.getTargetId(), event.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int preventedDamage = event.getAmount();
|
int preventedDamage = event.getAmount();
|
||||||
MageObject damageSource = game.getObject(event.getSourceId());
|
MageObject damageSource = game.getObject(event.getSourceId());
|
||||||
|
@ -91,9 +92,7 @@ class StonewiseFortifierPreventAllDamageToEffect extends PreventionEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (super.applies(event, source, game) && event.getTargetId().equals(source.getSourceId())) {
|
if (super.applies(event, source, game) && event.getTargetId().equals(source.getSourceId())) {
|
||||||
if (event.getSourceId().equals(targetPointer.getFirst(game, source))) {
|
return event.getSourceId().equals(targetPointer.getFirst(game, source));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.t;
|
package mage.cards.t;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.dynamicvalue.DynamicValue;
|
import mage.abilities.dynamicvalue.DynamicValue;
|
||||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||||
|
@ -12,12 +10,15 @@ import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author TheElk801
|
* @author TheElk801
|
||||||
*/
|
*/
|
||||||
public final class Temper extends CardImpl {
|
public final class Temper extends CardImpl {
|
||||||
|
@ -76,7 +77,7 @@ class TemperPreventDamageTargetEffect extends PreventionEffectImpl {
|
||||||
amount = dVal.calculate(game, source, this);
|
amount = dVal.calculate(game, source, this);
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int prevented = 0;
|
int prevented = 0;
|
||||||
if (event.getAmount() >= this.amount) {
|
if (event.getAmount() >= this.amount) {
|
||||||
|
@ -109,9 +110,7 @@ class TemperPreventDamageTargetEffect extends PreventionEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (!this.used && super.applies(event, source, game)) {
|
if (!this.used && super.applies(event, source, game)) {
|
||||||
if (source.getTargets().getFirstTarget().equals(event.getTargetId())) {
|
return source.getTargets().getFirstTarget().equals(event.getTargetId());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.t;
|
package mage.cards.t;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.PreventionEffectImpl;
|
import mage.abilities.effects.PreventionEffectImpl;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
@ -10,18 +8,21 @@ import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class TestOfFaith extends CardImpl {
|
public final class TestOfFaith extends CardImpl {
|
||||||
|
|
||||||
public TestOfFaith(UUID ownerId, CardSetInfo setInfo) {
|
public TestOfFaith(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{W}");
|
||||||
|
|
||||||
// Prevent the next 3 damage that would be dealt to target creature this turn. For each 1 damage prevented this way, put a +1/+1 counter on that creature.
|
// Prevent the next 3 damage that would be dealt to target creature this turn. For each 1 damage prevented this way, put a +1/+1 counter on that creature.
|
||||||
this.getSpellAbility().addEffect(new TestOfFaithPreventDamageTargetEffect(Duration.EndOfTurn));
|
this.getSpellAbility().addEffect(new TestOfFaithPreventDamageTargetEffect(Duration.EndOfTurn));
|
||||||
|
@ -64,7 +65,7 @@ class TestOfFaithPreventDamageTargetEffect extends PreventionEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int prevented = 0;
|
int prevented = 0;
|
||||||
if (event.getAmount() >= this.amount) {
|
if (event.getAmount() >= this.amount) {
|
||||||
|
@ -97,9 +98,7 @@ class TestOfFaithPreventDamageTargetEffect extends PreventionEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (!this.used && super.applies(event, source, game)) {
|
if (!this.used && super.applies(event, source, game)) {
|
||||||
if (source.getTargets().getFirstTarget().equals(event.getTargetId())) {
|
return source.getTargets().getFirstTarget().equals(event.getTargetId());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.u;
|
package mage.cards.u;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.EntersBattlefieldAbility;
|
import mage.abilities.common.EntersBattlefieldAbility;
|
||||||
|
@ -16,18 +14,21 @@ import mage.filter.common.FilterCreatureCard;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward
|
* @author BetaSteward
|
||||||
*/
|
*/
|
||||||
public final class UnbreathingHorde extends CardImpl {
|
public final class UnbreathingHorde extends CardImpl {
|
||||||
|
|
||||||
public UnbreathingHorde(UUID ownerId, CardSetInfo setInfo) {
|
public UnbreathingHorde(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{B}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}");
|
||||||
this.subtype.add(SubType.ZOMBIE);
|
this.subtype.add(SubType.ZOMBIE);
|
||||||
|
|
||||||
this.power = new MageInt(0);
|
this.power = new MageInt(0);
|
||||||
|
@ -115,7 +116,7 @@ class UnbreathingHordeEffect2 extends PreventionEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
boolean retValue = false;
|
boolean retValue = false;
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
int damage = event.getAmount();
|
int damage = event.getAmount();
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
event.setAmount(0);
|
event.setAmount(0);
|
||||||
|
@ -132,9 +133,7 @@ class UnbreathingHordeEffect2 extends PreventionEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (super.applies(event, source, game)) {
|
if (super.applies(event, source, game)) {
|
||||||
if (event.getTargetId().equals(source.getSourceId())) {
|
return event.getTargetId().equals(source.getSourceId());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.v;
|
package mage.cards.v;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.PutIntoGraveFromAnywhereSourceTriggeredAbility;
|
import mage.abilities.common.PutIntoGraveFromAnywhereSourceTriggeredAbility;
|
||||||
|
@ -11,24 +9,23 @@ import mage.abilities.effects.common.ShuffleIntoLibrarySourceEffect;
|
||||||
import mage.abilities.keyword.TrampleAbility;
|
import mage.abilities.keyword.TrampleAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.*;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author emerald000
|
* @author emerald000
|
||||||
*/
|
*/
|
||||||
public final class Vigor extends CardImpl {
|
public final class Vigor extends CardImpl {
|
||||||
|
|
||||||
public Vigor(UUID ownerId, CardSetInfo setInfo) {
|
public Vigor(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{G}{G}{G}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{G}{G}");
|
||||||
this.subtype.add(SubType.ELEMENTAL);
|
this.subtype.add(SubType.ELEMENTAL);
|
||||||
this.subtype.add(SubType.INCARNATION);
|
this.subtype.add(SubType.INCARNATION);
|
||||||
|
|
||||||
|
@ -37,10 +34,10 @@ public final class Vigor extends CardImpl {
|
||||||
|
|
||||||
// Trample
|
// Trample
|
||||||
this.addAbility(TrampleAbility.getInstance());
|
this.addAbility(TrampleAbility.getInstance());
|
||||||
|
|
||||||
// If damage would be dealt to a creature you control other than Vigor, prevent that damage. Put a +1/+1 counter on that creature for each 1 damage prevented this way.
|
// If damage would be dealt to a creature you control other than Vigor, prevent that damage. Put a +1/+1 counter on that creature for each 1 damage prevented this way.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new VigorReplacementEffect()));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new VigorReplacementEffect()));
|
||||||
|
|
||||||
// When Vigor is put into a graveyard from anywhere, shuffle it into its owner's library.
|
// When Vigor is put into a graveyard from anywhere, shuffle it into its owner's library.
|
||||||
this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new ShuffleIntoLibrarySourceEffect()));
|
this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new ShuffleIntoLibrarySourceEffect()));
|
||||||
}
|
}
|
||||||
|
@ -68,7 +65,7 @@ class VigorReplacementEffect extends ReplacementEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int preventedDamage = event.getAmount();
|
int preventedDamage = event.getAmount();
|
||||||
event.setAmount(0);
|
event.setAmount(0);
|
||||||
|
@ -81,15 +78,15 @@ class VigorReplacementEffect extends ReplacementEffectImpl {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checksEventType(GameEvent event, Game game) {
|
public boolean checksEventType(GameEvent event, Game game) {
|
||||||
return event.getType() == GameEvent.EventType.DAMAGE_CREATURE;
|
return event.getType() == GameEvent.EventType.DAMAGE_CREATURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
return event.getPlayerId().equals(source.getControllerId())
|
return event.getPlayerId().equals(source.getControllerId())
|
||||||
&& !event.getTargetId().equals(source.getSourceId());
|
&& !event.getTargetId().equals(source.getSourceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,4 +134,60 @@ public class ConditionalPreventionTest extends CardTestPlayerBase {
|
||||||
assertHandCount(playerA, "Lightning Bolt", 0);
|
assertHandCount(playerA, "Lightning Bolt", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_PrentableCombatDamage() {
|
||||||
|
// Prevent all damage that would be dealt to creatures.
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Bubble Matrix", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 1);
|
||||||
|
//
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Balduvian Bears", 1);
|
||||||
|
|
||||||
|
// player A must do damage
|
||||||
|
attack(1, playerA, "Balduvian Bears", playerB);
|
||||||
|
|
||||||
|
// player B can't do damage (bears must block and safe)
|
||||||
|
attack(4, playerB, "Balduvian Bears", playerA);
|
||||||
|
block(4, playerA, "Balduvian Bears", "Balduvian Bears");
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
setStopAt(4, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
|
assertPermanentCount(playerA, "Balduvian Bears", 1);
|
||||||
|
assertPermanentCount(playerB, "Balduvian Bears", 1);
|
||||||
|
assertLife(playerA, 20);
|
||||||
|
assertLife(playerB, 20 - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_UnpreventableCombatDamage() {
|
||||||
|
// Combat damage that would be dealt by creatures you control can't be prevented.
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Questing Beast", 1);
|
||||||
|
//
|
||||||
|
// Prevent all damage that would be dealt to creatures.
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Bubble Matrix", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 1);
|
||||||
|
//
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Balduvian Bears", 1);
|
||||||
|
|
||||||
|
// player A must do damage
|
||||||
|
attack(1, playerA, "Balduvian Bears", playerB);
|
||||||
|
|
||||||
|
// player B must be prevented by Bubble Matrix, but can't (Questing Beast)
|
||||||
|
// a -> b -- can't do damage (matrix)
|
||||||
|
// b -> a -- can do damage (matrix -> quest)
|
||||||
|
attack(4, playerB, "Balduvian Bears", playerA);
|
||||||
|
block(4, playerA, "Balduvian Bears", "Balduvian Bears");
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
setStopAt(4, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
|
assertPermanentCount(playerA, "Balduvian Bears", 0);
|
||||||
|
assertPermanentCount(playerB, "Balduvian Bears", 1);
|
||||||
|
assertLife(playerA, 20);
|
||||||
|
assertLife(playerB, 20 - 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,17 +260,16 @@ public class LoadTest {
|
||||||
@Ignore
|
@Ignore
|
||||||
public void test_TwoAIPlayGame_Multiple() {
|
public void test_TwoAIPlayGame_Multiple() {
|
||||||
|
|
||||||
int singleGameSID = -1554824422; // for one game test with same deck
|
int singleGameSID = 0; // for one game test with same deck
|
||||||
int singleGamePlaysAmount = 1000; // multiple run of one game test
|
int gamesAmount = 1000; // multiple run of one game test
|
||||||
|
|
||||||
// save random seeds for repeated results (in decks generating)
|
// save random seeds for repeated results (in decks generating)
|
||||||
List<Integer> seedsList = new ArrayList<>();
|
List<Integer> seedsList = new ArrayList<>();
|
||||||
if (singleGameSID != 0) {
|
if (singleGameSID != 0) {
|
||||||
for (int i = 1; i <= singleGamePlaysAmount; i++) {
|
for (int i = 1; i <= gamesAmount; i++) {
|
||||||
seedsList.add(singleGameSID);
|
seedsList.add(singleGameSID);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int gamesAmount = 1000;
|
|
||||||
for (int i = 1; i <= gamesAmount; i++) {
|
for (int i = 1; i <= gamesAmount; i++) {
|
||||||
seedsList.add(RandomUtil.nextInt());
|
seedsList.add(RandomUtil.nextInt());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package mage.abilities.effects.common;
|
package mage.abilities.effects.common;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.Mode;
|
import mage.abilities.Mode;
|
||||||
|
@ -10,14 +7,19 @@ import mage.abilities.dynamicvalue.DynamicValue;
|
||||||
import mage.abilities.effects.PreventionEffectImpl;
|
import mage.abilities.effects.PreventionEffectImpl;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.PreventDamageEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.Target;
|
import mage.target.Target;
|
||||||
import mage.target.TargetAmount;
|
import mage.target.TargetAmount;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public class PreventDamageToTargetMultiAmountEffect extends PreventionEffectImpl {
|
public class PreventDamageToTargetMultiAmountEffect extends PreventionEffectImpl {
|
||||||
|
@ -77,7 +79,7 @@ public class PreventDamageToTargetMultiAmountEffect extends PreventionEffectImpl
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
int targetAmount = targetAmountMap.get(event.getTargetId());
|
int targetAmount = targetAmountMap.get(event.getTargetId());
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, event.getTargetId(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(event.getTargetId(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
if (event.getAmount() >= targetAmount) {
|
if (event.getAmount() >= targetAmount) {
|
||||||
int damage = targetAmount;
|
int damage = targetAmount;
|
||||||
|
|
|
@ -2638,7 +2638,7 @@ public abstract class GameImpl implements Game, Serializable {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
DamageEvent damageEvent = (DamageEvent) event;
|
DamageEvent damageEvent = (DamageEvent) event;
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, damageEvent.getTargetId(), damageEvent.getSourceId(), source.getControllerId(), damageEvent.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(damageEvent.getTargetId(), damageEvent.getSourceId(), source.getControllerId(), damageEvent.getAmount(), damageEvent.isCombatDamage());
|
||||||
if (game.replaceEvent(preventEvent)) {
|
if (game.replaceEvent(preventEvent)) {
|
||||||
result.setReplaced(true);
|
result.setReplaced(true);
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -22,6 +22,7 @@ public class GameEvent implements Serializable {
|
||||||
// for counters: event is result of effect (+1 from planeswalkers is cost, not effect)
|
// for counters: event is result of effect (+1 from planeswalkers is cost, not effect)
|
||||||
// for combat damage: event is preventable damage
|
// for combat damage: event is preventable damage
|
||||||
// for discard: event is result of effect (1) or result of cost (0)
|
// for discard: event is result of effect (1) or result of cost (0)
|
||||||
|
// for prevent damage: try to prevent combat damage (1) or other damage (0)
|
||||||
protected boolean flag;
|
protected boolean flag;
|
||||||
protected String data;
|
protected String data;
|
||||||
protected Zone zone;
|
protected Zone zone;
|
||||||
|
|
17
Mage/src/main/java/mage/game/events/PreventDamageEvent.java
Normal file
17
Mage/src/main/java/mage/game/events/PreventDamageEvent.java
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
package mage.game.events;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author JayDi85
|
||||||
|
*/
|
||||||
|
public class PreventDamageEvent extends GameEvent {
|
||||||
|
|
||||||
|
public PreventDamageEvent(UUID targetId, UUID sourceId, UUID playerId, int damageToPrevent, boolean isCombatDamage) {
|
||||||
|
super(EventType.PREVENT_DAMAGE, targetId, sourceId, playerId, damageToPrevent, isCombatDamage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCombatDamage() {
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package mage.game.permanent;
|
package mage.game.permanent;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
|
@ -38,6 +37,8 @@ import mage.util.GameLog;
|
||||||
import mage.util.ThreadLocalStringBuilder;
|
import mage.util.ThreadLocalStringBuilder;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
@ -761,7 +762,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
||||||
this.attachedTo = attachToObjectId;
|
this.attachedTo = attachToObjectId;
|
||||||
this.attachedToZoneChangeCounter = game.getState().getZoneChangeCounter(attachToObjectId);
|
this.attachedToZoneChangeCounter = game.getState().getZoneChangeCounter(attachToObjectId);
|
||||||
for (Ability ability : this.getAbilities()) {
|
for (Ability ability : this.getAbilities()) {
|
||||||
for (Iterator<Effect> ite = ability.getEffects(game, EffectType.CONTINUOUS).iterator(); ite.hasNext();) {
|
for (Iterator<Effect> ite = ability.getEffects(game, EffectType.CONTINUOUS).iterator(); ite.hasNext(); ) {
|
||||||
ContinuousEffect effect = (ContinuousEffect) ite.next();
|
ContinuousEffect effect = (ContinuousEffect) ite.next();
|
||||||
game.getContinuousEffects().setOrder(effect);
|
game.getContinuousEffects().setOrder(effect);
|
||||||
// It's important to update the timestamp of the copied effect in ContinuousEffects because it does the action
|
// It's important to update the timestamp of the copied effect in ContinuousEffects because it does the action
|
||||||
|
@ -816,8 +817,8 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
||||||
* @param game
|
* @param game
|
||||||
* @param preventable
|
* @param preventable
|
||||||
* @param combat
|
* @param combat
|
||||||
* @param markDamage If true, damage will be dealt later in applyDamage
|
* @param markDamage If true, damage will be dealt later in applyDamage
|
||||||
* method
|
* method
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private int damage(int damageAmount, UUID sourceId, Game game, boolean preventable, boolean combat, boolean markDamage, List<UUID> appliedEffects) {
|
private int damage(int damageAmount, UUID sourceId, Game game, boolean preventable, boolean combat, boolean markDamage, List<UUID> appliedEffects) {
|
||||||
|
@ -969,7 +970,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
||||||
private int checkProtectionAbilities(GameEvent event, UUID sourceId, Game game) {
|
private int checkProtectionAbilities(GameEvent event, UUID sourceId, Game game) {
|
||||||
MageObject source = game.getObject(sourceId);
|
MageObject source = game.getObject(sourceId);
|
||||||
if (source != null && hasProtectionFrom(source, game)) {
|
if (source != null && hasProtectionFrom(source, game)) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, this.objectId, sourceId, this.controllerId, event.getAmount(), false);
|
GameEvent preventEvent = new PreventDamageEvent(this.objectId, sourceId, this.controllerId, event.getAmount(), ((DamageEvent) event).isCombatDamage());
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
int preventedDamage = event.getAmount();
|
int preventedDamage = event.getAmount();
|
||||||
event.setAmount(0);
|
event.setAmount(0);
|
||||||
|
|
Loading…
Reference in a new issue