mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
[AER] Added Battke at the Bridge.
This commit is contained in:
parent
24f72004e3
commit
c2852ca233
7 changed files with 246 additions and 6 deletions
149
Mage/src/main/java/mage/abilities/keyword/ImproviseAbility.java
Normal file
149
Mage/src/main/java/mage/abilities/keyword/ImproviseAbility.java
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
/*
|
||||
* 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.keyword;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpecialAction;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.mana.AlternateManaPaymentAbility;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterArtifactPermanent;
|
||||
import mage.filter.common.FilterControlledArtifactPermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.permanent.TappedPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.ManaPool;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ImproviseAbility extends SimpleStaticAbility implements AlternateManaPaymentAbility {
|
||||
|
||||
private static final FilterArtifactPermanent filterUntapped = new FilterArtifactPermanent();
|
||||
|
||||
static {
|
||||
filterUntapped.add(Predicates.not(new TappedPredicate()));
|
||||
}
|
||||
|
||||
public ImproviseAbility() {
|
||||
super(Zone.STACK, null);
|
||||
this.setRuleAtTheTop(true);
|
||||
}
|
||||
|
||||
public ImproviseAbility(final ImproviseAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImproviseAbility copy() {
|
||||
return new ImproviseAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && game.getBattlefield().contains(filterUntapped, controller.getId(), 1, game)) {
|
||||
if (source.getAbilityType().equals(AbilityType.SPELL) && unpaid.getMana().getGeneric() > 0) {
|
||||
SpecialAction specialAction = new ImproviseSpecialAction(unpaid);
|
||||
specialAction.setControllerId(source.getControllerId());
|
||||
specialAction.setSourceId(source.getSourceId());
|
||||
// create filter for possible artifacts to tap
|
||||
FilterControlledArtifactPermanent filter = new FilterControlledArtifactPermanent();
|
||||
filter.add(Predicates.not(new TappedPredicate()));
|
||||
Target target = new TargetControlledPermanent(1, unpaid.getMana().getGeneric(), filter, true);
|
||||
target.setTargetName("artifact to Improvise");
|
||||
specialAction.addTarget(target);
|
||||
if (specialAction.canActivate(source.getControllerId(), game)) {
|
||||
game.getState().getSpecialActions().add(specialAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Improvise <i>(Your artifacts can help cast this spell. Each artifact you tap after you're done activating mana abilities pays for {1}.)</i>";
|
||||
}
|
||||
}
|
||||
|
||||
class ImproviseSpecialAction extends SpecialAction {
|
||||
|
||||
public ImproviseSpecialAction(ManaCost unpaid) {
|
||||
super(Zone.ALL, true);
|
||||
setRuleVisible(false);
|
||||
this.addEffect(new ImproviseEffect(unpaid));
|
||||
}
|
||||
|
||||
public ImproviseSpecialAction(final ImproviseSpecialAction ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImproviseSpecialAction copy() {
|
||||
return new ImproviseSpecialAction(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ImproviseEffect extends OneShotEffect {
|
||||
|
||||
private final ManaCost unpaid;
|
||||
|
||||
public ImproviseEffect(ManaCost unpaid) {
|
||||
super(Outcome.Benefit);
|
||||
this.unpaid = unpaid;
|
||||
this.staticText = "Improvise (Your artifacts can help cast this spell. Each artifact you tap after you're done activating mana abilities pays for {1}.)";
|
||||
}
|
||||
|
||||
public ImproviseEffect(final ImproviseEffect effect) {
|
||||
super(effect);
|
||||
this.unpaid = effect.unpaid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImproviseEffect copy() {
|
||||
return new ImproviseEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Spell spell = game.getStack().getSpell(source.getSourceId());
|
||||
if (controller != null && spell != null) {
|
||||
for (UUID artifactId : this.getTargetPointer().getTargets(game, source)) {
|
||||
Permanent perm = game.getPermanent(artifactId);
|
||||
if (perm == null) {
|
||||
continue;
|
||||
}
|
||||
if (!perm.isTapped() && perm.tap(game)) {
|
||||
ManaPool manaPool = controller.getManaPool();
|
||||
manaPool.addMana(Mana.ColorlessMana(1), game, source);
|
||||
manaPool.unlockManaType(ManaType.COLORLESS);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers("Improvise: " + controller.getLogName() + " taps " + perm.getLogName() + " to pay {1}");
|
||||
}
|
||||
spell.setDoneActivatingManaAbilities(true);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -70,8 +70,10 @@ public abstract class ActivatedManaAbilityImpl extends ActivatedAbilityImpl impl
|
|||
if (!controlsAbility(playerId, game)) {
|
||||
return false;
|
||||
}
|
||||
// check if player is in the process of playing spell costs and he is no longer allowed to use activated mana abilities (e.g. becaus he started to use improvise)
|
||||
//20091005 - 605.3a
|
||||
return costs.canPay(this, sourceId, controllerId, game);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -88,6 +88,8 @@ public class Spell extends StackObjImpl implements Card {
|
|||
private boolean faceDown;
|
||||
private boolean countered;
|
||||
|
||||
private boolean doneActivatingManaAbilities; // if this is true, the player is no longer allowed to pay the spell costs with activating of mana abilies
|
||||
|
||||
public Spell(Card card, SpellAbility ability, UUID controllerId, Zone fromZone) {
|
||||
this.card = card;
|
||||
this.color = card.getColor(null).copy();
|
||||
|
|
@ -108,6 +110,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
this.controllerId = controllerId;
|
||||
this.fromZone = fromZone;
|
||||
this.countered = false;
|
||||
this.doneActivatingManaAbilities = false;
|
||||
}
|
||||
|
||||
public Spell(final Spell spell) {
|
||||
|
|
@ -135,6 +138,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
this.color = spell.color.copy();
|
||||
this.frameColor = spell.color.copy();
|
||||
this.frameStyle = spell.frameStyle;
|
||||
this.doneActivatingManaAbilities = spell.doneActivatingManaAbilities;
|
||||
}
|
||||
|
||||
public boolean activate(Game game, boolean noMana) {
|
||||
|
|
@ -383,6 +387,14 @@ public class Spell extends StackObjImpl implements Card {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isDoneActivatingManaAbilities() {
|
||||
return doneActivatingManaAbilities;
|
||||
}
|
||||
|
||||
public void setDoneActivatingManaAbilities(boolean doneActivatingManaAbilities) {
|
||||
this.doneActivatingManaAbilities = doneActivatingManaAbilities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSourceId() {
|
||||
return card.getId();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue