Merge origin/master

This commit is contained in:
Styxo 2016-04-06 20:23:15 +02:00
commit 7ff31fb12e
92 changed files with 2894 additions and 775 deletions

View file

@ -1167,6 +1167,9 @@ public abstract class AbilityImpl implements Ability {
public MageObject getSourceObjectIfItStillExists(Game game) {
MageObject currentObject = game.getObject(getSourceId());
if (currentObject != null) {
if (sourceObject == null) {
setSourceObject(currentObject, game);
}
MageObjectReference mor = new MageObjectReference(currentObject, game);
if (mor.getZoneChangeCounter() == getSourceObjectZoneChangeCounter()) {
// source object has meanwhile not changed zone

View file

@ -156,7 +156,7 @@ public class BeginningOfEndStepTriggeredAbility extends TriggeredAbilityImpl {
private String generateConditionString() {
if (interveningIfClauseCondition != null) {
return new StringBuilder(interveningIfClauseCondition.toString()).append(", ").toString();
return "if {this} is " + interveningIfClauseCondition.toString() + ", ";
}
switch (getZone()) {
case GRAVEYARD:

View file

@ -28,9 +28,9 @@
package mage.abilities.condition.common;
import java.util.UUID;
import mage.constants.CardType;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.constants.CardType;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -38,15 +38,15 @@ import mage.game.permanent.Permanent;
*
* @author North
*/
public class EnchantedCondition implements Condition {
public class EnchantedSourceCondition implements Condition {
private int numberOfEnchantments;
public EnchantedCondition() {
public EnchantedSourceCondition() {
this(1);
}
public EnchantedCondition(int numberOfEnchantments) {
public EnchantedSourceCondition(int numberOfEnchantments) {
this.numberOfEnchantments = numberOfEnchantments;
}
@ -58,7 +58,7 @@ public class EnchantedCondition implements Condition {
for (UUID uuid : permanent.getAttachments()) {
Permanent attached = game.getBattlefield().getPermanent(uuid);
if (attached != null && attached.getCardType().contains(CardType.ENCHANTMENT)) {
if (++numberOfFoundEnchantments >= numberOfEnchantments) {
if (++numberOfFoundEnchantments >= numberOfEnchantments) {
return true;
}
}
@ -66,4 +66,9 @@ public class EnchantedCondition implements Condition {
}
return (numberOfFoundEnchantments >= numberOfEnchantments);
}
@Override
public String toString() {
return "enchanted";
}
}

View file

@ -38,9 +38,9 @@ import mage.game.permanent.Permanent;
*
* @author nantuko
*/
public class EquippedCondition implements Condition {
public class EquippedSourceCondition implements Condition {
private static final EquippedCondition fInstance = new EquippedCondition();
private static final EquippedSourceCondition fInstance = new EquippedSourceCondition();
public static Condition getInstance() {
return fInstance;
@ -59,4 +59,10 @@ public class EquippedCondition implements Condition {
}
return false;
}
@Override
public String toString() {
return "equipped";
}
}

View file

@ -67,7 +67,7 @@ public class DiscardTargetCost extends CostImpl {
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
this.cards.clear();
this.targets.clearChosen();;
this.targets.clearChosen();
Player player = game.getPlayer(controllerId);
if (player == null) {
return false;

View file

@ -32,6 +32,7 @@ import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.keyword.TransformAbility;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.Duration;
@ -90,6 +91,10 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
UUID sourceId = event.getSourceId();
UUID controllerId = event.getPlayerId();
if (game.getState().getValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + card.getId()) != null) {
card = card.getSecondCardFace();
}
// Aura cards that go to battlefield face down (Manifest) don't have to select targets
if (card.isFaceDown(game)) {
return false;
@ -167,6 +172,7 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
}
Player targetPlayer = game.getPlayer(targetId);
if (targetCard != null || targetPermanent != null || targetPlayer != null) {
card = game.getCard(event.getTargetId());
card.removeFromZone(game, fromZone, sourceId);
card.updateZoneChangeCounter(game);
PermanentCard permanent = new PermanentCard(card, (controllingPlayer == null ? card.getOwnerId() : controllingPlayer.getId()), game);
@ -200,7 +206,12 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
if (((ZoneChangeEvent) event).getToZone().equals(Zone.BATTLEFIELD)
&& !(((ZoneChangeEvent) event).getFromZone().equals(Zone.STACK))) {
Card card = game.getCard(event.getTargetId());
if (card != null && card.getCardType().contains(CardType.ENCHANTMENT) && card.hasSubtype("Aura")) {
if (card != null && (card.getCardType().contains(CardType.ENCHANTMENT) && card.hasSubtype("Aura")
|| // in case of transformable enchantments
(game.getState().getValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + card.getId()) != null
&& card.getSecondCardFace() != null
&& card.getSecondCardFace().getCardType().contains(CardType.ENCHANTMENT)
&& card.getSecondCardFace().hasSubtype("Aura")))) {
return true;
}
}

View file

@ -90,6 +90,10 @@ public class DoIfCostPaid extends OneShotEffect {
return game.getPlayer(source.getControllerId());
}
public Cost getCost() {
return cost;
}
@Override
public String getText(Mode mode) {
if (!staticText.isEmpty()) {

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
@ -78,20 +79,30 @@ public class ReturnToBattlefieldUnderOwnerControlTargetEffect extends OneShotEff
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = null;
Cards cardsToMove = new CardsImpl();
if (fromExileZone) {
UUID exilZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
if (exilZoneId != null) {
ExileZone exileZone = game.getExile().getExileZone(exilZoneId);
if (exileZone != null && getTargetPointer().getFirst(game, source) != null) {
card = exileZone.get(getTargetPointer().getFirst(game, source), game);
if (exileZone != null) {
for (UUID cardId : getTargetPointer().getTargets(game, source)) {
Card card = exileZone.get(cardId, game);
if (card != null) {
cardsToMove.add(card);
}
}
}
}
} else {
card = game.getCard(getTargetPointer().getFirst(game, source));
for (UUID cardId : getTargetPointer().getTargets(game, source)) {
Card card = game.getCard(cardId);
if (card != null) {
cardsToMove.add(card);
}
}
}
if (card != null) {
controller.moveCards(new CardsImpl(card).getCards(game),
if (!cardsToMove.isEmpty()) {
controller.moveCards(cardsToMove.getCards(game),
Zone.BATTLEFIELD, source, game, tapped, false, true, null);
return true;
}