mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
[J22] Implement Goblin Researcher
This commit is contained in:
parent
be832e27b2
commit
ce44ba26aa
2 changed files with 123 additions and 0 deletions
122
Mage.Sets/src/mage/cards/g/GoblinResearcher.java
Normal file
122
Mage.Sets/src/mage/cards/g/GoblinResearcher.java
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
package mage.cards.g;
|
||||||
|
|
||||||
|
import mage.MageInt;
|
||||||
|
import mage.MageObjectReference;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
|
import mage.abilities.condition.Condition;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
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.players.Player;
|
||||||
|
import mage.util.CardUtil;
|
||||||
|
import mage.watchers.Watcher;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author TheElk801
|
||||||
|
*/
|
||||||
|
public final class GoblinResearcher extends CardImpl {
|
||||||
|
|
||||||
|
public GoblinResearcher(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}");
|
||||||
|
|
||||||
|
this.subtype.add(SubType.GOBLIN);
|
||||||
|
this.subtype.add(SubType.WIZARD);
|
||||||
|
this.power = new MageInt(3);
|
||||||
|
this.toughness = new MageInt(3);
|
||||||
|
|
||||||
|
// When Goblin Researcher enters the battlefield, exile the top card of your library. During any turn you attacked with Goblin Researcher, you may play that card.
|
||||||
|
this.addAbility(new EntersBattlefieldTriggeredAbility(new GoblinResearcherEffect()), new GoblinResearcherWatcher());
|
||||||
|
}
|
||||||
|
|
||||||
|
private GoblinResearcher(final GoblinResearcher card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GoblinResearcher copy() {
|
||||||
|
return new GoblinResearcher(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GoblinResearcherEffect extends OneShotEffect {
|
||||||
|
|
||||||
|
GoblinResearcherEffect() {
|
||||||
|
super(Outcome.Benefit);
|
||||||
|
staticText = "exile the top card of your library. " +
|
||||||
|
"During any turn you attacked with {this}, you may play that card";
|
||||||
|
}
|
||||||
|
|
||||||
|
private GoblinResearcherEffect(final GoblinResearcherEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GoblinResearcherEffect copy() {
|
||||||
|
return new GoblinResearcherEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
|
if (player == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Card card = player.getLibrary().getFromTop(game);
|
||||||
|
if (card == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
player.moveCards(card, Zone.EXILED, source, game);
|
||||||
|
CardUtil.makeCardPlayable(
|
||||||
|
game, source, card, Duration.Custom, false,
|
||||||
|
source.getControllerId(), GoblinResearcherCondition.instance
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum GoblinResearcherCondition implements Condition {
|
||||||
|
instance;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GoblinResearcherWatcher extends Watcher {
|
||||||
|
|
||||||
|
private final Map<MageObjectReference, Set<UUID>> map = new HashMap<>();
|
||||||
|
|
||||||
|
GoblinResearcherWatcher() {
|
||||||
|
super(WatcherScope.GAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void watch(GameEvent event, Game game) {
|
||||||
|
if (event.getType() != GameEvent.EventType.ATTACKER_DECLARED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
map.computeIfAbsent(new MageObjectReference(event.getSourceId(), game), x -> new HashSet<>()).add(event.getPlayerId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
super.reset();
|
||||||
|
map.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean checkPlayer(Ability source, Game game) {
|
||||||
|
game.getState()
|
||||||
|
.getWatcher(GoblinResearcherWatcher.class)
|
||||||
|
.map
|
||||||
|
.getOrDefault(new MageObjectReference(source, 0), Collections.emptySet())
|
||||||
|
.contains(source.getControllerId());
|
||||||
|
}
|
||||||
|
}
|
|
@ -319,6 +319,7 @@ public final class Jumpstart2022 extends ExpansionSet {
|
||||||
cards.add(new SetCardInfo("Goblin Psychopath", 544, Rarity.UNCOMMON, mage.cards.g.GoblinPsychopath.class));
|
cards.add(new SetCardInfo("Goblin Psychopath", 544, Rarity.UNCOMMON, mage.cards.g.GoblinPsychopath.class));
|
||||||
cards.add(new SetCardInfo("Goblin Rabblemaster", 545, Rarity.RARE, mage.cards.g.GoblinRabblemaster.class));
|
cards.add(new SetCardInfo("Goblin Rabblemaster", 545, Rarity.RARE, mage.cards.g.GoblinRabblemaster.class));
|
||||||
cards.add(new SetCardInfo("Goblin Rally", 546, Rarity.UNCOMMON, mage.cards.g.GoblinRally.class));
|
cards.add(new SetCardInfo("Goblin Rally", 546, Rarity.UNCOMMON, mage.cards.g.GoblinRally.class));
|
||||||
|
cards.add(new SetCardInfo("Goblin Researcher", 34, Rarity.COMMON, mage.cards.g.GoblinResearcher.class));
|
||||||
cards.add(new SetCardInfo("Goblin Trailblazer", 547, Rarity.COMMON, mage.cards.g.GoblinTrailblazer.class));
|
cards.add(new SetCardInfo("Goblin Trailblazer", 547, Rarity.COMMON, mage.cards.g.GoblinTrailblazer.class));
|
||||||
cards.add(new SetCardInfo("Goblin Warchief", 548, Rarity.UNCOMMON, mage.cards.g.GoblinWarchief.class));
|
cards.add(new SetCardInfo("Goblin Warchief", 548, Rarity.UNCOMMON, mage.cards.g.GoblinWarchief.class));
|
||||||
cards.add(new SetCardInfo("Goldhound", 549, Rarity.COMMON, mage.cards.g.Goldhound.class));
|
cards.add(new SetCardInfo("Goldhound", 549, Rarity.COMMON, mage.cards.g.Goldhound.class));
|
||||||
|
|
Loading…
Reference in a new issue