mirror of
https://github.com/magefree/mage.git
synced 2026-01-24 12:19:59 -08:00
* Split cards - Fixed a bug when split cards get copied (e.g. by Isochron Scepter) refering still to the copied card.
This commit is contained in:
parent
525da15640
commit
8d683a7e5c
8 changed files with 80 additions and 44 deletions
|
|
@ -366,7 +366,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
break;
|
||||
case STACK:
|
||||
StackObject stackObject = game.getStack().getSpell(getId());
|
||||
if (stackObject == null && (this instanceof SplitCard)) { // handle if half od Split cast is on the stack
|
||||
if (stackObject == null && (this instanceof SplitCard)) { // handle if half of Split cast is on the stack
|
||||
stackObject = game.getStack().getSpell(((SplitCard) this).getLeftHalfCard().getId());
|
||||
if (stackObject == null) {
|
||||
stackObject = game.getStack().getSpell(((SplitCard) this).getRightHalfCard().getId());
|
||||
|
|
|
|||
|
|
@ -60,16 +60,32 @@ public abstract class SplitCard extends CardImpl {
|
|||
|
||||
public SplitCard(SplitCard card) {
|
||||
super(card);
|
||||
this.leftHalfCard = card.leftHalfCard.copy();
|
||||
this.leftHalfCard = card.getLeftHalfCard().copy();
|
||||
((SplitCardHalf) leftHalfCard).setParentCard(this);
|
||||
this.rightHalfCard = card.rightHalfCard.copy();
|
||||
((SplitCardHalf) rightHalfCard).setParentCard(this);
|
||||
}
|
||||
|
||||
public Card getLeftHalfCard() {
|
||||
return leftHalfCard;
|
||||
public SplitCardHalf getLeftHalfCard() {
|
||||
return (SplitCardHalf) leftHalfCard;
|
||||
}
|
||||
|
||||
public Card getRightHalfCard() {
|
||||
return rightHalfCard;
|
||||
public SplitCardHalf getRightHalfCard() {
|
||||
return (SplitCardHalf) rightHalfCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assignNewId() {
|
||||
super.assignNewId();
|
||||
leftHalfCard.assignNewId();
|
||||
rightHalfCard.assignNewId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCopy(boolean isCopy) {
|
||||
super.setCopy(isCopy);
|
||||
leftHalfCard.setCopy(isCopy);
|
||||
rightHalfCard.setCopy(isCopy);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -12,5 +12,7 @@ package mage.cards;
|
|||
public interface SplitCardHalf extends Card {
|
||||
|
||||
@Override
|
||||
Card copy();
|
||||
SplitCardHalf copy();
|
||||
|
||||
void setParentCard(SplitCard card);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class SplitCardHalfImpl extends CardImpl implements SplitCardHalf {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Card getMainCard() {
|
||||
public SplitCard getMainCard() {
|
||||
return splitCardParent;
|
||||
}
|
||||
|
||||
|
|
@ -74,8 +74,13 @@ public class SplitCardHalfImpl extends CardImpl implements SplitCardHalf {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SplitCardHalfImpl copy() {
|
||||
public SplitCardHalf copy() {
|
||||
return new SplitCardHalfImpl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentCard(SplitCard card) {
|
||||
this.splitCardParent = card;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,12 +50,12 @@ public class MockSplitCard extends SplitCard {
|
|||
}
|
||||
|
||||
CardInfo leftHalf = CardRepository.instance.findCard(getLeftHalfName(card));
|
||||
if(leftHalf != null) {
|
||||
if (leftHalf != null) {
|
||||
this.leftHalfCard = new MockCard(leftHalf);
|
||||
}
|
||||
|
||||
CardInfo rightHalf = CardRepository.instance.findCard(getRightHalfName(card));
|
||||
if(rightHalf != null) {
|
||||
if (rightHalf != null) {
|
||||
this.rightHalfCard = new MockCard(rightHalf);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ public class Exile implements Serializable, Copyable<Exile> {
|
|||
}
|
||||
|
||||
public List<Card> getAllCards(Game game) {
|
||||
List<Card> cards = new ArrayList<Card>();
|
||||
List<Card> cards = new ArrayList<>();
|
||||
for (ExileZone exile : exileZones.values()) {
|
||||
cards.addAll(exile.getCards(game));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ import mage.cards.Card;
|
|||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.cards.SplitCard;
|
||||
import mage.cards.SplitCardHalf;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.choices.Choice;
|
||||
import mage.constants.CardType;
|
||||
|
|
@ -1525,6 +1526,9 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
Iterator<Card> copiedCards = this.getState().getCopiedCards().iterator();
|
||||
while (copiedCards.hasNext()) {
|
||||
Card card = copiedCards.next();
|
||||
if (card instanceof SplitCardHalf) {
|
||||
continue; // only the main card is moves, not the halves
|
||||
}
|
||||
Zone zone = state.getZone(card.getId());
|
||||
if (zone != Zone.BATTLEFIELD && zone != Zone.STACK) {
|
||||
switch (zone) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue