Some changes to split card handling (not finished).

This commit is contained in:
LevelX2 2015-02-02 17:54:06 +01:00
parent 2425704305
commit 1ac4196c9e
3 changed files with 35 additions and 41 deletions

View file

@ -88,6 +88,14 @@ public class FlashbackAbility extends SpellAbility {
if (super.canActivate(playerId, game)) {
Card card = game.getCard(getSourceId());
if (card != null) {
// Flashback can never cast a split card by Fuse, because Fuse only works from hand
if (card.isSplitCard()) {
if (((SplitCard)card).getLeftHalfCard().getName().equals(abilityName)) {
return ((SplitCard)card).getLeftHalfCard().getSpellAbility().canActivate(playerId, game);
} else if (((SplitCard)card).getRightHalfCard().getName().equals(abilityName)) {
return ((SplitCard)card).getRightHalfCard().getSpellAbility().canActivate(playerId, game);
}
}
return card.getSpellAbility().canActivate(playerId, game);
}
}

View file

@ -90,7 +90,7 @@ public abstract class SplitCard extends CardImpl {
public Card getRightHalfCard () {
return rightHalfCard;
}
@Override
public boolean cast(Game game, Zone fromZone, SpellAbility ability, UUID controllerId) {
switch(ability.getSpellAbilityType()) {
@ -102,7 +102,7 @@ public abstract class SplitCard extends CardImpl {
return super.cast(game, fromZone, ability, controllerId);
}
}
@Override
public Abilities<Ability> getAbilities(){
Abilities<Ability> allAbilites = new AbilitiesImpl<>();
@ -119,8 +119,6 @@ public abstract class SplitCard extends CardImpl {
@Override
public List<String> getRules() {
List<String> rules = new ArrayList<>();
// rules.addAll(leftHalfCard.getRules());
// rules.addAll(rightHalfCard.getRules());
if (getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {
rules.add("--------------------------------------------------------------------------\nFuse (You may cast one or both halves of this card from your hand.)");
}
@ -191,25 +189,16 @@ class LeftHalfCard extends CardImpl {
public int getCardNumber() {
return splitCardParent.getCardNumber();
}
@Override
public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag) {
return splitCardParent.moveToZone(toZone, sourceId, game, flag, null);
}
@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) {
return splitCardParent.moveToExile(exileId, name, sourceId, game, null);
}
@Override
public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList<UUID> appliedEffects) {
return splitCardParent.moveToExile(exileId, name, sourceId, game, appliedEffects);
}
}
}
/*
@ -249,21 +238,11 @@ class RightHalfCard extends CardImpl {
return splitCardParent.getCardNumber();
}
@Override
public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag) {
return splitCardParent.moveToZone(toZone, sourceId, game, flag, null);
}
@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) {
return splitCardParent.moveToExile(exileId, name, sourceId, game, null);
}
@Override
public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList<UUID> appliedEffects) {
return splitCardParent.moveToExile(exileId, name, sourceId, game, appliedEffects);

View file

@ -1080,19 +1080,20 @@ public abstract class PlayerImpl implements Player, Serializable {
if (!ability.canActivate(this.playerId, game)) {
return false;
}
if (ability instanceof SpecialAction) {
if (ability.getAbilityType().equals(AbilityType.SPECIAL_ACTION)) {
result = specialAction((SpecialAction)ability.copy(), game);
}
else if (ability instanceof ManaAbility) {
else if (ability.getAbilityType().equals(AbilityType.MANA)) {
result = playManaAbility((ManaAbility)ability.copy(), game);
}
else if (ability instanceof FlashbackAbility){
result = playAbility(ability.copy(), game);
}
else if (ability instanceof SpellAbility) {
result = cast((SpellAbility)ability, game, false);
}
else {
else if (ability.getAbilityType().equals(AbilityType.SPELL)) {
if (ability instanceof FlashbackAbility){
result = playAbility(ability.copy(), game);
} else {
result = cast((SpellAbility)ability, game, false);
}
} else {
result = playAbility(ability.copy(), game);
}
}
@ -1214,8 +1215,9 @@ public abstract class PlayerImpl implements Player, Serializable {
Card card = game.getCard(ability.getSourceId());
if (card.isSplitCard() && ability instanceof FlashbackAbility) {
FlashbackAbility flashbackAbility;
if (card.getCardType().contains(CardType.INSTANT)) {
flashbackAbility = new FlashbackAbility(((SplitCard) card).getLeftHalfCard().getManaCost(), TimingRule.INSTANT);
// Left Half
if (card.getCardType().contains(CardType.INSTANT)) {
flashbackAbility = new FlashbackAbility(((SplitCard) card).getLeftHalfCard().getManaCost(), TimingRule.INSTANT);
}
else {
flashbackAbility = new FlashbackAbility(((SplitCard) card).getLeftHalfCard().getManaCost(), TimingRule.SORCERY);
@ -1224,7 +1226,10 @@ public abstract class PlayerImpl implements Player, Serializable {
flashbackAbility.setControllerId(card.getOwnerId());
flashbackAbility.setSpellAbilityType(SpellAbilityType.SPLIT_LEFT);
flashbackAbility.setAbilityName(((SplitCard) card).getLeftHalfCard().getName());
useable.put(flashbackAbility.getId(), flashbackAbility);
if (flashbackAbility.canActivate(playerId, game)) {
useable.put(flashbackAbility.getId(), flashbackAbility);
}
// Right Half
if (card.getCardType().contains(CardType.INSTANT)) {
flashbackAbility = new FlashbackAbility(((SplitCard) card).getRightHalfCard().getManaCost(), TimingRule.INSTANT);
}
@ -1235,7 +1240,9 @@ public abstract class PlayerImpl implements Player, Serializable {
flashbackAbility.setControllerId(card.getOwnerId());
flashbackAbility.setSpellAbilityType(SpellAbilityType.SPLIT_RIGHT);
flashbackAbility.setAbilityName(((SplitCard) card).getRightHalfCard().getName());
useable.put(flashbackAbility.getId(), flashbackAbility);
if (flashbackAbility.canActivate(playerId, game)) {
useable.put(flashbackAbility.getId(), flashbackAbility);
}
} else {
useable.put(ability.getId(), ability);
@ -2205,7 +2212,7 @@ public abstract class PlayerImpl implements Player, Serializable {
ManaCostsImpl manaCosts = new ManaCostsImpl();
for(Cost cost:alternateSourceCostsAbility.getCosts()) {
if (cost instanceof ManaCost) {
manaCosts.add(cost);
manaCosts.add((ManaCost)cost);
}
}
@ -2242,7 +2249,7 @@ public abstract class PlayerImpl implements Player, Serializable {
ManaCostsImpl manaCosts = new ManaCostsImpl();
for(Cost cost:ability.getCosts()) {
if (cost instanceof ManaCost) {
manaCosts.add(cost);
manaCosts.add((ManaCost)cost);
}
}