Fix JTMS 0 Loyalty ability to use Brain Implementation.

As it is the exact same ability, implementing it twice slightly
differently made no sense. Now there is a single implementation for both
of them.
This commit is contained in:
Nathaniel Brandes 2016-05-11 02:29:06 -07:00
parent 43205b6f46
commit bceda744fd
3 changed files with 58 additions and 87 deletions

View file

@ -0,0 +1,51 @@
package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInHand;
public class BrainstormEffect extends OneShotEffect {
public BrainstormEffect() {
super(Outcome.DrawCard);
staticText = "Draw three cards, then put two cards from your hand on top of your library in any order";
}
public BrainstormEffect(final BrainstormEffect effect) {
super(effect);
}
@Override
public BrainstormEffect copy() {
return new BrainstormEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.drawCards(3, game);
putOnLibrary(player, source, game);
putOnLibrary(player, source, game);
return true;
}
return false;
}
private boolean putOnLibrary(Player player, Ability source, Game game) {
TargetCardInHand target = new TargetCardInHand();
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
player.chooseTarget(Outcome.ReturnToHand, target, source, game);
Card card = player.getHand().get(target.getFirstTarget(), game);
if (card != null) {
return player.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.HAND, true, false);
}
}
return false;
}
}