*Reintroduced TriggerReplacementBase as a specialized subclass of CardTraitBase

This commit is contained in:
Hellfish
2014-02-09 16:03:27 +00:00
parent d331c87ab5
commit 50c40311a7
264 changed files with 1010 additions and 1101 deletions

View File

@@ -95,7 +95,7 @@ public class FControlGamePlayback extends IGameEventVisitor.Base<Void> {
@Override
public Void visit(final GameEventSpellResolved event) {
FThreads.invokeInEdtNowOrLater(new Runnable() { @Override public void run() { CMatchUI.SINGLETON_INSTANCE.setCard(event.spell.getSourceCard()); } });
FThreads.invokeInEdtNowOrLater(new Runnable() { @Override public void run() { CMatchUI.SINGLETON_INSTANCE.setCard(event.spell.getHostCard()); } });
pauseForEvent(resolveDelay);
return null;
}
@@ -105,7 +105,7 @@ public class FControlGamePlayback extends IGameEventVisitor.Base<Void> {
*/
@Override
public Void visit(final GameEventSpellAbilityCast event) {
FThreads.invokeInEdtNowOrLater(new Runnable() { @Override public void run() { CMatchUI.SINGLETON_INSTANCE.setCard(event.sa.getSourceCard()); } });
FThreads.invokeInEdtNowOrLater(new Runnable() { @Override public void run() { CMatchUI.SINGLETON_INSTANCE.setCard(event.sa.getHostCard()); } });
pauseForEvent(castDelay);
return null;
}

View File

@@ -313,7 +313,7 @@ public class DualListBox<T> extends FDialog {
if (obj instanceof Card) {
card = (Card) obj;
} else if (obj instanceof SpellAbility) {
card = ((SpellAbility) obj).getSourceCard();
card = ((SpellAbility) obj).getHostCard();
} else if (obj instanceof PaperCard) {
card = Card.getCardForUi((IPaperCard) obj);
}

View File

@@ -148,8 +148,8 @@ public abstract class InputPayMana extends InputSyncronizedBase {
// Store some information about color costs to help with any mana choices
if (colorNeeded == 0) { // only colorless left
if (saPaidFor.getSourceCard() != null && saPaidFor.getSourceCard().hasSVar("ManaNeededToAvoidNegativeEffect")) {
String[] negEffects = saPaidFor.getSourceCard().getSVar("ManaNeededToAvoidNegativeEffect").split(",");
if (saPaidFor.getHostCard() != null && saPaidFor.getHostCard().hasSVar("ManaNeededToAvoidNegativeEffect")) {
String[] negEffects = saPaidFor.getHostCard().getSVar("ManaNeededToAvoidNegativeEffect").split(",");
for (String negColor : negEffects) {
byte col = MagicColor.fromName(negColor);
colorCanUse |= col;
@@ -196,7 +196,7 @@ public abstract class InputPayMana extends InputSyncronizedBase {
ColorSet colors = ColorSet.fromMask(0 == colorNeeded ? colorCanUse : colorNeeded);
chosen.getManaPartRecursive().setExpressChoice(colors);
// System.out.println("Chosen sa=" + chosen + " of " + chosen.getSourceCard() + " to pay mana");
// System.out.println("Chosen sa=" + chosen + " of " + chosen.getHostCard() + " to pay mana");
Runnable proc = new Runnable() {
@Override
public void run() {
@@ -229,7 +229,7 @@ public abstract class InputPayMana extends InputSyncronizedBase {
}
// check for produce mana replacement effects - they mess this up, so just use the mana ability
final Card source = am.getSourceCard();
final Card source = am.getHostCard();
final Player activator = am.getActivatingPlayer();
final Game g = source.getGame();
final HashMap<String, Object> repParams = new HashMap<String, Object>();

View File

@@ -29,7 +29,7 @@ public class InputPayManaOfCostPayment extends InputPayMana {
@Override
protected void done() {
final Card source = saPaidFor.getSourceCard();
final Card source = saPaidFor.getHostCard();
if (this.phyLifeToLose > 0) {
player.payLife(this.phyLifeToLose, source);
}

View File

@@ -40,9 +40,9 @@ public class InputPayManaSimple extends InputPayMana {
public InputPayManaSimple(final Game game, final SpellAbility sa, final ManaCostBeingPaid manaCostToPay) {
super(sa);
this.originalManaCost = manaCostToPay.toManaCost();
this.originalCard = sa.getSourceCard();
this.originalCard = sa.getHostCard();
if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) {
if (sa.getHostCard().isCopiedSpell() && sa.isSpell()) {
this.manaCost = new ManaCostBeingPaid(ManaCost.ZERO);
game.getStack().add(this.saPaidFor);
}
@@ -81,11 +81,11 @@ public class InputPayManaSimple extends InputPayMana {
if (this.phyLifeToLose > 0) {
player.payLife(this.phyLifeToLose, this.originalCard);
}
if (!this.saPaidFor.getSourceCard().isCopiedSpell()) {
if (!this.saPaidFor.getHostCard().isCopiedSpell()) {
player.getManaPool().clearManaPaid(this.saPaidFor, false);
if (this.saPaidFor.isSpell()) {
this.saPaidFor.setSourceCard(game.getAction().moveToStack(this.originalCard));
this.saPaidFor.setHostCard(game.getAction().moveToStack(this.originalCard));
}
}
}

View File

@@ -44,7 +44,7 @@ public class InputPayManaX extends InputPayMana {
manaCost = new ManaCostBeingPaid(manaCostPerX);
this.xCanBe0 = xCanBe0;
colorsPaid = saPaidFor.getSourceCard().getColorsPaid(); // for effects like sunburst
colorsPaid = saPaidFor.getHostCard().getColorsPaid(); // for effects like sunburst
}
/* (non-Javadoc)
@@ -72,7 +72,7 @@ public class InputPayManaX extends InputPayMana {
@Override
protected String getMessage() {
StringBuilder msg = new StringBuilder("Pay X Mana Cost for ");
msg.append(saPaidFor.getSourceCard().getName()).append("\n").append(this.xPaid);
msg.append(saPaidFor.getHostCard().getName()).append("\n").append(this.xPaid);
msg.append(" Paid so far.");
if (!xCanBe0) {
msg.append(" X Can't be 0.");
@@ -124,7 +124,7 @@ public class InputPayManaX extends InputPayMana {
@Override
protected void done() {
final Card card = saPaidFor.getSourceCard();
final Card card = saPaidFor.getHostCard();
card.setXManaCostPaid(this.xPaid);
card.setColorsPaid(this.colorsPaid);
card.setSunburstValue(ColorSet.fromMask(this.colorsPaid).countColors());

View File

@@ -62,9 +62,9 @@ public final class InputSelectTargets extends InputSyncronizedBase {
sb.append("\n");
}
sb.append(sa.getSourceCard() + " - " + tgt.getVTSelection());
sb.append(sa.getHostCard() + " - " + tgt.getVTSelection());
int maxTargets = tgt.getMaxTargets(sa.getSourceCard(), sa);
int maxTargets = tgt.getMaxTargets(sa.getHostCard(), sa);
int targeted = sa.getTargets().getNumTargeted();
if(maxTargets > 1)
sb.append("\n(").append(maxTargets - targeted).append(" more can be targeted)");
@@ -72,7 +72,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
showMessage(sb.toString());
// If reached Minimum targets, enable OK button
if (!tgt.isMinTargetsChosen(sa.getSourceCard(), sa) || tgt.isDividedAsYouChoose()) {
if (!tgt.isMinTargetsChosen(sa.getHostCard(), sa) || tgt.isDividedAsYouChoose()) {
if (mandatory && tgt.hasCandidates(sa, true)) {
// Player has to click on a target
ButtonUtil.disableAll();
@@ -110,14 +110,14 @@ public final class InputSelectTargets extends InputSyncronizedBase {
// leave this in temporarily, there some seriously wrong things going on here
// Can be targeted doesn't check if the target is a valid type, only if a card is generally "targetable"
if (!card.canBeTargetedBy(sa)) {
showMessage(sa.getSourceCard() + " - Cannot target this card (Shroud? Protection? Restrictions).");
showMessage(sa.getHostCard() + " - Cannot target this card (Shroud? Protection? Restrictions).");
return;
}
if (!choices.contains(card)) {
if (card.isPlaneswalker() && sa.getApi() == ApiType.DealDamage) {
showMessage(sa.getSourceCard() + " - To deal an opposing Planeswalker direct damage, target its controller and then redirect the damage on resolution.");
showMessage(sa.getHostCard() + " - To deal an opposing Planeswalker direct damage, target its controller and then redirect the damage on resolution.");
} else {
showMessage(sa.getSourceCard() + " - The selected card is not a valid choice to be targeted.");
showMessage(sa.getHostCard() + " - The selected card is not a valid choice to be targeted.");
}
return;
}
@@ -126,7 +126,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
final int stillToDivide = tgt.getStillToDivide();
int allocatedPortion = 0;
// allow allocation only if the max targets isn't reached and there are more candidates
if ((sa.getTargets().getNumTargeted() + 1 < tgt.getMaxTargets(sa.getSourceCard(), sa))
if ((sa.getTargets().getNumTargeted() + 1 < tgt.getMaxTargets(sa.getHostCard(), sa))
&& (tgt.getNumCandidates(sa, true) - 1 > 0) && stillToDivide > 1) {
final Integer[] choices = new Integer[stillToDivide];
for (int i = 1; i <= stillToDivide; i++) {
@@ -164,7 +164,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
}
if (!sa.canTarget(player)) {
showMessage(sa.getSourceCard() + " - Cannot target this player (Hexproof? Protection? Restrictions?).");
showMessage(sa.getHostCard() + " - Cannot target this player (Hexproof? Protection? Restrictions?).");
return;
}
@@ -172,7 +172,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
final int stillToDivide = tgt.getStillToDivide();
int allocatedPortion = 0;
// allow allocation only if the max targets isn't reached and there are more candidates
if ((sa.getTargets().getNumTargeted() + 1 < tgt.getMaxTargets(sa.getSourceCard(), sa)) && (tgt.getNumCandidates(sa, true) - 1 > 0) && stillToDivide > 1) {
if ((sa.getTargets().getNumTargeted() + 1 < tgt.getMaxTargets(sa.getHostCard(), sa)) && (tgt.getNumCandidates(sa, true) - 1 > 0) && stillToDivide > 1) {
final Integer[] choices = new Integer[stillToDivide];
for (int i = 1; i <= stillToDivide; i++) {
choices[i - 1] = i;
@@ -225,6 +225,6 @@ public final class InputSelectTargets extends InputSyncronizedBase {
}
private boolean hasAllTargets() {
return tgt.isMaxTargetsChosen(sa.getSourceCard(), sa) || ( tgt.getStillToDivide() == 0 && tgt.isDividedAsYouChoose());
return tgt.isMaxTargetsChosen(sa.getHostCard(), sa) || ( tgt.getStillToDivide() == 0 && tgt.isDividedAsYouChoose());
}
}

View File

@@ -192,7 +192,7 @@ public enum VStack implements IVDoc<CStack> {
* TODO - we should figure out how to display cards on the stack in
* the Picture/Detail panel The problem not is that when a computer
* casts a Morph, the real card shows because Picture/Detail checks
* isFaceDown() which will be false on for spell.getSourceCard() on
* isFaceDown() which will be false on for spell.getHostCard() on
* the stack.
*/
@@ -201,7 +201,7 @@ public enum VStack implements IVDoc<CStack> {
@Override
public void mouseEntered(final MouseEvent e) {
if (!spell.getStackDescription().startsWith("Morph ")) {
CMatchUI.SINGLETON_INSTANCE.setCard(spell.getSpellAbility().getSourceCard());
CMatchUI.SINGLETON_INSTANCE.setCard(spell.getSpellAbility().getHostCard());
}
}
});

View File

@@ -315,7 +315,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
for (SpellAbilityStackInstance si : game.getStack()) {
final Card stC = si.getSourceCard();
final SpellAbility stSA = si.getSpellAbility().getRootAbility();
if (stC.isValid(cost.getType().split(";"), sa.getActivatingPlayer(), sa.getSourceCard()) && stSA.isSpell()) {
if (stC.isValid(cost.getType().split(";"), sa.getActivatingPlayer(), sa.getHostCard()) && stSA.isSpell()) {
saList.add(stSA);
if (stC.isCopiedSpell()) {
descList.add(stSA.getStackDescription() + " (Copied Spell)");
@@ -336,7 +336,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
if (o != null) {
final SpellAbility toExile = saList.get(descList.indexOf(o));
final Card c = toExile.getSourceCard();
final Card c = toExile.getHostCard();
saList.remove(toExile);
descList.remove(o);
@@ -631,7 +631,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
}
// Cards to use this branch: Scarscale Ritual, Wandering Mage - each adds only one counter
List<Card> typeList = CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), player, ability.getSourceCard());
List<Card> typeList = CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), player, ability.getHostCard());
InputSelectCardsFromList inp = new InputSelectCardsFromList(1, 1, typeList);
inp.setMessage("Put " + Lang.nounWithAmount(c, cost.getCounter().getName() + " counter") + " on " +cost.getDescriptiveType());
@@ -660,13 +660,13 @@ public class HumanCostDecision extends CostDecisionMakerBase {
}
}
if (cost.payCostFromSource()) {
final Card card = ability.getSourceCard();
final Card card = ability.getHostCard();
if (card.getController() == player && card.isInPlay()) {
return player.getController().confirmPayment(cost, "Return " + card.getName() + " to hand?") ? PaymentDecision.card(card) : null;
}
}
else {
List<Card> validCards = CardLists.getValidCards(ability.getActivatingPlayer().getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), ability.getActivatingPlayer(), ability.getSourceCard());
List<Card> validCards = CardLists.getValidCards(ability.getActivatingPlayer().getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), ability.getActivatingPlayer(), ability.getHostCard());
InputSelectCardsFromList inp = new InputSelectCardsFromList(c, c, validCards);
inp.setMessage("Return %d " + cost.getType() + " " + cost.getType() + " card(s) to hand");
@@ -726,7 +726,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
Integer num = cost.convertAmount();
List<Card> handList = player.getCardsIn(ZoneType.Hand);
handList = CardLists.getValidCards(handList, cost.getType().split(";"), player, ability.getSourceCard());
handList = CardLists.getValidCards(handList, cost.getType().split(";"), player, ability.getHostCard());
if (num == null) {
final String sVar = ability.getSVar(amount);
@@ -1002,7 +1002,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
type = type.replace("+withTotalPowerGE" + totalP, "");
}
typeList = CardLists.getValidCards(typeList, type.split(";"), player, ability.getSourceCard());
typeList = CardLists.getValidCards(typeList, type.split(";"), player, ability.getHostCard());
typeList = CardLists.filter(typeList, Presets.UNTAPPED);
if (c == null && !amount.equals("Any")) {
final String sVar = ability.getSVar(amount);
@@ -1077,7 +1077,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
@Override
public PaymentDecision visit(CostUntapType cost) {
List<Card> typeList = CardLists.getValidCards(player.getGame().getCardsIn(ZoneType.Battlefield), cost.getType().split(";"),
player, ability.getSourceCard());
player, ability.getHostCard());
typeList = CardLists.filter(typeList, Presets.TAPPED);
if (!cost.canUntapSource) {
typeList.remove(source);
@@ -1108,7 +1108,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
@Override
public PaymentDecision visit(CostUnattach cost) {
final Card source = ability.getSourceCard();
final Card source = ability.getHostCard();
Card cardToUnattach = cost.findCardToUnattach(source, player, ability);
if (cardToUnattach != null && player.getController().confirmPayment(cost, "Unattach " + cardToUnattach.getName() + "?")) {

View File

@@ -54,12 +54,12 @@ public class HumanPlay {
FThreads.assertExecutedByEdt(false);
if (sa == Ability.PLAY_LAND_SURROGATE) {
p.playLand(sa.getSourceCard(), false);
p.playLand(sa.getHostCard(), false);
return;
}
sa.setActivatingPlayer(p);
final Card source = sa.getSourceCard();
final Card source = sa.getHostCard();
source.setSplitStateToPlayAbility(sa);
sa = chooseOptionalAdditionalCosts(p, sa);
@@ -85,7 +85,7 @@ public class HumanPlay {
ability = ability.getSubAbility();
}
// System.out.println("Playing:" + sa.getDescription() + " of " + sa.getSourceCard() + " new = " + newAbility);
// System.out.println("Playing:" + sa.getDescription() + " of " + sa.getHostCard() + " new = " + newAbility);
if (newAbility) {
Cost abCost = sa.getPayCosts() == null ? new Cost("0", sa.isAbility()) : sa.getPayCosts();
CostPayment payment = new CostPayment(abCost, sa);
@@ -95,7 +95,7 @@ public class HumanPlay {
}
else if (payManaCostIfNeeded(p, sa)) {
if (sa.isSpell() && !source.isCopiedSpell()) {
sa.setSourceCard(p.getGame().getAction().moveToStack(source));
sa.setHostCard(p.getGame().getAction().moveToStack(source));
}
p.getGame().getStack().add(sa);
}
@@ -119,7 +119,7 @@ public class HumanPlay {
private static boolean payManaCostIfNeeded(final Player p, final SpellAbility sa) {
final ManaCostBeingPaid manaCost;
if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) {
if (sa.getHostCard().isCopiedSpell() && sa.isSpell()) {
manaCost = new ManaCostBeingPaid(ManaCost.ZERO);
}
else {
@@ -147,7 +147,7 @@ public class HumanPlay {
*/
public static final void playSaWithoutPayingManaCost(final Game game, final SpellAbility sa, boolean mayChooseNewTargets) {
FThreads.assertExecutedByEdt(false);
final Card source = sa.getSourceCard();
final Card source = sa.getHostCard();
source.setSplitStateToPlayAbility(sa);
@@ -162,9 +162,9 @@ public class HumanPlay {
}
else {
if (sa.isSpell()) {
final Card c = sa.getSourceCard();
final Card c = sa.getHostCard();
if (!c.isCopiedSpell()) {
sa.setSourceCard(game.getAction().moveToStack(c));
sa.setHostCard(game.getAction().moveToStack(c));
}
}
game.getStack().add(sa);
@@ -659,7 +659,7 @@ public class HumanPlay {
final Card offering = ability.getSacrificedAsOffering();
offering.setUsedToPay(false);
if (done) {
ability.getSourceCard().getGame().getAction().sacrifice(offering, ability);
ability.getHostCard().getGame().getAction().sacrifice(offering, ability);
}
ability.resetSacrificedAsOffering();
}
@@ -676,7 +676,7 @@ public class HumanPlay {
}
public static boolean payManaCost(final ManaCost realCost, final CostPartMana mc, final SpellAbility ability, final Player activator) {
final Card source = ability.getSourceCard();
final Card source = ability.getHostCard();
ManaCostBeingPaid toPay = new ManaCostBeingPaid(realCost, mc.getRestiction());
boolean xWasBilled = false;
@@ -688,7 +688,7 @@ public class HumanPlay {
toPay.increaseShard(ManaCostShard.valueOf(xColor), xCost);
xWasBilled = true;
}
int timesMultikicked = ability.getSourceCard().getKickerMagnitude();
int timesMultikicked = ability.getHostCard().getKickerMagnitude();
if ( timesMultikicked > 0 && ability.isAnnouncing("Multikicker")) {
ManaCost mkCost = ability.getMultiKickerManaCost();
for(int i = 0; i < timesMultikicked; i++)

View File

@@ -61,13 +61,13 @@ public class HumanPlaySpellAbility {
Zone fromZone = null;
int zonePosition = 0;
final Card c = this.ability.getSourceCard();
final Card c = this.ability.getHostCard();
if (this.ability instanceof Spell && !c.isCopiedSpell()) {
fromZone = game.getZoneOf(c);
if (fromZone != null) {
zonePosition = fromZone.getCards().indexOf(c);
}
this.ability.setSourceCard(game.getAction().moveToStack(c));
this.ability.setHostCard(game.getAction().moveToStack(c));
}
// freeze Stack. No abilities should go onto the stack while I'm filling requirements.
@@ -78,7 +78,7 @@ public class HumanPlaySpellAbility {
boolean prerequisitesMet = this.announceValuesLikeX()
&& this.announceType()
&& (!mayChooseTargets || setupTargets()) // if you can choose targets, then do choose them.
&& (isFree || this.payment.payCost(new HumanCostDecision(human, ability, ability.getSourceCard())));
&& (isFree || this.payment.payCost(new HumanCostDecision(human, ability, ability.getHostCard())));
if (!prerequisitesMet) {
if (!ability.isTrigger()) {
@@ -87,8 +87,8 @@ public class HumanPlaySpellAbility {
// if a player failed to play madness cost, move the card to graveyard
game.getAction().moveToGraveyard(c);
ability.setMadness(false);
} else if (ability.getSourceCard().isBestowed()) {
ability.getSourceCard().unanimateBestow();
} else if (ability.getHostCard().isBestowed()) {
ability.getHostCard().unanimateBestow();
}
}
return;
@@ -116,7 +116,7 @@ public class HumanPlaySpellAbility {
// Skip to paying if parent ability doesn't target and has no subAbilities.
// (or trigger case where its already targeted)
SpellAbility currentAbility = ability;
final Card source = ability.getSourceCard();
final Card source = ability.getHostCard();
do {
TargetRestrictions tgt = currentAbility.getTargetRestrictions();
if (tgt != null && tgt.doesTarget()) {
@@ -141,7 +141,7 @@ public class HumanPlaySpellAbility {
TargetRestrictions tg = ability.getTargetRestrictions();
if (tg != null) {
ability.resetTargets();
tg.calculateStillToDivide(ability.getParam("DividedAsYouChoose"), ability.getSourceCard(), ability);
tg.calculateStillToDivide(ability.getParam("DividedAsYouChoose"), ability.getHostCard(), ability);
}
}
@@ -151,7 +151,7 @@ public class HumanPlaySpellAbility {
if (fromZone != null) { // and not a copy
// add back to where it came from
game.getAction().moveTo(fromZone, ability.getSourceCard(), zonePosition >= 0 ? Integer.valueOf(zonePosition) : null);
game.getAction().moveTo(fromZone, ability.getHostCard(), zonePosition >= 0 ? Integer.valueOf(zonePosition) : null);
}
clearTargets(ability);
@@ -180,10 +180,10 @@ public class HumanPlaySpellAbility {
ability.setSVar(varName, value.toString());
if ("Multikicker".equals(varName)) {
ability.getSourceCard().setKickerMagnitude(value);
ability.getHostCard().setKickerMagnitude(value);
}
else {
ability.getSourceCard().setSVar(varName, value.toString());
ability.getHostCard().setSVar(varName, value.toString());
}
}
}
@@ -199,14 +199,14 @@ public class HumanPlaySpellAbility {
String varName = aVar.trim();
if ("CreatureType".equals(varName)) {
String choice = pc.chooseSomeType("Creature", ability, CardType.getCreatureTypes(), new ArrayList<String>());
ability.getSourceCard().setChosenType(choice);
ability.getHostCard().setChosenType(choice);
}
if ("ChooseNumber".equals(varName)) {
int min = Integer.parseInt(ability.getParam("Min"));
int max = Integer.parseInt(ability.getParam("Max"));
int i = ability.getActivatingPlayer().getController().chooseNumber(ability,
"Choose a number", min, max);
ability.getSourceCard().setChosenNumber(i);
ability.getHostCard().setChosenNumber(i);
}
}
}
@@ -220,7 +220,7 @@ public class HumanPlaySpellAbility {
// For older abilities that don't setStackDescription set it here
final StringBuilder sb = new StringBuilder();
sb.append(ability.getSourceCard().getName());
sb.append(ability.getHostCard().getName());
if (ability.getTargetRestrictions() != null) {
final Iterable<GameObject> targets = ability.getTargets().getTargets();
if (!Iterables.isEmpty(targets)) {

View File

@@ -250,7 +250,7 @@ public class PlayerControllerHuman extends PlayerController {
@Override
public Integer announceRequirements(SpellAbility ability, String announce, boolean canChooseZero) {
int min = canChooseZero ? 0 : 1;
return GuiChoose.getInteger("Choose " + announce + " for " + ability.getSourceCard().getName(),
return GuiChoose.getInteger("Choose " + announce + " for " + ability.getHostCard().getName(),
min, Integer.MAX_VALUE, min + 9);
}
@@ -291,7 +291,7 @@ public class PlayerControllerHuman extends PlayerController {
Card singleChosen = chooseSingleEntityForEffect(sourceList, sa, title, isOptional);
return singleChosen == null ? Lists.<Card>newArrayList() : Lists.newArrayList(singleChosen);
}
GuiUtils.setPanelSelection(sa.getSourceCard());
GuiUtils.setPanelSelection(sa.getHostCard());
// try to use InputSelectCardsFromList when possible
boolean cardsAreInMyHandOrBattlefield = true;
@@ -311,7 +311,7 @@ public class PlayerControllerHuman extends PlayerController {
return Lists.newArrayList(sc.getSelected());
}
return GuiChoose.many(title, "Chosen Cards", min, max, sourceList, sa.getSourceCard());
return GuiChoose.many(title, "Chosen Cards", min, max, sourceList, sa.getHostCard());
}
@Override
@@ -373,7 +373,7 @@ public class PlayerControllerHuman extends PlayerController {
*/
@Override
public boolean confirmAction(SpellAbility sa, PlayerActionConfirmMode mode, String message) {
return GuiDialog.confirm(sa.getSourceCard(), message);
return GuiDialog.confirm(sa.getHostCard(), message);
}
@Override
@@ -721,7 +721,7 @@ public class PlayerControllerHuman extends PlayerController {
public List<SpellAbility> chooseSaToActivateFromOpeningHand(List<SpellAbility> usableFromOpeningHand) {
List<Card> srcCards = new ArrayList<Card>();
for (SpellAbility sa : usableFromOpeningHand) {
srcCards.add(sa.getSourceCard());
srcCards.add(sa.getHostCard());
}
List<SpellAbility> result = new ArrayList<SpellAbility>();
if (srcCards.isEmpty()) {
@@ -730,7 +730,7 @@ public class PlayerControllerHuman extends PlayerController {
List<Card> chosen = GuiChoose.many("Choose cards to activate from opening hand and their order", "Activate first", -1, srcCards, null);
for (Card c : chosen) {
for (SpellAbility sa : usableFromOpeningHand) {
if (sa.getSourceCard() == c) {
if (sa.getHostCard() == c) {
result.add(sa);
break;
}
@@ -755,7 +755,7 @@ public class PlayerControllerHuman extends PlayerController {
case UntapTimeVault: labels = new String[]{"Untap (and skip this turn)", "Leave tapped"}; break;
case PlayOrDraw: labels = new String[]{"Play", "Draw"}; break;
}
return GuiDialog.confirm(sa.getSourceCard(), question, defaultVal == null || defaultVal.booleanValue(), labels);
return GuiDialog.confirm(sa.getHostCard(), question, defaultVal == null || defaultVal.booleanValue(), labels);
}
@Override
@@ -765,7 +765,7 @@ public class PlayerControllerHuman extends PlayerController {
for (int i = 0; i < results.length; i++) {
strResults[i] = labelsSrc[results[i] ? 0 : 1];
}
return GuiChoose.one(sa.getSourceCard().getName() + " - Choose a result", strResults) == labelsSrc[0];
return GuiChoose.one(sa.getHostCard().getName() + " - Choose a result", strResults) == labelsSrc[0];
}
@Override
@@ -805,14 +805,14 @@ public class PlayerControllerHuman extends PlayerController {
}
};
List<Pair<SpellAbilityStackInstance, GameObject>> chosen = GuiChoose.getChoices(saSpellskite.getSourceCard().getName(), 1, 1, allTargets, null, fnToString);
List<Pair<SpellAbilityStackInstance, GameObject>> chosen = GuiChoose.getChoices(saSpellskite.getHostCard().getName(), 1, 1, allTargets, null, fnToString);
return Iterables.getFirst(chosen, null);
}
@Override
public void notifyOfValue(SpellAbility sa, GameObject realtedTarget, String value) {
String message = formatNotificationMessage(sa, realtedTarget, value);
GuiDialog.message(message, sa.getSourceCard() == null ? "" : sa.getSourceCard().getName());
GuiDialog.message(message, sa.getHostCard() == null ? "" : sa.getHostCard().getName());
}
private String formatMessage(String message, Object related) {
@@ -824,7 +824,7 @@ public class PlayerControllerHuman extends PlayerController {
// These are not much related to PlayerController
private String formatNotificationMessage(SpellAbility sa, GameObject target, String value) {
if (sa.getApi() == null || sa.getSourceCard() == null) {
if (sa.getApi() == null || sa.getHostCard() == null) {
return ("Result: " + value);
}
switch(sa.getApi()) {
@@ -840,7 +840,7 @@ public class PlayerControllerHuman extends PlayerController {
String choser = StringUtils.capitalize(mayBeYou(target));
return String.format("%s %s protection from %s", choser, Lang.joinVerb(choser, "choose"), value);
default:
return String.format("%s effect's value for %s is %s", sa.getSourceCard().getName(), mayBeYou(target), value);
return String.format("%s effect's value for %s is %s", sa.getHostCard().getName(), mayBeYou(target), value);
}
}
@@ -856,7 +856,7 @@ public class PlayerControllerHuman extends PlayerController {
@Override
public List<AbilitySub> chooseModeForAbility(SpellAbility sa, int min, int num) {
List<AbilitySub> choices = CharmEffect.makePossibleOptions(sa);
String modeTitle = String.format("%s activated %s - Choose a mode", sa.getActivatingPlayer(), sa.getSourceCard());
String modeTitle = String.format("%s activated %s - Choose a mode", sa.getActivatingPlayer(), sa.getHostCard());
List<AbilitySub> chosen = new ArrayList<AbilitySub>();
for (int i = 0; i < num; i++) {
AbilitySub a;
@@ -887,7 +887,7 @@ public class PlayerControllerHuman extends PlayerController {
switch (cntColors) {
case 0: return 0;
case 1: return colors.getColor();
default: return chooseColorCommon(message, sa == null ? null : sa.getSourceCard(), colors, false);
default: return chooseColorCommon(message, sa == null ? null : sa.getHostCard(), colors, false);
}
}
@@ -955,7 +955,7 @@ public class PlayerControllerHuman extends PlayerController {
@Override
public boolean payCostToPreventEffect(Cost cost, SpellAbility sa, boolean alreadyPaid, List<Player> allPayers) {
// if it's paid by the AI already the human can pay, but it won't change anything
final Card source = sa.getSourceCard();
final Card source = sa.getHostCard();
return HumanPlay.payCostDuringAbilityResolve(player, source, cost, sa, null);
}
@@ -1010,7 +1010,7 @@ public class PlayerControllerHuman extends PlayerController {
final String p1Str = String.format("Pile 1 (%s cards)", pile1.size());
final String p2Str = String.format("Pile 2 (%s cards)", pile2.size());
final String[] possibleValues = { p1Str , p2Str };
return GuiDialog.confirm(sa.getSourceCard(), "Choose a Pile", possibleValues);
return GuiDialog.confirm(sa.getHostCard(), "Choose a Pile", possibleValues);
} else {
final Card[] disp = new Card[pile1.size() + pile2.size() + 2];
disp[0] = new Card(-1);
@@ -1081,9 +1081,9 @@ public class PlayerControllerHuman extends PlayerController {
public String chooseCardName(SpellAbility sa, Predicate<PaperCard> cpp, String valid, String message) {
PaperCard cp = null;
while(true) {
cp = chooseSinglePaperCard(sa, message, cpp, sa.getSourceCard().getName());
cp = chooseSinglePaperCard(sa, message, cpp, sa.getHostCard().getName());
Card instanceForPlayer = Card.fromPaperCard(cp, player); // the Card instance for test needs a game to be tested
if (instanceForPlayer.isValid(valid, sa.getSourceCard().getController(), sa.getSourceCard()))
if (instanceForPlayer.isValid(valid, sa.getHostCard().getController(), sa.getHostCard()))
return cp.getName();
}
}

View File

@@ -72,8 +72,8 @@ public class TargetSelection {
throw new RuntimeException("TargetSelection.chooseTargets called for ability that does not target - " + ability);
// Number of targets is explicitly set only if spell is being redirected (ex. Swerve or Redirect)
final int minTargets = numTargets != null ? numTargets.intValue() : tgt.getMinTargets(ability.getSourceCard(), ability);
final int maxTargets = numTargets != null ? numTargets.intValue() : tgt.getMaxTargets(ability.getSourceCard(), ability);
final int minTargets = numTargets != null ? numTargets.intValue() : tgt.getMinTargets(ability.getHostCard(), ability);
final int maxTargets = numTargets != null ? numTargets.intValue() : tgt.getMaxTargets(ability.getHostCard(), ability);
final int numTargeted = ability.getTargets().getNumTargeted();
boolean hasEnoughTargets = minTargets == 0 || numTargeted >= minTargets;
@@ -140,14 +140,14 @@ public class TargetSelection {
final List<ZoneType> zone = tgt.getZone();
final boolean canTgtStack = zone.contains(ZoneType.Stack);
List<Card> validCards = CardLists.getValidCards(game.getCardsIn(zone), tgt.getValidTgts(), this.ability.getActivatingPlayer(), this.ability.getSourceCard());
List<Card> validCards = CardLists.getValidCards(game.getCardsIn(zone), tgt.getValidTgts(), this.ability.getActivatingPlayer(), this.ability.getHostCard());
List<Card> choices = CardLists.getTargetableCards(validCards, this.ability);
if (canTgtStack) {
// Since getTargetableCards doesn't have additional checks if one of the Zones is stack
// Remove the activating card from targeting itself if its on the Stack
Card activatingCard = ability.getSourceCard();
Card activatingCard = ability.getHostCard();
if (activatingCard.isInZone(ZoneType.Stack)) {
choices.remove(ability.getSourceCard());
choices.remove(ability.getHostCard());
}
}
List<GameObject> targetedObjects = this.ability.getUniqueTargets();
@@ -302,7 +302,7 @@ public class TargetSelection {
}
final String msgDone = "[FINISH TARGETING]";
if (this.getTgt().isMinTargetsChosen(this.ability.getSourceCard(), this.ability)) {
if (this.getTgt().isMinTargetsChosen(this.ability.getHostCard(), this.ability)) {
// is there a more elegant way of doing this?
choicesFiltered.add(msgDone);
}
@@ -353,12 +353,12 @@ public class TargetSelection {
}
while(!bTargetingDone) {
if (tgt.isMaxTargetsChosen(this.ability.getSourceCard(), this.ability)) {
if (tgt.isMaxTargetsChosen(this.ability.getHostCard(), this.ability)) {
bTargetingDone = true;
return true;
}
if (!selectOptions.contains("[FINISH TARGETING]") && tgt.isMinTargetsChosen(this.ability.getSourceCard(), this.ability)) {
if (!selectOptions.contains("[FINISH TARGETING]") && tgt.isMinTargetsChosen(this.ability.getHostCard(), this.ability)) {
selectOptions.add("[FINISH TARGETING]");
}

View File

@@ -73,7 +73,7 @@ public class EventVisualizer extends IGameEventVisitor.Base<SoundEffectType> imp
return null;
}
Card source = evt.spell.getSourceCard();
Card source = evt.spell.getHostCard();
if (evt.spell.isSpell()) {
// if there's a specific effect for this particular card, play it and
// we're done.
@@ -171,7 +171,7 @@ public class EventVisualizer extends IGameEventVisitor.Base<SoundEffectType> imp
Card c = null;
if (evt instanceof GameEventSpellResolved) {
c = ((GameEventSpellResolved) evt).spell.getSourceCard();
c = ((GameEventSpellResolved) evt).spell.getHostCard();
} else if (evt instanceof GameEventLandPlayed) {
c = ((GameEventLandPlayed) evt).land;
}

View File

@@ -95,9 +95,9 @@ public class PlayerControllerForTests extends PlayerController {
return;
}
if (
(effectSA.getSourceCard().getName().equals("Nefarious Lich") && effectSA.getApi().getAi() instanceof DrawAi) ||
(effectSA.getSourceCard().getName().equals("Laboratory Maniac") && effectSA.getApi().getAi() instanceof GameWinAi) ||
(effectSA.getSourceCard().getName().equals("Nefarious Lich") && effectSA.getApi().getAi() instanceof ChangeZoneAi)
(effectSA.getHostCard().getName().equals("Nefarious Lich") && effectSA.getApi().getAi() instanceof DrawAi) ||
(effectSA.getHostCard().getName().equals("Laboratory Maniac") && effectSA.getApi().getAi() instanceof GameWinAi) ||
(effectSA.getHostCard().getName().equals("Nefarious Lich") && effectSA.getApi().getAi() instanceof ChangeZoneAi)
) {//test_104_3f_if_a_player_would_win_and_lose_simultaneously_he_loses
HumanPlay.playSpellAbilityNoStack(player, effectSA, !mayChoseNewTargets);
return;
@@ -478,7 +478,7 @@ public class PlayerControllerForTests extends PlayerController {
@Override
public void orderAndPlaySimultaneousSa(List<SpellAbility> activePlayerSAs) {
for (final SpellAbility sa : activePlayerSAs) {
prepareSingleSa(sa.getSourceCard(),sa,true);
prepareSingleSa(sa.getHostCard(),sa,true);
ComputerUtil.playStack(sa, player, game);
}
}

View File

@@ -34,7 +34,7 @@ public class CastSpellFromHandAction extends BasePlayerAction {
SpellAbility spellAbility = cardToPlay.getSpells().get( 0 );
spellAbility.setActivatingPlayer( player );
spellAbility.setSourceCard( game.getAction().moveToStack( cardToPlay ) );
spellAbility.setHostCard(game.getAction().moveToStack(cardToPlay));
spellAbility.getTargets().add( player );//TODO
game.getStack().freezeStack();
game.getStack().addAndUnfreeze( spellAbility );