mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
Added IsPhaseCondition, some minor framework formatting.
This commit is contained in:
parent
f9f26d3416
commit
5186f690d7
8 changed files with 82 additions and 6 deletions
|
@ -31,6 +31,7 @@ package mage.abilities.common;
|
|||
import java.util.UUID;
|
||||
import mage.abilities.ActivatedAbilityImpl;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.InvertCondition;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
|
@ -80,7 +81,12 @@ public class ActivateIfConditionActivatedAbility extends ActivatedAbilityImpl<Ac
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
StringBuilder sb = new StringBuilder(super.getRule()).append(" Activate this ability only ");
|
||||
StringBuilder sb = new StringBuilder(super.getRule());
|
||||
if (condition instanceof InvertCondition) {
|
||||
sb.append(" You can't activate this ability ");
|
||||
} else {
|
||||
sb.append(" Activate this ability only ");
|
||||
}
|
||||
if (condition.toString() != null) {
|
||||
if (!condition.toString().startsWith("during")) {
|
||||
sb.append("if ");
|
||||
|
|
|
@ -39,7 +39,7 @@ import mage.game.Game;
|
|||
*/
|
||||
public class InvertCondition implements Condition {
|
||||
|
||||
private Condition condition;
|
||||
private final Condition condition;
|
||||
|
||||
public InvertCondition ( Condition condition ) {
|
||||
this.condition = condition;
|
||||
|
@ -53,4 +53,9 @@ public class InvertCondition implements Condition {
|
|||
return !condition.apply(game, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return condition.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* 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.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class IsPhaseCondition implements Condition {
|
||||
|
||||
protected TurnPhase turnPhase;
|
||||
|
||||
public IsPhaseCondition(TurnPhase turnPhase) {
|
||||
this.turnPhase = turnPhase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return game.getTurn().getPhaseType().equals(turnPhase);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder("during ").append(turnPhase).toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@ public enum TurnPhase {
|
|||
POSTCOMBAT_MAIN ("Postcombat Main"),
|
||||
END ("End");
|
||||
|
||||
private String text;
|
||||
private final String text;
|
||||
|
||||
TurnPhase(String text) {
|
||||
this.text = text;
|
||||
|
|
|
@ -42,6 +42,7 @@ import java.util.UUID;
|
|||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @param <T>
|
||||
*/
|
||||
public class TargetCard<T extends TargetCard<T>> extends TargetObject<TargetCard<T>> {
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ import java.util.*;
|
|||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class TargetImpl<T extends TargetImpl<T>> implements Target {
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ import java.util.UUID;
|
|||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class TargetObject<T extends TargetObject<T>> extends TargetImpl<T> {
|
||||
|
||||
|
|
|
@ -28,15 +28,14 @@
|
|||
|
||||
package mage.target.common;
|
||||
|
||||
import mage.constants.Zone;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.target.TargetCard;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -47,6 +46,11 @@ public class TargetCardInGraveyard extends TargetCard<TargetCardInGraveyard> {
|
|||
this(1, 1, new FilterCard("card from a graveyard"));
|
||||
}
|
||||
|
||||
public TargetCardInGraveyard(boolean required) {
|
||||
this();
|
||||
this.setRequired(required);
|
||||
}
|
||||
|
||||
public TargetCardInGraveyard(FilterCard filter) {
|
||||
this(1, 1, filter);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue