mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 12:22:10 -08:00
Merge origin/master
This commit is contained in:
commit
9072fb95d7
81 changed files with 4550 additions and 355 deletions
|
|
@ -445,20 +445,28 @@ public abstract class AbilityImpl implements Ability {
|
|||
public boolean activateAlternateOrAdditionalCosts(MageObject sourceObject, boolean noMana, Player controller, Game game) {
|
||||
boolean alternativeCostisUsed = false;
|
||||
if (sourceObject != null && !(sourceObject instanceof Permanent) && !(this instanceof FlashbackAbility)) {
|
||||
for (Ability ability : sourceObject.getAbilities()) {
|
||||
// if cast for noMana no Alternative costs are allowed
|
||||
if (!noMana && ability instanceof AlternativeSourceCosts) {
|
||||
AlternativeSourceCosts alternativeSpellCosts = (AlternativeSourceCosts) ability;
|
||||
if (alternativeSpellCosts.isAvailable(this, game)) {
|
||||
if (alternativeSpellCosts.askToActivateAlternativeCosts(this, game)) {
|
||||
// only one alternative costs may be activated
|
||||
alternativeCostisUsed = true;
|
||||
break;
|
||||
Abilities<Ability> abilities = null;
|
||||
if (sourceObject instanceof Card) {
|
||||
abilities = ((Card) sourceObject).getAbilities(game);
|
||||
} else {
|
||||
sourceObject.getAbilities();
|
||||
}
|
||||
if (abilities != null) {
|
||||
for (Ability ability : abilities) {
|
||||
// if cast for noMana no Alternative costs are allowed
|
||||
if (!noMana && ability instanceof AlternativeSourceCosts) {
|
||||
AlternativeSourceCosts alternativeSpellCosts = (AlternativeSourceCosts) ability;
|
||||
if (alternativeSpellCosts.isAvailable(this, game)) {
|
||||
if (alternativeSpellCosts.askToActivateAlternativeCosts(this, game)) {
|
||||
// only one alternative costs may be activated
|
||||
alternativeCostisUsed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ability instanceof OptionalAdditionalSourceCosts) {
|
||||
((OptionalAdditionalSourceCosts) ability).addOptionalAdditionalCosts(this, game);
|
||||
if (ability instanceof OptionalAdditionalSourceCosts) {
|
||||
((OptionalAdditionalSourceCosts) ability).addOptionalAdditionalCosts(this, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
// controller specific alternate spell costs
|
||||
|
|
|
|||
|
|
@ -1,21 +1,23 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
* "When enchanted/equipped creature dies" triggered ability
|
||||
*
|
||||
* @author Loki
|
||||
*/
|
||||
public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
|
||||
private String attachedDescription;
|
||||
private boolean diesRuleText;
|
||||
|
||||
|
||||
public DiesAttachedTriggeredAbility(Effect effect, String attachedDescription) {
|
||||
this(effect, attachedDescription, false);
|
||||
}
|
||||
|
|
@ -30,7 +32,6 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
this.diesRuleText = diesRuleText;
|
||||
}
|
||||
|
||||
|
||||
public DiesAttachedTriggeredAbility(final DiesAttachedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.attachedDescription = ability.attachedDescription;
|
||||
|
|
@ -49,9 +50,21 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
if (((ZoneChangeEvent) event).isDiesEvent()) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
boolean triggered = false;
|
||||
if (zEvent.getTarget().getAttachments().contains(this.getSourceId())) {
|
||||
triggered = true;
|
||||
} else {
|
||||
// If both (attachment and attached went to graveyard at the same time, the attachemnets can be already removed from the attached object.)
|
||||
// So check here with the LKI of the enchantment
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(getSourceId());
|
||||
if (attachment != null && attachment.getAttachedTo().equals(zEvent.getTargetId())
|
||||
&& attachment.getAttachedToZoneChangeCounter() == zEvent.getTarget().getZoneChangeCounter(game)) {
|
||||
triggered = true;
|
||||
}
|
||||
}
|
||||
if (triggered) {
|
||||
for (Effect effect : getEffects()) {
|
||||
effect.setValue("attachedTo", zEvent.getTarget());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,11 +39,11 @@ import mage.game.Game;
|
|||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class OpponentControllsMoreCondition implements Condition {
|
||||
public class OpponentControlsMoreCondition implements Condition {
|
||||
|
||||
private final FilterPermanent filter;
|
||||
|
||||
public OpponentControllsMoreCondition(FilterPermanent filter) {
|
||||
public OpponentControlsMoreCondition(FilterPermanent filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
|
|
@ -157,8 +157,7 @@ public abstract class VariableCostImpl implements Cost, VariableCost {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
xValue = controller.announceXCost(getMinValue(source, game), getMaxValue(source, game),
|
||||
new StringBuilder("Announce the number of ").append(actionText).toString(),
|
||||
game, source, this);
|
||||
"Announce the number of " + actionText, game, source, this);
|
||||
}
|
||||
return xValue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,9 @@ public class RemoveCounterCost extends CostImpl {
|
|||
int countersRemoved = 0;
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
if (countersToRemove == 0) { // Can happen when used for X costs where X = 0;
|
||||
return paid = true;
|
||||
}
|
||||
target.clearChosen();
|
||||
if (target.choose(Outcome.UnboostCreature, controllerId, sourceId, game)) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* 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
|
||||
|
|
@ -20,12 +20,11 @@
|
|||
* 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.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -49,11 +48,12 @@ public class ExileSourceEffect extends OneShotEffect {
|
|||
public ExileSourceEffect() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param toUniqueExileZone moves the card to a source object dependant unique exile zone, so another
|
||||
* effect of the same source object (e.g. Deadeye Navigator) can identify the card
|
||||
*
|
||||
* @param toUniqueExileZone moves the card to a source object dependant
|
||||
* unique exile zone, so another effect of the same source object (e.g.
|
||||
* Deadeye Navigator) can identify the card
|
||||
*/
|
||||
public ExileSourceEffect(boolean toUniqueExileZone) {
|
||||
super(Outcome.Exile);
|
||||
|
|
@ -72,10 +72,10 @@ public class ExileSourceEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
|
||||
MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
|
||||
if (sourceObject instanceof Card) {
|
||||
UUID exileZoneId = null;
|
||||
String exileZoneName = "";
|
||||
|
|
@ -84,7 +84,7 @@ public class ExileSourceEffect extends OneShotEffect {
|
|||
exileZoneName = sourceObject.getName();
|
||||
}
|
||||
Card sourceCard = (Card) sourceObject;
|
||||
return controller.moveCardToExileWithInfo(sourceCard, exileZoneId, exileZoneName, source.getSourceId(), game, game.getState().getZone(sourceCard.getId()), true);
|
||||
return controller.moveCardsToExile(sourceCard, source, game, true, exileZoneId, exileZoneName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -58,14 +57,14 @@ public class ExileSpellEffect extends OneShotEffect implements MageSingleton {
|
|||
public ExileSpellEffect copy() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
|
||||
if (spellCard != null) {
|
||||
controller.moveCardToExileWithInfo(spellCard, null, "", source.getSourceId(), game, Zone.STACK, true);
|
||||
controller.moveCards(spellCard, null, Zone.EXILED, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.effects.common.combat;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CantBeBlockedByAllTargetEffect extends RestrictionEffect {
|
||||
|
||||
private final FilterCreaturePermanent filterBlockedBy;
|
||||
|
||||
public CantBeBlockedByAllTargetEffect(FilterCreaturePermanent filterBlockedBy, Duration duration) {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
this.filterBlockedBy = filterBlockedBy;
|
||||
staticText = "Target creature"
|
||||
+ " can't be blocked "
|
||||
+ (filterBlockedBy.getMessage().startsWith("except by") ? "" : "by ")
|
||||
+ filterBlockedBy.getMessage();
|
||||
}
|
||||
|
||||
public CantBeBlockedByAllTargetEffect(final CantBeBlockedByAllTargetEffect effect) {
|
||||
super(effect);
|
||||
this.filterBlockedBy = effect.filterBlockedBy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
return getTargetPointer().getTargets(game, source).contains(permanent.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||
return !filterBlockedBy.match(blocker, source.getSourceId(), source.getControllerId(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CantBeBlockedByAllTargetEffect copy() {
|
||||
return new CantBeBlockedByAllTargetEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -27,14 +27,16 @@
|
|||
*/
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.StaticAbility;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.Costs;
|
||||
import mage.abilities.costs.OptionalAdditionalCost;
|
||||
import mage.abilities.costs.OptionalAdditionalCostImpl;
|
||||
import mage.abilities.costs.OptionalAdditionalSourceCosts;
|
||||
import mage.abilities.costs.common.TapTargetCost;
|
||||
|
|
@ -50,48 +52,77 @@ import mage.filter.predicate.permanent.TappedPredicate;
|
|||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
/**
|
||||
* 702.77. Conspire 702.77a Conspire is a keyword that represents two abilities.
|
||||
* The first is a static ability that functions while the spell with conspire is
|
||||
* on the stack. The second is a triggered ability that functions while the
|
||||
* spell with conspire is on the stack. "Conspire" means "As an additional cost
|
||||
* to cast this spell, you may tap two untapped creatures you control that each
|
||||
* share a color with it" and "When you cast this spell, if its conspire cost
|
||||
* was paid, copy it. If the spell has any targets, you may choose new targets
|
||||
* for the copy." Paying a spell’s conspire cost follows the rules for paying
|
||||
* additional costs in rules 601.2b and 601.2e–g. 702.77b If a spell has
|
||||
* multiple instances of conspire, each is paid separately and triggers based on
|
||||
* its own payment, not any other instance of conspire. *
|
||||
/*
|
||||
* 702.77. Conspire
|
||||
* 702.77a Conspire is a keyword that represents two abilities.
|
||||
* The first is a static ability that functions while the spell with conspire is on the stack.
|
||||
* The second is a triggered ability that functions while the spell with conspire is on the stack.
|
||||
* "Conspire" means "As an additional cost to cast this spell,
|
||||
* you may tap two untapped creatures you control that each share a color with it"
|
||||
* and "When you cast this spell, if its conspire cost was paid, copy it.
|
||||
* If the spell has any targets, you may choose new targets for the copy."
|
||||
* Paying a spell’s conspire cost follows the rules for paying additional costs in rules 601.2b and 601.2e–g.
|
||||
* 702.77b If a spell has multiple instances of conspire, each is paid separately and triggers
|
||||
* based on its own payment, not any other instance of conspire. *
|
||||
*
|
||||
* @author jeffwadsworth heavily based off the replicate keyword by LevelX
|
||||
*/
|
||||
public class ConspireAbility extends StaticAbility implements OptionalAdditionalSourceCosts {
|
||||
|
||||
private static final String keywordText = "Conspire";
|
||||
private static final String reminderTextCost = "<i>As you cast this spell, you may tap two untapped creatures you control that share a color with it. When you do, copy it and you may choose a new target for the copy.)</i>";
|
||||
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("two untapped creatures you control that share a color with it");
|
||||
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("untapped creatures you control that share a color with it");
|
||||
protected static final String CONSPIRE_ACTIVATION_KEY = "ConspireActivation";
|
||||
|
||||
static {
|
||||
filter.add(Predicates.not(new TappedPredicate()));
|
||||
filter.add(new SharesColorWithSourcePredicate());
|
||||
}
|
||||
|
||||
Cost costConspire = new TapTargetCost(new TargetControlledPermanent(2, 2, filter, true));
|
||||
OptionalAdditionalCost conspireCost = new OptionalAdditionalCostImpl(keywordText, "-", reminderTextCost, costConspire);
|
||||
public enum ConspireTargets {
|
||||
|
||||
public ConspireAbility(Card card) {
|
||||
NONE,
|
||||
ONE,
|
||||
MORE
|
||||
}
|
||||
|
||||
private UUID conspireId;
|
||||
private String reminderText;
|
||||
private OptionalAdditionalCostImpl conspireCost;
|
||||
|
||||
/**
|
||||
* Unique Id for a ConspireAbility but may not change while a continuous
|
||||
* effect gives Conspire
|
||||
*
|
||||
* @param conspireId
|
||||
* @param conspireTargets controls the content of the reminder text
|
||||
*/
|
||||
public ConspireAbility(UUID conspireId, ConspireTargets conspireTargets) {
|
||||
super(Zone.STACK, null);
|
||||
setRuleAtTheTop(false);
|
||||
addSubAbility(new ConspireTriggeredAbility());
|
||||
this.conspireId = conspireId;
|
||||
switch (conspireTargets) {
|
||||
case NONE:
|
||||
reminderText = "As you cast this spell, you may tap two untapped creatures you control that share a color with it. When you do, copy it.)";
|
||||
break;
|
||||
case ONE:
|
||||
reminderText = "As you cast this spell, you may tap two untapped creatures you control that share a color with it. When you do, copy it and you may choose a new target for the copy.)";
|
||||
break;
|
||||
case MORE:
|
||||
reminderText = "As you cast this spell, you may tap two untapped creatures you control that share a color with it. When you do, copy it and you may choose a new targets for the copy.)";
|
||||
break;
|
||||
}
|
||||
conspireCost = new OptionalAdditionalCostImpl(keywordText, "-", reminderText,
|
||||
new TapTargetCost(new TargetControlledPermanent(2, 2, filter, true)));
|
||||
addSubAbility(new ConspireTriggeredAbility(conspireId));
|
||||
}
|
||||
|
||||
public ConspireAbility(final ConspireAbility ability) {
|
||||
super(ability);
|
||||
conspireCost = ability.conspireCost;
|
||||
this.conspireId = ability.conspireId;
|
||||
this.conspireCost = ability.conspireCost.copy();
|
||||
this.reminderText = ability.reminderText;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -106,18 +137,21 @@ public class ConspireAbility extends StaticAbility implements OptionalAdditional
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActivated() {
|
||||
if (conspireCost != null) {
|
||||
return conspireCost.isActivated();
|
||||
}
|
||||
return false;
|
||||
public UUID getConspireId() {
|
||||
return conspireId;
|
||||
}
|
||||
|
||||
public void resetConspire() {
|
||||
if (conspireCost != null) {
|
||||
conspireCost.reset();
|
||||
@Override
|
||||
public boolean isActivated() {
|
||||
throw new UnsupportedOperationException("Use ConspireAbility.isActivated(Ability ability, Game game) method instead!");
|
||||
}
|
||||
|
||||
public boolean isActivated(Ability ability, Game game) {
|
||||
Set<UUID> activations = (Set<UUID>) game.getState().getValue(CONSPIRE_ACTIVATION_KEY + ability.getId());
|
||||
if (activations != null) {
|
||||
return activations.contains(getConspireId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -125,9 +159,9 @@ public class ConspireAbility extends StaticAbility implements OptionalAdditional
|
|||
if (ability instanceof SpellAbility) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
if (player != null) {
|
||||
this.resetConspire();
|
||||
if (player.chooseUse(Outcome.Benefit, new StringBuilder("Pay ").append(conspireCost.getText(false)).append(" ?").toString(), ability, game)) {
|
||||
conspireCost.activate();
|
||||
resetConspire(ability, game);
|
||||
if (player.chooseUse(Outcome.Benefit, "Pay " + conspireCost.getText(false) + " ?", ability, game)) {
|
||||
activateConspire(ability, game);
|
||||
for (Iterator it = ((Costs) conspireCost).iterator(); it.hasNext();) {
|
||||
Cost cost = (Cost) it.next();
|
||||
ability.getCosts().add(cost.copy());
|
||||
|
|
@ -137,6 +171,22 @@ public class ConspireAbility extends StaticAbility implements OptionalAdditional
|
|||
}
|
||||
}
|
||||
|
||||
private void activateConspire(Ability ability, Game game) {
|
||||
Set<UUID> activations = (Set<UUID>) game.getState().getValue(CONSPIRE_ACTIVATION_KEY + ability.getId());
|
||||
if (activations == null) {
|
||||
activations = new HashSet<>();
|
||||
game.getState().setValue(CONSPIRE_ACTIVATION_KEY + ability.getId(), activations);
|
||||
}
|
||||
activations.add(getConspireId());
|
||||
}
|
||||
|
||||
private void resetConspire(Ability ability, Game game) {
|
||||
Set<UUID> activations = (Set<UUID>) game.getState().getValue(CONSPIRE_ACTIVATION_KEY + ability.getId());
|
||||
if (activations != null) {
|
||||
activations.remove(getConspireId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
|
@ -167,13 +217,17 @@ public class ConspireAbility extends StaticAbility implements OptionalAdditional
|
|||
|
||||
class ConspireTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public ConspireTriggeredAbility() {
|
||||
private UUID conspireId;
|
||||
|
||||
public ConspireTriggeredAbility(UUID conspireId) {
|
||||
super(Zone.STACK, new ConspireEffect());
|
||||
this.conspireId = conspireId;
|
||||
this.setRuleVisible(false);
|
||||
}
|
||||
|
||||
private ConspireTriggeredAbility(final ConspireTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.conspireId = ability.conspireId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -188,20 +242,18 @@ class ConspireTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getSourceId().equals(this.sourceId)) {
|
||||
StackObject spell = game.getStack().getStackObject(this.sourceId);
|
||||
if (spell instanceof Spell) {
|
||||
Card card = game.getCard(spell.getSourceId());
|
||||
if (card != null) {
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
if (ability instanceof ConspireAbility) {
|
||||
if (((ConspireAbility) ability).isActivated()) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setValue("ConspireSpell", spell);
|
||||
}
|
||||
return true;
|
||||
if (event.getSourceId().equals(getSourceId())) {
|
||||
Spell spell = game.getStack().getSpell(event.getSourceId());
|
||||
for (Ability ability : spell.getAbilities(game)) {
|
||||
if (ability instanceof ConspireAbility
|
||||
&& ((ConspireAbility) ability).getConspireId().equals(getConspireId())) {
|
||||
if (((ConspireAbility) ability).isActivated(spell.getSpellAbility(), game)) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
if (effect instanceof ConspireEffect) {
|
||||
((ConspireEffect) effect).setConspiredSpell(spell);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -209,52 +261,53 @@ class ConspireTriggeredAbility extends TriggeredAbilityImpl {
|
|||
return false;
|
||||
}
|
||||
|
||||
public UUID getConspireId() {
|
||||
return conspireId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Conspire: <i>As you cast this spell, you may tap two untapped creatures you control that share a color with it. When you do, copy it and you may choose a new target for the copy.)</i>";
|
||||
return "When you pay the conspire costs, copy it and you may choose a new target for the copy.";
|
||||
}
|
||||
}
|
||||
|
||||
class ConspireEffect extends OneShotEffect {
|
||||
|
||||
private Spell conspiredSpell;
|
||||
|
||||
public ConspireEffect() {
|
||||
super(Outcome.Copy);
|
||||
}
|
||||
|
||||
public ConspireEffect(final ConspireEffect effect) {
|
||||
super(effect);
|
||||
this.conspiredSpell = effect.conspiredSpell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Spell spell = (Spell) this.getValue("ConspireSpell");
|
||||
if (spell != null) {
|
||||
Card card = game.getCard(spell.getSourceId());
|
||||
if (card != null) {
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
if (ability instanceof ConspireAbility) {
|
||||
if (((ConspireAbility) ability).isActivated()) {
|
||||
((ConspireAbility) ability).resetConspire();
|
||||
}
|
||||
}
|
||||
}
|
||||
Spell copy = spell.copySpell();
|
||||
copy.setControllerId(source.getControllerId());
|
||||
copy.setCopiedSpell(true);
|
||||
game.getStack().push(copy);
|
||||
copy.chooseNewTargets(game, source.getControllerId());
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(new StringBuilder(controller.getLogName()).append(copy.getActivatedMessage(game)).toString());
|
||||
}
|
||||
return true;
|
||||
if (controller != null && conspiredSpell != null) {
|
||||
Card card = game.getCard(conspiredSpell.getSourceId());
|
||||
if (card != null) {
|
||||
Spell copy = conspiredSpell.copySpell();
|
||||
copy.setControllerId(source.getControllerId());
|
||||
copy.setCopiedSpell(true);
|
||||
game.getStack().push(copy);
|
||||
copy.chooseNewTargets(game, source.getControllerId());
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(controller.getLogName() + copy.getActivatedMessage(game));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setConspiredSpell(Spell conspiredSpell) {
|
||||
this.conspiredSpell = conspiredSpell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConspireEffect copy() {
|
||||
return new ConspireEffect(this);
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -41,6 +39,8 @@ import mage.constants.Outcome;
|
|||
import mage.constants.TargetController;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
|
|
@ -48,12 +48,10 @@ import mage.players.Player;
|
|||
*
|
||||
* @author Plopman
|
||||
*/
|
||||
|
||||
|
||||
public class CumulativeUpkeepAbility extends BeginningOfUpkeepTriggeredAbility {
|
||||
|
||||
|
||||
private Cost cumulativeCost;
|
||||
|
||||
|
||||
public CumulativeUpkeepAbility(Cost cumulativeCost) {
|
||||
super(new AddCountersSourceEffect(CounterType.AGE.createInstance()), TargetController.YOU, false);
|
||||
this.addEffect(new CumulativeUpkeepEffect(cumulativeCost));
|
||||
|
|
@ -82,9 +80,9 @@ public class CumulativeUpkeepAbility extends BeginningOfUpkeepTriggeredAbility {
|
|||
}
|
||||
|
||||
class CumulativeUpkeepEffect extends OneShotEffect {
|
||||
|
||||
private Cost cumulativeCost;
|
||||
|
||||
|
||||
private final Cost cumulativeCost;
|
||||
|
||||
CumulativeUpkeepEffect(Cost cumulativeCost) {
|
||||
super(Outcome.Sacrifice);
|
||||
this.cumulativeCost = cumulativeCost;
|
||||
|
|
@ -95,46 +93,44 @@ class CumulativeUpkeepEffect extends OneShotEffect {
|
|||
this.cumulativeCost = effect.cumulativeCost.copy();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (player != null && permanent != null) {
|
||||
if (player != null && permanent != null) {
|
||||
int ageCounter = permanent.getCounters().getCount(CounterType.AGE);
|
||||
if(cumulativeCost instanceof ManaCost){
|
||||
ManaCostsImpl totalCost = new ManaCostsImpl();
|
||||
for(int i = 0 ; i < ageCounter; i++){
|
||||
if (cumulativeCost instanceof ManaCost) {
|
||||
ManaCostsImpl totalCost = new ManaCostsImpl<>();
|
||||
for (int i = 0; i < ageCounter; i++) {
|
||||
totalCost.add((ManaCost) cumulativeCost.copy());
|
||||
}
|
||||
if (player.chooseUse(Outcome.Benefit, "Pay " + totalCost.getText() + "?", source, game)) {
|
||||
totalCost.clearPaid();
|
||||
if (totalCost.payOrRollback(source, game, source.getSourceId(), source.getControllerId())){
|
||||
if (totalCost.payOrRollback(source, game, source.getSourceId(), source.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
game.fireEvent(new GameEvent(EventType.DIDNT_PAY_CUMULATIVE_UPKEEP, permanent.getId(), permanent.getId(), player.getId(), ageCounter, false));
|
||||
permanent.sacrifice(source.getSourceId(), game);
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
CostsImpl totalCost = new CostsImpl();
|
||||
for(int i = 0 ; i < ageCounter; i++){
|
||||
return true;
|
||||
} else {
|
||||
CostsImpl<Cost> totalCost = new CostsImpl<>();
|
||||
for (int i = 0; i < ageCounter; i++) {
|
||||
totalCost.add(cumulativeCost.copy());
|
||||
}
|
||||
if (player.chooseUse(Outcome.Benefit, totalCost.getText() + "?", source, game)) {
|
||||
totalCost.clearPaid();
|
||||
int bookmark = game.bookmarkState();
|
||||
if (totalCost.pay(source, game, source.getSourceId(), source.getControllerId(), false)){
|
||||
if (totalCost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
game.restoreState(bookmark, source.getRule());
|
||||
}
|
||||
}
|
||||
game.fireEvent(new GameEvent(EventType.DIDNT_PAY_CUMULATIVE_UPKEEP, permanent.getId(), permanent.getId(), player.getId(), ageCounter, false));
|
||||
permanent.sacrifice(source.getSourceId(), game);
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public enum CardRepository {
|
|||
// raise this if db structure was changed
|
||||
private static final long CARD_DB_VERSION = 41;
|
||||
// raise this if new cards were added to the server
|
||||
private static final long CARD_CONTENT_VERSION = 39;
|
||||
private static final long CARD_CONTENT_VERSION = 40;
|
||||
|
||||
private final Random random = new Random();
|
||||
private Dao<CardInfo, Object> cardDao;
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@ public class GameEvent implements Serializable {
|
|||
ENCHANT_PLAYER, ENCHANTED_PLAYER,
|
||||
CAN_TAKE_MULLIGAN,
|
||||
FLIP_COIN, COIN_FLIPPED, SCRY, FATESEAL,
|
||||
DIDNT_PAY_CUMULATIVE_UPKEEP,
|
||||
//permanent events
|
||||
ENTERS_THE_BATTLEFIELD,
|
||||
TAP, TAPPED, TAPPED_FOR_MANA,
|
||||
|
|
@ -241,7 +242,6 @@ public class GameEvent implements Serializable {
|
|||
//combat events
|
||||
COMBAT_DAMAGE_APPLIED,
|
||||
SELECTED_ATTACKER, SELECTED_BLOCKER;
|
||||
|
||||
}
|
||||
|
||||
public GameEvent(EventType type, UUID targetId, UUID sourceId, UUID playerId) {
|
||||
|
|
|
|||
|
|
@ -109,6 +109,8 @@ public interface Permanent extends Card, Controllable {
|
|||
|
||||
UUID getAttachedTo();
|
||||
|
||||
int getAttachedToZoneChangeCounter();
|
||||
|
||||
void attachTo(UUID permanentId, Game game);
|
||||
|
||||
boolean addAttachment(UUID permanentId, Game game);
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
protected Map<String, List<UUID>> connectedCards = new HashMap<>();
|
||||
protected HashSet<MageObjectReference> dealtDamageByThisTurn;
|
||||
protected UUID attachedTo;
|
||||
protected int attachedToZoneChangeCounter;
|
||||
protected UUID pairedCard;
|
||||
protected Counters counters;
|
||||
protected List<Counter> markedDamage;
|
||||
|
|
@ -172,6 +173,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
}
|
||||
this.counters = permanent.counters.copy();
|
||||
this.attachedTo = permanent.attachedTo;
|
||||
this.attachedToZoneChangeCounter = permanent.attachedToZoneChangeCounter;
|
||||
this.minBlockedBy = permanent.minBlockedBy;
|
||||
this.maxBlockedBy = permanent.maxBlockedBy;
|
||||
this.transformed = permanent.transformed;
|
||||
|
|
@ -676,6 +678,11 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
return attachedTo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAttachedToZoneChangeCounter() {
|
||||
return attachedToZoneChangeCounter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addConnectedCard(String key, UUID connectedCard) {
|
||||
if (this.connectedCards.containsKey(key)) {
|
||||
|
|
@ -712,6 +719,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
}
|
||||
}
|
||||
this.attachedTo = permanentId;
|
||||
this.attachedToZoneChangeCounter = game.getState().getZoneChangeCounter(permanentId);
|
||||
for (Ability ability : this.getAbilities()) {
|
||||
for (Iterator<Effect> ite = ability.getEffects(game, EffectType.CONTINUOUS).iterator(); ite.hasNext();) {
|
||||
ContinuousEffect effect = (ContinuousEffect) ite.next();
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ public abstract class StackObjImpl implements StackObject {
|
|||
public boolean chooseNewTargets(Game game, UUID targetControllerId, boolean forceChange, boolean onlyOneTarget, FilterPermanent filterNewTarget) {
|
||||
Player targetController = game.getPlayer(targetControllerId);
|
||||
if (targetController != null) {
|
||||
StringBuilder oldTargetDescription = new StringBuilder();
|
||||
StringBuilder newTargetDescription = new StringBuilder();
|
||||
// Fused split spells or spells where "Splice on Arcane" was used can have more than one ability
|
||||
Abilities<Ability> objectAbilities = new AbilitiesImpl<>();
|
||||
|
|
@ -118,6 +119,7 @@ public abstract class StackObjImpl implements StackObject {
|
|||
// Some spells can have more than one mode
|
||||
for (UUID modeId : ability.getModes().getSelectedModes()) {
|
||||
Mode mode = ability.getModes().get(modeId);
|
||||
oldTargetDescription.append(ability.getTargetDescription(mode.getTargets(), game));
|
||||
for (Target target : mode.getTargets()) {
|
||||
Target newTarget = chooseNewTarget(targetController, ability, mode, target, forceChange, filterNewTarget, game);
|
||||
// clear the old target and copy all targets from new target
|
||||
|
|
@ -131,7 +133,7 @@ public abstract class StackObjImpl implements StackObject {
|
|||
}
|
||||
|
||||
}
|
||||
if (newTargetDescription.length() > 0 && !game.isSimulation()) {
|
||||
if (!newTargetDescription.toString().equals(oldTargetDescription.toString()) && !game.isSimulation()) {
|
||||
game.informPlayers(this.getLogName() + " is now " + newTargetDescription.toString());
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1104,7 +1104,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
return false;
|
||||
}
|
||||
|
||||
private void restoreState(int bookmark, String text, Game game) {
|
||||
protected void restoreState(int bookmark, String text, Game game) {
|
||||
game.restoreState(bookmark, text);
|
||||
if (storedBookmark >= bookmark) {
|
||||
resetStoredBookmark(game);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue