mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
[SWS] Fixed No Contest.
This commit is contained in:
parent
a5b1db4ec1
commit
4619f45771
3 changed files with 79 additions and 12 deletions
|
@ -28,12 +28,12 @@
|
|||
package mage.sets.planechase2012;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
@ -49,7 +49,6 @@ public class RivalsDuel extends CardImpl {
|
|||
super(ownerId, 51, "Rivals' Duel", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{3}{R}");
|
||||
this.expansionSetCode = "PC2";
|
||||
|
||||
|
||||
// Choose two target creatures that share no creature types. Those creatures fight each other.
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanentWithDifferentTypes(2));
|
||||
this.getSpellAbility().addEffect(new RivalsDuelFightTargetsEffect());
|
||||
|
@ -114,7 +113,7 @@ class RivalsDuelFightTargetsEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
TargetCreaturePermanentWithDifferentTypes target = (TargetCreaturePermanentWithDifferentTypes) source.getTargets().get(0);
|
||||
Permanent creature1 = game.getPermanent(target.getFirstTarget());
|
||||
Permanent creature2 = game.getPermanent((UUID) target.getTargets().get(1));
|
||||
Permanent creature2 = game.getPermanent(target.getTargets().get(1));
|
||||
// 20110930 - 701.10
|
||||
if (creature1 != null && creature2 != null) {
|
||||
if (creature1.getCardType().contains(CardType.CREATURE) && creature2.getCardType().contains(CardType.CREATURE)) {
|
||||
|
|
|
@ -27,13 +27,22 @@
|
|||
*/
|
||||
package mage.sets.starwars;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.common.FightTargetsEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.PowerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -48,8 +57,8 @@ public class NoContest extends CardImpl {
|
|||
// Target creature you control fights target creature with power less than its power.
|
||||
this.getSpellAbility().addEffect(new FightTargetsEffect());
|
||||
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
||||
// NEEDS FILTER
|
||||
this.getSpellAbility().addTarget(new TargetCreatureWithLessPowerPermanent());
|
||||
|
||||
}
|
||||
|
||||
public NoContest(final NoContest card) {
|
||||
|
@ -61,3 +70,63 @@ public class NoContest extends CardImpl {
|
|||
return new NoContest(this);
|
||||
}
|
||||
}
|
||||
|
||||
class TargetCreatureWithLessPowerPermanent extends TargetPermanent {
|
||||
|
||||
public TargetCreatureWithLessPowerPermanent() {
|
||||
super(1, 1, new FilterCreaturePermanent("creature with power less than its power"), false);
|
||||
}
|
||||
|
||||
public TargetCreatureWithLessPowerPermanent(final TargetCreatureWithLessPowerPermanent target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
int maxPower = Integer.MIN_VALUE; // get the most poerful controlled creature that can be targeted
|
||||
Card sourceCard = game.getCard(sourceId);
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), sourceControllerId, game)) {
|
||||
if (permanent.getPower().getValue() > maxPower && permanent.canBeTargetedBy(sourceCard, sourceControllerId, game)) {
|
||||
maxPower = permanent.getPower().getValue();
|
||||
}
|
||||
}
|
||||
// now check, if another creature has less power and can be targeted
|
||||
FilterCreaturePermanent checkFilter = new FilterCreaturePermanent();
|
||||
checkFilter.add(new PowerPredicate(Filter.ComparisonType.LessThan, maxPower));
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(checkFilter, sourceControllerId, sourceId, game)) {
|
||||
if (permanent.canBeTargetedBy(sourceCard, sourceControllerId, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Spell spell = game.getStack().getSpell(sourceId);
|
||||
if (spell != null) {
|
||||
Permanent firstTarget = getPermanentFromFirstTarget(spell.getSpellAbility(), game);
|
||||
if (firstTarget != null) {
|
||||
int power = firstTarget.getPower().getValue();
|
||||
// overwrite the filter with the power predicate
|
||||
filter = new FilterCreaturePermanent("creature with power less than " + power);
|
||||
filter.add(new PowerPredicate(Filter.ComparisonType.LessThan, power));
|
||||
}
|
||||
}
|
||||
return super.possibleTargets(sourceId, sourceControllerId, game);
|
||||
}
|
||||
|
||||
private Permanent getPermanentFromFirstTarget(Ability source, Game game) {
|
||||
Permanent firstTarget = null;
|
||||
if (source.getTargets().size() == 2) {
|
||||
firstTarget = game.getPermanent(source.getTargets().get(0).getFirstTarget());
|
||||
}
|
||||
return firstTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetCreatureWithLessPowerPermanent copy() {
|
||||
return new TargetCreatureWithLessPowerPermanent(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,16 +27,15 @@
|
|||
*/
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import mage.constants.Duration;
|
||||
import java.io.ObjectStreamException;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.EvasionAbility;
|
||||
import mage.abilities.MageSingleton;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
|
@ -59,7 +58,7 @@ public class SpaceflightAbility extends EvasionAbility implements MageSingleton
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Spaceflight";
|
||||
return "Spaceflight <i>(This creature can only block or be blocked by creatures with spaceflight)</i>";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue