@Override public boolean cast(Game game, Zone fromZone, SpellAbility ability, UUID controllerId) { switch (ability.getSpellAbilityType()) { case SPLIT_LEFT: return this.getLeftHalfCard().cast(game, fromZone, ability, controllerId); case SPLIT_RIGHT: return this.getRightHalfCard().cast(game, fromZone, ability, controllerId); default: this.getLeftHalfCard().getSpellAbility().setControllerId(controllerId); this.getRightHalfCard().getSpellAbility().setControllerId(controllerId); return super.cast(game, fromZone, ability, controllerId); } }
@Override public List<String> getRules() { List<String> rules = new ArrayList<>(); if (getSpellAbility().getSpellAbilityType() == SpellAbilityType.SPLIT_FUSED) { rules.add("--------------------------------------------------------------------------\nFuse (You may cast one or both halves of this card from your hand.)"); } return rules; }
@Override public String getCardNumber() { return splitCardParent.getCardNumber(); }
@Override public void setZone(Zone zone, Game game) { game.setZone(splitCardParent.getId(), zone); game.setZone(splitCardParent.getLeftHalfCard().getId(), zone); game.setZone(splitCardParent.getRightHalfCard().getId(), zone); }
@Override public LinkedHashMap<UUID, ActivatedAbility> getUseableActivatedAbilities(MageObject object, Zone zone, Game game) { LinkedHashMap<UUID, ActivatedAbility> useable = new LinkedHashMap<>(); if (object instanceof StackAbility) { // It may not be possible to activate abilities of stack abilities return useable; } if (object instanceof SplitCard) { SplitCard splitCard = (SplitCard) object; getUseableActivatedAbilitiesHalfImpl(splitCard.getLeftHalfCard(), zone, game, splitCard.getLeftHalfCard().getAbilities(), useable); getUseableActivatedAbilitiesHalfImpl(splitCard.getRightHalfCard(), zone, game, splitCard.getRightHalfCard().getAbilities(), useable); getUseableActivatedAbilitiesHalfImpl(splitCard, zone, game, splitCard.getSharedAbilities(), useable); } else { getUseableActivatedAbilitiesHalfImpl(object, zone, game, object.getAbilities(), useable); } getOtherUseableActivatedAbilities(object, zone, game, useable); return useable; }
public SplitCard(SplitCard card) { super(card); this.leftHalfCard = card.getLeftHalfCard().copy(); ((SplitCardHalf) leftHalfCard).setParentCard(this); this.rightHalfCard = card.rightHalfCard.copy(); ((SplitCardHalf) rightHalfCard).setParentCard(this); }
if (card.isSplitCard()) { splitCard = (SplitCard) card; rotate = (((SplitCard) card).getSpellAbility().getSpellAbilityType()) != SpellAbilityType.SPLIT_AFTERMATH; } else if (card instanceof Spell) { switch (((Spell) card).getSpellAbility().getSpellAbilityType()) { leftSplitName = splitCard.getLeftHalfCard().getName(); leftSplitCosts = splitCard.getLeftHalfCard().getManaCost(); leftSplitRules = splitCard.getLeftHalfCard().getRules(game); leftSplitTypeLine = getCardTypeLine(game, splitCard.getLeftHalfCard()); rightSplitName = splitCard.getRightHalfCard().getName(); rightSplitCosts = splitCard.getRightHalfCard().getManaCost(); rightSplitRules = splitCard.getRightHalfCard().getRules(game); rightSplitTypeLine = getCardTypeLine(game, splitCard.getRightHalfCard()); } else if (spell.getCard() != null) { SplitCard wholeCard = ((SplitCardHalf) spell.getCard()).getParentCard(); Abilities<Ability> aftermathHalfAbilities = wholeCard.getRightHalfCard().getAbilities(); if (aftermathHalfAbilities.stream().anyMatch(ability -> ability instanceof AftermathAbility)) { if (ty == SpellAbilityType.SPLIT_RIGHT) {
@Override public String getImageName() { return splitCardParent.getImageName(); }
@Override public String getExpansionSetCode() { return splitCardParent.getExpansionSetCode(); }
UUID idToCheck; if (affectedAbility != null && affectedAbility.getSourceObject(game) instanceof SplitCardHalf) { idToCheck = ((SplitCardHalf) affectedAbility.getSourceObject(game)).getParentCard().getId(); } else { if (game.getObject(objectId) instanceof SplitCardHalf) { idToCheck = ((SplitCardHalf) game.getObject(objectId)).getParentCard().getId(); } else { idToCheck = objectId;
@Override public boolean canTarget(UUID id, Game game) { if (super.canTarget(id, game)) { Card card = game.getCard(id); if (card != null) { if (targets.size() == 1) { Card card2 = game.getCard(targets.entrySet().iterator().next().getKey()); return card2 != null && card2.getName().equals(card.getName()); } else { FilterCard nameFilter = new FilterCard(); nameFilter.add(new NamePredicate(card.isSplitCard() ? ((SplitCard) card).getLeftHalfCard().getName() : card.getName())); Player player = game.getPlayer(card.getOwnerId()); return player != null && player.getHand().getCards(nameFilter, game).size() > 1; } } } return false; }
@Override public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, List<UUID> appliedEffects) { if (super.moveToExile(exileId, name, sourceId, game, appliedEffects)) { Zone currentZone = game.getState().getZone(getId()); game.getState().setZone(getLeftHalfCard().getId(), currentZone); game.getState().setZone(getRightHalfCard().getId(), currentZone); return true; } return false; }
getPlayableFromGraveyardCard(game, splitCard.getLeftHalfCard(), splitCard.getLeftHalfCard().getAbilities(), availableMana, playable); getPlayableFromGraveyardCard(game, splitCard.getRightHalfCard(), splitCard.getRightHalfCard().getAbilities(), availableMana, playable); getPlayableFromGraveyardCard(game, splitCard, splitCard.getSharedAbilities(), availableMana, playable); } else { getPlayableFromGraveyardCard(game, card, card.getAbilities(), availableMana, playable);
@Override public void setZone(Zone zone, Game game) { super.setZone(zone, game); game.setZone(getLeftHalfCard().getId(), zone); game.setZone(getRightHalfCard().getId(), zone); }
Card card = game.getCard(cardToCheck); if (card != null) { nameFilter.add(new NamePredicate(card.isSplitCard() ? ((SplitCard) card).getLeftHalfCard().getName() : card.getName())); if (cardsToCheck.count(nameFilter, game) > 1) { newPossibleTargets.add(cardToCheck);
public void removeCopiedCard(Card card) { if (copiedCards.containsKey(card.getId())) { copiedCards.remove(card.getId()); cardState.remove(card.getId()); zones.remove(card.getId()); zoneChangeCounter.remove(card.getId()); } // TODO Watchers? // TODO Abilities? if (card.isSplitCard()) { removeCopiedCard(((SplitCard) card).getLeftHalfCard()); removeCopiedCard(((SplitCard) card).getRightHalfCard()); } }
@Override public boolean canChoose(UUID sourceControllerId, Game game) { Cards cardsToCheck = new CardsImpl(); Player player = game.getPlayer(sourceControllerId); if (player == null) { return false; } for (Card card : player.getHand().getCards(filter, game)) { cardsToCheck.add(card.getId()); } int possibleCards = 0; for (Card card : cardsToCheck.getCards(game)) { FilterCard nameFilter = new FilterCard(); nameFilter.add(new NamePredicate(card.isSplitCard() ? ((SplitCard) card).getLeftHalfCard().getName() : card.getName())); if (cardsToCheck.count(nameFilter, game) > 1) { ++possibleCards; } } return possibleCards > 0; }
public Spell(Card card, SpellAbility ability, UUID controllerId, Zone fromZone) { this.card = card; this.color = card.getColor(null).copy(); this.frameColor = card.getFrameColor(null).copy(); this.frameStyle = card.getFrameStyle(); id = ability.getId(); this.ability = ability; this.ability.setControllerId(controllerId); if (ability.getSpellAbilityType() == SpellAbilityType.SPLIT_FUSED) { spellCards.add(((SplitCard) card).getLeftHalfCard()); spellAbilities.add(((SplitCard) card).getLeftHalfCard().getSpellAbility().copy()); spellCards.add(((SplitCard) card).getRightHalfCard()); spellAbilities.add(((SplitCard) card).getRightHalfCard().getSpellAbility().copy()); } else { spellCards.add(card); spellAbilities.add(ability); } this.controllerId = controllerId; this.fromZone = fromZone; this.countered = false; }
controller.moveCards(targetCard, Zone.EXILED, source, game); FilterCard nameFilter = new FilterCard(); String nameToSearch = targetCard.isSplitCard() ? ((SplitCard) targetCard).getLeftHalfCard().getName() : targetCard.getName(); nameFilter.add(new NamePredicate(nameToSearch)); TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, nameFilter);
@Override public boolean apply(MageObject input, Game game) { Set<String> cardNames = new HashSet<>(); UUID exileId = CardUtil.getCardExileZoneId(game, sourceId); ExileZone exileZone = game.getExile().getExileZone(exileId); if (exileZone != null) { for (Card card : exileZone.getCards(game)) { cardNames.add(card.getName()); } } // If a player names a card, the player may name either half of a split card, but not both. // A split card has the chosen name if one of its two names matches the chosen name. if (input instanceof SplitCard) { return cardNames.contains(((SplitCard) input).getLeftHalfCard().getName()) || cardNames.contains(((SplitCard) input).getRightHalfCard().getName()); } else if (input instanceof Spell && ((Spell) input).getSpellAbility().getSpellAbilityType() == SpellAbilityType.SPLIT_FUSED) { SplitCard card = (SplitCard) ((Spell) input).getCard(); return cardNames.contains(card.getLeftHalfCard().getName()) || cardNames.contains(card.getRightHalfCard().getName()); } else { return cardNames.contains(input.getName()); } }