mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
- Removed deprecated targetPlayer variable from SpellAbility.
- Cleanup.
This commit is contained in:
@@ -11,7 +11,6 @@ import forge.card.spellability.AbilityActivated;
|
|||||||
import forge.card.spellability.Target;
|
import forge.card.spellability.Target;
|
||||||
import forge.control.input.Input;
|
import forge.control.input.Input;
|
||||||
import forge.control.input.InputSelectManyCards;
|
import forge.control.input.InputSelectManyCards;
|
||||||
import forge.game.ai.ComputerUtil;
|
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.PlayerZone;
|
import forge.game.zone.PlayerZone;
|
||||||
import forge.game.zone.Zone;
|
import forge.game.zone.Zone;
|
||||||
@@ -54,8 +53,10 @@ class CardFactoryArtifacts {
|
|||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
this.getTarget().resetTargets();
|
this.getTarget().resetTargets();
|
||||||
final List<Card> libList = getActivatingPlayer().getOpponent().getCardsIn(ZoneType.Library);
|
Player human = getActivatingPlayer().getOpponent();
|
||||||
return !libList.isEmpty() && ComputerUtil.targetHumanAI(this);
|
final List<Card> libList = human.getCardsIn(ZoneType.Library);
|
||||||
|
this.getTarget().addTarget(human);
|
||||||
|
return !libList.isEmpty() && canTarget(human);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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("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.");
|
sb.append("If both cards share a color, repeat this process.");
|
||||||
ab1.setDescription(sb.toString());
|
ab1.setDescription(sb.toString());
|
||||||
|
ab1.setStackDescription(sb.toString());
|
||||||
card.addSpellAbility(ab1);
|
card.addSpellAbility(ab1);
|
||||||
} // *************** END ************ END **************************
|
} // *************** END ************ END **************************
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ public abstract class SpellAbility implements ISpellAbility {
|
|||||||
|
|
||||||
// choices for constructor isPermanent argument
|
// choices for constructor isPermanent argument
|
||||||
private String description = "";
|
private String description = "";
|
||||||
private Player targetPlayer = null;
|
|
||||||
private String stackDescription = "";
|
private String stackDescription = "";
|
||||||
private ManaCost manaCost = null;
|
private ManaCost manaCost = null;
|
||||||
private ManaCost multiKickerManaCost = null;
|
private ManaCost multiKickerManaCost = null;
|
||||||
@@ -1111,7 +1110,6 @@ public abstract class SpellAbility implements ISpellAbility {
|
|||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgt.addTarget(card);
|
tgt.addTarget(card);
|
||||||
} else {
|
} else {
|
||||||
this.targetPlayer = null; // reset setTargetPlayer()
|
|
||||||
this.targetCard = card;
|
this.targetCard = card;
|
||||||
}
|
}
|
||||||
String desc = "";
|
String desc = "";
|
||||||
@@ -1124,74 +1122,6 @@ public abstract class SpellAbility implements ISpellAbility {
|
|||||||
this.setStackDescription(desc);
|
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>
|
* <p>
|
||||||
* Getter for the field <code>targetPlayer</code>.
|
* 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.
|
* @return a {@link forge.game.player.Player} object.
|
||||||
*/
|
*/
|
||||||
public Player getTargetPlayer() {
|
public Player getTargetPlayer() {
|
||||||
if (this.targetPlayer == null) {
|
final Target tgt = this.getTarget();
|
||||||
final Target tgt = this.getTarget();
|
if (tgt != null) {
|
||||||
if (tgt != null) {
|
final ArrayList<Player> list = tgt.getTargetPlayers();
|
||||||
final ArrayList<Player> list = tgt.getTargetPlayers();
|
|
||||||
|
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
return list.get(0);
|
return list.get(0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
return this.targetPlayer;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -340,16 +340,6 @@ public class WrappedAbility extends Ability implements ISpellAbility {
|
|||||||
sa.setTargetCard(card);
|
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
|
@Override
|
||||||
public void setType(final String s) {
|
public void setType(final String s) {
|
||||||
sa.setType(s);
|
sa.setType(s);
|
||||||
|
|||||||
@@ -945,19 +945,6 @@ public class ComputerUtil {
|
|||||||
return false;
|
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
|
// returns true if it's better to wait until blockers are declared
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -680,7 +680,7 @@ public class MagicStack extends MyObservable {
|
|||||||
// Create a new object, since the triggers aren't happening right away
|
// Create a new object, since the triggers aren't happening right away
|
||||||
runParams = new HashMap<String, Object>();
|
runParams = new HashMap<String, Object>();
|
||||||
runParams.put("SourceSA", sp);
|
runParams.put("SourceSA", sp);
|
||||||
if (chosenTargets.size() > 0) {
|
if (!chosenTargets.isEmpty()) {
|
||||||
HashSet<Object> distinctObjects = new HashSet<Object>();
|
HashSet<Object> distinctObjects = new HashSet<Object>();
|
||||||
for (final TargetChoices tc : chosenTargets) {
|
for (final TargetChoices tc : chosenTargets) {
|
||||||
if ((tc != null) && (tc.getTargetCards() != null)) {
|
if ((tc != null) && (tc.getTargetCards() != null)) {
|
||||||
@@ -704,10 +704,6 @@ public class MagicStack extends MyObservable {
|
|||||||
else if (sp.getTargetCard() != null) {
|
else if (sp.getTargetCard() != null) {
|
||||||
runParams.put("Target", sp.getTargetCard());
|
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);
|
game.getTriggerHandler().runTrigger(TriggerType.BecomesTarget, runParams, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1075,9 +1071,6 @@ public class MagicStack extends MyObservable {
|
|||||||
else if (sa.getTargetCard() != null) {
|
else if (sa.getTargetCard() != null) {
|
||||||
fizzle = !CardFactoryUtil.isTargetStillValid(sa, sa.getTargetCard());
|
fizzle = !CardFactoryUtil.isTargetStillValid(sa, sa.getTargetCard());
|
||||||
}
|
}
|
||||||
else if (sa.getTargetPlayer() != null) {
|
|
||||||
fizzle = !sa.getTargetPlayer().canBeTargetedBy(sa);
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
// Set fizzle to the same as the parent if there's no target info
|
// Set fizzle to the same as the parent if there's no target info
|
||||||
fizzle = parentFizzled;
|
fizzle = parentFizzled;
|
||||||
|
|||||||
@@ -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>
|
* <p>
|
||||||
* setTriggers.
|
* setTriggers.
|
||||||
|
|||||||
Reference in New Issue
Block a user