forked from External/mage
Reworked and improved special mana payment abilities (convoke, delve, assist, improvise):
* now it can be used to calc and find available mana and playable abilities; * now tests and AI can use that abilities; * now it follows mtg's rules and restrictions for mana activation order (rule 601.2f, see #768);
This commit is contained in:
parent
bdaf6454de
commit
c2e7b02e13
9 changed files with 341 additions and 177 deletions
|
|
@ -1,18 +1,22 @@
|
|||
|
||||
|
||||
package mage.abilities;
|
||||
|
||||
import mage.abilities.costs.mana.AlternateManaPaymentAbility;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.mana.ManaOptions;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @author BetaSteward_at_googlemail.com, JayDi85
|
||||
*/
|
||||
public abstract class SpecialAction extends ActivatedAbilityImpl {
|
||||
|
||||
private boolean manaAction;
|
||||
private final AlternateManaPaymentAbility manaAbility; // mana actions generates on every pay cycle, no need to copy it
|
||||
protected ManaCost unpaidMana;
|
||||
|
||||
public SpecialAction() {
|
||||
|
|
@ -20,22 +24,23 @@ public abstract class SpecialAction extends ActivatedAbilityImpl {
|
|||
}
|
||||
|
||||
public SpecialAction(Zone zone) {
|
||||
this(zone, false);
|
||||
this(zone, null);
|
||||
}
|
||||
public SpecialAction(Zone zone, boolean manaAction) {
|
||||
|
||||
public SpecialAction(Zone zone, AlternateManaPaymentAbility manaAbility) {
|
||||
super(AbilityType.SPECIAL_ACTION, zone);
|
||||
this.usesStack = false;
|
||||
this.manaAction = manaAction;
|
||||
this.manaAbility = manaAbility;
|
||||
}
|
||||
|
||||
public SpecialAction(final SpecialAction action) {
|
||||
super(action);
|
||||
this.manaAction = action.manaAction;
|
||||
this.unpaidMana = action.unpaidMana;
|
||||
this.manaAbility = action.manaAbility;
|
||||
}
|
||||
|
||||
public boolean isManaAction() {
|
||||
return manaAction;
|
||||
return manaAbility != null;
|
||||
}
|
||||
|
||||
public void setUnpaidMana(ManaCost manaCost) {
|
||||
|
|
@ -45,4 +50,29 @@ public abstract class SpecialAction extends ActivatedAbilityImpl {
|
|||
public ManaCost getUnpaidMana() {
|
||||
return unpaidMana;
|
||||
}
|
||||
|
||||
public ManaOptions getManaOptions(Ability source, Game game, ManaCost unpaid) {
|
||||
if (manaAbility != null) {
|
||||
return manaAbility.getManaOptions(source, game, unpaid);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivationStatus canActivate(UUID playerId, Game game) {
|
||||
if (isManaAction()) {
|
||||
// limit play mana abilities by steps
|
||||
int currentStepOrder = 0;
|
||||
if (!game.getStack().isEmpty()) {
|
||||
StackObject stackObject = game.getStack().getFirst();
|
||||
if (stackObject instanceof Spell) {
|
||||
currentStepOrder = ((Spell) stackObject).getCurrentActivatingManaAbilitiesStep().getStepOrder();
|
||||
}
|
||||
}
|
||||
if (currentStepOrder > manaAbility.useOnActivationManaAbilityStep().getStepOrder()) {
|
||||
return ActivationStatus.getFalse();
|
||||
}
|
||||
}
|
||||
return super.canActivate(playerId, game);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue