* 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;
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.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.cards.Card;
import mage.cards.repository.CardCriteria;
import mage.cards.repository.CardInfo;
@ -13,20 +24,12 @@ import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.GameCommanderImpl;
import mage.game.command.CommandObject;
import mage.game.command.Plane;
import mage.game.permanent.Permanent;
import mage.players.Player;
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
*/
@ -233,8 +236,8 @@ public final class SystemUtil {
* <br/>
* <b>Implementation note:</b><br/>
* 1. Read init.txt line by line<br/>
* 2. Parse line using for searching groups like: [group 1]
* 3. Parse line using the following format: line ::=
* 2. Parse line using for searching groups like: [group 1] 3. Parse line
* using the following format: line ::=
* <zone>:<nickname>:<card name>:<amount><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/>
@ -432,6 +435,23 @@ public final class SystemUtil {
}
} else if ("plane".equalsIgnoreCase(command.zone)) {
// 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);
Constructor<?> cons = c.getConstructor();
Object plane = cons.newInstance();

View file

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

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common;
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
for (CommandObject cobject : game.getState().getCommand()) {
if (cobject instanceof Plane) {
game.getState().addSeenPlane((Plane) cobject, game, id);
if (((Plane) cobject).getAbilities() != null) {
for (Ability ability : ((Plane) cobject).getAbilities()) {
for (Effect effect : ability.getEffects()) {

View file

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

View file

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