mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
Orcish Spy: modify LookLibraryTopCardTargetPlayerEffect to admit multiple cards
This commit is contained in:
parent
9149e66e71
commit
a49d082823
2 changed files with 29 additions and 54 deletions
|
@ -27,25 +27,16 @@
|
|||
*/
|
||||
package mage.sets.fallenempires;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.LookLibraryTopCardTargetPlayerEffect;
|
||||
import mage.abilities.effects.common.RevealTargetPlayerLibraryEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -62,7 +53,7 @@ public class OrcishSpy extends CardImpl {
|
|||
this.toughness = new MageInt(1);
|
||||
|
||||
// {tap}: Look at the top three cards of target player's library.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.LIBRARY, new LookLibraryTopXCardsTargetPlayerEffect(3, "look at the top three cards of target player's library"), new TapSourceCost());
|
||||
Ability ability = new SimpleActivatedAbility(Zone.LIBRARY, new LookLibraryTopCardTargetPlayerEffect(3), new TapSourceCost());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
|
@ -75,37 +66,3 @@ public class OrcishSpy extends CardImpl {
|
|||
return new OrcishSpy(this);
|
||||
}
|
||||
}
|
||||
|
||||
class LookLibraryTopXCardsTargetPlayerEffect extends OneShotEffect {
|
||||
|
||||
protected int number;
|
||||
|
||||
public LookLibraryTopXCardsTargetPlayerEffect(int number, String text) {
|
||||
super(Outcome.Benefit);
|
||||
this.number = number;
|
||||
this.staticText = text;
|
||||
}
|
||||
|
||||
public LookLibraryTopXCardsTargetPlayerEffect(final LookLibraryTopXCardsTargetPlayerEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LookLibraryTopXCardsTargetPlayerEffect copy() {
|
||||
return new LookLibraryTopXCardsTargetPlayerEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Player targetPlayer = game.getPlayer(source.getFirstTarget());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (player != null && targetPlayer != null && sourceObject != null) {
|
||||
CardsImpl cards = new CardsImpl();
|
||||
cards.addAll(targetPlayer.getLibrary().getTopCards(game, number));
|
||||
player.lookAtCards(sourceObject.getName(), cards, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,26 +30,34 @@ package mage.abilities.effects.common;
|
|||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class LookLibraryTopCardTargetPlayerEffect extends OneShotEffect {
|
||||
|
||||
public LookLibraryTopCardTargetPlayerEffect() {
|
||||
protected int amount;
|
||||
|
||||
public LookLibraryTopCardTargetPlayerEffect(int amount) {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "look at the top card of target player's library";
|
||||
this.amount = amount;
|
||||
setText();
|
||||
}
|
||||
|
||||
public LookLibraryTopCardTargetPlayerEffect() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public LookLibraryTopCardTargetPlayerEffect(final LookLibraryTopCardTargetPlayerEffect effect) {
|
||||
super(effect);
|
||||
amount = effect.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -63,14 +71,24 @@ public class LookLibraryTopCardTargetPlayerEffect extends OneShotEffect {
|
|||
Player targetPlayer = game.getPlayer(source.getFirstTarget());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (player != null && targetPlayer != null && sourceObject != null) {
|
||||
Card card = targetPlayer.getLibrary().getFromTop(game);
|
||||
if (card != null) {
|
||||
CardsImpl cards = new CardsImpl();
|
||||
cards.add(card);
|
||||
player.lookAtCards(sourceObject.getName(), cards, game);
|
||||
}
|
||||
Cards cards = new CardsImpl();
|
||||
cards.addAll(targetPlayer.getLibrary().getTopCards(game, amount));
|
||||
player.lookAtCards(sourceObject.getName(), cards, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setText() {
|
||||
StringBuilder sb = new StringBuilder("look at the top ");
|
||||
if (amount > 1) {
|
||||
sb.append(CardUtil.numberToText(amount));
|
||||
sb.append(" cards ");
|
||||
}
|
||||
else {
|
||||
sb.append(" card ");
|
||||
}
|
||||
sb.append("of target player's library");
|
||||
this.staticText = sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue