* Panopticon Plane - Fixed draw card abilities.

This commit is contained in:
LevelX2 2020-01-11 01:25:26 +01:00
parent b8c459a6b9
commit 1f7a7a10b0
5 changed files with 47 additions and 27 deletions

View file

@ -1,6 +1,17 @@
package mage.server.util; package mage.server.util;
import java.io.File;
import java.lang.reflect.Constructor;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.repository.CardCriteria; import mage.cards.repository.CardCriteria;
import mage.cards.repository.CardInfo; import mage.cards.repository.CardInfo;
@ -13,20 +24,12 @@ import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.GameCommanderImpl; import mage.game.GameCommanderImpl;
import mage.game.command.CommandObject;
import mage.game.command.Plane;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.util.RandomUtil; import mage.util.RandomUtil;
import java.io.File;
import java.lang.reflect.Constructor;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/** /**
* @author JayDi85 * @author JayDi85
*/ */
@ -233,8 +236,8 @@ public final class SystemUtil {
* <br/> * <br/>
* <b>Implementation note:</b><br/> * <b>Implementation note:</b><br/>
* 1. Read init.txt line by line<br/> * 1. Read init.txt line by line<br/>
* 2. Parse line using for searching groups like: [group 1] * 2. Parse line using for searching groups like: [group 1] 3. Parse line
* 3. Parse line using the following format: line ::= * using the following format: line ::=
* <zone>:<nickname>:<card name>:<amount><br/> * <zone>:<nickname>:<card name>:<amount><br/>
* 4. If zone equals to 'hand', add card to player's library<br/> * 4. If zone equals to 'hand', add card to player's library<br/>
* 5a. Then swap added card with any card in player's hand<br/> * 5a. Then swap added card with any card in player's hand<br/>
@ -432,6 +435,23 @@ public final class SystemUtil {
} }
} else if ("plane".equalsIgnoreCase(command.zone)) { } else if ("plane".equalsIgnoreCase(command.zone)) {
// eg: plane:Human:BantPlane:1 // eg: plane:Human:BantPlane:1
// Steps: 1) Remove the last plane and set its effects to discarded
for (CommandObject cobject : game.getState().getCommand()) {
if (cobject instanceof Plane) {
if (((Plane) cobject).getAbilities() != null) {
for (Ability ability : ((Plane) cobject).getAbilities()) {
for (Effect effect : ability.getEffects()) {
if (effect instanceof ContinuousEffect) {
((ContinuousEffect) effect).discard();
}
}
}
}
game.getState().removeTriggersOfSourceId(((Plane) cobject).getId());
game.getState().getCommand().remove(cobject);
break;
}
}
Class<?> c = Class.forName("mage.game.command.planes." + command.cardName); Class<?> c = Class.forName("mage.game.command.planes." + command.cardName);
Constructor<?> cons = c.getConstructor(); Constructor<?> cons = c.getConstructor();
Object plane = cons.newInstance(); Object plane = cons.newInstance();

View file

@ -1,4 +1,3 @@
package mage.abilities.common; package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
@ -86,6 +85,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl {
} }
break; break;
case ANY: case ANY:
case ACTIVE:
if (getTargets().isEmpty()) { if (getTargets().isEmpty()) {
this.getEffects().setTargetPointer(new FixedTarget(event.getPlayerId())); this.getEffects().setTargetPointer(new FixedTarget(event.getPlayerId()));
} }
@ -97,6 +97,8 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public String getRule() { public String getRule() {
switch (targetController) { switch (targetController) {
case ACTIVE:
return "At the beginning of your draw step, " + generateZoneString() + getEffects().getText(modes.getMode());
case YOU: case YOU:
return "At the beginning of your draw step, " + generateZoneString() + getEffects().getText(modes.getMode()); return "At the beginning of your draw step, " + generateZoneString() + getEffects().getText(modes.getMode());
case OPPONENT: case OPPONENT:

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common; package mage.abilities.effects.common;
import java.util.List; import java.util.List;
@ -102,7 +101,6 @@ public class RollPlanarDieEffect extends OneShotEffect {
// Steps: 1) Remove the last plane and set its effects to discarded // Steps: 1) Remove the last plane and set its effects to discarded
for (CommandObject cobject : game.getState().getCommand()) { for (CommandObject cobject : game.getState().getCommand()) {
if (cobject instanceof Plane) { if (cobject instanceof Plane) {
game.getState().addSeenPlane((Plane) cobject, game, id);
if (((Plane) cobject).getAbilities() != null) { if (((Plane) cobject).getAbilities() != null) {
for (Ability ability : ((Plane) cobject).getAbilities()) { for (Ability ability : ((Plane) cobject).getAbilities()) {
for (Effect effect : ability.getEffects()) { for (Effect effect : ability.getEffects()) {

View file

@ -1,15 +1,13 @@
package mage.constants; package mage.constants;
/** /**
* *
* @author spjspj * @author spjspj
*/ */
public enum PlanarDieRoll { public enum PlanarDieRoll {
NIL_ROLL ("Nil Roll"), NIL_ROLL("Blank Roll"),
CHAOS_ROLL("Chaos Roll"), CHAOS_ROLL("Chaos Roll"),
PLANAR_ROLL ("Planar Roll"); PLANAR_ROLL("Planar Roll");
private final String text; private final String text;

View file

@ -1,4 +1,3 @@
package mage.game.command.planes; package mage.game.command.planes;
import java.util.ArrayList; import java.util.ArrayList;
@ -22,6 +21,7 @@ import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.players.Player; import mage.players.Player;
import mage.target.Target; import mage.target.Target;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.PlanarRollWatcher; import mage.watchers.common.PlanarRollWatcher;
/** /**
@ -36,12 +36,14 @@ public class PanopticonPlane extends Plane {
this.setName("Plane - Panopticon"); this.setName("Plane - Panopticon");
this.setExpansionSetCodeForImage("PCA"); this.setExpansionSetCodeForImage("PCA");
// At the beginning of your draw step, draw an additional card. // When you planeswalk to Panopticon, draw a card
Ability ability = new BeginningOfDrawTriggeredAbility(new DrawCardTargetEffect(1), TargetController.ANY, false);
this.getAbilities().add(ability);
Ability pwability = new PanopticonTriggeredAbility(new DrawCardTargetEffect(1)); Ability pwability = new PanopticonTriggeredAbility(new DrawCardTargetEffect(1));
this.getAbilities().add(pwability); this.getAbilities().add(pwability);
// At the beginning of your draw step, draw an additional card.
Ability ability = new BeginningOfDrawTriggeredAbility(Zone.COMMAND, new DrawCardTargetEffect(1), TargetController.ACTIVE, false);
this.getAbilities().add(ability);
// Active player can roll the planar die: Whenever you roll {CHAOS}, draw a card // Active player can roll the planar die: Whenever you roll {CHAOS}, draw a card
Effect chaosEffect = new DrawCardSourceControllerEffect(1); Effect chaosEffect = new DrawCardSourceControllerEffect(1);
Target chaosTarget = null; Target chaosTarget = null;
@ -84,7 +86,7 @@ class PanopticonTriggeredAbility extends TriggeredAbilityImpl {
Player activePlayer = game.getPlayer(game.getActivePlayerId()); Player activePlayer = game.getPlayer(game.getActivePlayerId());
if (activePlayer != null) { if (activePlayer != null) {
activePlayer.drawCards(1, game); getEffects().setTargetPointer(new FixedTarget(activePlayer.getId()));
return true; return true;
} }
return false; return false;