mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 12:31:59 -08:00
[STX] Implemented Pop Quiz
This commit is contained in:
parent
4e4bc6de7a
commit
6d99f28bef
5 changed files with 132 additions and 49 deletions
|
|
@ -0,0 +1,46 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.common.DiscardCardCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class LearnEffect extends OneShotEffect {
|
||||
|
||||
private static final FilterCard filter = new FilterCard("Lesson card");
|
||||
|
||||
static {
|
||||
filter.add(SubType.LESSON.getPredicate());
|
||||
}
|
||||
|
||||
public LearnEffect() {
|
||||
super(Outcome.Neutral);
|
||||
staticText = "learn. <i>(You may reveal a Lesson card you own from outside the game " +
|
||||
"and put it into your hand, or discard a card to draw a card.)</i>";
|
||||
}
|
||||
|
||||
private LearnEffect(final LearnEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
return new WishEffect(filter, true).apply(game, source)
|
||||
|| new DoIfCostPaid(
|
||||
new DrawCardSourceControllerEffect(1), new DiscardCardCost()
|
||||
).apply(game, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LearnEffect copy() {
|
||||
return new LearnEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -84,57 +84,58 @@ public class WishEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (controller != null && sourceObject != null) {
|
||||
if (controller.chooseUse(Outcome.Benefit, choiceText, source, game)) {
|
||||
Cards cards = controller.getSideboard();
|
||||
List<Card> exile = game.getExile().getAllCards(game);
|
||||
boolean noTargets = cards.isEmpty() && (!alsoFromExile || exile.isEmpty());
|
||||
if (noTargets) {
|
||||
game.informPlayer(controller, "You have no cards outside the game" + (alsoFromExile ? " or in exile" : "") + '.');
|
||||
return true;
|
||||
}
|
||||
|
||||
Set<Card> filtered = cards.getCards(filter, game);
|
||||
Cards filteredCards = new CardsImpl();
|
||||
for (Card card : filtered) {
|
||||
filteredCards.add(card.getId());
|
||||
}
|
||||
if (alsoFromExile) {
|
||||
for (Card exileCard : exile) {
|
||||
if (exileCard.isOwnedBy(source.getControllerId()) && filter.match(exileCard, game)) {
|
||||
filteredCards.add(exileCard);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (filteredCards.isEmpty()) {
|
||||
game.informPlayer(controller, "You don't have " + filter.getMessage() + " outside the game" + (alsoFromExile ? " or in exile" : "") + '.');
|
||||
return true;
|
||||
}
|
||||
|
||||
TargetCard target = new TargetCard(Zone.ALL, filter);
|
||||
target.setNotTarget(true);
|
||||
if (controller.choose(Outcome.Benefit, filteredCards, target, game)) {
|
||||
Card card = controller.getSideboard().get(target.getFirstTarget(), game);
|
||||
if (card == null && alsoFromExile) {
|
||||
card = game.getCard(target.getFirstTarget());
|
||||
}
|
||||
if (card != null) {
|
||||
if (topOfLibrary) {
|
||||
controller.putCardsOnTopOfLibrary(card, game, source, true);
|
||||
} else {
|
||||
controller.moveCards(card, Zone.HAND, source, game);
|
||||
}
|
||||
if (reveal) {
|
||||
Cards revealCard = new CardsImpl();
|
||||
revealCard.add(card);
|
||||
controller.revealCards(sourceObject.getIdName(), revealCard, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (controller == null || sourceObject == null) {
|
||||
return false;
|
||||
}
|
||||
if (!controller.chooseUse(Outcome.Benefit, choiceText, source, game)) {
|
||||
return false;
|
||||
}
|
||||
Cards cards = controller.getSideboard();
|
||||
List<Card> exile = game.getExile().getAllCards(game);
|
||||
boolean noTargets = cards.isEmpty() && (!alsoFromExile || exile.isEmpty());
|
||||
if (noTargets) {
|
||||
game.informPlayer(controller, "You have no cards outside the game" + (alsoFromExile ? " or in exile" : "") + '.');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Set<Card> filtered = cards.getCards(filter, game);
|
||||
Cards filteredCards = new CardsImpl();
|
||||
for (Card card : filtered) {
|
||||
filteredCards.add(card.getId());
|
||||
}
|
||||
if (alsoFromExile) {
|
||||
for (Card exileCard : exile) {
|
||||
if (exileCard.isOwnedBy(source.getControllerId()) && filter.match(exileCard, game)) {
|
||||
filteredCards.add(exileCard);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (filteredCards.isEmpty()) {
|
||||
game.informPlayer(controller, "You don't have " + filter.getMessage() + " outside the game" + (alsoFromExile ? " or in exile" : "") + '.');
|
||||
return true;
|
||||
}
|
||||
|
||||
TargetCard target = new TargetCard(Zone.ALL, filter);
|
||||
target.setNotTarget(true);
|
||||
if (controller.choose(Outcome.Benefit, filteredCards, target, game)) {
|
||||
Card card = controller.getSideboard().get(target.getFirstTarget(), game);
|
||||
if (card == null && alsoFromExile) {
|
||||
card = game.getCard(target.getFirstTarget());
|
||||
}
|
||||
if (card != null) {
|
||||
if (topOfLibrary) {
|
||||
controller.putCardsOnTopOfLibrary(card, game, source, true);
|
||||
} else {
|
||||
controller.moveCards(card, Zone.HAND, source, game);
|
||||
}
|
||||
if (reveal) {
|
||||
Cards revealCard = new CardsImpl();
|
||||
revealCard.add(card);
|
||||
controller.revealCards(sourceObject.getIdName(), revealCard, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ public enum SubType {
|
|||
//205.3k Instants and sorceries share their lists of subtypes; these subtypes are called spell types.
|
||||
ADVENTURE("Adventure", SubTypeSet.SpellType),
|
||||
ARCANE("Arcane", SubTypeSet.SpellType),
|
||||
LESSON("Lesson", SubTypeSet.SpellType),
|
||||
TRAP("Trap", SubTypeSet.SpellType),
|
||||
// 205.3i: Lands have their own unique set of subtypes; these subtypes are called land types.
|
||||
// Of that list, Forest, Island, Mountain, Plains, and Swamp are the basic land types.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue