mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 13:32:06 -08:00
fixed an issue with modular keyword and LKI
This commit is contained in:
parent
440adfa18b
commit
8dde735851
2 changed files with 83 additions and 27 deletions
|
|
@ -1,8 +1,5 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.StaticAbility;
|
||||
import mage.abilities.common.DiesSourceTriggeredAbility;
|
||||
|
|
@ -20,14 +17,16 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetArtifactPermanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* 702.41. Modular
|
||||
*
|
||||
* <p>
|
||||
* 702.41a Modular represents both a static ability and a triggered ability.
|
||||
* "Modular N" means "This permanent enters the battlefield with N +1/+1
|
||||
* counters on it" and "When this permanent is put into a graveyard from the
|
||||
|
|
@ -35,7 +34,6 @@ import mage.util.CardUtil;
|
|||
* +1/+1 counter on this permanent." 702.41b If a creature has multiple
|
||||
* instances of modular, each one works separately.
|
||||
*
|
||||
*
|
||||
* @author Loki, LevelX2
|
||||
*/
|
||||
public class ModularAbility extends DiesSourceTriggeredAbility {
|
||||
|
|
@ -45,8 +43,9 @@ public class ModularAbility extends DiesSourceTriggeredAbility {
|
|||
static {
|
||||
filter.add(CardType.CREATURE.getPredicate());
|
||||
}
|
||||
private int amount;
|
||||
private boolean sunburst;
|
||||
|
||||
private final int amount;
|
||||
private final boolean sunburst;
|
||||
|
||||
public ModularAbility(Card card, int amount) {
|
||||
this(card, amount, false);
|
||||
|
|
@ -54,8 +53,7 @@ public class ModularAbility extends DiesSourceTriggeredAbility {
|
|||
|
||||
public ModularAbility(Card card, int amount, boolean sunburst) {
|
||||
super(new ModularDistributeCounterEffect(), true);
|
||||
Target target = new TargetArtifactPermanent(filter);
|
||||
this.addTarget(target);
|
||||
this.addTarget(new TargetArtifactPermanent(filter));
|
||||
this.amount = amount;
|
||||
this.sunburst = sunburst;
|
||||
if (sunburst) {
|
||||
|
|
@ -67,7 +65,7 @@ public class ModularAbility extends DiesSourceTriggeredAbility {
|
|||
}
|
||||
}
|
||||
|
||||
public ModularAbility(ModularAbility ability) {
|
||||
private ModularAbility(ModularAbility ability) {
|
||||
super(ability);
|
||||
this.amount = ability.amount;
|
||||
this.sunburst = ability.sunburst;
|
||||
|
|
@ -102,20 +100,19 @@ public class ModularAbility extends DiesSourceTriggeredAbility {
|
|||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ModularStaticAbility extends StaticAbility {
|
||||
|
||||
private String ruleText;
|
||||
private final String ruleText;
|
||||
|
||||
public ModularStaticAbility(int amount) {
|
||||
ModularStaticAbility(int amount) {
|
||||
super(Zone.ALL, new EntersBattlefieldEffect(new AddCountersSourceEffect(CounterType.P1P1.createInstance(amount))));
|
||||
ruleText = "This enters the battlefield with " + CardUtil.numberToText(amount, "a") + " +1/+1 counter" + (amount != 1 ? "s" : "") + " on it.";
|
||||
this.setRuleVisible(false);
|
||||
}
|
||||
|
||||
public ModularStaticAbility(final ModularStaticAbility ability) {
|
||||
private ModularStaticAbility(final ModularStaticAbility ability) {
|
||||
super(ability);
|
||||
this.ruleText = ability.ruleText;
|
||||
}
|
||||
|
|
@ -133,18 +130,12 @@ class ModularStaticAbility extends StaticAbility {
|
|||
|
||||
class ModularDistributeCounterEffect extends OneShotEffect {
|
||||
|
||||
private static final FilterArtifactPermanent filter = new FilterArtifactPermanent("artifact creature");
|
||||
|
||||
static {
|
||||
filter.add(CardType.CREATURE.getPredicate());
|
||||
}
|
||||
|
||||
public ModularDistributeCounterEffect() {
|
||||
ModularDistributeCounterEffect() {
|
||||
super(Outcome.BoostCreature);
|
||||
this.staticText = "you may put a +1/+1 counter on target artifact creature for each +1/+1 counter on this permanent";
|
||||
}
|
||||
|
||||
public ModularDistributeCounterEffect(final ModularDistributeCounterEffect effect) {
|
||||
private ModularDistributeCounterEffect(final ModularDistributeCounterEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
|
@ -155,7 +146,7 @@ class ModularDistributeCounterEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent sourcePermanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
||||
Permanent sourcePermanent = (Permanent) getValue("permanentLeftBattlefield");
|
||||
Permanent targetArtifact = game.getPermanent(targetPointer.getFirst(game, source));
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (sourcePermanent != null && targetArtifact != null && player != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue