Fixed different ZCC in split card's parts (flashback fix, see 95075cf33e);

Improve moveToZone code and fixed some cards with wrong commands queue (e.g. directly removes card from zone and then calls moveToZone again);
This commit is contained in:
Oleg Agafonov 2020-06-04 23:47:50 +04:00
parent f010454cb2
commit e95ae2675b
21 changed files with 116 additions and 36 deletions

View file

@ -9,6 +9,7 @@ import mage.constants.CardType;
import mage.constants.SpellAbilityType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.ZoneChangeEvent;
import java.util.ArrayList;
import java.util.List;
@ -74,6 +75,13 @@ public abstract class SplitCard extends CardImpl {
return false;
}
@Override
public void setZone(Zone zone, Game game) {
super.setZone(zone, game);
game.setZone(getLeftHalfCard().getId(), zone);
game.setZone(getRightHalfCard().getId(), zone);
}
@Override
public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, List<UUID> appliedEffects) {
if (super.moveToExile(exileId, name, sourceId, game, appliedEffects)) {
@ -85,6 +93,23 @@ public abstract class SplitCard extends CardImpl {
return false;
}
@Override
public boolean removeFromZone(Game game, Zone fromZone, UUID sourceId) {
// zone contains only one main card
return super.removeFromZone(game, fromZone, sourceId);
}
@Override
public void updateZoneChangeCounter(Game game, ZoneChangeEvent event) {
if (isCopy()) { // same as meld cards
super.updateZoneChangeCounter(game, event);
return;
}
super.updateZoneChangeCounter(game, event);
getLeftHalfCard().updateZoneChangeCounter(game, event);
getRightHalfCard().updateZoneChangeCounter(game, event);
}
@Override
public boolean cast(Game game, Zone fromZone, SpellAbility ability, UUID controllerId) {
switch (ability.getSpellAbilityType()) {
@ -99,13 +124,6 @@ public abstract class SplitCard extends CardImpl {
}
}
@Override
public void setZone(Zone zone, Game game) {
super.setZone(zone, game);
game.setZone(getLeftHalfCard().getId(), zone);
game.setZone(getRightHalfCard().getId(), zone);
}
@Override
public Abilities<Ability> getAbilities() {
Abilities<Ability> allAbilites = new AbilitiesImpl<>();
@ -168,7 +186,5 @@ public abstract class SplitCard extends CardImpl {
leftHalfCard.setOwnerId(ownerId);
rightHalfCard.getAbilities().setControllerId(ownerId);
rightHalfCard.setOwnerId(ownerId);
}
}