Fixed some handling problems of triggered abilities.

This commit is contained in:
LevelX2 2014-05-24 21:10:56 +02:00
parent e02b3377b3
commit 0443311f0e
8 changed files with 30 additions and 28 deletions

View file

@ -28,10 +28,6 @@
package mage.sets.gatecrash;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.common.DiesAttachedTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
@ -39,9 +35,12 @@ import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.SoldierToken;
import mage.target.TargetPermanent;
import mage.target.common.TargetControlledCreaturePermanent;
@ -65,7 +64,6 @@ public class MurderInvestigation extends CardImpl<MurderInvestigation> {
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
// When enchanted creature dies, put X 1/1 white Soldier creature tokens onto the battlefield, where X is its power.
this.addAbility(new DiesAttachedTriggeredAbility(new CreateTokenEffect(new SoldierToken(), new AttachedPermanentPowerCount()), "enchanted creature"));
}

View file

@ -43,12 +43,12 @@ public abstract class MageTestPlayerBase {
protected Pattern pattern = Pattern.compile("([a-zA-Z]*):([\\w]*):([a-zA-Z ,\\-.!'\\d]*):([\\d]*)(:\\{tapped\\})?");
protected Map<TestPlayer, List<Card>> handCards = new HashMap<TestPlayer, List<Card>>();
protected Map<TestPlayer, List<PermanentCard>> battlefieldCards = new HashMap<TestPlayer, List<PermanentCard>>();
protected Map<TestPlayer, List<Card>> graveyardCards = new HashMap<TestPlayer, List<Card>>();
protected Map<TestPlayer, List<Card>> libraryCards = new HashMap<TestPlayer, List<Card>>();
protected Map<TestPlayer, List<Card>> handCards = new HashMap<>();
protected Map<TestPlayer, List<PermanentCard>> battlefieldCards = new HashMap<>();
protected Map<TestPlayer, List<Card>> graveyardCards = new HashMap<>();
protected Map<TestPlayer, List<Card>> libraryCards = new HashMap<>();
protected Map<TestPlayer, Map<Zone, String>> commands = new HashMap<TestPlayer, Map<Zone, String>>();
protected Map<TestPlayer, Map<Zone, String>> commands = new HashMap<>();
protected TestPlayer playerA;
protected TestPlayer playerB;
@ -90,7 +90,7 @@ public abstract class MageTestPlayerBase {
* battlefield:ComputerB:Tine Shrike:0
* graveyard:ComputerB:Tine Shrike:1
*/
protected List<String> expectedResults = new ArrayList<String>();
protected List<String> expectedResults = new ArrayList<>();
protected static final String TESTS_PATH = "tests" + File.separator;
@ -148,8 +148,9 @@ public abstract class MageTestPlayerBase {
private static void deleteSavedGames() {
File directory = new File("saved/");
if (!directory.exists())
if (!directory.exists()) {
directory.mkdirs();
}
File[] files = directory.listFiles(
new FilenameFilter() {
@Override
@ -170,7 +171,9 @@ public abstract class MageTestPlayerBase {
try {
while (scanner.hasNextLine()) {
String line = scanner.nextLine().trim();
if (line == null || line.isEmpty() || line.startsWith("#")) continue;
if (line == null || line.isEmpty() || line.startsWith("#")) {
continue;
}
if (line.startsWith("$include")) {
includeFrom(line);
continue;
@ -273,7 +276,7 @@ public abstract class MageTestPlayerBase {
if (handCards.containsKey(player)) {
return handCards.get(player);
}
List<Card> hand = new ArrayList<Card>();
List<Card> hand = new ArrayList<>();
handCards.put(player, hand);
return hand;
}
@ -282,7 +285,7 @@ public abstract class MageTestPlayerBase {
if (graveyardCards.containsKey(player)) {
return graveyardCards.get(player);
}
List<Card> grave = new ArrayList<Card>();
List<Card> grave = new ArrayList<>();
graveyardCards.put(player, grave);
return grave;
}
@ -291,7 +294,7 @@ public abstract class MageTestPlayerBase {
if (libraryCards.containsKey(player)) {
return libraryCards.get(player);
}
List<Card> library = new ArrayList<Card>();
List<Card> library = new ArrayList<>();
libraryCards.put(player, library);
return library;
}
@ -300,7 +303,7 @@ public abstract class MageTestPlayerBase {
if (battlefieldCards.containsKey(player)) {
return battlefieldCards.get(player);
}
List<PermanentCard> battlefield = new ArrayList<PermanentCard>();
List<PermanentCard> battlefield = new ArrayList<>();
battlefieldCards.put(player, battlefield);
return battlefield;
}
@ -309,7 +312,7 @@ public abstract class MageTestPlayerBase {
if (commands.containsKey(player)) {
return commands.get(player);
}
Map<Zone, String> command = new HashMap<Zone, String>();
Map<Zone, String> command = new HashMap<>();
commands.put(player, command);
return command;
}

View file

@ -228,6 +228,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
/**
* Define turn number and step to stop the game on.
* The game stops after executing the step
* @param turn
* @param step
*/

View file

@ -1100,7 +1100,9 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
} finally {
if (top != null) {
state.getStack().remove(top);
state.handleSimultaneousEvent(this);
while (state.hasSimultaneousEvents()) {
state.handleSimultaneousEvent(this);
}
}
}
}

View file

@ -11,7 +11,7 @@ import mage.constants.PhaseStep;
*/
public class GameOptions implements Serializable {
private static GameOptions defInstance = new GameOptions();
private static final GameOptions defInstance = new GameOptions();
public static GameOptions getDefault() {
return defInstance;

View file

@ -235,7 +235,6 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
if (this.getSpellAbility() instanceof BestowAbility) {
updateOptionalCosts(0);
result = card.putOntoBattlefield(game, fromZone, ability.getId(), controllerId);
game.getState().handleSimultaneousEvent(game);
return result;
} else {
//20091005 - 608.2b
@ -246,7 +245,6 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
} else {
updateOptionalCosts(0);
result = card.putOntoBattlefield(game, fromZone, ability.getId(), controllerId);
game.getState().handleSimultaneousEvent(game);
return result;
}
}

View file

@ -28,13 +28,12 @@
package mage.game.stack;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.game.Controllable;
import mage.game.Game;
import java.util.UUID;
public interface StackObject extends MageObject, Controllable {
boolean resolve(Game game);

View file

@ -108,12 +108,13 @@ public abstract class Phase<T extends Phase<T>> implements Serializable {
return false;
}
currentStep = step;
if (!game.isSimulation() && checkStopOnStepOption(game)) {
return false;
}
if (!game.getState().getTurnMods().skipStep(activePlayerId, getStep().getType())) {
playStep(game);
}
if (!game.isSimulation() && checkStopOnStepOption(game)) {
return false;
}
}
if (game.isPaused() || game.gameOver(null)) {
return false;