mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
fixed Yidaro, Wandering Monster
This commit is contained in:
parent
74a81c6f18
commit
599c5cf742
2 changed files with 16 additions and 10 deletions
|
@ -4,6 +4,8 @@ import mage.MageInt;
|
|||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.CycleTriggeredAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.Costs;
|
||||
import mage.abilities.costs.common.CyclingDiscardCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
@ -48,7 +50,7 @@ public final class YidaroWanderingMonster extends CardImpl {
|
|||
this.addAbility(new CyclingAbility(new ManaCostsImpl("{1}{R}")));
|
||||
|
||||
// When you cycle Yidaro, Wandering Monster, shuffle it into your library from your graveyard. If you've cycled a card named Yidaro, Wandering Monster four or more times this game, put it onto the battlefield from your graveyard instead.
|
||||
this.addAbility(new CycleTriggeredAbility(new YidaroWanderingMonsterEffect()));
|
||||
this.addAbility(new CycleTriggeredAbility(new YidaroWanderingMonsterEffect()), new YidaroWanderingMonsterWatcher());
|
||||
}
|
||||
|
||||
private YidaroWanderingMonster(final YidaroWanderingMonster card) {
|
||||
|
@ -85,8 +87,11 @@ class YidaroWanderingMonsterEffect extends OneShotEffect {
|
|||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
MageObjectReference cycledCard = source
|
||||
.getCosts()
|
||||
Costs<Cost> costs = (Costs) this.getValue("cycleCosts");
|
||||
if (costs == null) {
|
||||
return false;
|
||||
}
|
||||
MageObjectReference cycledCard = costs
|
||||
.stream()
|
||||
.filter(CyclingDiscardCost.class::isInstance)
|
||||
.map(CyclingDiscardCost.class::cast)
|
||||
|
@ -122,6 +127,9 @@ class YidaroWanderingMonsterWatcher extends Watcher {
|
|||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() != GameEvent.EventType.ACTIVATED_ABILITY) {
|
||||
return;
|
||||
}
|
||||
StackObject object = game.getStack().getStackObject(event.getSourceId());
|
||||
if (object == null || !(object.getStackAbility() instanceof CyclingAbility)) {
|
||||
return;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.effects.Effect;
|
||||
|
@ -10,7 +8,6 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.stack.StackObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Plopman
|
||||
*/
|
||||
public class CycleTriggeredAbility extends ZoneChangeTriggeredAbility {
|
||||
|
@ -34,9 +31,10 @@ public class CycleTriggeredAbility extends ZoneChangeTriggeredAbility {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if(event.getSourceId().equals(this.getSourceId())) {
|
||||
if (event.getSourceId().equals(this.getSourceId())) {
|
||||
StackObject object = game.getStack().getStackObject(event.getSourceId());
|
||||
if(object != null && object.getStackAbility() instanceof CyclingAbility){
|
||||
if (object != null && object.getStackAbility() instanceof CyclingAbility) {
|
||||
this.getEffects().setValue("cycleCosts", object.getStackAbility().getCosts());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue