mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Implemented Yidaro, Wandering Monster
This commit is contained in:
parent
7e86626f1d
commit
297710c7fa
3 changed files with 154 additions and 9 deletions
139
Mage.Sets/src/mage/cards/y/YidaroWanderingMonster.java
Normal file
139
Mage.Sets/src/mage/cards/y/YidaroWanderingMonster.java
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
package mage.cards.y;
|
||||||
|
|
||||||
|
import mage.MageInt;
|
||||||
|
import mage.MageObjectReference;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.CycleTriggeredAbility;
|
||||||
|
import mage.abilities.costs.common.CyclingDiscardCost;
|
||||||
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.keyword.CyclingAbility;
|
||||||
|
import mage.abilities.keyword.HasteAbility;
|
||||||
|
import mage.abilities.keyword.TrampleAbility;
|
||||||
|
import mage.cards.Card;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.*;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.stack.StackObject;
|
||||||
|
import mage.players.Player;
|
||||||
|
import mage.watchers.Watcher;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author TheElk801
|
||||||
|
*/
|
||||||
|
public final class YidaroWanderingMonster extends CardImpl {
|
||||||
|
|
||||||
|
public YidaroWanderingMonster(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{R}{R}");
|
||||||
|
|
||||||
|
this.addSuperType(SuperType.LEGENDARY);
|
||||||
|
this.subtype.add(SubType.DINOSAUR);
|
||||||
|
this.subtype.add(SubType.TURTLE);
|
||||||
|
this.power = new MageInt(8);
|
||||||
|
this.toughness = new MageInt(8);
|
||||||
|
|
||||||
|
// Trample
|
||||||
|
this.addAbility(TrampleAbility.getInstance());
|
||||||
|
|
||||||
|
// Haste
|
||||||
|
this.addAbility(HasteAbility.getInstance());
|
||||||
|
|
||||||
|
// Cycling {1}{R}
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private YidaroWanderingMonster(final YidaroWanderingMonster card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public YidaroWanderingMonster copy() {
|
||||||
|
return new YidaroWanderingMonster(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class YidaroWanderingMonsterEffect extends OneShotEffect {
|
||||||
|
|
||||||
|
YidaroWanderingMonsterEffect() {
|
||||||
|
super(Outcome.Benefit);
|
||||||
|
staticText = "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.";
|
||||||
|
}
|
||||||
|
|
||||||
|
private YidaroWanderingMonsterEffect(final YidaroWanderingMonsterEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public YidaroWanderingMonsterEffect copy() {
|
||||||
|
return new YidaroWanderingMonsterEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
|
if (player == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
MageObjectReference cycledCard = source
|
||||||
|
.getCosts()
|
||||||
|
.stream()
|
||||||
|
.filter(CyclingDiscardCost.class::isInstance)
|
||||||
|
.map(CyclingDiscardCost.class::cast)
|
||||||
|
.map(CyclingDiscardCost::getCycledCard)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
if (cycledCard == null || game.getState().getZone(cycledCard.getSourceId()) != Zone.GRAVEYARD) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Card card = cycledCard.getCard(game);
|
||||||
|
if (card == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
YidaroWanderingMonsterWatcher watcher = game.getState().getWatcher(YidaroWanderingMonsterWatcher.class);
|
||||||
|
Zone zone;
|
||||||
|
if (watcher == null || watcher.getYidaroCount(player.getId()) < 4) {
|
||||||
|
player.putCardsOnBottomOfLibrary(card, game, source, true);
|
||||||
|
player.shuffleLibrary(source, game);
|
||||||
|
} else {
|
||||||
|
player.moveCards(card, Zone.BATTLEFIELD, source, game);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class YidaroWanderingMonsterWatcher extends Watcher {
|
||||||
|
|
||||||
|
private Map<UUID, Integer> countMap = new HashMap();
|
||||||
|
|
||||||
|
YidaroWanderingMonsterWatcher() {
|
||||||
|
super(WatcherScope.GAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void watch(GameEvent event, Game game) {
|
||||||
|
StackObject object = game.getStack().getStackObject(event.getSourceId());
|
||||||
|
if (object == null || !(object.getStackAbility() instanceof CyclingAbility)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Card card = game.getCard(object.getSourceId());
|
||||||
|
if (card != null && "Yidaro, Wandering Monster".equals(card.getName())) {
|
||||||
|
countMap.putIfAbsent(object.getControllerId(), 0);
|
||||||
|
countMap.compute(object.getControllerId(), (u, i) -> i + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int getYidaroCount(UUID playerId) {
|
||||||
|
return countMap.getOrDefault(playerId, 0);
|
||||||
|
}
|
||||||
|
}
|
|
@ -305,6 +305,7 @@ public final class IkoriaLairOfBehemoths extends ExpansionSet {
|
||||||
cards.add(new SetCardInfo("Wind-Scarred Crag", 258, Rarity.COMMON, mage.cards.w.WindScarredCrag.class));
|
cards.add(new SetCardInfo("Wind-Scarred Crag", 258, Rarity.COMMON, mage.cards.w.WindScarredCrag.class));
|
||||||
cards.add(new SetCardInfo("Wingfold Pteron", 71, Rarity.COMMON, mage.cards.w.WingfoldPteron.class));
|
cards.add(new SetCardInfo("Wingfold Pteron", 71, Rarity.COMMON, mage.cards.w.WingfoldPteron.class));
|
||||||
cards.add(new SetCardInfo("Wingspan Mentor", 72, Rarity.UNCOMMON, mage.cards.w.WingspanMentor.class));
|
cards.add(new SetCardInfo("Wingspan Mentor", 72, Rarity.UNCOMMON, mage.cards.w.WingspanMentor.class));
|
||||||
|
cards.add(new SetCardInfo("Yidaro, Wandering Monster", 141, Rarity.RARE, mage.cards.y.YidaroWanderingMonster.class));
|
||||||
cards.add(new SetCardInfo("Zagoth Crystal", 242, Rarity.UNCOMMON, mage.cards.z.ZagothCrystal.class));
|
cards.add(new SetCardInfo("Zagoth Crystal", 242, Rarity.UNCOMMON, mage.cards.z.ZagothCrystal.class));
|
||||||
cards.add(new SetCardInfo("Zagoth Mamba", 106, Rarity.UNCOMMON, mage.cards.z.ZagothMamba.class));
|
cards.add(new SetCardInfo("Zagoth Mamba", 106, Rarity.UNCOMMON, mage.cards.z.ZagothMamba.class));
|
||||||
cards.add(new SetCardInfo("Zagoth Triome", 259, Rarity.RARE, mage.cards.z.ZagothTriome.class));
|
cards.add(new SetCardInfo("Zagoth Triome", 259, Rarity.RARE, mage.cards.z.ZagothTriome.class));
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author jeffwadsworth
|
|
||||||
*/
|
|
||||||
|
|
||||||
package mage.abilities.costs.common;
|
package mage.abilities.costs.common;
|
||||||
|
|
||||||
import java.util.UUID;
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
import mage.abilities.costs.CostImpl;
|
import mage.abilities.costs.CostImpl;
|
||||||
|
@ -16,12 +9,19 @@ import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jeffwadsworth
|
||||||
|
*/
|
||||||
public class CyclingDiscardCost extends CostImpl {
|
public class CyclingDiscardCost extends CostImpl {
|
||||||
|
|
||||||
|
private MageObjectReference cycledCard = null;
|
||||||
|
|
||||||
public CyclingDiscardCost() {
|
public CyclingDiscardCost() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CyclingDiscardCost(CyclingDiscardCost cost) {
|
private CyclingDiscardCost(CyclingDiscardCost cost) {
|
||||||
super(cost);
|
super(cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ public class CyclingDiscardCost extends CostImpl {
|
||||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.CYCLE_CARD, card.getId(), card.getId(), card.getOwnerId()));
|
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.CYCLE_CARD, card.getId(), card.getId(), card.getOwnerId()));
|
||||||
paid = player.discard(card, null, game);
|
paid = player.discard(card, null, game);
|
||||||
if (paid) {
|
if (paid) {
|
||||||
|
cycledCard = new MageObjectReference(card, game);
|
||||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.CYCLED_CARD, card.getId(), card.getId(), card.getOwnerId()));
|
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.CYCLED_CARD, card.getId(), card.getId(), card.getOwnerId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,4 +56,8 @@ public class CyclingDiscardCost extends CostImpl {
|
||||||
public CyclingDiscardCost copy() {
|
public CyclingDiscardCost copy() {
|
||||||
return new CyclingDiscardCost(this);
|
return new CyclingDiscardCost(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MageObjectReference getCycledCard() {
|
||||||
|
return cycledCard;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue