Merge pull request #2567 from HCrescent/master

Fixed Shapeshifter. Added Magus of the Jar.
This commit is contained in:
LevelX2 2016-11-06 07:44:37 +01:00 committed by GitHub
commit e0b722cf68
3 changed files with 275 additions and 44 deletions

View file

@ -0,0 +1,197 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.cards.m;
import java.util.Iterator;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
/**
*
* @author HCrescent
*/
public class MagusOfTheJar extends CardImpl {
public MagusOfTheJar(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}{U}");
this.subtype.add("Human");
this.subtype.add("Wizard");
this.power = new MageInt(3);
this.toughness = new MageInt(3);
// {tap}, Sacrifice Magus of the Jar: Each player exiles all cards from his or her hand face down and draws seven cards. At the beginning of the next end step, each player discards his or her hand and returns to his or her hand each card he or she exiled this way.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MagusoftheJarEffect(), new TapSourceCost());
ability.addCost(new SacrificeSourceCost());
this.addAbility(ability);
}
public MagusOfTheJar(final MagusOfTheJar card) {
super(card);
}
@Override
public MagusOfTheJar copy() {
return new MagusOfTheJar(this);
}
}
class MagusoftheJarEffect extends OneShotEffect {
public MagusoftheJarEffect() {
super(Outcome.DrawCard);
staticText = "Each player exiles all cards from his or her hand face down and draws seven cards. At the beginning of the next end step, each player discards his or her hand and returns to his or her hand each card he or she exiled this way.";
}
public MagusoftheJarEffect(final MagusoftheJarEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Cards cards = new CardsImpl();
//Exile hand
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
Cards hand = player.getHand();
while (hand.size() > 0) {
Card card = hand.get(hand.iterator().next(), game);
if (card != null) {
card.moveToExile(getId(), "Magus of the Jar", source.getSourceId(), game);
card.setFaceDown(true, game);
cards.add(card);
}
}
}
}
//Draw 7 cards
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.drawCards(7, game);
}
}
//Delayed ability
Effect effect = new MagusoftheJarDelayedEffect();
effect.setValue("MagusoftheJarCards", cards);
game.addDelayedTriggeredAbility(new MagusoftheJarDelayedTriggeredAbility(effect), source);
return true;
}
@Override
public MagusoftheJarEffect copy() {
return new MagusoftheJarEffect(this);
}
}
class MagusoftheJarDelayedEffect extends OneShotEffect {
public MagusoftheJarDelayedEffect() {
super(Outcome.DrawCard);
staticText = "At the beginning of the next end step, each player discards his or her hand and returns to his or her hand each card he or she exiled this way";
}
public MagusoftheJarDelayedEffect(final MagusoftheJarDelayedEffect effect) {
super(effect);
}
@Override
public MagusoftheJarDelayedEffect copy() {
return new MagusoftheJarDelayedEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Cards cards = (Cards) this.getValue("MagusoftheJarCards");
if (cards != null) {
//Discard
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.discard(player.getHand().size(), false, source, game);
}
}
//Return to hand
for (Iterator<Card> it = cards.getCards(game).iterator(); it.hasNext();) {
Card card = it.next();
card.moveToZone(Zone.HAND, source.getSourceId(), game, true);
}
return true;
}
return false;
}
}
class MagusoftheJarDelayedTriggeredAbility extends DelayedTriggeredAbility {
public MagusoftheJarDelayedTriggeredAbility(Effect effect) {
super(effect);
}
public MagusoftheJarDelayedTriggeredAbility(final MagusoftheJarDelayedTriggeredAbility ability) {
super(ability);
}
@Override
public MagusoftheJarDelayedTriggeredAbility copy() {
return new MagusoftheJarDelayedTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.END_TURN_STEP_PRE;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return true;
}
}

View file

@ -30,44 +30,48 @@ package mage.cards.s;
import java.util.HashSet;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.SubLayer;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
/**
*
* @author MarcoMarin
* @author MarcoMarin / HCrescent
*/
public class Shapeshifter extends CardImpl {
public Integer lastChosenNumber = 0;
public Shapeshifter(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{6}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{6}");
this.subtype.add("Shapeshifter");
this.power = new MageInt(0);
this.toughness = new MageInt(7);
// As Shapeshifter enters the battlefield, choose a number between 0 and 7.
this.addAbility(new EntersBattlefieldAbility(new ShapeshifterEffect()));
this.addAbility(new AsEntersBattlefieldAbility(new ShapeshifterEffect()));
// At the beginning of your upkeep, you may choose a number between 0 and 7.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new ShapeshifterEffect(), TargetController.YOU, true));
// Shapeshifter's power is equal to the last chosen number and its toughness is equal to 7 minus that number.
this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(lastChosenNumber, 7-lastChosenNumber, Duration.EndOfGame)));
this.addAbility(new SimpleStaticAbility(Zone.ALL, new ShapeshifterContinuousEffect()));
}
public Shapeshifter(final Shapeshifter card) {
@ -80,47 +84,76 @@ public class Shapeshifter extends CardImpl {
}
}
class ShapeshifterEffect extends OneShotEffect {
ShapeshifterEffect() {
super(Outcome.Damage);
staticText = "Name a nonland card and choose a number greater than 0. Target player reveals his or her library. If that library contains exactly the chosen number of the named card, {this} deals 8 damage to that player. Then that player shuffles his or her library";
public ShapeshifterEffect() {
super(Outcome.Benefit);
this.staticText = "Choose a number between 0 and 7.";
}
ShapeshifterEffect(final ShapeshifterEffect effect) {
public ShapeshifterEffect(final ShapeshifterEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player playerControls = game.getPlayer(source.getControllerId());
if (playerControls != null) {
Choice numberChoice = new ChoiceImpl();
numberChoice.setMessage("Choose a number beween 0 and 7");
HashSet<String> numbers = new HashSet<String>();
for (int i = 1; i <= 7; i++) {
numbers.add(Integer.toString(i));
}
numberChoice.setChoices(numbers);
while (!playerControls.choose(Outcome.Neutral, numberChoice, game)) {
if (!playerControls.canRespond()) {
return false;
}
}
game.informPlayers("Shapeshifter, chosen number: [" + numberChoice.getChoice() + "]");
Shapeshifter shapeShifter = (Shapeshifter) game.getCard(source.getSourceId());
if(shapeShifter!=null){
shapeShifter.lastChosenNumber = Integer.parseInt(numberChoice.getChoice());
return true;
}
}
return false;
}
@Override
public ShapeshifterEffect copy() {
return new ShapeshifterEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player Controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getPermanentEntering(source.getSourceId());
if (mageObject == null) {
mageObject = game.getPermanent(source.getSourceId());
}
if (Controller != null) {
Choice numberChoice = new ChoiceImpl();
numberChoice.setMessage("Choose a number beween 0 and 7");
HashSet<String> numbers = new HashSet<>();
for (int i = 0; i <= 7; i++) {
numbers.add(Integer.toString(i));
}
numberChoice.setChoices(numbers);
while (!Controller.choose(Outcome.Neutral, numberChoice, game)) {
if (!Controller.canRespond()) {
return false;
}
}
game.informPlayers("Shapeshifter, chosen number: [" + numberChoice.getChoice() + "]");
game.getState().setValue(source.getSourceId().toString() + "_Shapeshifter", numberChoice.getChoice());
if (mageObject instanceof Permanent) {
((Permanent) mageObject).addInfo("lastChosenNumber", CardUtil.addToolTipMarkTags("Last chosen number: " + numberChoice.getChoice()), game);
}
}
return false;
}
}
class ShapeshifterContinuousEffect extends ContinuousEffectImpl {
public ShapeshifterContinuousEffect() {
super(Duration.WhileOnBattlefield, Layer.PTChangingEffects_7, SubLayer.CharacteristicDefining_7a, Outcome.BoostCreature);
staticText = "{this}'s power is equal to the last chosen number and its toughness is equal to 7 minus that number.";
}
public ShapeshifterContinuousEffect(final ShapeshifterContinuousEffect effect) {
super(effect);
}
@Override
public ShapeshifterContinuousEffect copy() {
return new ShapeshifterContinuousEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if(permanent!=null){
String lastChosen = (String) game.getState().getValue(source.getSourceId().toString() + "_Shapeshifter");
int lastChosenNumber = Integer.parseInt(lastChosen);
permanent.getPower().modifyBaseValue(lastChosenNumber);
permanent.getToughness().modifyBaseValue(7 - lastChosenNumber);
return true;
}
return false;
}
}

View file

@ -158,6 +158,7 @@ public class TimeSpiral extends ExpansionSet {
cards.add(new SetCardInfo("Lotus Bloom", 259, Rarity.RARE, mage.cards.l.LotusBloom.class));
cards.add(new SetCardInfo("Magus of the Candelabra", 203, Rarity.RARE, mage.cards.m.MagusOfTheCandelabra.class));
cards.add(new SetCardInfo("Magus of the Disk", 27, Rarity.RARE, mage.cards.m.MagusOfTheDisk.class));
cards.add(new SetCardInfo("Magus of the Jar", 67, Rarity.RARE, mage.cards.m.MagusOfTheJar.class));
cards.add(new SetCardInfo("Magus of the Mirror", 116, Rarity.RARE, mage.cards.m.MagusOfTheMirror.class));
cards.add(new SetCardInfo("Magus of the Scroll", 169, Rarity.RARE, mage.cards.m.MagusOfTheScroll.class));
cards.add(new SetCardInfo("Mana Skimmer", 117, Rarity.COMMON, mage.cards.m.ManaSkimmer.class));