mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
[filters] added WasDealtDamageThisTurn Predicate
This commit is contained in:
parent
badb0ede21
commit
50b650bb7d
7 changed files with 65 additions and 53 deletions
|
@ -42,6 +42,7 @@ import mage.abilities.keyword.BushidoAbility;
|
||||||
import mage.abilities.keyword.DoubleStrikeAbility;
|
import mage.abilities.keyword.DoubleStrikeAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
|
import mage.filter.predicate.permanent.WasDealtDamageThisTurnPredicate;
|
||||||
import mage.game.permanent.token.Token;
|
import mage.game.permanent.token.Token;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -54,8 +55,7 @@ public class BushiTenderfoot extends CardImpl<BushiTenderfoot> {
|
||||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that was dealt damage this turn");
|
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that was dealt damage this turn");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.setUseDamageDealt(true);
|
filter.add(new WasDealtDamageThisTurnPredicate());
|
||||||
filter.setDamageDealt(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BushiTenderfoot(UUID ownerId) {
|
public BushiTenderfoot(UUID ownerId) {
|
||||||
|
|
|
@ -36,6 +36,7 @@ import mage.Constants.Rarity;
|
||||||
import mage.abilities.effects.common.DamageTargetEffect;
|
import mage.abilities.effects.common.DamageTargetEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
|
import mage.filter.predicate.permanent.WasDealtDamageThisTurnPredicate;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,10 +46,11 @@ import mage.target.common.TargetCreaturePermanent;
|
||||||
public class CrushingPain extends CardImpl<CrushingPain> {
|
public class CrushingPain extends CardImpl<CrushingPain> {
|
||||||
|
|
||||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that was dealt damage this turn");
|
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that was dealt damage this turn");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.setUseDamageDealt(true);
|
filter.add(new WasDealtDamageThisTurnPredicate());
|
||||||
filter.setDamageDealt(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CrushingPain (UUID ownerId) {
|
public CrushingPain (UUID ownerId) {
|
||||||
super(ownerId, 162, "Crushing Pain", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{R}");
|
super(ownerId, 162, "Crushing Pain", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{R}");
|
||||||
this.expansionSetCode = "CHK";
|
this.expansionSetCode = "CHK";
|
||||||
|
|
|
@ -44,6 +44,7 @@ import mage.abilities.effects.common.DamageTargetEffect;
|
||||||
import mage.abilities.effects.common.FlipSourceEffect;
|
import mage.abilities.effects.common.FlipSourceEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
|
import mage.filter.predicate.permanent.WasDealtDamageThisTurnPredicate;
|
||||||
import mage.game.permanent.token.Token;
|
import mage.game.permanent.token.Token;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
@ -57,8 +58,7 @@ public class InitiateOfBlood extends CardImpl<InitiateOfBlood> {
|
||||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that was dealt damage this turn");
|
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that was dealt damage this turn");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.setUseDamageDealt(true);
|
filter.add(new WasDealtDamageThisTurnPredicate());
|
||||||
filter.setDamageDealt(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public InitiateOfBlood(UUID ownerId) {
|
public InitiateOfBlood(UUID ownerId) {
|
||||||
|
@ -98,8 +98,7 @@ class GokaTheUnjust extends Token {
|
||||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that was dealt damage this turn");
|
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that was dealt damage this turn");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.setUseDamageDealt(true);
|
filter.add(new WasDealtDamageThisTurnPredicate());
|
||||||
filter.setDamageDealt(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GokaTheUnjust() {
|
GokaTheUnjust() {
|
||||||
|
|
|
@ -38,6 +38,7 @@ import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
|
import mage.filter.predicate.permanent.WasDealtDamageThisTurnPredicate;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,15 +48,16 @@ import mage.target.common.TargetCreaturePermanent;
|
||||||
public class WitchsMist extends CardImpl<WitchsMist> {
|
public class WitchsMist extends CardImpl<WitchsMist> {
|
||||||
|
|
||||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that was dealt damage this turn");
|
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that was dealt damage this turn");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.setUseDamageDealt(true);
|
filter.add(new WasDealtDamageThisTurnPredicate());
|
||||||
filter.setDamageDealt(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public WitchsMist(UUID ownerId) {
|
public WitchsMist(UUID ownerId) {
|
||||||
super(ownerId, 92, "Witch's Mist", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}");
|
super(ownerId, 92, "Witch's Mist", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}");
|
||||||
this.expansionSetCode = "FUT";
|
this.expansionSetCode = "FUT";
|
||||||
this.color.setBlack(true);
|
this.color.setBlack(true);
|
||||||
|
|
||||||
// {2}{B}, {T}: Destroy target creature that was dealt damage this turn.
|
// {2}{B}, {T}: Destroy target creature that was dealt damage this turn.
|
||||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(),new ManaCostsImpl("{2}{B}"));
|
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(),new ManaCostsImpl("{2}{B}"));
|
||||||
ability.addTarget(new TargetCreaturePermanent(filter));
|
ability.addTarget(new TargetCreaturePermanent(filter));
|
||||||
|
|
|
@ -40,6 +40,7 @@ import mage.abilities.costs.common.TapSourceCost;
|
||||||
import mage.abilities.effects.common.DamageTargetEffect;
|
import mage.abilities.effects.common.DamageTargetEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
|
import mage.filter.predicate.permanent.WasDealtDamageThisTurnPredicate;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,8 +51,7 @@ public class Opportunist extends CardImpl<Opportunist> {
|
||||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that was dealt damage this turn");
|
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that was dealt damage this turn");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.setUseDamageDealt(true);
|
filter.add(new WasDealtDamageThisTurnPredicate());
|
||||||
filter.setDamageDealt(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Opportunist(UUID ownerId) {
|
public Opportunist(UUID ownerId) {
|
||||||
|
|
|
@ -31,8 +31,6 @@ package mage.filter.common;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -40,9 +38,6 @@ import mage.game.permanent.Permanent;
|
||||||
*/
|
*/
|
||||||
public class FilterCreaturePermanent extends FilterPermanent {
|
public class FilterCreaturePermanent extends FilterPermanent {
|
||||||
|
|
||||||
protected boolean useDamageDealt;
|
|
||||||
protected boolean damageDealt;
|
|
||||||
|
|
||||||
public FilterCreaturePermanent() {
|
public FilterCreaturePermanent() {
|
||||||
this("creature");
|
this("creature");
|
||||||
}
|
}
|
||||||
|
@ -54,41 +49,6 @@ public class FilterCreaturePermanent extends FilterPermanent {
|
||||||
|
|
||||||
public FilterCreaturePermanent(final FilterCreaturePermanent filter) {
|
public FilterCreaturePermanent(final FilterCreaturePermanent filter) {
|
||||||
super(filter);
|
super(filter);
|
||||||
this.useDamageDealt = filter.useDamageDealt;
|
|
||||||
this.damageDealt = filter.damageDealt;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean match(Permanent permanent, Game game) {
|
|
||||||
if (!super.match(permanent, game))
|
|
||||||
return notFilter;
|
|
||||||
|
|
||||||
if (useDamageDealt) {
|
|
||||||
// use this instead of getDamage() because damage is reset in case of regeneration
|
|
||||||
if (permanent.getDealtDamageByThisTurn().isEmpty()) {
|
|
||||||
return notFilter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return !notFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Select creatures dependant if they already got damage during the current turn. Works also if the creature was
|
|
||||||
* meanwhile regenerated during the turn.
|
|
||||||
*
|
|
||||||
* @param useDamageDealt
|
|
||||||
*/
|
|
||||||
public void setUseDamageDealt(boolean useDamageDealt) {
|
|
||||||
this.useDamageDealt = useDamageDealt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Select creatures that got damage dealt to this turn.
|
|
||||||
*
|
|
||||||
* @param damageDealt
|
|
||||||
*/
|
|
||||||
public void setDamageDealt(boolean damageDealt) {
|
|
||||||
this.damageDealt = damageDealt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.filter.predicate.permanent;
|
||||||
|
|
||||||
|
import mage.filter.predicate.Predicate;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author North
|
||||||
|
*/
|
||||||
|
public class WasDealtDamageThisTurnPredicate implements Predicate<Permanent> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Permanent input, Game game) {
|
||||||
|
return !input.getDealtDamageByThisTurn().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "WasDealtDamageThisTurn";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue