mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 06:22:01 -08:00
rework effects and abilities which care about controlling your own commander (fixes #13542)
This commit is contained in:
parent
c0c27c81fa
commit
d4954bf784
15 changed files with 128 additions and 203 deletions
|
|
@ -1,14 +1,11 @@
|
|||
|
||||
|
||||
package mage.abilities.abilityword;
|
||||
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.condition.common.CommanderInPlayCondition;
|
||||
import mage.abilities.condition.common.ControlYourCommanderCondition;
|
||||
import mage.abilities.decorator.ConditionalContinuousEffect;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
import mage.constants.AbilityWord;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Zone;
|
||||
|
||||
|
|
@ -18,16 +15,19 @@ import mage.constants.Zone;
|
|||
|
||||
public class LieutenantAbility extends SimpleStaticAbility {
|
||||
|
||||
public LieutenantAbility(ContinuousEffect effect) {
|
||||
super(Zone.BATTLEFIELD, new ConditionalContinuousEffect(new BoostSourceEffect(2, 2, Duration.WhileOnBattlefield), CommanderInPlayCondition.instance, "<i>Lieutenant</i> — As long as you control your commander, {this} gets +2/+2"));
|
||||
this.addEffect(new ConditionalContinuousEffect(effect, CommanderInPlayCondition.instance, effect.getText(null)));
|
||||
public LieutenantAbility(ContinuousEffect effect, String text) {
|
||||
super(Zone.BATTLEFIELD, new ConditionalContinuousEffect(
|
||||
new BoostSourceEffect(2, 2, Duration.WhileOnBattlefield),
|
||||
ControlYourCommanderCondition.instance,
|
||||
"as long as you control your commander, {this} gets +2/+2"
|
||||
));
|
||||
this.setAbilityWord(AbilityWord.LIEUTENANT);
|
||||
this.addLieutenantEffect(effect, text);
|
||||
}
|
||||
|
||||
public LieutenantAbility(Effects effects) {
|
||||
super(Zone.BATTLEFIELD, new ConditionalContinuousEffect(new BoostSourceEffect(2, 2, Duration.WhileOnBattlefield), CommanderInPlayCondition.instance, "<i>Lieutenant</i> — As long as you control your commander, {this} gets +2/+2"));
|
||||
for (Effect effect : effects) {
|
||||
this.addEffect(new ConditionalContinuousEffect((ContinuousEffect) effect, CommanderInPlayCondition.instance, effect.getText(null)));
|
||||
}
|
||||
public LieutenantAbility addLieutenantEffect(ContinuousEffect effect, String text) {
|
||||
this.addEffect(new ConditionalContinuousEffect(effect, ControlYourCommanderCondition.instance, text));
|
||||
return this;
|
||||
}
|
||||
|
||||
protected LieutenantAbility(final LieutenantAbility ability) {
|
||||
|
|
@ -38,4 +38,4 @@ public class LieutenantAbility extends SimpleStaticAbility {
|
|||
public LieutenantAbility copy() {
|
||||
return new LieutenantAbility(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* Checks if the player has its commander in play and controls it
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public enum CommanderInPlayCondition implements Condition {
|
||||
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return ControlYourCommanderCondition.instance.apply(game, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "As long as you control your commander";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,10 +3,10 @@ package mage.abilities.condition.common;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.constants.CommanderCardType;
|
||||
import mage.game.Controllable;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
|
|
@ -19,21 +19,18 @@ public enum ControlYourCommanderCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return game.getPlayerList()
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
return player != null && game
|
||||
.getCommandersIds(player, CommanderCardType.COMMANDER_OR_OATHBREAKER, true)
|
||||
.stream()
|
||||
.map(game::getPlayer)
|
||||
.filter(Objects::nonNull)
|
||||
.map(player -> game.getCommandersIds(player, CommanderCardType.COMMANDER_OR_OATHBREAKER, true)) // must search all card parts (example: mdf commander on battlefield)
|
||||
.flatMap(Collection::stream)
|
||||
.map(game::getPermanent)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(Permanent::isPhasedIn)
|
||||
.map(Permanent::getOwnerId)
|
||||
.anyMatch(source.getControllerId()::equals);
|
||||
.map(Controllable::getControllerId)
|
||||
.anyMatch(source::isControlledBy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "If you control your commander";
|
||||
return "you control your commander";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue