mirror of
https://github.com/correl/mage.git
synced 2025-04-10 01:01:05 -09:00
Continuing implementation of Planechase.
This commit is contained in:
parent
2f966b7a2c
commit
b45a409939
4 changed files with 58 additions and 50 deletions
Mage.Server/src/main/java/mage/server
Mage/src/main/java/mage/game
|
@ -53,6 +53,7 @@ import mage.game.GameException;
|
|||
import mage.game.GameOptions;
|
||||
import mage.game.GameState;
|
||||
import mage.game.Table;
|
||||
import mage.game.command.Plane;
|
||||
import mage.game.events.Listener;
|
||||
import mage.game.events.PlayerQueryEvent;
|
||||
import mage.game.events.TableEvent;
|
||||
|
@ -1174,6 +1175,15 @@ public class GameController implements GameCallback {
|
|||
sb.append(state.getTurnMods());
|
||||
sb.append("<br>getTurnNum: ");
|
||||
sb.append(state.getTurnNum());
|
||||
|
||||
sb.append("<br>Using plane chase?:" + state.isPlaneChase());
|
||||
if (state.isPlaneChase()) {
|
||||
Plane currentPlane = state.getCurrentPlane();
|
||||
if (currentPlane != null) {
|
||||
sb.append("<br>Current plane:" + currentPlane.getName());
|
||||
}
|
||||
}
|
||||
|
||||
sb.append("<br>Future Timeout:");
|
||||
if (futureTimeout != null) {
|
||||
sb.append("Cancelled?=");
|
||||
|
|
|
@ -42,6 +42,7 @@ public final class SystemUtil {
|
|||
private static final String COMMAND_SHOW_OPPONENT_HAND = "@show opponent hand";
|
||||
private static final String COMMAND_SHOW_OPPONENT_LIBRARY = "@show opponent library";
|
||||
private static final Map<String, String> supportedCommands = new HashMap<>();
|
||||
|
||||
static {
|
||||
supportedCommands.put(COMMAND_MANA_ADD, "MANA ADD");
|
||||
supportedCommands.put(COMMAND_LANDS_ADD, "LANDS ADD");
|
||||
|
@ -62,6 +63,7 @@ public final class SystemUtil {
|
|||
private static final String PARAM_ABILITIES_LIST = "abilities list";
|
||||
|
||||
private static class CommandGroup {
|
||||
|
||||
String name;
|
||||
boolean isSpecialCommand;
|
||||
ArrayList<String> commands = new ArrayList<>();
|
||||
|
@ -144,6 +146,7 @@ public final class SystemUtil {
|
|||
}
|
||||
|
||||
private static class CardCommandData {
|
||||
|
||||
public String source;
|
||||
public String zone;
|
||||
public String player;
|
||||
|
@ -247,7 +250,6 @@ public final class SystemUtil {
|
|||
// 2. ask user if many groups
|
||||
// 3. process system commands
|
||||
// 4. run commands from selected group
|
||||
|
||||
// 1. parse
|
||||
ArrayList<CommandGroup> groups = new ArrayList<>();
|
||||
|
||||
|
@ -300,7 +302,7 @@ public final class SystemUtil {
|
|||
runGroup = groups.get(0);
|
||||
} else if (groups.size() > 1) {
|
||||
// need to ask
|
||||
logger.info("Founded " + groups.size() + " groups. Need to select.");
|
||||
logger.info("Found " + groups.size() + " groups. Need to select.");
|
||||
|
||||
if (feedbackPlayer != null) {
|
||||
// choice dialog
|
||||
|
@ -318,8 +320,7 @@ public final class SystemUtil {
|
|||
|
||||
if (feedbackPlayer.choose(Outcome.Benefit, groupChoice, game)) {
|
||||
String need = groupChoice.getChoiceKey();
|
||||
if ((need != null) && list.containsKey(need))
|
||||
{
|
||||
if ((need != null) && list.containsKey(need)) {
|
||||
runGroup = groups.get(Integer.parseInt(need) - 1);
|
||||
}
|
||||
}
|
||||
|
@ -399,6 +400,16 @@ public final class SystemUtil {
|
|||
game.addEmblem((mage.game.command.Emblem) emblem, null, player.getId());
|
||||
continue;
|
||||
}
|
||||
} else if ("plane".equalsIgnoreCase(command.zone)) {
|
||||
// eg: plane:Human:BantPlane:1
|
||||
Class<?> c = Class.forName("mage.game.command.planes." + command.cardName);
|
||||
Constructor<?> cons = c.getConstructor();
|
||||
Object plane = cons.newInstance();
|
||||
if (plane != null && plane instanceof mage.game.command.Plane) {
|
||||
((mage.game.command.Plane) plane).setControllerId(player.getId());
|
||||
game.addPlane((mage.game.command.Plane) plane, null, player.getId());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Zone gameZone;
|
||||
|
@ -414,6 +425,8 @@ public final class SystemUtil {
|
|||
gameZone = Zone.BATTLEFIELD;
|
||||
} else if ("emblem".equalsIgnoreCase(command.zone)) {
|
||||
gameZone = Zone.COMMAND;
|
||||
} else if ("plane".equalsIgnoreCase(command.zone)) {
|
||||
gameZone = Zone.COMMAND;
|
||||
} else {
|
||||
logger.warn("Unknown zone [" + command.zone + "]: " + line);
|
||||
continue;
|
||||
|
|
|
@ -36,7 +36,6 @@ import mage.MageObject;
|
|||
import mage.abilities.*;
|
||||
import mage.abilities.common.AttachableToRestrictedAbility;
|
||||
import mage.abilities.common.CantHaveMoreThanAmountCountersSourceAbility;
|
||||
import mage.abilities.common.SagaAbility;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.ContinuousEffects;
|
||||
import mage.abilities.effects.Effect;
|
||||
|
@ -1079,6 +1078,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
Plane plane = Plane.getRandomPlane();
|
||||
plane.setControllerId(getActivePlayerId());
|
||||
addPlane(plane, null, getActivePlayerId());
|
||||
state.setPlaneChase(this, gameOptions.planeChase);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1564,6 +1564,14 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
state.addCommandObject(newPlane);
|
||||
informPlayers("You have planeswalked to " + newPlane.getLogName());
|
||||
|
||||
// Fire off the planeswalked event
|
||||
GameEvent event = new GameEvent(GameEvent.EventType.PLANESWALK, newPlane.getId(), null, newPlane.getId(), 0, true);
|
||||
if (!replaceEvent(event)) {
|
||||
GameEvent ge = new GameEvent(GameEvent.EventType.PLANESWALKED, newPlane.getId(), null, newPlane.getId(), 0, true);
|
||||
fireEvent(ge);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1915,7 +1923,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
if (perm.isWorld()) {
|
||||
worldEnchantment.add(perm);
|
||||
}
|
||||
if (perm.hasSubtype(SubType.AURA, this)) {
|
||||
if (StaticFilters.FILTER_PERMANENT_AURA.match(perm, this)) {
|
||||
//20091005 - 704.5n, 702.14c
|
||||
if (perm.getAttachedTo() == null) {
|
||||
Card card = this.getCard(perm.getId());
|
||||
|
@ -2005,30 +2013,6 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
}
|
||||
}
|
||||
// Remove Saga enchantment if last chapter is reached and chapter ability has left the stack
|
||||
if (perm.hasSubtype(SubType.SAGA, this)) {
|
||||
for (Ability sagaAbility : perm.getAbilities()) {
|
||||
if (sagaAbility instanceof SagaAbility) {
|
||||
int maxChapter = ((SagaAbility) sagaAbility).getMaxChapter().getNumber();
|
||||
if (maxChapter <= perm.getCounters(this).getCount(CounterType.LORE)) {
|
||||
boolean noChapterAbilityOnStack = true;
|
||||
// Check chapter abilities on stack
|
||||
for (StackObject stackObject : getStack()) {
|
||||
if (stackObject.getSourceId().equals(perm.getId()) && SagaAbility.isChapterAbility(stackObject)) {
|
||||
noChapterAbilityOnStack = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (noChapterAbilityOnStack) {
|
||||
// After the last chapter ability has left the stack, you'll sacrifice the Saga
|
||||
perm.sacrifice(perm.getId(), this);
|
||||
somethingHappened = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.getState().isLegendaryRuleActive() && StaticFilters.FILTER_PERMANENT_LEGENDARY.match(perm, this)) {
|
||||
legendary.add(perm);
|
||||
}
|
||||
|
|
|
@ -232,6 +232,7 @@ public class GameEvent implements Serializable {
|
|||
FLIP_COIN, COIN_FLIPPED, SCRY, FATESEAL,
|
||||
ROLL_DICE, DICE_ROLLED,
|
||||
ROLL_PLANAR_DIE, PLANAR_DIE_ROLLED,
|
||||
PLANESWALK, PLANESWALKED,
|
||||
PAID_CUMULATIVE_UPKEEP,
|
||||
DIDNT_PAY_CUMULATIVE_UPKEEP,
|
||||
//permanent events
|
||||
|
|
Loading…
Add table
Reference in a new issue