Some redesign for split cards.

This commit is contained in:
LevelX2 2015-07-19 19:27:20 +02:00
parent 42112622d3
commit 2d54604fd2
4 changed files with 178 additions and 202 deletions

View file

@ -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<Ability> getAbilities(Game game);
void setSpellAbility(SpellAbility ability);
SpellAbility getSpellAbility();
List<String> getRules(); // gets base card rules
List<String> 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
* <ul>
* <li>LIBRARY: <ul><li>true - put on top</li><li>false - put on bottom</li></ul></li>
* <li>BATTLEFIELD: <ul><li>true - tapped</li><li>false - untapped</li></ul></li>
* <li>GRAVEYARD: <ul><li>true - not from Battlefield</li><li>false - from Battlefield</li></ul></li>
* <li>LIBRARY: <ul><li>true - put on top</li><li>false - put on
* bottom</li></ul></li>
* <li>BATTLEFIELD: <ul><li>true - tapped</li><li>false -
* untapped</li></ul></li>
* <li>GRAVEYARD: <ul><li>true - not from Battlefield</li><li>false - from
* Battlefield</li></ul></li>
* </ul>
* @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
@ -101,12 +123,16 @@ public interface Card extends MageObject {
boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList<UUID> 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<UUID> appliedEffects);
List<Mana> getMana();
void build();
@ -116,14 +142,19 @@ 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<UUID> appliedEffects);
void addCounters(Counter counter, Game game);
void addCounters(Counter counter, Game game, ArrayList<UUID> appliedEffects);
void removeCounters(String name, int amount, Game game);
void removeCounters(Counter counter, Game game);
@Override
@ -131,7 +162,8 @@ public interface Card extends MageObject {
/**
*
* @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();

View file

@ -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,12 +112,11 @@ public abstract class SplitCard extends CardImpl {
game.setZone(getRightHalfCard().getId(), zone);
}
@Override
public Abilities<Ability> getAbilities(){
public Abilities<Ability> getAbilities() {
Abilities<Ability> 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);
}
}
@ -149,7 +129,7 @@ public abstract class SplitCard extends CardImpl {
public Abilities<Ability> getAbilities(Game game) {
Abilities<Ability> 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);
}
}
@ -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<UUID> appliedEffects) {
return splitCardParent.moveToZone(toZone, sourceId, game, flag, appliedEffects);
}
@Override
public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList<UUID> 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<UUID> appliedEffects) {
return splitCardParent.moveToZone(toZone, sourceId, game, flag, appliedEffects);
}
@Override
public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList<UUID> 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);
}
}

View file

@ -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();
}

View file

@ -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<UUID> appliedEffects) {
return splitCardParent.moveToZone(toZone, sourceId, game, flag, appliedEffects);
}
@Override
public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList<UUID> 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);
}
}