- Removed deprecated targetPlayer variable from SpellAbility.

- Cleanup.
This commit is contained in:
Sloth
2013-03-01 20:44:38 +00:00
parent 0d0ea30e0e
commit b9473367d8
6 changed files with 12 additions and 137 deletions

View File

@@ -11,7 +11,6 @@ import forge.card.spellability.AbilityActivated;
import forge.card.spellability.Target;
import forge.control.input.Input;
import forge.control.input.InputSelectManyCards;
import forge.game.ai.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.Zone;
@@ -54,8 +53,10 @@ class CardFactoryArtifacts {
@Override
public boolean canPlayAI() {
this.getTarget().resetTargets();
final List<Card> libList = getActivatingPlayer().getOpponent().getCardsIn(ZoneType.Library);
return !libList.isEmpty() && ComputerUtil.targetHumanAI(this);
Player human = getActivatingPlayer().getOpponent();
final List<Card> libList = human.getCardsIn(ZoneType.Library);
this.getTarget().addTarget(human);
return !libList.isEmpty() && canTarget(human);
}
@Override
@@ -98,6 +99,7 @@ class CardFactoryArtifacts {
sb.append("Put the top two cards of target player's library into that player's graveyard. ");
sb.append("If both cards share a color, repeat this process.");
ab1.setDescription(sb.toString());
ab1.setStackDescription(sb.toString());
card.addSpellAbility(ab1);
} // *************** END ************ END **************************

View File

@@ -51,7 +51,6 @@ public abstract class SpellAbility implements ISpellAbility {
// choices for constructor isPermanent argument
private String description = "";
private Player targetPlayer = null;
private String stackDescription = "";
private ManaCost manaCost = null;
private ManaCost multiKickerManaCost = null;
@@ -1111,7 +1110,6 @@ public abstract class SpellAbility implements ISpellAbility {
if (tgt != null) {
tgt.addTarget(card);
} else {
this.targetPlayer = null; // reset setTargetPlayer()
this.targetCard = card;
}
String desc = "";
@@ -1124,74 +1122,6 @@ public abstract class SpellAbility implements ISpellAbility {
this.setStackDescription(desc);
}
// /**
// * <p>
// * Getter for the field <code>targetList</code>.
// * </p>
// *
// * @return a {@link forge.CardList} object.
// */
// public List<Card> getTargetList() {
// return this.targetList;
// }
// /**
// * <p>
// * Setter for the field <code>targetList</code>.
// * </p>
// *
// * @param list
// * a {@link forge.CardList} object.
// */
// public void setTargetList(final List<Card> list) {
// // The line below started to create a null error at
// // forge.CardFactoryUtil.canBeTargetedBy(CardFactoryUtil.java:3329)
// // after ForgeSVN r2699. I hope that commenting out the line below will
// // not result in other bugs. :)
// // targetPlayer = null;//reset setTargetPlayer()
//
// this.targetList = list;
// final StringBuilder sb = new StringBuilder();
// sb.append(this.getSourceCard().getName()).append(" - targeting ");
// for (int i = 0; i < this.targetList.size(); i++) {
//
// if (!this.targetList.get(i).isFaceDown()) {
// sb.append(this.targetList.get(i));
// } else {
// sb.append("Morph(").append(this.targetList.get(i).getUniqueNumber()).append(")");
// }
//
// if (i < (this.targetList.size() - 1)) {
// sb.append(", ");
// }
// }
// this.setStackDescription(sb.toString());
// }
/**
* <p>
* Setter for the field <code>targetPlayer</code>.
* </p>
*
* @param p
* a {@link forge.game.player.Player} object.
*/
public void setTargetPlayer(final Player p) {
if (p == null) {
throw new RuntimeException("SpellAbility : setTargetPlayer() error, argument is " + p + " source card is "
+ this.getSourceCard());
}
final Target tgt = this.getTarget();
if (tgt != null) {
tgt.addTarget(p);
} else {
this.targetCard = null; // reset setTargetCard()
this.targetPlayer = p;
}
this.setStackDescription(this.getSourceCard().getName() + " - targeting " + p);
}
/**
* <p>
* Getter for the field <code>targetPlayer</code>.
@@ -1200,18 +1130,15 @@ public abstract class SpellAbility implements ISpellAbility {
* @return a {@link forge.game.player.Player} object.
*/
public Player getTargetPlayer() {
if (this.targetPlayer == null) {
final Target tgt = this.getTarget();
if (tgt != null) {
final ArrayList<Player> list = tgt.getTargetPlayers();
final Target tgt = this.getTarget();
if (tgt != null) {
final ArrayList<Player> list = tgt.getTargetPlayers();
if (!list.isEmpty()) {
return list.get(0);
}
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
return this.targetPlayer;
return null;
}
/**

View File

@@ -340,16 +340,6 @@ public class WrappedAbility extends Ability implements ISpellAbility {
sa.setTargetCard(card);
}
// @Override
// public void setTargetList(final List<Card> list) {
// sa.setTargetList(list);
// }
@Override
public void setTargetPlayer(final Player p) {
sa.setTargetPlayer(p);
}
@Override
public void setType(final String s) {
sa.setType(s);

View File

@@ -945,19 +945,6 @@ public class ComputerUtil {
return false;
}
public static boolean targetHumanAI(final SpellAbility sa) {
if (sa == null || sa.getActivatingPlayer() == null) {
return false;
}
Player human = sa.getActivatingPlayer().getOpponent();
if (!sa.canTarget(human)) {
return false;
}
sa.setTargetPlayer(human);
return true;
}
// returns true if it's better to wait until blockers are declared
/**
* <p>

View File

@@ -680,7 +680,7 @@ public class MagicStack extends MyObservable {
// Create a new object, since the triggers aren't happening right away
runParams = new HashMap<String, Object>();
runParams.put("SourceSA", sp);
if (chosenTargets.size() > 0) {
if (!chosenTargets.isEmpty()) {
HashSet<Object> distinctObjects = new HashSet<Object>();
for (final TargetChoices tc : chosenTargets) {
if ((tc != null) && (tc.getTargetCards() != null)) {
@@ -704,10 +704,6 @@ public class MagicStack extends MyObservable {
else if (sp.getTargetCard() != null) {
runParams.put("Target", sp.getTargetCard());
game.getTriggerHandler().runTrigger(TriggerType.BecomesTarget, runParams, false);
} else if (sp.getTargetPlayer() != null) {
runParams.put("Target", sp.getTargetPlayer());
game.getTriggerHandler().runTrigger(TriggerType.BecomesTarget, runParams, false);
}
}
@@ -1075,9 +1071,6 @@ public class MagicStack extends MyObservable {
else if (sa.getTargetCard() != null) {
fizzle = !CardFactoryUtil.isTargetStillValid(sa, sa.getTargetCard());
}
else if (sa.getTargetPlayer() != null) {
fizzle = !sa.getTargetPlayer().canBeTargetedBy(sa);
}
else {
// Set fizzle to the same as the parent if there's no target info
fizzle = parentFizzled;

View File

@@ -244,30 +244,6 @@ public class PlayerZoneBattlefield extends PlayerZone {
}
}
/**
* <p>
* Setter for the field <code>trigger</code>.
* </p>
*
* @param b
* a boolean.
*/
public final void setTrigger(final boolean b) {
this.trigger = b;
}
/**
* <p>
* Setter for the field <code>leavesTrigger</code>.
* </p>
*
* @param b
* a boolean.
*/
public final void setLeavesTrigger(final boolean b) {
this.leavesTrigger = b;
}
/**
* <p>
* setTriggers.