Merge pull request #4772 from spjspj/master

Continuing implementation of Planechase.
This commit is contained in:
spjspj 2018-04-17 02:43:45 +10:00 committed by GitHub
commit 91cf3556d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 141 additions and 10 deletions

View file

@ -1077,7 +1077,7 @@ public abstract class GameImpl implements Game, Serializable {
// 20180408 - 901.5
if (gameOptions.planeChase) {
Plane plane = Plane.getRandomPlane();
plane.setControllerId(getActivePlayerId());
plane.setControllerId(startingPlayerId);
addPlane(plane, null, getActivePlayerId());
state.setPlaneChase(this, gameOptions.planeChase);
}

View file

@ -33,17 +33,23 @@ import mage.abilities.Ability;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.HellbentCondition;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.MainPhaseStackEmptyCondition;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.abilities.effects.common.discard.DiscardHandControllerEffect;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.command.Plane;
import mage.players.Player;
import mage.target.Target;
import mage.util.CardUtil;
import mage.watchers.common.PlanarRollWatcher;
/**
@ -57,7 +63,7 @@ public class AcademyAtTolariaWestPlane extends Plane {
this.setExpansionSetCodeForImage("PCA");
// At the beginning of your end step, if you have 0 cards in hand, draw seven cards
Ability ability = new BeginningOfEndStepTriggeredAbility(Zone.COMMAND, new DrawCardSourceControllerEffect(7), TargetController.ANY, HellbentCondition.instance, false);
Ability ability = new BeginningOfEndStepTriggeredAbility(Zone.COMMAND, new DrawCardsActivePlayerEffect(7), TargetController.ANY, HellbentAPCondition.instance, false);
this.getAbilities().add(ability);
// Active player can roll the planar die: Whenever you roll {CHAOS}, discard your hand
@ -77,3 +83,66 @@ public class AcademyAtTolariaWestPlane extends Plane {
this.getAbilities().add(new SimpleStaticAbility(Zone.ALL, new PlanarDieRollCostIncreasingEffect(chaosAbility.getOriginalId())));
}
}
class DrawCardsActivePlayerEffect extends OneShotEffect {
protected DynamicValue amount;
public DrawCardsActivePlayerEffect(int amount) {
this(new StaticValue(amount));
}
public DrawCardsActivePlayerEffect(DynamicValue amount) {
super(Outcome.DrawCard);
this.amount = amount.copy();
setText();
}
public DrawCardsActivePlayerEffect(final DrawCardsActivePlayerEffect effect) {
super(effect);
this.amount = effect.amount.copy();
}
@Override
public DrawCardsActivePlayerEffect copy() {
return new DrawCardsActivePlayerEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
if (game.getState().getCurrentPlane() != null) {
if (!game.getState().getCurrentPlane().getName().equalsIgnoreCase("Plane - Academy at Tolaria West")) {
return false;
}
}
Player player = game.getPlayer(game.getActivePlayerId());
if (player != null) {
player.drawCards(amount.calculate(game, source, this), game);
return true;
}
return false;
}
private void setText() {
StringBuilder sb = new StringBuilder();
sb.append("draw ").append(CardUtil.numberToText(amount.toString())).append(" cards");
staticText = sb.toString();
}
}
enum HellbentAPCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
return game.getPlayer(game.getActivePlayerId()).getHand().isEmpty();
}
@Override
public String toString() {
return "if you have no cards in hand";
}
}

View file

@ -29,15 +29,17 @@ package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.MainPhaseStackEmptyCondition;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.abilities.effects.common.SkipUntapStepEffect;
import mage.abilities.effects.common.UntapAllControllerEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.constants.Duration;
@ -120,11 +122,19 @@ class EdgeOfMalacolEffect extends ContinuousRuleModifyingEffectImpl {
public boolean applies(GameEvent event, Ability source, Game game) {
// Prevent untap event of creatures of target player
if (game.getTurn().getStepType() == PhaseStep.UNTAP) {
if (game.getState().getCurrentPlane() != null) {
if (!game.getState().getCurrentPlane().getName().equalsIgnoreCase("Plane - Edge of Malacol")) {
return false;
}
}
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && filter.match(permanent, game)) {
if (permanent != null && filter.match(permanent, game) && permanent.getControllerId() == game.getActivePlayerId()) {
UUID oldController = source.getControllerId();
source.setControllerId(game.getActivePlayerId());
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(2));
effect.setTargetPointer(new FixedTarget(permanent, game));
effect.apply(game, source);
source.setControllerId(oldController);
return true;
}
}

View file

@ -117,6 +117,11 @@ class HedronFieldsOfAgadeemRestrictionEffect extends RestrictionEffect {
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
if (game.getState().getCurrentPlane() != null) {
if (!game.getState().getCurrentPlane().getName().equalsIgnoreCase("Plane - Hedron Fields of Agadeem")) {
return false;
}
}
return filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
}
}

View file

@ -34,14 +34,18 @@ import mage.abilities.common.ActivateIfConditionActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.MainPhaseStackEmptyCondition;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.abilities.effects.common.SkipUntapStepEffect;
import mage.abilities.effects.common.UntapAllControllerEffect;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.game.command.Plane;
import mage.game.events.GameEvent;
import mage.target.Target;
import mage.watchers.common.PlanarRollWatcher;
@ -56,7 +60,7 @@ public class TheEonFogPlane extends Plane {
this.setExpansionSetCodeForImage("PCA");
// All players miss their untap step
Ability ability = new SimpleStaticAbility(Zone.COMMAND, new SkipUntapStepEffect());
Ability ability = new SimpleStaticAbility(Zone.COMMAND, new TheEonFogSkipUntapStepEffect(Duration.Custom, true));
this.getAbilities().add(ability);
// Active player can roll the planar die: Whenever you roll {CHAOS}, untap all permanents you control
@ -76,3 +80,40 @@ public class TheEonFogPlane extends Plane {
this.getAbilities().add(new SimpleStaticAbility(Zone.ALL, new PlanarDieRollCostIncreasingEffect(chaosAbility.getOriginalId())));
}
}
class TheEonFogSkipUntapStepEffect extends ContinuousRuleModifyingEffectImpl {
boolean allPlayers = false;
public TheEonFogSkipUntapStepEffect() {
super(Duration.WhileOnBattlefield, Outcome.Neutral, false, false);
this.allPlayers = false;
staticText = "Players skip their untap steps";
}
public TheEonFogSkipUntapStepEffect(Duration d, boolean allPlayers) {
super(d, Outcome.Neutral, false, false);
this.allPlayers = allPlayers;
staticText = "Players skip their untap steps";
}
public TheEonFogSkipUntapStepEffect(final TheEonFogSkipUntapStepEffect effect) {
super(effect);
this.allPlayers = effect.allPlayers;
}
@Override
public TheEonFogSkipUntapStepEffect copy() {
return new TheEonFogSkipUntapStepEffect(this);
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getState().getCurrentPlane() != null) {
if (!game.getState().getCurrentPlane().getName().equalsIgnoreCase("Plane - The Eon Fog")) {
return false;
}
}
return event.getType() == GameEvent.EventType.UNTAP_STEP;
}
}

View file

@ -29,14 +29,16 @@ package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import static jdk.nashorn.internal.objects.NativeRegExp.source;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.MainPhaseStackEmptyCondition;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.DrawCardTargetEffect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.abilities.effects.common.continuous.MaximumHandSizeControllerEffect;
import mage.abilities.effects.common.continuous.MaximumHandSizeControllerEffect.HandSizeModification;
@ -53,6 +55,7 @@ import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.target.Target;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.PlanarRollWatcher;
/**
@ -96,7 +99,7 @@ public class UndercityReachesPlane extends Plane {
class UndercityReachesTriggeredAbility extends TriggeredAbilityImpl {
public UndercityReachesTriggeredAbility() {
super(Zone.COMMAND, new DrawCardSourceControllerEffect(1), true);
super(Zone.COMMAND, null, true);
}
public UndercityReachesTriggeredAbility(final UndercityReachesTriggeredAbility ability) {
@ -118,6 +121,9 @@ class UndercityReachesTriggeredAbility extends TriggeredAbilityImpl {
if (((DamagedPlayerEvent) event).isCombatDamage()) {
Permanent creature = game.getPermanent(event.getSourceId());
if (creature != null) {
Effect effect = new DrawCardTargetEffect(new StaticValue(1), false, true);
effect.setTargetPointer(new FixedTarget(creature.getControllerId()));
effect.apply(game, null);
return true;
}
}