mirror of
https://github.com/magefree/mage.git
synced 2026-01-24 20:29:19 -08:00
Reworked selected modes handling. That fixed the Subtle Strike targeting problem.
This commit is contained in:
parent
0b118d074e
commit
c9bb0be016
33 changed files with 163 additions and 131 deletions
|
|
@ -104,7 +104,8 @@ class ZadaHedronGrinderTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (isControlledInstantOrSorcery(spell)) {
|
||||
boolean targetsSource = false;
|
||||
for (Ability ability : spell.getSpellAbilities()) {
|
||||
for (Mode mode : ability.getModes().getSelectedModes()) {
|
||||
for (UUID modeId : ability.getModes().getSelectedModes()) {
|
||||
Mode mode = ability.getModes().get(modeId);
|
||||
for (Target target : mode.getTargets()) {
|
||||
if (!target.isNotTarget()) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
|
|
@ -167,7 +168,8 @@ class ZadaHedronGrinderEffect extends OneShotEffect {
|
|||
Target usedTarget = null;
|
||||
setUsedTarget:
|
||||
for (Ability ability : spell.getSpellAbilities()) {
|
||||
for (Mode mode : ability.getModes().getSelectedModes()) {
|
||||
for (UUID modeId : ability.getModes().getSelectedModes()) {
|
||||
Mode mode = ability.getModes().get(modeId);
|
||||
for (Target target : mode.getTargets()) {
|
||||
if (!target.isNotTarget() && target.getFirstTarget().equals(source.getSourceId())) {
|
||||
usedTarget = target.copy();
|
||||
|
|
@ -185,7 +187,8 @@ class ZadaHedronGrinderEffect extends OneShotEffect {
|
|||
Spell copy = spell.copySpell(source.getControllerId());
|
||||
game.getStack().push(copy);
|
||||
setTarget:
|
||||
for (Mode mode : copy.getSpellAbility().getModes().getSelectedModes()) {
|
||||
for (UUID modeId : copy.getSpellAbility().getModes().getSelectedModes()) {
|
||||
Mode mode = copy.getSpellAbility().getModes().get(modeId);
|
||||
for (Target target : mode.getTargets()) {
|
||||
if (target.getClass().equals(usedTarget.getClass())) {
|
||||
target.clearChosen(); // For targets with Max > 1 we need to clear before the text is comapred
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public class GoblinArtisans extends CardImpl {
|
|||
|
||||
// {tap}: Flip a coin. If you win the flip, draw a card. If you lose the flip, counter target artifact spell you control that isn't the target of an ability from another creature named Goblin Artisans.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new GoblinArtisansEffect(), new TapSourceCost()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public GoblinArtisans(final GoblinArtisans card) {
|
||||
|
|
@ -83,15 +83,14 @@ public class GoblinArtisans extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class GoblinArtisansEffect extends OneShotEffect {
|
||||
|
||||
private static final FilterPermanent filter = new FilterPermanent("permanent named Goblin Artisans");
|
||||
|
||||
|
||||
static {
|
||||
filter.add(new NamePredicate("Goblin Artisans"));
|
||||
}
|
||||
|
||||
|
||||
public GoblinArtisansEffect() {
|
||||
super(Outcome.Damage);
|
||||
staticText = "Flip a coin. If you win the flip, draw a card. If you lose the flip, counter target artifact spell you control that isn't the target of an ability from another creature named Goblin Artisans.";
|
||||
|
|
@ -109,37 +108,38 @@ class GoblinArtisansEffect extends OneShotEffect {
|
|||
controller.drawCards(1, game);
|
||||
} else {
|
||||
List<Permanent> artifacts = game.getBattlefield().getActivePermanents(new FilterControlledArtifactPermanent(), source.getControllerId(), game);
|
||||
if (artifacts.isEmpty()){//Don't even bother if there is no artifact to 'counter'/sacrifice
|
||||
if (artifacts.isEmpty()) {//Don't even bother if there is no artifact to 'counter'/sacrifice
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
filter.add(Predicates.not(new PermanentIdPredicate(source.getSourceId())));
|
||||
//removed the activating instance of Artisans, btw, wasn't that filter declared as static final? How come I can do this here? :)
|
||||
List<Permanent> list = game.getBattlefield().getAllActivePermanents(filter, game);
|
||||
for (Permanent perm : list){ // should I limit below for a particular kind of ability? Going for the most general, it's unlikely there'll be any other artisans anyway, so not concerned about efficiency :p
|
||||
for (Ability abil : perm.getAbilities(game)){//below is copied from TargetsPermanentPredicate, but why only "selectedModes"? Shouldnt be more general as well?
|
||||
for (Mode mode : abil.getModes().getSelectedModes()){
|
||||
//removed the activating instance of Artisans, btw, wasn't that filter declared as static final? How come I can do this here? :)
|
||||
List<Permanent> list = game.getBattlefield().getAllActivePermanents(filter, game);
|
||||
for (Permanent perm : list) { // should I limit below for a particular kind of ability? Going for the most general, it's unlikely there'll be any other artisans anyway, so not concerned about efficiency :p
|
||||
for (Ability abil : perm.getAbilities(game)) {//below is copied from TargetsPermanentPredicate, but why only "selectedModes"? Shouldnt be more general as well?
|
||||
for (UUID modeId : abil.getModes().getSelectedModes()) {
|
||||
Mode mode = abil.getModes().get(modeId);
|
||||
for (Target target : mode.getTargets()) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
artifacts.remove(game.getPermanentOrLKIBattlefield(targetId));
|
||||
}// we could
|
||||
}// remove this
|
||||
}//closing bracers
|
||||
}// pyramid, if it's bothering anyone
|
||||
} //they are all one-liners after all :)
|
||||
if (!artifacts.isEmpty()){
|
||||
Cards cards=new CardsImpl();
|
||||
for (Permanent perm : artifacts){
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
artifacts.remove(game.getPermanentOrLKIBattlefield(targetId));
|
||||
}// we could
|
||||
}// remove this
|
||||
}//closing bracers
|
||||
}// pyramid, if it's bothering anyone
|
||||
} //they are all one-liners after all :)
|
||||
if (!artifacts.isEmpty()) {
|
||||
Cards cards = new CardsImpl();
|
||||
for (Permanent perm : artifacts) {
|
||||
cards.add(perm.getId());
|
||||
}
|
||||
TargetCard target = new TargetCard(Zone.BATTLEFIELD, new FilterCard());
|
||||
TargetCard target = new TargetCard(Zone.BATTLEFIELD, new FilterCard());
|
||||
controller.choose(Outcome.Sacrifice, cards, target, game);
|
||||
game.getPermanent(target.getFirstTarget()).sacrifice(source.getSourceId(), game);
|
||||
}
|
||||
game.getPermanent(target.getFirstTarget()).sacrifice(source.getSourceId(), game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -227,7 +227,8 @@ class IcefallRegentCostIncreaseEffect extends CostModificationEffectImpl {
|
|||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if (abilityToModify instanceof SpellAbility) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) {
|
||||
for (Mode mode : abilityToModify.getModes().getSelectedModes()) {
|
||||
for (UUID modeId : abilityToModify.getModes().getSelectedModes()) {
|
||||
Mode mode = abilityToModify.getModes().get(modeId);
|
||||
for (Target target : mode.getTargets()) {
|
||||
for (UUID targetUUID : target.getTargets()) {
|
||||
if (targetUUID.equals(source.getSourceId())) {
|
||||
|
|
|
|||
|
|
@ -109,7 +109,8 @@ class MonasterySiegeCostIncreaseEffect extends CostModificationEffectImpl {
|
|||
if (new ModeChoiceSourceCondition("Dragons").apply(game, source)) {
|
||||
if (abilityToModify instanceof SpellAbility) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) {
|
||||
for (Mode mode : abilityToModify.getModes().getSelectedModes()) {
|
||||
for (UUID modeId : abilityToModify.getModes().getSelectedModes()) {
|
||||
Mode mode = abilityToModify.getModes().get(modeId);
|
||||
for (Target target : mode.getTargets()) {
|
||||
for (UUID targetUUID : target.getTargets()) {
|
||||
if (targetUUID.equals(source.getControllerId())) {
|
||||
|
|
|
|||
|
|
@ -141,7 +141,8 @@ class CapturedByTheConsulateTriggeredAbility extends TriggeredAbilityImpl {
|
|||
}
|
||||
if (stackObject != null) {
|
||||
int numberOfTargets = 0;
|
||||
for (Mode mode : stackObject.getStackAbility().getModes().getSelectedModes()) {
|
||||
for (UUID modeId : stackObject.getStackAbility().getModes().getSelectedModes()) {
|
||||
Mode mode = stackObject.getStackAbility().getModes().get(modeId);
|
||||
for (Target target : mode.getTargets()) {
|
||||
numberOfTargets += target.getTargets().size();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,7 +135,8 @@ class PsychicRebuttalPredicate implements ObjectPlayerPredicate<ObjectPlayer<Sta
|
|||
if (controllerId == null) {
|
||||
return false;
|
||||
}
|
||||
for (Mode mode : input.getObject().getStackAbility().getModes().getSelectedModes()) {
|
||||
for (UUID modeId : input.getObject().getStackAbility().getModes().getSelectedModes()) {
|
||||
Mode mode = input.getObject().getStackAbility().getModes().get(modeId);
|
||||
for (Target target : mode.getTargets()) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
if (controllerId.equals(targetId)) {
|
||||
|
|
|
|||
|
|
@ -106,7 +106,8 @@ class ElderwoodScionCostReductionEffect extends CostModificationEffectImpl {
|
|||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility) {
|
||||
if (abilityToModify.getControllerId().equals(source.getControllerId())) {
|
||||
for (Mode mode : abilityToModify.getModes().getSelectedModes()) {
|
||||
for (UUID modeId : abilityToModify.getModes().getSelectedModes()) {
|
||||
Mode mode = abilityToModify.getModes().get(modeId);
|
||||
for (Target target : mode.getTargets()) {
|
||||
for (UUID targetUUID : target.getTargets()) {
|
||||
if (targetUUID.equals(source.getSourceId())) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
package mage.sets.scourge;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -108,7 +107,8 @@ class GripOfChaosTriggeredAbility extends TriggeredAbilityImpl {
|
|||
}
|
||||
if (stackObject != null) {
|
||||
int numberOfTargets = 0;
|
||||
for (Mode mode : stackObject.getStackAbility().getModes().getSelectedModes()) {
|
||||
for (UUID modeId : stackObject.getStackAbility().getModes().getSelectedModes()) {
|
||||
Mode mode = stackObject.getStackAbility().getModes().get(modeId);
|
||||
for (Target target : mode.getTargets()) {
|
||||
numberOfTargets += target.getTargets().size();
|
||||
}
|
||||
|
|
@ -149,7 +149,8 @@ class GripOfChaosEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
StackObject stackObject = game.getStack().getStackObject(this.getTargetPointer().getFirst(game, source));
|
||||
if (stackObject != null) {
|
||||
for (Mode mode : stackObject.getStackAbility().getModes().getSelectedModes()) {
|
||||
for (UUID modeId : stackObject.getStackAbility().getModes().getSelectedModes()) {
|
||||
Mode mode = stackObject.getStackAbility().getModes().get(modeId);
|
||||
for (Target target : mode.getTargets()) {
|
||||
UUID oldTargetId = target.getFirstTarget();
|
||||
Set<UUID> possibleTargets = target.possibleTargets(source.getSourceId(), source.getControllerId(), game);
|
||||
|
|
|
|||
|
|
@ -140,7 +140,8 @@ class AccursedWitchSpellsCostReductionEffect extends CostModificationEffectImpl
|
|||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if (abilityToModify instanceof SpellAbility) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) {
|
||||
for (Mode mode : abilityToModify.getModes().getSelectedModes()) {
|
||||
for (UUID modeId : abilityToModify.getModes().getSelectedModes()) {
|
||||
Mode mode = abilityToModify.getModes().get(modeId);
|
||||
for (Target target : mode.getTargets()) {
|
||||
for (UUID targetUUID : target.getTargets()) {
|
||||
Permanent permanent = game.getPermanent(targetUUID);
|
||||
|
|
|
|||
|
|
@ -155,7 +155,8 @@ class InfectiousCurseCostReductionEffect extends CostModificationEffectImpl {
|
|||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if (abilityToModify instanceof SpellAbility) {
|
||||
if (source.getControllerId().equals(abilityToModify.getControllerId())) {
|
||||
for (Mode mode : abilityToModify.getModes().getSelectedModes()) {
|
||||
for (UUID modeId : abilityToModify.getModes().getSelectedModes()) {
|
||||
Mode mode = abilityToModify.getModes().get(modeId);
|
||||
for (Target target : mode.getTargets()) {
|
||||
for (UUID targetUUID : target.getTargets()) {
|
||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||
|
|
|
|||
|
|
@ -84,7 +84,8 @@ class HinderingLightPredicate implements ObjectPlayerPredicate<ObjectPlayer<Stac
|
|||
if (controllerId == null) {
|
||||
return false;
|
||||
}
|
||||
for (Mode mode : input.getObject().getStackAbility().getModes().getSelectedModes()) {
|
||||
for (UUID modeId : input.getObject().getStackAbility().getModes().getSelectedModes()) {
|
||||
Mode mode = input.getObject().getStackAbility().getModes().get(modeId);
|
||||
for (Target target : mode.getTargets()) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
if (controllerId.equals(targetId)) {
|
||||
|
|
|
|||
|
|
@ -113,13 +113,13 @@ class TorchlingTargetPredicate implements Predicate<MageObject> {
|
|||
if (spell != null) {
|
||||
int numberOfTargets = 0;
|
||||
for (SpellAbility spellAbility : spell.getSpellAbilities()) {
|
||||
for (Mode mode : spellAbility.getModes().getSelectedModes()) {
|
||||
for (UUID modeId : spellAbility.getModes().getSelectedModes()) {
|
||||
Mode mode = spellAbility.getModes().get(modeId);
|
||||
for (Target target : mode.getTargets()) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
if (!targetId.equals(sourceId)) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
numberOfTargets++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,8 @@ class KaerveksTorchCostIncreaseEffect extends CostModificationEffectImpl {
|
|||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility) {
|
||||
for (Mode mode : abilityToModify.getModes().getSelectedModes()) {
|
||||
for (UUID modeId : abilityToModify.getModes().getSelectedModes()) {
|
||||
Mode mode = abilityToModify.getModes().get(modeId);
|
||||
for (Target target : mode.getTargets()) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
if (targetId.equals(source.getSourceObject(game).getId())) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue