mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
[C21] Implemented Fractal Harness
This commit is contained in:
parent
2e5619e268
commit
1fad23b9fb
7 changed files with 152 additions and 131 deletions
|
|
@ -1,7 +1,6 @@
|
|||
|
||||
package mage.abilities.common;
|
||||
|
||||
import java.util.Locale;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.AttachmentType;
|
||||
|
|
@ -10,6 +9,8 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* "When enchanted/equipped creature attacks " triggered ability
|
||||
*
|
||||
|
|
@ -52,9 +53,8 @@ public class AttacksAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
Permanent equipment = game.getPermanent(this.sourceId);
|
||||
if (equipment != null && equipment.getAttachedTo() != null
|
||||
&& event.getSourceId().equals(equipment.getAttachedTo())) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setValue("sourceId", event.getSourceId());
|
||||
}
|
||||
getEffects().setValue("sourceId", event.getSourceId());
|
||||
getEffects().setValue("attachedPermanent", game.getPermanent(event.getSourceId()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -3,14 +3,20 @@ package mage.abilities.dynamicvalue.common;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.game.Game;
|
||||
import mage.watchers.common.ManaSpentToCastWatcher;
|
||||
|
||||
public enum ManacostVariableValue implements DynamicValue {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
return sourceAbility.getManaCostsToPay().getX();
|
||||
if (sourceAbility.getAbilityType() == AbilityType.SPELL) {
|
||||
return sourceAbility.getManaCostsToPay().getX();
|
||||
}
|
||||
ManaSpentToCastWatcher watcher = game.getState().getWatcher(ManaSpentToCastWatcher.class, sourceAbility.getSourceId());
|
||||
return watcher != null ? watcher.getAndResetLastXValue() : sourceAbility.getManaCostsToPay().getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import mage.watchers.Watcher;
|
|||
public class ManaSpentToCastWatcher extends Watcher {
|
||||
|
||||
private Mana payment = null;
|
||||
private Integer xValue = 0;
|
||||
|
||||
public ManaSpentToCastWatcher() {
|
||||
super(WatcherScope.CARD);
|
||||
|
|
@ -29,12 +30,14 @@ public class ManaSpentToCastWatcher extends Watcher {
|
|||
Spell spell = (Spell) game.getObject(event.getTargetId());
|
||||
if (spell != null && this.getSourceId().equals(spell.getSourceId())) {
|
||||
payment = spell.getSpellAbility().getManaCostsToPay().getUsedManaToPay();
|
||||
xValue = spell.getSpellAbility().getManaCostsToPay().getX();
|
||||
}
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE
|
||||
&& this.getSourceId().equals(event.getSourceId())) {
|
||||
if (((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
|
||||
payment = null;
|
||||
xValue = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -45,13 +48,16 @@ public class ManaSpentToCastWatcher extends Watcher {
|
|||
returnPayment = payment.copy();
|
||||
}
|
||||
return returnPayment;
|
||||
}
|
||||
|
||||
public int getAndResetLastXValue() {
|
||||
return xValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
payment = null;
|
||||
xValue = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue