mirror of
https://github.com/magefree/mage.git
synced 2025-12-29 23:12:10 -08:00
Update Mystic Barrier
This commit is contained in:
parent
8949987b78
commit
2b7c337736
1 changed files with 12 additions and 88 deletions
|
|
@ -1,32 +1,24 @@
|
|||
|
||||
package mage.cards.m;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.ChooseModeEffect;
|
||||
import mage.abilities.meta.OrTriggeredAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.players.PlayerList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public final class MysticBarrier extends CardImpl {
|
||||
|
|
@ -38,7 +30,10 @@ public final class MysticBarrier extends CardImpl {
|
|||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{4}{W}");
|
||||
|
||||
// When Mystic Barrier enters the battlefield or at the beginning of your upkeep, choose left or right.
|
||||
this.addAbility(new MysticBarrierTriggeredAbility());
|
||||
this.addAbility(new OrTriggeredAbility(Zone.BATTLEFIELD, new ChooseModeEffect("Choose a direction to allow attacking in.",
|
||||
ALLOW_ATTACKING_LEFT, ALLOW_ATTACKING_RIGHT),
|
||||
new EntersBattlefieldTriggeredAbility(null, false),
|
||||
new BeginningOfUpkeepTriggeredAbility(null, TargetController.YOU, false)));
|
||||
|
||||
// Each player may attack only the opponent seated nearest him or her in the last chosen direction and planeswalkers controlled by that player.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new MysticBarrierReplacementEffect()));
|
||||
|
|
@ -54,77 +49,6 @@ public final class MysticBarrier extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class MysticBarrierTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public MysticBarrierTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new MysticBarrierChooseEffect(), false);
|
||||
}
|
||||
|
||||
public MysticBarrierTriggeredAbility(final MysticBarrierTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MysticBarrierTriggeredAbility copy() {
|
||||
return new MysticBarrierTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.ENTERS_THE_BATTLEFIELD || event.getType() == EventType.UPKEEP_STEP_PRE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.ENTERS_THE_BATTLEFIELD) {
|
||||
return event.getTargetId().equals(this.getSourceId());
|
||||
} else {
|
||||
return event.getPlayerId().equals(this.getControllerId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "When {this} enters the battlefield or at the beginning of your upkeep, " + super.getRule();
|
||||
}
|
||||
}
|
||||
|
||||
class MysticBarrierChooseEffect extends OneShotEffect {
|
||||
|
||||
static final String[] SET_VALUES = new String[]{MysticBarrier.ALLOW_ATTACKING_LEFT, MysticBarrier.ALLOW_ATTACKING_RIGHT};
|
||||
static final Set<String> CHOICES = new HashSet<>(Arrays.asList(SET_VALUES));
|
||||
|
||||
public MysticBarrierChooseEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "choose left or right";
|
||||
}
|
||||
|
||||
public MysticBarrierChooseEffect(final MysticBarrierChooseEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MysticBarrierChooseEffect copy() {
|
||||
return new MysticBarrierChooseEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Choice directionChoice = new ChoiceImpl(true);
|
||||
directionChoice.setChoices(CHOICES);
|
||||
directionChoice.setMessage("Direction each player may only attack to");
|
||||
directionChoice.isRequired();
|
||||
if (!controller.choose(outcome, directionChoice, game)) {
|
||||
game.getState().setValue("attack_direction_" + source.getSourceId(), directionChoice.getChoice());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class MysticBarrierReplacementEffect extends ReplacementEffectImpl {
|
||||
|
||||
MysticBarrierReplacementEffect() {
|
||||
|
|
@ -152,7 +76,7 @@ class MysticBarrierReplacementEffect extends ReplacementEffectImpl {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
if (game.getState().getPlayersInRange(controller.getId(), game).contains(event.getPlayerId())) {
|
||||
String allowedDirection = (String) game.getState().getValue(new StringBuilder("attack_direction_").append(source.getSourceId()).toString());
|
||||
String allowedDirection = (String) game.getState().getValue(source.getSourceId() + "_modeChoice");
|
||||
if (allowedDirection != null) {
|
||||
Player defender = game.getPlayer(event.getTargetId());
|
||||
if (defender == null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue