* Changed "Activate only during upkeep" abilities to conditional abilities instead of a cost for this restriction.

This commit is contained in:
LevelX2 2014-07-28 16:53:37 +02:00
parent f51e7722cc
commit caf8a1e5ec
16 changed files with 102 additions and 160 deletions

View file

@ -70,7 +70,7 @@ public class EntersBattlefieldControlledTriggeredAbility extends EntersBattlefie
super(zone, effect, filter, optional, setTargetPointer, rule, true);
}
public EntersBattlefieldControlledTriggeredAbility(EntersBattlefieldControlledTriggeredAbility ability) {
public EntersBattlefieldControlledTriggeredAbility(final EntersBattlefieldControlledTriggeredAbility ability) {
super(ability);
}

View file

@ -18,7 +18,7 @@ public interface Condition extends Serializable {
Equal("=="),
LessThan("<");
private String text;
private final String text;
ComparisonType(String text) {
this.text = text;

View file

@ -31,7 +31,6 @@ package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.constants.PhaseStep;
import mage.constants.TurnPhase;
import mage.game.Game;
/**
@ -41,19 +40,25 @@ import mage.game.Game;
public class IsStepCondition implements Condition {
protected PhaseStep phaseStep;
protected boolean onlyDuringYourSteps;
public IsStepCondition(PhaseStep phaseStep) {
this(phaseStep, true);
}
public IsStepCondition(PhaseStep phaseStep, boolean onlyDuringYourSteps) {
this.phaseStep = phaseStep;
this.onlyDuringYourSteps = onlyDuringYourSteps;
}
@Override
public boolean apply(Game game, Ability source) {
return game.getActivePlayerId().equals(source.getSourceId()) && game.getStep().getType().equals(phaseStep);
return phaseStep.equals(game.getStep().getType()) && (!onlyDuringYourSteps || game.getActivePlayerId().equals(source.getControllerId()));
}
@Override
public String toString() {
return new StringBuilder("during your ").append(phaseStep.toString()).toString();
return new StringBuilder("during ").append(onlyDuringYourSteps ? "your ":"the ").append(phaseStep.getStepText()).toString();
}
}

View file

@ -1,68 +0,0 @@
/*
* Copyright 2011 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.costs.common;
import java.util.UUID;
import mage.constants.PhaseStep;
import mage.abilities.Ability;
import mage.abilities.costs.CostImpl;
import mage.game.Game;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class OnlyDuringUpkeepCost extends CostImpl {
public OnlyDuringUpkeepCost() {
text = "Activate this ability only during your upkeep";
}
public OnlyDuringUpkeepCost(final OnlyDuringUpkeepCost cost) {
super(cost);
}
@Override
public OnlyDuringUpkeepCost copy() {
return new OnlyDuringUpkeepCost(this);
}
@Override
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
if (game.getActivePlayerId().equals(controllerId) && game.getStep().getType() == PhaseStep.UPKEEP)
return true;
return false;
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
this.paid = true;
return paid;
}
}

View file

@ -23,7 +23,7 @@ import mage.game.Game;
*/
public class ConditionalActivatedAbility extends ActivatedAbilityImpl {
private Condition condition;
private final Condition condition;
private String ruleText = null;
private static final Effects emptyEffects = new Effects();
@ -34,7 +34,7 @@ public class ConditionalActivatedAbility extends ActivatedAbilityImpl {
this.ruleText = rule;
}
public ConditionalActivatedAbility(Zone zone, Effect effect, Costs costs, Condition condition, String rule) {
public ConditionalActivatedAbility(Zone zone, Effect effect, Costs<Cost> costs, Condition condition, String rule) {
super(zone, effect, costs);
this.condition = condition;
this.ruleText = rule;

View file

@ -5,30 +5,32 @@ package mage.constants;
* @author North
*/
public enum PhaseStep {
UNTAP ("Untap", 0),
UPKEEP ("Upkeep", 1),
DRAW ("Draw", 2),
PRECOMBAT_MAIN ("Precombat Main", 3),
BEGIN_COMBAT ("Begin Combat", 4),
DECLARE_ATTACKERS ("Declare Attackers", 5),
DECLARE_BLOCKERS ("Declare Blockers", 6),
FIRST_COMBAT_DAMAGE ("First Combat Damage", 7),
COMBAT_DAMAGE ("Combat Damage", 8),
END_COMBAT ("End Combat", 9),
POSTCOMBAT_MAIN ("Postcombat Main", 10),
END_TURN ("End Turn", 11),
CLEANUP ("Cleanup", 12);
UNTAP ("Untap", 0, "untap step"),
UPKEEP ("Upkeep", 1, "upkeep"), // card texts don't use the word "step" for this phase step
DRAW ("Draw", 2, "draw step"),
PRECOMBAT_MAIN ("Precombat Main", 3,"precombat main step"),
BEGIN_COMBAT ("Begin Combat", 4, "begin combat step"),
DECLARE_ATTACKERS ("Declare Attackers", 5, "declare attackers step"),
DECLARE_BLOCKERS ("Declare Blockers", 6, "declare blockers"),
FIRST_COMBAT_DAMAGE ("First Combat Damage", 7, "first combat damage"),
COMBAT_DAMAGE ("Combat Damage", 8, "combat damage step"),
END_COMBAT ("End Combat", 9, "end combat step"),
POSTCOMBAT_MAIN ("Postcombat Main", 10, "postcombat main step"),
END_TURN ("End Turn", 11, "end turn step"),
CLEANUP ("Cleanup", 12, "cleanup step");
private final String text;
private final String stepText;
/**
* Index is used for game state scoring system.
*/
private final int index;
PhaseStep(String text, int index) {
PhaseStep(String text, int index, String stepText) {
this.text = text;
this.index = index;
this.stepText = stepText;
}
public int getIndex() {
@ -40,4 +42,8 @@ public enum PhaseStep {
return text;
}
public String getStepText() {
return stepText;
}
}