This commit is contained in:
jeffwadsworth 2020-02-27 13:26:25 -06:00
parent 4446f07306
commit 448d618a8a

View file

@ -1,4 +1,3 @@
package mage.cards.a;
import java.util.UUID;
@ -23,13 +22,15 @@ import mage.players.Player;
public final class AngelsGrace extends CardImpl {
public AngelsGrace(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{W}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{W}");
// Split second (As long as this spell is on the stack, players can't cast spells or activate abilities that aren't mana abilities.)
// Split second (As long as this spell is on the stack, players can't
// cast spells or activate abilities that aren't mana abilities.)
this.addAbility(new SplitSecondAbility());
// You can't lose the game this turn and your opponents can't win the game this turn. Until end of turn, damage that would reduce your life total to less than 1 reduces it to 1 instead.
// You can't lose the game this turn and your opponents can't win the
// game this turn. Until end of turn, damage that would reduce your
// life total to less than 1 reduces it to 1 instead.
this.getSpellAbility().addEffect(new AngelsGraceEffect());
this.getSpellAbility().addEffect(new AngelsGraceReplacementEffect());
}
@ -48,7 +49,8 @@ class AngelsGraceEffect extends ContinuousRuleModifyingEffectImpl {
public AngelsGraceEffect() {
super(Duration.EndOfTurn, Outcome.Benefit, false, false);
staticText = "You can't lose the game this turn and your opponents can't win the game this turn";
staticText = "You can't lose the game this turn "
+ "and your opponents can't win the game this turn";
}
public AngelsGraceEffect(final AngelsGraceEffect effect) {
@ -64,11 +66,13 @@ class AngelsGraceEffect extends ContinuousRuleModifyingEffectImpl {
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.WINS || event.getType() == EventType.LOSES;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return (event.getType() == EventType.WINS && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) ||
(event.getType() == EventType.LOSES && event.getPlayerId().equals(source.getControllerId()));
return (event.getType() == EventType.WINS
&& game.getOpponents(source.getControllerId()).contains(event.getPlayerId()))
|| (event.getType() == EventType.LOSES
&& event.getPlayerId().equals(source.getControllerId()));
}
}
@ -77,7 +81,8 @@ class AngelsGraceReplacementEffect extends ReplacementEffectImpl {
public AngelsGraceReplacementEffect() {
super(Duration.EndOfTurn, Outcome.Benefit);
staticText = "Until end of turn, damage that would reduce your life total to less than 1 reduces it to 1 instead";
staticText = "Until end of turn, damage that would reduce your "
+ "life total to less than 1 reduces it to 1 instead";
}
public AngelsGraceReplacementEffect(final AngelsGraceReplacementEffect effect) {
@ -94,13 +99,13 @@ class AngelsGraceReplacementEffect extends ReplacementEffectImpl {
return event.getType() == EventType.DAMAGE_CAUSES_LIFE_LOSS;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getPlayerId().equals(source.getControllerId())) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null
&& (controller.getLife() - event.getAmount()) < 1 ) {
&& controller.getLife() > 0
&& (controller.getLife() - event.getAmount()) < 1) {
event.setAmount(controller.getLife() - 1);
}
}