mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
[AFR] Implemented Wish
This commit is contained in:
parent
20245f32f6
commit
1c3b42996d
3 changed files with 112 additions and 0 deletions
104
Mage.Sets/src/mage/cards/w/Wish.java
Normal file
104
Mage.Sets/src/mage/cards/w/Wish.java
Normal file
|
@ -0,0 +1,104 @@
|
|||
package mage.cards.w;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author weirddan455
|
||||
*/
|
||||
public final class Wish extends CardImpl {
|
||||
|
||||
public Wish(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{R}");
|
||||
|
||||
// You may play a card you own from outside the game this turn.
|
||||
this.getSpellAbility().addEffect(new WishEffect());
|
||||
}
|
||||
|
||||
private Wish(final Wish card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Wish copy() {
|
||||
return new Wish(this);
|
||||
}
|
||||
}
|
||||
|
||||
class WishEffect extends OneShotEffect {
|
||||
|
||||
public WishEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "You may play a card you own from outside the game this turn";
|
||||
}
|
||||
|
||||
private WishEffect(final WishEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WishEffect copy() {
|
||||
return new WishEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && !controller.getSideboard().isEmpty()) {
|
||||
controller.lookAtCards(source, "Sideboard", controller.getSideboard(), game);
|
||||
game.addEffect(new WishPlayFromSideboardEffect(), source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class WishPlayFromSideboardEffect extends AsThoughEffectImpl {
|
||||
|
||||
public WishPlayFromSideboardEffect() {
|
||||
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit);
|
||||
}
|
||||
|
||||
private WishPlayFromSideboardEffect(final WishPlayFromSideboardEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WishPlayFromSideboardEffect copy() {
|
||||
return new WishPlayFromSideboardEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (source.getControllerId().equals(affectedControllerId)) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
UUID mainCardId = CardUtil.getMainCardId(game, objectId);
|
||||
if (controller != null && controller.getSideboard().contains(mainCardId)) {
|
||||
// Only allow one card to be played
|
||||
if (!game.inCheckPlayableState()) {
|
||||
discard();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -254,6 +254,7 @@ public final class AdventuresInTheForgottenRealms extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("White Dragon", 41, Rarity.UNCOMMON, mage.cards.w.WhiteDragon.class));
|
||||
cards.add(new SetCardInfo("Wight", 127, Rarity.RARE, mage.cards.w.Wight.class));
|
||||
cards.add(new SetCardInfo("Wild Shape", 212, Rarity.UNCOMMON, mage.cards.w.WildShape.class));
|
||||
cards.add(new SetCardInfo("Wish", 166, Rarity.RARE, mage.cards.w.Wish.class));
|
||||
cards.add(new SetCardInfo("Wizard Class", 81, Rarity.UNCOMMON, mage.cards.w.WizardClass.class));
|
||||
cards.add(new SetCardInfo("Xorn", 167, Rarity.RARE, mage.cards.x.Xorn.class));
|
||||
cards.add(new SetCardInfo("You Come to a River", 83, Rarity.COMMON, mage.cards.y.YouComeToARiver.class));
|
||||
|
|
|
@ -3653,6 +3653,13 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
getPlayableFromObjectAll(game, Zone.OUTSIDE, card, availableMana, playable);
|
||||
}
|
||||
}
|
||||
// Check sideboard. Ex: Wish lets player play cards directly from sideboard.
|
||||
for (UUID sideboardCardId : getSideboard()) {
|
||||
Card sideboardCard = game.getCard(sideboardCardId);
|
||||
if (sideboardCard != null) {
|
||||
getPlayableFromObjectAll(game, Zone.OUTSIDE, sideboardCard, availableMana, playable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if it's possible to play the top card of a library
|
||||
|
|
Loading…
Reference in a new issue