diff --git a/Mage.Sets/src/mage/sets/tenthedition/ChromaticStar.java b/Mage.Sets/src/mage/sets/tenthedition/ChromaticStar.java index e87f1b20c7..2851ec8634 100644 --- a/Mage.Sets/src/mage/sets/tenthedition/ChromaticStar.java +++ b/Mage.Sets/src/mage/sets/tenthedition/ChromaticStar.java @@ -48,10 +48,14 @@ public class ChromaticStar extends CardImpl { public ChromaticStar(UUID ownerId) { super(ownerId, 314, "Chromatic Star", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{1}"); this.expansionSetCode = "10E"; + + // {1}, {T}, Sacrifice Chromatic Star: Add one mana of any color to your mana pool. Ability ability = new AnyColorManaAbility(new GenericManaCost(1)); ability.addCost(new TapSourceCost()); ability.addCost(new SacrificeSourceCost()); this.addAbility(ability); + + // When Chromatic Star is put into a graveyard from the battlefield, draw a card. this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new DrawCardSourceControllerEffect(1))); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/rules/WorldEnchantmentsRuleTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/rules/WorldEnchantmentsRuleTest.java index 09d210b6a7..4a0784a22d 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/rules/WorldEnchantmentsRuleTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/rules/WorldEnchantmentsRuleTest.java @@ -48,13 +48,16 @@ public class WorldEnchantmentsRuleTest extends CardTestPlayerBase { */ @Test public void TestTwoWorldEnchantsments() { - addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4); + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1); + addCard(Zone.BATTLEFIELD, playerA, "Plains", 5); addCard(Zone.HAND, playerA, "Nether Void", 1); + addCard(Zone.HAND, playerA, "Silvercoat Lion", 1); addCard(Zone.BATTLEFIELD, playerB, "Swamp", 7); addCard(Zone.HAND, playerB, "Nether Void", 1); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Nether Void"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Silvercoat Lion"); // just needed to get different craete time to second Nether Void castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Nether Void"); setStopAt(2, PhaseStep.END_TURN); diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index a5dde0e6ca..960ad22c8d 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -30,6 +30,7 @@ package mage.game; import java.io.IOException; import java.io.Serializable; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -1278,6 +1279,7 @@ public abstract class GameImpl implements Game, Serializable { @Override public void addPermanent(Permanent permanent) { getBattlefield().addPermanent(permanent); + permanent.setCreateOrder(getState().getNextPermanentOrderNumber()); } @Override @@ -1735,17 +1737,17 @@ public abstract class GameImpl implements Game, Serializable { } //704.5m - World Enchantments if (worldEnchantment.size() > 1) { - Date newestCard = null; + int newestCard = -1; Permanent newestPermanent = null; for (Permanent permanent :worldEnchantment) { - if (newestCard == null) { - newestCard = permanent.getCreateDate(); + if (newestCard == -1) { + newestCard = permanent.getCreateOrder(); newestPermanent = permanent; - } else if (newestCard.before(permanent.getCreateDate())) { - newestCard = permanent.getCreateDate(); + } else if (newestCard < permanent.getCreateOrder()) { + newestCard = permanent.getCreateOrder(); newestPermanent = permanent; - } else if(newestCard.equals(permanent.getCreateDate())) { - newestCard = null; + } else if(newestCard == permanent.getCreateOrder()) { + newestPermanent = null; } } for (Permanent permanent :worldEnchantment) { diff --git a/Mage/src/mage/game/GameState.java b/Mage/src/mage/game/GameState.java index 6f4c02c23c..332ead3e16 100644 --- a/Mage/src/mage/game/GameState.java +++ b/Mage/src/mage/game/GameState.java @@ -111,6 +111,7 @@ public class GameState implements Serializable, Copyable { private Map cardState = new HashMap<>(); private Map zoneChangeCounter = new HashMap<>(); private Map copiedCards = new HashMap<>(); + private int permanentOrderNumber; public GameState() { players = new Players(); @@ -169,6 +170,7 @@ public class GameState implements Serializable, Copyable { } this.zoneChangeCounter.putAll(state.zoneChangeCounter); this.copiedCards.putAll(state.copiedCards); + this.permanentOrderNumber = state.permanentOrderNumber; } @Override @@ -575,6 +577,7 @@ public class GameState implements Serializable, Copyable { this.cardState = state.cardState; this.zoneChangeCounter = state.zoneChangeCounter; this.copiedCards = state.copiedCards; + this.permanentOrderNumber = state.permanentOrderNumber; } public void addSimultaneousEvent(GameEvent event, Game game) { @@ -837,6 +840,7 @@ public class GameState implements Serializable, Copyable { values.clear(); zones.clear(); simultaneousEvents.clear(); + permanentOrderNumber = 0; } public void pause() { @@ -925,4 +929,8 @@ public class GameState implements Serializable, Copyable { } return copiedCard; } + + public int getNextPermanentOrderNumber() { + return permanentOrderNumber++; } +} diff --git a/Mage/src/mage/game/permanent/Permanent.java b/Mage/src/mage/game/permanent/Permanent.java index 0123c19141..8e7258301a 100644 --- a/Mage/src/mage/game/permanent/Permanent.java +++ b/Mage/src/mage/game/permanent/Permanent.java @@ -29,7 +29,6 @@ package mage.game.permanent; import java.util.ArrayList; -import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.UUID; @@ -275,5 +274,8 @@ public interface Permanent extends Card, Controllable { @Override Permanent copy(); - Date getCreateDate(); + // Simple int counter to set a timewise create order , the lower the number the earlier the object was created + // if objects enter the battlefield at the same time they can get (and should) get the same number. + int getCreateOrder(); + void setCreateOrder(int createOrder); } diff --git a/Mage/src/mage/game/permanent/PermanentImpl.java b/Mage/src/mage/game/permanent/PermanentImpl.java index 98899b343c..098313d633 100644 --- a/Mage/src/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/mage/game/permanent/PermanentImpl.java @@ -120,7 +120,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { protected List markedDamage; protected int timesLoyaltyUsed = 0; protected Map info; - protected Date createDate; + protected int createOrder; private static final List emptyList = Collections.unmodifiableList(new ArrayList()); @@ -129,7 +129,6 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { this.originalControllerId = controllerId; this.controllerId = controllerId; this.counters = new Counters(); - this.createDate = new Date(); } public PermanentImpl(UUID id, UUID ownerId, UUID controllerId, String name) { @@ -137,7 +136,6 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { this.originalControllerId = controllerId; this.controllerId = controllerId; this.counters = new Counters(); - this.createDate = new Date(); } public PermanentImpl(final PermanentImpl permanent) { @@ -183,7 +181,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { this.morphed = permanent.morphed; this.manifested = permanent.manifested; - this.createDate = permanent.createDate; + this.createOrder = permanent.createOrder; } @Override @@ -1354,8 +1352,13 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { } @Override - public Date getCreateDate() { - return createDate; + public int getCreateOrder() { + return createOrder; + } + + @Override + public void setCreateOrder(int createOrder) { + this.createOrder = createOrder; } }