mirror of
https://github.com/magefree/mage.git
synced 2026-01-23 19:59:54 -08:00
Some improvements to split card handling. Better display of tooltip of split cards, also added handling if not cast from hand.
This commit is contained in:
parent
a29dc6cb18
commit
b352217e17
11 changed files with 256 additions and 66 deletions
|
|
@ -33,9 +33,7 @@ import mage.Constants.AsThoughEffectType;
|
|||
import mage.Constants.CardType;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.keyword.FlashAbility;
|
||||
import mage.game.Game;
|
||||
|
||||
|
|
@ -90,7 +88,9 @@ public class SpellAbility extends ActivatedAbilityImpl<SpellAbility> {
|
|||
object.getAbilities().containsKey(FlashAbility.getInstance().getId()) ||
|
||||
game.getContinuousEffects().asThough(sourceId, AsThoughEffectType.CAST, game) ||
|
||||
game.canPlaySorcery(playerId))) {
|
||||
|
||||
if (spellAbilityType.equals(SpellAbilityType.SPLIT)) {
|
||||
return false;
|
||||
}
|
||||
// fix for Gitaxian Probe and casting opponent's spells
|
||||
if (!controllerId.equals(playerId)) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -38,8 +38,6 @@ import mage.abilities.Abilities;
|
|||
import mage.abilities.AbilitiesImpl;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
/**
|
||||
|
|
@ -108,11 +106,10 @@ public abstract class SplitCard<T extends SplitCard<T>> extends CardImpl<T> {
|
|||
@Override
|
||||
public List<String> getRules() {
|
||||
List<String> rules = new ArrayList<String>();
|
||||
rules.addAll(leftHalfCard.getRules());
|
||||
rules.addAll(rightHalfCard.getRules());
|
||||
// rules.addAll(leftHalfCard.getRules());
|
||||
// rules.addAll(rightHalfCard.getRules());
|
||||
if (getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {
|
||||
rules.add("--------------------------------------------------------------------------");
|
||||
rules.add("Fuse (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.)");
|
||||
}
|
||||
return rules;
|
||||
}
|
||||
|
|
@ -163,23 +160,24 @@ class LeftHalfCard extends CardImpl<LeftHalfCard> {
|
|||
return new LeftHalfCard(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRules() {
|
||||
List<String> rules = new ArrayList<String>();
|
||||
// TODO: Move formatting to client CardInfoPaneImpl.java
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("<table cellspacing=0 cellpadding=0 border=0 width='100%'>");
|
||||
buffer.append("<tr><td valign='top'><b>");
|
||||
buffer.append(this.getName());
|
||||
buffer.append("</b></td><td align='right' valign='top' style='width:");
|
||||
buffer.append(getSpellAbility().getManaCosts().getSymbols().size() * 11 + 1);
|
||||
buffer.append("px'>");
|
||||
buffer.append(getSpellAbility().getManaCosts().getText());
|
||||
buffer.append("</td></tr></table>");
|
||||
rules.add(buffer.toString());
|
||||
rules.addAll(super.getRules());
|
||||
return rules;
|
||||
}
|
||||
// @Override
|
||||
// public List<String> getRules() {
|
||||
// List<String> rules = new ArrayList<String>();
|
||||
// // TODO: Move formatting to client CardInfoPaneImpl.java
|
||||
// StringBuilder buffer = new StringBuilder();
|
||||
// buffer.append("<table cellspacing=0 cellpadding=0 border=0 width='100%'>");
|
||||
// buffer.append("<tr><td valign='top'><b>");
|
||||
// buffer.append(this.getName());
|
||||
// buffer.append("</b></td><td align='right' valign='top' style='width:");
|
||||
// buffer.append(getSpellAbility().getManaCosts().getSymbols().size() * 11 + 1);
|
||||
// buffer.append("px'>");
|
||||
// buffer.append(getSpellAbility().getManaCosts().getText());
|
||||
// buffer.append("</td></tr></table>");
|
||||
//
|
||||
// rules.add(buffer.toString());
|
||||
// rules.addAll(super.getRules());
|
||||
// return rules;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -202,21 +200,21 @@ class RightHalfCard extends CardImpl<RightHalfCard> {
|
|||
return new RightHalfCard(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRules() {
|
||||
List<String> rules = new ArrayList<String>();
|
||||
// TODO: Move formatting to client CardInfoPaneImpl.java
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("<table cellspacing=0 cellpadding=0 border=0 width='100%'>");
|
||||
buffer.append("<tr><td valign='top'><b>");
|
||||
buffer.append(this.getName());
|
||||
buffer.append("</b></td><td align='right' valign='top' style='width:");
|
||||
buffer.append(getSpellAbility().getManaCosts().getSymbols().size() * 11 + 1);
|
||||
buffer.append("px'>");
|
||||
buffer.append(getSpellAbility().getManaCosts().getText());
|
||||
buffer.append("</td></tr></table>");
|
||||
rules.add(buffer.toString());
|
||||
rules.addAll(super.getRules());
|
||||
return rules;
|
||||
}
|
||||
// @Override
|
||||
// public List<String> getRules() {
|
||||
// List<String> rules = new ArrayList<String>();
|
||||
// // TODO: Move formatting to client CardInfoPaneImpl.java
|
||||
// StringBuilder buffer = new StringBuilder();
|
||||
// buffer.append("<table cellspacing=0 cellpadding=0 border=0 width='100%'>");
|
||||
// buffer.append("<tr><td valign='top'><b>");
|
||||
// buffer.append(this.getName());
|
||||
// buffer.append("</b></td><td align='right' valign='top' style='width:");
|
||||
// buffer.append(getSpellAbility().getManaCosts().getSymbols().size() * 11 + 1);
|
||||
// buffer.append("px'>");
|
||||
// buffer.append(getSpellAbility().getManaCosts().getText());
|
||||
// buffer.append("</td></tr></table>");
|
||||
// rules.add(buffer.toString());
|
||||
// rules.addAll(super.getRules());
|
||||
// return rules;
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -591,4 +591,8 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
|
||||
@Override
|
||||
public void removeCounters(Counter counter, Game game) {}
|
||||
|
||||
public Card getCard() {
|
||||
return card;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
int drawCards(int num, Game game);
|
||||
int drawCards(int num, Game game, ArrayList<UUID> appliedEffects);
|
||||
boolean cast(SpellAbility ability, Game game, boolean noMana);
|
||||
SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana);
|
||||
boolean putInHand(Card card, Game game);
|
||||
boolean removeFromHand(Card card, Game game);
|
||||
boolean removeFromBattlefield(Permanent permanent, Game game);
|
||||
|
|
|
|||
|
|
@ -595,6 +595,9 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
|||
|
||||
@Override
|
||||
public boolean cast(SpellAbility ability, Game game, boolean noMana) {
|
||||
if (!ability.getSpellAbilityType().equals(SpellAbilityType.BASE)) {
|
||||
ability = chooseSpellAbilityForCast(ability, game, noMana);
|
||||
}
|
||||
//20091005 - 601.2a
|
||||
Card card = game.getCard(ability.getSourceId());
|
||||
if (card != null) {
|
||||
|
|
@ -618,6 +621,11 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) {
|
||||
return ability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playLand(Card card, Game game) {
|
||||
//20091005 - 305.1
|
||||
|
|
@ -775,6 +783,31 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
|||
return false;
|
||||
}
|
||||
|
||||
protected LinkedHashMap<UUID, ActivatedAbility> getSpellAbilities(MageObject object, Zone zone, Game game) {
|
||||
LinkedHashMap<UUID, ActivatedAbility> useable = new LinkedHashMap<UUID, ActivatedAbility>();
|
||||
for (Ability ability: object.getAbilities()) {
|
||||
if (ability instanceof SpellAbility) {
|
||||
if (((SpellAbility) ability).getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {
|
||||
if (zone.equals(Zone.HAND)) {
|
||||
// Fix so you don't need to choose Fuse twice
|
||||
useable.clear();
|
||||
useable.put(ability.getId(), (SpellAbility) ability);
|
||||
return useable;
|
||||
} else {
|
||||
// Fuse only allowed from hand
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (((SpellAbility) ability).getSpellAbilityType().equals(SpellAbilityType.SPLIT)) {
|
||||
continue;
|
||||
}
|
||||
useable.put(ability.getId(), (SpellAbility) ability);
|
||||
}
|
||||
}
|
||||
return useable;
|
||||
}
|
||||
|
||||
|
||||
protected LinkedHashMap<UUID, ActivatedAbility> getUseableActivatedAbilities(MageObject object, Zone zone, Game game) {
|
||||
LinkedHashMap<UUID, ActivatedAbility> useable = new LinkedHashMap<UUID, ActivatedAbility>();
|
||||
for (ActivatedAbility ability: object.getAbilities().getActivatedAbilities(zone)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue