Merge remote-tracking branch 'remotes/upstream/master'

This commit is contained in:
ciaccona007 2017-07-16 16:38:29 -04:00
commit 3e4809b224
7 changed files with 237 additions and 11 deletions

View file

@ -41,7 +41,7 @@ public class MageVersion implements Serializable, Comparable<MageVersion> {
public final static int MAGE_VERSION_MAJOR = 1;
public final static int MAGE_VERSION_MINOR = 4;
public final static int MAGE_VERSION_PATCH = 24;
public final static String MAGE_VERSION_MINOR_PATCH = "V2";
public final static String MAGE_VERSION_MINOR_PATCH = "V3";
public final static String MAGE_VERSION_INFO = "";
private final int major;

View file

@ -0,0 +1,187 @@
/*
* 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.c;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.condition.common.SuspendedCondition;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalTriggeredAbility;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.SuspendAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
import mage.target.TargetPlayer;
import mage.target.common.TargetControlledPermanent;
/**
*
* @author anonymous
*/
public class CurseOfTheCabal extends CardImpl {
public CurseOfTheCabal(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{9}{B}");
this.subtype.add("Arcane");
// Target player sacrifices half the permanents he or she controls, rounded down.
this.getSpellAbility().addTarget(new TargetPlayer());
this.getSpellAbility().addEffect(new CurseOfTheCabalSacrificeEffect());
// Suspend 2-{2}{B}{B}
this.addAbility(new SuspendAbility(2, new ManaCostsImpl("{2}{B}{B}"), this));
// At the beginning of each player's upkeep, if Curse of the Cabal is suspended, that player may sacrifice a permanent. If he or she does, put two time counters on Curse of the Cabal.
this.addAbility(new CurseOfTheCabalTriggeredAbility());
}
public CurseOfTheCabal(final CurseOfTheCabal card) {
super(card);
}
@Override
public CurseOfTheCabal copy() {
return new CurseOfTheCabal(this);
}
}
class CurseOfTheCabalSacrificeEffect extends OneShotEffect{
private static final FilterControlledPermanent FILTER = new FilterControlledPermanent(); // ggf filter.FilterPermanent
public CurseOfTheCabalSacrificeEffect() {
super(Outcome.Sacrifice);
this.staticText = "Target player sacrifices half the permanents he or she controls, rounded down.";
}
public CurseOfTheCabalSacrificeEffect(final CurseOfTheCabalSacrificeEffect effect) {
super(effect);
}
@Override
public CurseOfTheCabalSacrificeEffect copy() {
return new CurseOfTheCabalSacrificeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if(targetPlayer != null) {
int amount = game.getBattlefield().countAll(FILTER, targetPlayer.getId(), game) / 2;
if(amount < 1)
return true;
Target target = new TargetControlledPermanent(amount, amount, FILTER, true);
if (target.canChoose(targetPlayer.getId(), game)) {
while (!target.isChosen() && target.canChoose(targetPlayer.getId(), game) && targetPlayer.canRespond()) {
targetPlayer.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
}
for (int idx = 0; idx < target.getTargets().size(); idx++) {
Permanent permanent = game.getPermanent(target.getTargets().get(idx));
if (permanent != null) {
permanent.sacrifice(source.getSourceId(), game);
}
}
}
return true;
}
return false;
}
}
class CurseOfTheCabalTriggeredAbility extends ConditionalTriggeredAbility {
public CurseOfTheCabalTriggeredAbility() {
super(new BeginningOfUpkeepTriggeredAbility(
Zone.EXILED, new CurseOfTheCabalTriggeredAbilityConditionalDelay(),
TargetController.ANY, false, true
),
SuspendedCondition.instance,
"At the beginning of each player's upkeep, if {this} is suspended, that player may sacrifice a permanent. If he or she does, put two time counters on {this}."
);
// controller has to sac a permanent
// counters aren't placed
}
public CurseOfTheCabalTriggeredAbility(final CurseOfTheCabalTriggeredAbility effect) {
super(effect);
}
@Override
public CurseOfTheCabalTriggeredAbility copy() {
return new CurseOfTheCabalTriggeredAbility(this);
}
}
class CurseOfTheCabalTriggeredAbilityConditionalDelay extends AddCountersSourceEffect{
public CurseOfTheCabalTriggeredAbilityConditionalDelay(){
super(CounterType.TIME.createInstance(), new StaticValue(2), false, true);
}
public boolean apply(Game game, Ability source) {
UUID id = game.getActivePlayerId();
Player target = game.getPlayer(id);
Cost cost = new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledPermanent()));
if(target == null)
return false;
if (cost.canPay(source, source.getSourceId(), id, game)
&& target.chooseUse(Outcome.Sacrifice, "Sacrifice a permanent to delay Curse of the Cabal?", source, game)
&& cost.pay(source, game, source.getSourceId(), id, true, null)) {
return super.apply(game, source);
}
return true;
}
public CurseOfTheCabalTriggeredAbilityConditionalDelay(final CurseOfTheCabalTriggeredAbilityConditionalDelay effect) {
super(effect);
}
@Override
public CurseOfTheCabalTriggeredAbilityConditionalDelay copy() {
return new CurseOfTheCabalTriggeredAbilityConditionalDelay(this);
}
}

View file

@ -27,12 +27,14 @@
*/
package mage.cards.f;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.abilities.effects.common.PutTokenOntoBattlefieldCopyTargetEffect;
import mage.cards.CardImpl;
@ -48,8 +50,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
*
* @author fireshoes
@ -63,12 +63,14 @@ public class FlameshadowConjuring extends CardImpl {
}
public FlameshadowConjuring(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{R}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{R}");
// Whenever a nontoken creature enters the battlefield under your control, you may pay {R}. If you do, create a token that's a copy of that creature. That token gains haste. Exile it at the beginning of the next end step.
Ability ability = new EntersBattlefieldControlledTriggeredAbility(Zone.BATTLEFIELD, new FlameshadowConjuringEffect(), filterNontoken, false, SetTargetPointer.PERMANENT,
"Whenever a nontoken creature enters the battlefield under your control, you may pay {R}. If you do, create a token that's a copy of that creature. That token gains haste. Exile it at the beginning of the next end step");
ability.addCost(new ManaCostsImpl("{R}"));
Ability ability = new EntersBattlefieldControlledTriggeredAbility(Zone.BATTLEFIELD, new DoIfCostPaid(
new FlameshadowConjuringEffect(), new ManaCostsImpl("{R}"), "Pay {R} to create a token that's a copy of that creature that entered the battlefield?"), filterNontoken, false, SetTargetPointer.PERMANENT,
"Whenever a nontoken creature enters the battlefield under your control, "
+ "you may pay {R}. If you do, create a token that's a copy of that creature. "
+ "That token gains haste. Exile it at the beginning of the next end step");
this.addAbility(ability);
}

View file

@ -68,6 +68,7 @@ public class TimeSpiral extends ExpansionSet {
cards.add(new SetCardInfo("Coral Trickster", 54, Rarity.COMMON, mage.cards.c.CoralTrickster.class));
cards.add(new SetCardInfo("Corpulent Corpse", 98, Rarity.COMMON, mage.cards.c.CorpulentCorpse.class));
cards.add(new SetCardInfo("Crookclaw Transmuter", 55, Rarity.COMMON, mage.cards.c.CrookclawTransmuter.class));
cards.add(new SetCardInfo("Curse of the Cabal", 99, Rarity.RARE, mage.cards.c.CurseOfTheCabal.class));
cards.add(new SetCardInfo("Dark Withering", 101, Rarity.COMMON, mage.cards.d.DarkWithering.class));
cards.add(new SetCardInfo("D'Avenant Healer", 11, Rarity.COMMON, mage.cards.d.DAvenantHealer.class));
cards.add(new SetCardInfo("Deathspore Thallid", 102, Rarity.COMMON, mage.cards.d.DeathsporeThallid.class));

View file

@ -81,7 +81,7 @@ public class JaceTest extends CardTestPlayerBase {
// {T}: Draw a card, then discard a card. If there are five or more cards in your graveyard,
// exile Jace, Vryn's Prodigy, then return him to the battefield transformed under his owner's control.
addCard(Zone.BATTLEFIELD, playerA, "Jace, Vryn's Prodigy", 1); // {2}{R} - 3/2
addCard(Zone.BATTLEFIELD, playerA, "Jace, Vryn's Prodigy", 1); // {U}{1} - 0/2
addCard(Zone.HAND, playerA, "Pillarfield Ox", 1);
// Flash
@ -97,7 +97,41 @@ public class JaceTest extends CardTestPlayerBase {
assertGraveyardCount(playerA, "Pillarfield Ox", 1);
assertExileCount("Jace, Vryn's Prodigy", 0);
assertPermanentCount(playerA, "Jace, Telepath Unbound", 1);
}
@Test
public void vrynCannotCastAncestralVisions() {
// {T}: Draw a card, then discard a card. If there are five or more cards in your graveyard,
// exile Jace, Vryn's Prodigy, then return him to the battefield transformed under his owner's control.
String jVryn = "Jace, Vryn's Prodigy"; // {U}{1} 0/2
//3: You may cast target instant or sorcery card from your graveyard this turn. If that card would be put into your graveyard this turn, exile it instead.
String jTelepath = "Jace, Telepath Unbound"; // 5 loyalty
// Sorcery, Suspend 4 {U}. Target player draws three cards.
String ancestralVision = "Ancestral Vision";
addCard(Zone.BATTLEFIELD, playerA, "Jace, Vryn's Prodigy", 1); // {U}{1} - 0/2
addCard(Zone.BATTLEFIELD, playerA, "Island");
addCard(Zone.GRAVEYARD, playerA, "Island", 4);
addCard(Zone.GRAVEYARD, playerA, ancestralVision);
addCard(Zone.HAND, playerA, "Swamp", 1);
activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Draw a card, then discard a card. If there are five or more cards in your graveyard");
setChoice(playerA, "Swamp");
activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "-3:");
addTarget(playerA, ancestralVision);
castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, ancestralVision);
setStopAt(3, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, jTelepath, 1);
assertGraveyardCount(playerA, "Swamp", 1);
assertGraveyardCount(playerA, ancestralVision, 1);
assertHandCount(playerA, 2); // 1 draw step + jace draw card
assertCounterCount(playerA, jTelepath, CounterType.LOYALTY, 2);
}
/**

View file

@ -58,7 +58,7 @@ public enum CardRepository {
// raise this if db structure was changed
private static final long CARD_DB_VERSION = 51;
// raise this if new cards were added to the server
private static final long CARD_CONTENT_VERSION = 84;
private static final long CARD_CONTENT_VERSION = 85;
private final TreeSet<String> landTypes = new TreeSet<>();
private Dao<CardInfo, Object> cardDao;
private Set<String> classNames;

View file

@ -61,7 +61,9 @@ public class CardsCycledOrDiscardedThisTurnWatcher extends Watcher {
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.DISCARDED_CARD && event.getPlayerId() != null) {
if (event.getType() == GameEvent.EventType.DISCARDED_CARD
|| event.getType() == GameEvent.EventType.CYCLED_CARD
&& event.getPlayerId() != null) {
Card card = game.getCard(event.getTargetId());
if (card != null) {
Cards c = getCardsCycledOrDiscardedThisTurn(event.getPlayerId());