diff --git a/Mage/src/mage/cards/Card.java b/Mage/src/mage/cards/Card.java index 91217b0c02a..6e5ec8c1d32 100644 --- a/Mage/src/mage/cards/Card.java +++ b/Mage/src/mage/cards/Card.java @@ -1,31 +1,30 @@ /* -* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, are -* permitted provided that the following conditions are met: -* -* 1. Redistributions of source code must retain the above copyright notice, this list of -* conditions and the following disclaimer. -* -* 2. Redistributions in binary form must reproduce the above copyright notice, this list -* of conditions and the following disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR -* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The views and conclusions contained in the software and documentation are those of the -* authors and should not be interpreted as representing official policies, either expressed -* or implied, of BetaSteward_at_googlemail.com. -*/ - + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ package mage.cards; import java.util.ArrayList; @@ -33,7 +32,6 @@ import java.util.List; import java.util.UUID; import mage.MageObject; import mage.Mana; -import mage.ObjectColor; import mage.abilities.Abilities; import mage.abilities.Ability; import mage.abilities.SpellAbility; @@ -46,26 +44,45 @@ import mage.game.Game; public interface Card extends MageObject { UUID getOwnerId(); + int getCardNumber(); + Rarity getRarity(); + void setOwnerId(UUID ownerId); + public Abilities getAbilities(Game game); + void setSpellAbility(SpellAbility ability); + SpellAbility getSpellAbility(); + List getRules(); // gets base card rules + List getRules(Game game); // gets card rules + in game modifications + String getExpansionSetCode(); + String getTokenSetCode(); + void setFaceDown(boolean value, Game game); + boolean isFaceDown(Game game); + boolean turnFaceUp(Game game, UUID playerId); + boolean turnFaceDown(Game game, UUID playerId); + boolean isFlipCard(); + String getFlipCardName(); + boolean isSplitCard(); boolean canTransform(); + Card getSecondCardFace(); + boolean isNightCard(); void assignNewId(); @@ -74,14 +91,18 @@ public interface Card extends MageObject { /** * Moves the card to the specified zone + * * @param zone * @param sourceId * @param game * @param flag If zone *
    - *
  • LIBRARY:
    • true - put on top
    • false - put on bottom
  • - *
  • BATTLEFIELD:
    • true - tapped
    • false - untapped
  • - *
  • GRAVEYARD:
    • true - not from Battlefield
    • false - from Battlefield
  • + *
  • LIBRARY:
    • true - put on top
    • false - put on + * bottom
  • + *
  • BATTLEFIELD:
    • true - tapped
    • false - + * untapped
  • + *
  • GRAVEYARD:
    • true - not from Battlefield
    • false - from + * Battlefield
  • *
* @return true if card was moved to zone */ @@ -91,6 +112,7 @@ public interface Card extends MageObject { /** * Moves the card to an exile zone + * * @param exileId set to null for generic exile zone * @param name used for exile zone with the specified exileId * @param sourceId @@ -98,15 +120,19 @@ public interface Card extends MageObject { * @return true if card was moved to zone */ boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game); - + boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList appliedEffects); - boolean cast(Game game, Zone fromZone, SpellAbility ability, UUID controllerId); + boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId); + boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped); + boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, boolean facedown); + boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, boolean facedown, ArrayList appliedEffects); + List getMana(); void build(); @@ -116,24 +142,30 @@ public interface Card extends MageObject { * @return true if there exists various art images for this card */ boolean getUsesVariousArt(); + Counters getCounters(Game game); void addCounters(String name, int amount, Game game); + void addCounters(String name, int amount, Game game, ArrayList appliedEffects); + void addCounters(Counter counter, Game game); + void addCounters(Counter counter, Game game, ArrayList appliedEffects); void removeCounters(String name, int amount, Game game); + void removeCounters(Counter counter, Game game); - + @Override Card copy(); - + /** * - * @return The main card of a split half card, otherwise thae card itself is returned + * @return The main card of a split half card, otherwise thae card itself is + * returned */ Card getMainCard(); - void setZone(Zone zone, Game game); + void setZone(Zone zone, Game game); } diff --git a/Mage/src/mage/cards/SplitCard.java b/Mage/src/mage/cards/SplitCard.java index 1bfe550d540..7aef9b2756d 100644 --- a/Mage/src/mage/cards/SplitCard.java +++ b/Mage/src/mage/cards/SplitCard.java @@ -25,7 +25,6 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.cards; import java.util.ArrayList; @@ -53,9 +52,9 @@ public abstract class SplitCard extends CardImpl { protected Card rightHalfCard; public SplitCard(UUID ownerId, int cardNumber, String nameLeft, String nameRight, Rarity rarity, CardType[] cardTypes, String costsLeft, String costsRight, boolean fused) { - super(ownerId, cardNumber, new StringBuilder(nameLeft).append(" // ").append(nameRight).toString(), rarity, cardTypes, costsLeft + costsRight, (fused ?SpellAbilityType.SPLIT_FUSED:SpellAbilityType.SPLIT)); - this.createLeftHalfCard(nameLeft, costsLeft); - this.createRightHalfCard(nameRight, costsRight); + super(ownerId, cardNumber, new StringBuilder(nameLeft).append(" // ").append(nameRight).toString(), rarity, cardTypes, costsLeft + costsRight, (fused ? SpellAbilityType.SPLIT_FUSED : SpellAbilityType.SPLIT)); + leftHalfCard = new SplitCardHalfImpl(this.getOwnerId(), this.getCardNumber(), nameLeft, this.rarity, cardTypes, costsLeft, this, SpellAbilityType.SPLIT_LEFT); + rightHalfCard = new SplitCardHalfImpl(this.getOwnerId(), this.getCardNumber(), nameRight, this.rarity, cardTypes, costsRight, this, SpellAbilityType.SPLIT_RIGHT); this.splitCard = true; } @@ -65,29 +64,11 @@ public abstract class SplitCard extends CardImpl { this.rightHalfCard = card.rightHalfCard.copy(); } - private Card createLeftHalfCard (String nameLeft, String costsLeft) { - CardType[] cardTypes = new CardType[getCardType().size()]; - this.getCardType().toArray(cardTypes); - leftHalfCard = new LeftHalfCard(this.getOwnerId(), this.getCardNumber(), nameLeft, this.rarity, cardTypes, costsLeft, this); - //leftHalfCard.getAbilities().setSourceId(objectId); + public Card getLeftHalfCard() { return leftHalfCard; } - private Card createRightHalfCard (String nameRight, String costsRight) { - CardType[] cardTypes = new CardType[getCardType().size()]; - this.getCardType().toArray(cardTypes); - rightHalfCard = new RightHalfCard(this.getOwnerId(), this.getCardNumber(), nameRight, this.rarity, cardTypes, costsRight, this); - //rightHalfCard.getAbilities().setSourceId(objectId); - return rightHalfCard; - } - - - - public Card getLeftHalfCard () { - return leftHalfCard; - } - - public Card getRightHalfCard () { + public Card getRightHalfCard() { return rightHalfCard; } @@ -114,7 +95,7 @@ public abstract class SplitCard extends CardImpl { @Override public boolean cast(Game game, Zone fromZone, SpellAbility ability, UUID controllerId) { - switch(ability.getSpellAbilityType()) { + switch (ability.getSpellAbilityType()) { case SPLIT_LEFT: return this.getLeftHalfCard().cast(game, fromZone, ability, controllerId); case SPLIT_RIGHT: @@ -131,17 +112,16 @@ public abstract class SplitCard extends CardImpl { game.setZone(getRightHalfCard().getId(), zone); } - @Override - public Abilities getAbilities(){ + public Abilities getAbilities() { Abilities allAbilites = new AbilitiesImpl<>(); for (Ability ability : super.getAbilities()) { - if (ability instanceof SpellAbility && !((SpellAbility)ability).getSpellAbilityType().equals(SpellAbilityType.SPLIT)) { + if (ability instanceof SpellAbility && !((SpellAbility) ability).getSpellAbilityType().equals(SpellAbilityType.SPLIT)) { allAbilites.add(ability); } } allAbilites.addAll(leftHalfCard.getAbilities()); - allAbilites.addAll(rightHalfCard.getAbilities()); + allAbilites.addAll(rightHalfCard.getAbilities()); return allAbilites; } @@ -149,15 +129,15 @@ public abstract class SplitCard extends CardImpl { public Abilities getAbilities(Game game) { Abilities allAbilites = new AbilitiesImpl<>(); for (Ability ability : super.getAbilities(game)) { - if (ability instanceof SpellAbility && !((SpellAbility)ability).getSpellAbilityType().equals(SpellAbilityType.SPLIT)) { + if (ability instanceof SpellAbility && !((SpellAbility) ability).getSpellAbilityType().equals(SpellAbilityType.SPLIT)) { allAbilites.add(ability); } } allAbilites.addAll(leftHalfCard.getAbilities(game)); - allAbilites.addAll(rightHalfCard.getAbilities(game)); + allAbilites.addAll(rightHalfCard.getAbilities(game)); return allAbilites; } - + @Override public List getRules() { List rules = new ArrayList<>(); @@ -179,136 +159,3 @@ public abstract class SplitCard extends CardImpl { } } - -/* - * The left side card of the split card - */ -class LeftHalfCard extends CardImpl { - - SplitCard splitCardParent; - - public LeftHalfCard(UUID ownerId, int cardNumber, String name, Rarity rarity, CardType[] cardTypes, String costs, SplitCard splitCardParent) { - super(ownerId, cardNumber, name, rarity, cardTypes, costs, SpellAbilityType.SPLIT_LEFT); - this.splitCardParent = splitCardParent; - } - - public LeftHalfCard(final LeftHalfCard card) { - super(card); - this.splitCardParent = card.splitCardParent; - } - - @Override - public LeftHalfCard copy() { - return new LeftHalfCard(this); - } - - @Override - public UUID getOwnerId() { - return splitCardParent.getOwnerId(); - } - - @Override - public String getImageName() { - return splitCardParent.getImageName(); - } - - @Override - public String getExpansionSetCode() { - return splitCardParent.getExpansionSetCode(); - } - - @Override - public int getCardNumber() { - return splitCardParent.getCardNumber(); - } - - @Override - public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, ArrayList appliedEffects) { - return splitCardParent.moveToZone(toZone, sourceId, game, flag, appliedEffects); - } - - @Override - public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList appliedEffects) { - return splitCardParent.moveToExile(exileId, name, sourceId, game, appliedEffects); - } - - @Override - public Card getMainCard() { - return splitCardParent; - } - - @Override - public void setZone(Zone zone, Game game) { - super.setZone(zone, game); - game.setZone(splitCardParent.getId(), zone); - game.setZone(splitCardParent.getRightHalfCard().getId(), zone); - } - - -} - -/* - * The right side card of the split card - */ -class RightHalfCard extends CardImpl { - - SplitCard splitCardParent; - - public RightHalfCard(UUID ownerId, int cardNumber, String name, Rarity rarity, CardType[] cardTypes, String costs, SplitCard splitCardParent) { - super(ownerId, cardNumber, name, rarity, cardTypes, costs, SpellAbilityType.SPLIT_RIGHT); - this.splitCardParent = splitCardParent; - } - - public RightHalfCard(final RightHalfCard card) { - super(card); - this.splitCardParent = card.splitCardParent; - } - - @Override - public RightHalfCard copy() { - return new RightHalfCard(this); - } - - @Override - public UUID getOwnerId() { - return splitCardParent.getOwnerId(); - } - - @Override - public String getImageName() { - return splitCardParent.getImageName(); - } - - @Override - public String getExpansionSetCode() { - return splitCardParent.getExpansionSetCode(); - } - - @Override - public int getCardNumber() { - return splitCardParent.getCardNumber(); - } - - @Override - public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, ArrayList appliedEffects) { - return splitCardParent.moveToZone(toZone, sourceId, game, flag, appliedEffects); - } - - @Override - public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList appliedEffects) { - return splitCardParent.moveToExile(exileId, name, sourceId, game, appliedEffects); - } - - @Override - public Card getMainCard() { - return splitCardParent; - } - - @Override - public void setZone(Zone zone, Game game) { - super.setZone(zone, game); - game.setZone(splitCardParent.getId(), zone); - game.setZone(splitCardParent.getLeftHalfCard().getId(), zone); - } - -} diff --git a/Mage/src/mage/cards/SplitCardHalf.java b/Mage/src/mage/cards/SplitCardHalf.java new file mode 100644 index 00000000000..52fa1086bb6 --- /dev/null +++ b/Mage/src/mage/cards/SplitCardHalf.java @@ -0,0 +1,16 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mage.cards; + +/** + * + * @author LevelX2 + */ +public interface SplitCardHalf extends Card { + + @Override + Card copy(); +} diff --git a/Mage/src/mage/cards/SplitCardHalfImpl.java b/Mage/src/mage/cards/SplitCardHalfImpl.java new file mode 100644 index 00000000000..af6cc3f6ab6 --- /dev/null +++ b/Mage/src/mage/cards/SplitCardHalfImpl.java @@ -0,0 +1,81 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mage.cards; + +import java.util.ArrayList; +import java.util.UUID; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.constants.SpellAbilityType; +import mage.constants.Zone; +import mage.game.Game; + +/** + * + * @author LevelX2 + */ +public class SplitCardHalfImpl extends CardImpl implements SplitCardHalf { + + SplitCard splitCardParent; + + public SplitCardHalfImpl(UUID ownerId, int cardNumber, String name, Rarity rarity, CardType[] cardTypes, String costs, SplitCard splitCardParent, SpellAbilityType spellAbilityType) { + super(ownerId, cardNumber, name, rarity, cardTypes, costs, spellAbilityType); + this.splitCardParent = splitCardParent; + } + + public SplitCardHalfImpl(final SplitCardHalfImpl card) { + super(card); + this.splitCardParent = card.splitCardParent; + } + + @Override + public UUID getOwnerId() { + return splitCardParent.getOwnerId(); + } + + @Override + public String getImageName() { + return splitCardParent.getImageName(); + } + + @Override + public String getExpansionSetCode() { + return splitCardParent.getExpansionSetCode(); + } + + @Override + public int getCardNumber() { + return splitCardParent.getCardNumber(); + } + + @Override + public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, ArrayList appliedEffects) { + return splitCardParent.moveToZone(toZone, sourceId, game, flag, appliedEffects); + } + + @Override + public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList appliedEffects) { + return splitCardParent.moveToExile(exileId, name, sourceId, game, appliedEffects); + } + + @Override + public Card getMainCard() { + return splitCardParent; + } + + @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 SplitCardHalfImpl copy() { + return new SplitCardHalfImpl(this); + } + +}