mirror of
https://github.com/magefree/mage.git
synced 2026-01-23 03:39:54 -08:00
listening to Pet Sounds on repeat while I refactor ConditionalInterveningIfTriggeredAbility
This commit is contained in:
parent
cdcda710c8
commit
79a2f80563
151 changed files with 1189 additions and 1889 deletions
|
|
@ -10,6 +10,7 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
|
|
@ -30,7 +31,7 @@ public class PutIntoGraveFromBattlefieldAllTriggeredAbility extends TriggeredAbi
|
|||
this.filter = filter;
|
||||
this.onlyToControllerGraveyard = onlyToControllerGraveyard;
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
setTriggerPhrase("Whenever " + filter.getMessage() + " is put into " +
|
||||
setTriggerPhrase("Whenever " + CardUtil.addArticle(filter.getMessage()) + " is put into " +
|
||||
(onlyToControllerGraveyard ? "your" : "a") + " graveyard, ");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,6 @@ public enum HaveInitiativeCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "if you have the initiative";
|
||||
return "you have the initiative";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author xenohedron
|
||||
|
|
@ -20,9 +21,10 @@ public class LifeCompareCondition implements Condition {
|
|||
|
||||
/**
|
||||
* "As long as [player] has [number] or [more/less] life"
|
||||
*
|
||||
* @param targetController YOU, OPPONENT, ANY, EACH_PLAYER
|
||||
* @param comparisonType comparison operator
|
||||
* @param amount life threshold
|
||||
* @param comparisonType comparison operator
|
||||
* @param amount life threshold
|
||||
*/
|
||||
public LifeCompareCondition(TargetController targetController, ComparisonType comparisonType, int amount) {
|
||||
this.targetController = targetController;
|
||||
|
|
@ -40,7 +42,8 @@ public class LifeCompareCondition implements Condition {
|
|||
case YOU:
|
||||
return ComparisonType.compare(controller.getLife(), comparisonType, amount);
|
||||
case OPPONENT:
|
||||
return game.getOpponents(controller.getId())
|
||||
return game
|
||||
.getOpponents(controller.getId())
|
||||
.stream()
|
||||
.map(game::getPlayer)
|
||||
.filter(Objects::nonNull)
|
||||
|
|
@ -48,7 +51,9 @@ public class LifeCompareCondition implements Condition {
|
|||
.map(Player::getLife)
|
||||
.anyMatch(l -> ComparisonType.compare(l, comparisonType, amount));
|
||||
case ANY:
|
||||
return game.getState().getPlayersInRange(controller.getId(), game)
|
||||
return game
|
||||
.getState()
|
||||
.getPlayersInRange(controller.getId(), game)
|
||||
.stream()
|
||||
.map(game::getPlayer)
|
||||
.filter(Objects::nonNull)
|
||||
|
|
@ -56,13 +61,23 @@ public class LifeCompareCondition implements Condition {
|
|||
.map(Player::getLife)
|
||||
.anyMatch(l -> ComparisonType.compare(l, comparisonType, amount));
|
||||
case EACH_PLAYER:
|
||||
return game.getState().getPlayersInRange(controller.getId(), game)
|
||||
return game
|
||||
.getState()
|
||||
.getPlayersInRange(controller.getId(), game)
|
||||
.stream()
|
||||
.map(game::getPlayer)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(Player::isInGame)
|
||||
.map(Player::getLife)
|
||||
.allMatch(l -> ComparisonType.compare(l, comparisonType, amount));
|
||||
case ACTIVE:
|
||||
return Optional
|
||||
.ofNullable(game)
|
||||
.map(Game::getActivePlayerId)
|
||||
.map(game::getPlayer)
|
||||
.map(Player::getLife)
|
||||
.filter(l -> ComparisonType.compare(l, comparisonType, amount))
|
||||
.isPresent();
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported TargetController in LifeCompareCondition: " + targetController);
|
||||
}
|
||||
|
|
@ -84,27 +99,30 @@ public class LifeCompareCondition implements Condition {
|
|||
case EACH_PLAYER:
|
||||
sb.append("each player has ");
|
||||
break;
|
||||
case ACTIVE:
|
||||
sb.append("that player has ");
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported TargetController in LifeCompareCondition: " + targetController);
|
||||
}
|
||||
switch (comparisonType) {
|
||||
case MORE_THAN:
|
||||
sb.append("more than ").append(amount);
|
||||
break;
|
||||
case FEWER_THAN:
|
||||
sb.append("less than ").append(amount);
|
||||
break;
|
||||
case EQUAL_TO:
|
||||
sb.append("exactly ").append(amount);
|
||||
break;
|
||||
case OR_GREATER:
|
||||
sb.append(amount).append(" or more");
|
||||
break;
|
||||
case OR_LESS:
|
||||
sb.append(amount).append(" or less");
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported ComparisonType in LifeCompareCondition: " + comparisonType);
|
||||
case MORE_THAN:
|
||||
sb.append("more than ").append(amount);
|
||||
break;
|
||||
case FEWER_THAN:
|
||||
sb.append("less than ").append(amount);
|
||||
break;
|
||||
case EQUAL_TO:
|
||||
sb.append("exactly ").append(amount);
|
||||
break;
|
||||
case OR_GREATER:
|
||||
sb.append(amount).append(" or more");
|
||||
break;
|
||||
case OR_LESS:
|
||||
sb.append(amount).append(" or less");
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported ComparisonType in LifeCompareCondition: " + comparisonType);
|
||||
}
|
||||
sb.append(" life");
|
||||
return sb.toString();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -19,6 +18,6 @@ public enum MonarchIsNotSetCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "if there is no monarch";
|
||||
return "there is no monarch";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,27 +6,32 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
* Checks if a Permanent is renown
|
||||
* Checks if a Permanent is renowned
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public enum RenownedSourceCondition implements Condition {
|
||||
|
||||
instance;
|
||||
THIS("{this} is"),
|
||||
ITS("it's");
|
||||
private final String name;
|
||||
|
||||
RenownedSourceCondition(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
return permanent.isRenowned();
|
||||
return permanent.isRenowned();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "it's renowned";
|
||||
return name + " renowned";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import mage.game.Game;
|
|||
*
|
||||
* @author Susucr
|
||||
*/
|
||||
|
||||
public enum SourceInExileCondition implements Condition {
|
||||
instance;
|
||||
|
||||
|
|
@ -18,4 +17,9 @@ public enum SourceInExileCondition implements Condition {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
return game.getState().getZone(source.getSourceId()) == Zone.EXILED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{this} is exiled";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -11,11 +10,15 @@ import mage.util.CardUtil;
|
|||
* @author TheElk801
|
||||
*/
|
||||
public enum SpectacleCondition implements Condition {
|
||||
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return CardUtil.checkSourceCostsTagExists(game, source, SpectacleAbility.SPECTACLE_ACTIVATION_VALUE_KEY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "its spectacle cost was paid";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -8,15 +7,18 @@ import mage.game.Game;
|
|||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public enum SurgedCondition implements Condition {
|
||||
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return CardUtil.checkSourceCostsTagExists(game, source, SurgeAbility.SURGE_ACTIVATION_VALUE_KEY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "its surge cost was paid";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public enum YouControlTwoOrMoreGatesCondition implements Condition {
|
||||
instance;
|
||||
private static final FilterPermanent filter = new FilterControlledPermanent(SubType.GATE);
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return game.getBattlefield().count(filter, source.getControllerId(), source, game) >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "you control two or more Gates";
|
||||
}
|
||||
}
|
||||
|
|
@ -20,12 +20,11 @@ public class LearnEffect extends OneShotEffect {
|
|||
filter.add(SubType.LESSON.getPredicate());
|
||||
}
|
||||
|
||||
private static final String defaultText = "learn. <i>(You may reveal a Lesson card you own from outside the game " +
|
||||
"and put it into your hand, or discard a card to draw a card.)</i>";
|
||||
|
||||
public LearnEffect() {
|
||||
super(Outcome.Neutral);
|
||||
staticText = defaultText;
|
||||
staticText = "learn. <i>(You may reveal a Lesson card you own " +
|
||||
"from outside the game and put it into your hand, or discard a card to draw a card.)</i>";
|
||||
}
|
||||
|
||||
private LearnEffect(final LearnEffect effect) {
|
||||
|
|
@ -50,8 +49,4 @@ public class LearnEffect extends OneShotEffect {
|
|||
public LearnEffect copy() {
|
||||
return new LearnEffect(this);
|
||||
}
|
||||
|
||||
public static String getDefaultText() {
|
||||
return defaultText;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import mage.game.Game;
|
|||
|
||||
public enum RenownedHint implements Hint {
|
||||
instance;
|
||||
private static final ConditionHint hint = new ConditionHint(RenownedSourceCondition.instance,
|
||||
private static final ConditionHint hint = new ConditionHint(RenownedSourceCondition.THIS,
|
||||
"{this} is renowned", null,
|
||||
"{this} isn't renowned", null, true);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import mage.game.permanent.Permanent;
|
|||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class RenownAbility extends TriggeredAbilityImpl {
|
||||
|
|
|
|||
|
|
@ -1,25 +1,28 @@
|
|||
package mage.target.common;
|
||||
|
||||
import mage.filter.common.FilterOpponentOrPlaneswalker;
|
||||
import mage.filter.common.FilterPermanentOrPlayer;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class TargetOpponentOrPlaneswalker extends TargetPermanentOrPlayer {
|
||||
|
||||
private static final FilterPermanentOrPlayer filter = new FilterOpponentOrPlaneswalker();
|
||||
|
||||
public TargetOpponentOrPlaneswalker() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public TargetOpponentOrPlaneswalker(FilterOpponentOrPlaneswalker filter) {
|
||||
this(1, 1, filter, false);
|
||||
}
|
||||
|
||||
public TargetOpponentOrPlaneswalker(int numTargets) {
|
||||
this(numTargets, numTargets, new FilterOpponentOrPlaneswalker("opponent or planeswalker"), false);
|
||||
this(numTargets, numTargets);
|
||||
}
|
||||
|
||||
public TargetOpponentOrPlaneswalker(int minNumTargets, int maxNumTargets, FilterOpponentOrPlaneswalker filter, boolean notTarget) {
|
||||
public TargetOpponentOrPlaneswalker(int minNumTargets, int maxNumTargets) {
|
||||
this(minNumTargets, maxNumTargets, false);
|
||||
}
|
||||
|
||||
public TargetOpponentOrPlaneswalker(int minNumTargets, int maxNumTargets, boolean notTarget) {
|
||||
super(minNumTargets, maxNumTargets, filter, notTarget);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue