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)) { if (super.canActivate(playerId, game)) {
Card card = game.getCard(getSourceId()); Card card = game.getCard(getSourceId());
if (card != null) { 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); return card.getSpellAbility().canActivate(playerId, game);
} }
} }

View file

@ -119,8 +119,6 @@ public abstract class SplitCard extends CardImpl {
@Override @Override
public List<String> getRules() { public List<String> getRules() {
List<String> rules = new ArrayList<>(); List<String> rules = new ArrayList<>();
// rules.addAll(leftHalfCard.getRules());
// rules.addAll(rightHalfCard.getRules());
if (getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) { if (getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {
rules.add("--------------------------------------------------------------------------\nFuse (You may cast one or both halves of this card from your hand.)"); rules.add("--------------------------------------------------------------------------\nFuse (You may cast one or both halves of this card from your hand.)");
} }
@ -191,21 +189,12 @@ class LeftHalfCard extends CardImpl {
public int getCardNumber() { public int getCardNumber() {
return splitCardParent.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 @Override
public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, ArrayList<UUID> appliedEffects) { public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, ArrayList<UUID> appliedEffects) {
return splitCardParent.moveToZone(toZone, sourceId, game, flag, 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 @Override
public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList<UUID> appliedEffects) { public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList<UUID> appliedEffects) {
return splitCardParent.moveToExile(exileId, name, sourceId, game, appliedEffects); return splitCardParent.moveToExile(exileId, name, sourceId, game, appliedEffects);
@ -249,21 +238,11 @@ class RightHalfCard extends CardImpl {
return splitCardParent.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 @Override
public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, ArrayList<UUID> appliedEffects) { public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, ArrayList<UUID> appliedEffects) {
return splitCardParent.moveToZone(toZone, sourceId, game, flag, 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 @Override
public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList<UUID> appliedEffects) { public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList<UUID> appliedEffects) {
return splitCardParent.moveToExile(exileId, name, sourceId, game, 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)) { if (!ability.canActivate(this.playerId, game)) {
return false; return false;
} }
if (ability instanceof SpecialAction) {
if (ability.getAbilityType().equals(AbilityType.SPECIAL_ACTION)) {
result = specialAction((SpecialAction)ability.copy(), game); result = specialAction((SpecialAction)ability.copy(), game);
} }
else if (ability instanceof ManaAbility) { else if (ability.getAbilityType().equals(AbilityType.MANA)) {
result = playManaAbility((ManaAbility)ability.copy(), game); result = playManaAbility((ManaAbility)ability.copy(), game);
} }
else if (ability instanceof FlashbackAbility){ else if (ability.getAbilityType().equals(AbilityType.SPELL)) {
if (ability instanceof FlashbackAbility){
result = playAbility(ability.copy(), game); result = playAbility(ability.copy(), game);
} } else {
else if (ability instanceof SpellAbility) {
result = cast((SpellAbility)ability, game, false); result = cast((SpellAbility)ability, game, false);
} }
else { } else {
result = playAbility(ability.copy(), game); result = playAbility(ability.copy(), game);
} }
} }
@ -1214,6 +1215,7 @@ public abstract class PlayerImpl implements Player, Serializable {
Card card = game.getCard(ability.getSourceId()); Card card = game.getCard(ability.getSourceId());
if (card.isSplitCard() && ability instanceof FlashbackAbility) { if (card.isSplitCard() && ability instanceof FlashbackAbility) {
FlashbackAbility flashbackAbility; FlashbackAbility flashbackAbility;
// Left Half
if (card.getCardType().contains(CardType.INSTANT)) { if (card.getCardType().contains(CardType.INSTANT)) {
flashbackAbility = new FlashbackAbility(((SplitCard) card).getLeftHalfCard().getManaCost(), TimingRule.INSTANT); flashbackAbility = new FlashbackAbility(((SplitCard) card).getLeftHalfCard().getManaCost(), TimingRule.INSTANT);
} }
@ -1224,7 +1226,10 @@ public abstract class PlayerImpl implements Player, Serializable {
flashbackAbility.setControllerId(card.getOwnerId()); flashbackAbility.setControllerId(card.getOwnerId());
flashbackAbility.setSpellAbilityType(SpellAbilityType.SPLIT_LEFT); flashbackAbility.setSpellAbilityType(SpellAbilityType.SPLIT_LEFT);
flashbackAbility.setAbilityName(((SplitCard) card).getLeftHalfCard().getName()); flashbackAbility.setAbilityName(((SplitCard) card).getLeftHalfCard().getName());
if (flashbackAbility.canActivate(playerId, game)) {
useable.put(flashbackAbility.getId(), flashbackAbility); useable.put(flashbackAbility.getId(), flashbackAbility);
}
// Right Half
if (card.getCardType().contains(CardType.INSTANT)) { if (card.getCardType().contains(CardType.INSTANT)) {
flashbackAbility = new FlashbackAbility(((SplitCard) card).getRightHalfCard().getManaCost(), TimingRule.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.setControllerId(card.getOwnerId());
flashbackAbility.setSpellAbilityType(SpellAbilityType.SPLIT_RIGHT); flashbackAbility.setSpellAbilityType(SpellAbilityType.SPLIT_RIGHT);
flashbackAbility.setAbilityName(((SplitCard) card).getRightHalfCard().getName()); flashbackAbility.setAbilityName(((SplitCard) card).getRightHalfCard().getName());
if (flashbackAbility.canActivate(playerId, game)) {
useable.put(flashbackAbility.getId(), flashbackAbility); useable.put(flashbackAbility.getId(), flashbackAbility);
}
} else { } else {
useable.put(ability.getId(), ability); useable.put(ability.getId(), ability);
@ -2205,7 +2212,7 @@ public abstract class PlayerImpl implements Player, Serializable {
ManaCostsImpl manaCosts = new ManaCostsImpl(); ManaCostsImpl manaCosts = new ManaCostsImpl();
for(Cost cost:alternateSourceCostsAbility.getCosts()) { for(Cost cost:alternateSourceCostsAbility.getCosts()) {
if (cost instanceof ManaCost) { 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(); ManaCostsImpl manaCosts = new ManaCostsImpl();
for(Cost cost:ability.getCosts()) { for(Cost cost:ability.getCosts()) {
if (cost instanceof ManaCost) { if (cost instanceof ManaCost) {
manaCosts.add(cost); manaCosts.add((ManaCost)cost);
} }
} }