mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
removed everything from HumanPlayer class, deleting on next step
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -14241,6 +14241,7 @@ src/main/java/forge/game/phase/Upkeep.java svneol=native#text/plain
|
|||||||
src/main/java/forge/game/phase/package-info.java svneol=native#text/plain
|
src/main/java/forge/game/phase/package-info.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/player/AIPlayer.java svneol=native#text/plain
|
src/main/java/forge/game/player/AIPlayer.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/player/GameLossReason.java -text
|
src/main/java/forge/game/player/GameLossReason.java -text
|
||||||
|
src/main/java/forge/game/player/HumanPlay.java -text
|
||||||
src/main/java/forge/game/player/HumanPlayer.java svneol=native#text/plain
|
src/main/java/forge/game/player/HumanPlayer.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/player/LobbyPlayer.java -text
|
src/main/java/forge/game/player/LobbyPlayer.java -text
|
||||||
src/main/java/forge/game/player/LobbyPlayerAi.java -text
|
src/main/java/forge/game/player/LobbyPlayerAi.java -text
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import forge.game.GameState;
|
|||||||
import forge.game.ai.ComputerUtil;
|
import forge.game.ai.ComputerUtil;
|
||||||
import forge.game.ai.ComputerUtilCard;
|
import forge.game.ai.ComputerUtilCard;
|
||||||
import forge.game.player.AIPlayer;
|
import forge.game.player.AIPlayer;
|
||||||
import forge.game.player.HumanPlayer;
|
import forge.game.player.HumanPlay;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.GuiChoose;
|
import forge.gui.GuiChoose;
|
||||||
@@ -245,7 +245,7 @@ public class PlayEffect extends SpellAbilityEffect {
|
|||||||
boolean noManaCost = sa.hasParam("WithoutManaCost");
|
boolean noManaCost = sa.hasParam("WithoutManaCost");
|
||||||
if (controller.isHuman()) {
|
if (controller.isHuman()) {
|
||||||
SpellAbility newSA = noManaCost ? tgtSA.copyWithNoManaCost() : tgtSA;
|
SpellAbility newSA = noManaCost ? tgtSA.copyWithNoManaCost() : tgtSA;
|
||||||
HumanPlayer.playSpellAbility(activator, newSA);
|
HumanPlay.playSpellAbility(activator, newSA);
|
||||||
} else {
|
} else {
|
||||||
if (tgtSA instanceof Spell) { // Isn't it ALWAYS a spell?
|
if (tgtSA instanceof Spell) { // Isn't it ALWAYS a spell?
|
||||||
Spell spell = (Spell) tgtSA;
|
Spell spell = (Spell) tgtSA;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import forge.card.spellability.SpellAbility;
|
|||||||
import forge.game.GameState;
|
import forge.game.GameState;
|
||||||
import forge.game.ai.ComputerUtil;
|
import forge.game.ai.ComputerUtil;
|
||||||
import forge.game.player.AIPlayer;
|
import forge.game.player.AIPlayer;
|
||||||
import forge.game.player.HumanPlayer;
|
import forge.game.player.HumanPlay;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.GuiChoose;
|
import forge.gui.GuiChoose;
|
||||||
@@ -240,7 +240,7 @@ public class ReplacementHandler {
|
|||||||
Player player = replacementEffect.getHostCard().getController();
|
Player player = replacementEffect.getHostCard().getController();
|
||||||
//player.getController().playNoStack()
|
//player.getController().playNoStack()
|
||||||
if (player.isHuman()) {
|
if (player.isHuman()) {
|
||||||
HumanPlayer.playSpellAbilityNoStack(player, effectSA);
|
HumanPlay.playSpellAbilityNoStack(player, effectSA);
|
||||||
} else {
|
} else {
|
||||||
ComputerUtil.playNoStack((AIPlayer) player, effectSA, game);
|
ComputerUtil.playNoStack((AIPlayer) player, effectSA, game);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import forge.game.GlobalRuleChange;
|
|||||||
import forge.game.ai.ComputerUtil;
|
import forge.game.ai.ComputerUtil;
|
||||||
import forge.game.phase.PhaseType;
|
import forge.game.phase.PhaseType;
|
||||||
import forge.game.player.AIPlayer;
|
import forge.game.player.AIPlayer;
|
||||||
import forge.game.player.HumanPlayer;
|
import forge.game.player.HumanPlay;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
|
|
||||||
@@ -430,7 +430,7 @@ public class TriggerHandler {
|
|||||||
|
|
||||||
if (regtrig.isStatic()) {
|
if (regtrig.isStatic()) {
|
||||||
if (wrapperAbility.getActivatingPlayer().isHuman()) {
|
if (wrapperAbility.getActivatingPlayer().isHuman()) {
|
||||||
HumanPlayer.playSpellAbilityNoStack(wrapperAbility.getActivatingPlayer(), wrapperAbility);
|
HumanPlay.playSpellAbilityNoStack(wrapperAbility.getActivatingPlayer(), wrapperAbility);
|
||||||
} else {
|
} else {
|
||||||
wrapperAbility.doTrigger(isMandatory, (AIPlayer)wrapperAbility.getActivatingPlayer());
|
wrapperAbility.doTrigger(isMandatory, (AIPlayer)wrapperAbility.getActivatingPlayer());
|
||||||
ComputerUtil.playNoStack((AIPlayer)wrapperAbility.getActivatingPlayer(), wrapperAbility, game);
|
ComputerUtil.playNoStack((AIPlayer)wrapperAbility.getActivatingPlayer(), wrapperAbility, game);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import forge.card.spellability.TargetChoices;
|
|||||||
import forge.game.GameState;
|
import forge.game.GameState;
|
||||||
import forge.game.ai.ComputerUtil;
|
import forge.game.ai.ComputerUtil;
|
||||||
import forge.game.player.AIPlayer;
|
import forge.game.player.AIPlayer;
|
||||||
import forge.game.player.HumanPlayer;
|
import forge.game.player.HumanPlay;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.gui.GuiDialog;
|
import forge.gui.GuiDialog;
|
||||||
|
|
||||||
@@ -365,7 +365,7 @@ public class WrappedAbility extends Ability implements ISpellAbility {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (getActivatingPlayer().isHuman()) {
|
if (getActivatingPlayer().isHuman()) {
|
||||||
HumanPlayer.playSpellAbilityNoStack(getActivatingPlayer(), sa, true);
|
HumanPlay.playSpellAbilityNoStack(getActivatingPlayer(), sa, true);
|
||||||
} else {
|
} else {
|
||||||
// commented out because i don't think this should be called
|
// commented out because i don't think this should be called
|
||||||
// again here
|
// again here
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ import forge.Card;
|
|||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.phase.PhaseHandler;
|
import forge.game.phase.PhaseHandler;
|
||||||
import forge.game.player.HumanPlayer;
|
import forge.game.player.HumanPlay;
|
||||||
|
import forge.game.player.Player;
|
||||||
import forge.gui.GuiDisplayUtil;
|
import forge.gui.GuiDisplayUtil;
|
||||||
import forge.gui.framework.SDisplayUtil;
|
import forge.gui.framework.SDisplayUtil;
|
||||||
import forge.gui.match.CMatchUI;
|
import forge.gui.match.CMatchUI;
|
||||||
@@ -44,7 +45,7 @@ public class InputPassPriority extends InputBase {
|
|||||||
* TODO: Write javadoc for Constructor.
|
* TODO: Write javadoc for Constructor.
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
public InputPassPriority(HumanPlayer human) {
|
public InputPassPriority(Player human) {
|
||||||
super(human);
|
super(human);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +87,7 @@ public class InputPassPriority extends InputBase {
|
|||||||
Runnable execAbility = new Runnable() {
|
Runnable execAbility = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
HumanPlayer.playSpellAbility(player, card, ab);
|
HumanPlay.playSpellAbility(player, card, ab);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import forge.card.mana.ManaCostBeingPaid;
|
|||||||
import forge.card.spellability.AbilityManaPart;
|
import forge.card.spellability.AbilityManaPart;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.GameState;
|
import forge.game.GameState;
|
||||||
import forge.game.player.HumanPlayer;
|
import forge.game.player.HumanPlay;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.GuiChoose;
|
import forge.gui.GuiChoose;
|
||||||
import forge.gui.framework.SDisplayUtil;
|
import forge.gui.framework.SDisplayUtil;
|
||||||
@@ -292,7 +292,7 @@ public abstract class InputPayManaBase extends InputSyncronizedBase implements I
|
|||||||
Runnable proc = new Runnable() {
|
Runnable proc = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
HumanPlayer.playSpellAbility(chosen.getActivatingPlayer(), chosen);
|
HumanPlay.playSpellAbility(chosen.getActivatingPlayer(), chosen);
|
||||||
onManaAbilityPlayed(chosen);
|
onManaAbilityPlayed(chosen);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ import forge.game.event.CardRegeneratedEvent;
|
|||||||
import forge.game.event.CardSacrificedEvent;
|
import forge.game.event.CardSacrificedEvent;
|
||||||
import forge.game.player.AIPlayer;
|
import forge.game.player.AIPlayer;
|
||||||
import forge.game.player.GameLossReason;
|
import forge.game.player.GameLossReason;
|
||||||
import forge.game.player.HumanPlayer;
|
import forge.game.player.HumanPlay;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.player.PlayerType;
|
import forge.game.player.PlayerType;
|
||||||
import forge.game.zone.PlayerZone;
|
import forge.game.zone.PlayerZone;
|
||||||
@@ -1435,7 +1435,7 @@ public class GameAction {
|
|||||||
if (GuiDialog.confirm(c, "Use " + c +"'s ability?")) {
|
if (GuiDialog.confirm(c, "Use " + c +"'s ability?")) {
|
||||||
// If we ever let the AI memorize cards in the players
|
// If we ever let the AI memorize cards in the players
|
||||||
// hand, this would be a place to do so.
|
// hand, this would be a place to do so.
|
||||||
HumanPlayer.playSpellAbilityNoStack(p, effect);
|
HumanPlay.playSpellAbilityNoStack(p, effect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ import forge.control.input.InputSelectCardsFromList;
|
|||||||
import forge.game.event.CardDamagedEvent;
|
import forge.game.event.CardDamagedEvent;
|
||||||
import forge.game.event.LifeLossEvent;
|
import forge.game.event.LifeLossEvent;
|
||||||
import forge.game.player.AIPlayer;
|
import forge.game.player.AIPlayer;
|
||||||
|
import forge.game.player.HumanPlay;
|
||||||
import forge.game.player.HumanPlayer;
|
import forge.game.player.HumanPlayer;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
@@ -282,7 +283,7 @@ public final class GameActionUtil {
|
|||||||
|
|
||||||
if (p.isHuman()) {
|
if (p.isHuman()) {
|
||||||
if (GuiDialog.confirm(rippledCards[i], "Cast " + rippledCards[i].getName() + "?")) {
|
if (GuiDialog.confirm(rippledCards[i], "Cast " + rippledCards[i].getName() + "?")) {
|
||||||
HumanPlayer.playCardWithoutPayingManaCost(((HumanPlayer)p), rippledCards[i]);
|
HumanPlay.playCardWithoutPayingManaCost(((HumanPlayer)p), rippledCards[i]);
|
||||||
revealed.remove(rippledCards[i]);
|
revealed.remove(rippledCards[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
226
src/main/java/forge/game/player/HumanPlay.java
Normal file
226
src/main/java/forge/game/player/HumanPlay.java
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
package forge.game.player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import forge.Card;
|
||||||
|
import forge.FThreads;
|
||||||
|
import forge.card.ability.AbilityUtils;
|
||||||
|
import forge.card.ability.ApiType;
|
||||||
|
import forge.card.ability.effects.CharmEffect;
|
||||||
|
import forge.card.cost.Cost;
|
||||||
|
import forge.card.cost.CostPayment;
|
||||||
|
import forge.card.mana.ManaCost;
|
||||||
|
import forge.card.mana.ManaCostBeingPaid;
|
||||||
|
import forge.card.mana.ManaCostShard;
|
||||||
|
import forge.card.spellability.Ability;
|
||||||
|
import forge.card.spellability.HumanPlaySpellAbility;
|
||||||
|
import forge.card.spellability.SpellAbility;
|
||||||
|
import forge.card.spellability.Target;
|
||||||
|
import forge.control.input.InputPayManaBase;
|
||||||
|
import forge.control.input.InputPayManaSimple;
|
||||||
|
import forge.game.GameActionUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this type.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class HumanPlay {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for Constructor.
|
||||||
|
*/
|
||||||
|
public HumanPlay() {
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
* @param card
|
||||||
|
* @param ab
|
||||||
|
*/
|
||||||
|
public static void playSpellAbility(Player p, Card c, SpellAbility ab) {
|
||||||
|
if (ab == Ability.PLAY_LAND_SURROGATE)
|
||||||
|
p.playLand(c);
|
||||||
|
else {
|
||||||
|
HumanPlay.playSpellAbility(p, ab);
|
||||||
|
}
|
||||||
|
p.getGame().getPhaseHandler().setPriority(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* playSpellAbility.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param sa
|
||||||
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
|
*/
|
||||||
|
public final static void playSpellAbility(Player p, SpellAbility sa) {
|
||||||
|
FThreads.assertExecutedByEdt(false);
|
||||||
|
sa.setActivatingPlayer(p);
|
||||||
|
|
||||||
|
final Card source = sa.getSourceCard();
|
||||||
|
|
||||||
|
source.setSplitStateToPlayAbility(sa);
|
||||||
|
|
||||||
|
if (sa.getApi() == ApiType.Charm && !sa.isWrapper()) {
|
||||||
|
CharmEffect.makeChoices(sa);
|
||||||
|
}
|
||||||
|
|
||||||
|
sa = chooseOptionalAdditionalCosts(p, sa);
|
||||||
|
|
||||||
|
if (sa == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Need to check PayCosts, and Ability + All SubAbilities for Target
|
||||||
|
boolean newAbility = sa.getPayCosts() != null;
|
||||||
|
SpellAbility ability = sa;
|
||||||
|
while ((ability != null) && !newAbility) {
|
||||||
|
final Target tgt = ability.getTarget();
|
||||||
|
|
||||||
|
newAbility |= tgt != null;
|
||||||
|
ability = ability.getSubAbility();
|
||||||
|
}
|
||||||
|
|
||||||
|
// System.out.println("Playing:" + sa.getDescription() + " of " + sa.getSourceCard() + " new = " + newAbility);
|
||||||
|
if (newAbility) {
|
||||||
|
CostPayment payment = null;
|
||||||
|
if (sa.getPayCosts() == null) {
|
||||||
|
payment = new CostPayment(new Cost("0", sa.isAbility()), sa);
|
||||||
|
} else {
|
||||||
|
payment = new CostPayment(sa.getPayCosts(), sa);
|
||||||
|
}
|
||||||
|
|
||||||
|
final HumanPlaySpellAbility req = new HumanPlaySpellAbility(sa, payment);
|
||||||
|
req.fillRequirements(false, false, false);
|
||||||
|
} else {
|
||||||
|
if (payManaCostIfNeeded(p, sa)) {
|
||||||
|
if (sa.isSpell() && !source.isCopiedSpell()) {
|
||||||
|
sa.setSourceCard(p.getGame().getAction().moveToStack(source));
|
||||||
|
}
|
||||||
|
p.getGame().getStack().add(sa);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* choose optional additional costs. For HUMAN only
|
||||||
|
* @param activator
|
||||||
|
*
|
||||||
|
* @param original
|
||||||
|
* the original sa
|
||||||
|
* @return an ArrayList<SpellAbility>.
|
||||||
|
*/
|
||||||
|
static SpellAbility chooseOptionalAdditionalCosts(Player p, final SpellAbility original) {
|
||||||
|
//final HashMap<String, SpellAbility> map = new HashMap<String, SpellAbility>();
|
||||||
|
final List<SpellAbility> abilities = GameActionUtil.getOptionalCosts(original);
|
||||||
|
|
||||||
|
if (!original.isSpell()) {
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
|
||||||
|
return p.getController().getAbilityToPlay(abilities);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean payManaCostIfNeeded(final Player p, final SpellAbility sa) {
|
||||||
|
final ManaCostBeingPaid manaCost;
|
||||||
|
if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) {
|
||||||
|
manaCost = new ManaCostBeingPaid(ManaCost.ZERO);
|
||||||
|
} else {
|
||||||
|
manaCost = new ManaCostBeingPaid(sa.getPayCosts().getTotalMana());
|
||||||
|
manaCost.applySpellCostChange(sa);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isPaid = manaCost.isPaid();
|
||||||
|
|
||||||
|
if( !isPaid ) {
|
||||||
|
InputPayManaBase inputPay = new InputPayManaSimple(p.getGame(), sa, manaCost);
|
||||||
|
FThreads.setInputAndWait(inputPay);
|
||||||
|
isPaid = inputPay.isPaid();
|
||||||
|
}
|
||||||
|
return isPaid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
* @param humanPlayer
|
||||||
|
* @param c
|
||||||
|
*/
|
||||||
|
public static final void playCardWithoutPayingManaCost(Player player, Card c) {
|
||||||
|
final List<SpellAbility> choices = c.getBasicSpells();
|
||||||
|
// TODO add Buyback, Kicker, ... , spells here
|
||||||
|
|
||||||
|
SpellAbility sa = player.getController().getAbilityToPlay(choices);
|
||||||
|
|
||||||
|
if (sa != null) {
|
||||||
|
sa.setActivatingPlayer(player);
|
||||||
|
playSaWithoutPayingManaCost(player, sa);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* playSpellAbilityForFree.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param sa
|
||||||
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
|
*/
|
||||||
|
public static final void playSaWithoutPayingManaCost(final Player player, final SpellAbility sa) {
|
||||||
|
FThreads.assertExecutedByEdt(false);
|
||||||
|
final Card source = sa.getSourceCard();
|
||||||
|
|
||||||
|
source.setSplitStateToPlayAbility(sa);
|
||||||
|
|
||||||
|
if (sa.getPayCosts() != null) {
|
||||||
|
if (sa.getApi() == ApiType.Charm && !sa.isWrapper()) {
|
||||||
|
CharmEffect.makeChoices(sa);
|
||||||
|
}
|
||||||
|
final CostPayment payment = new CostPayment(sa.getPayCosts(), sa);
|
||||||
|
|
||||||
|
final HumanPlaySpellAbility req = new HumanPlaySpellAbility(sa, payment);
|
||||||
|
req.fillRequirements(false, true, false);
|
||||||
|
} else {
|
||||||
|
if (sa.isSpell()) {
|
||||||
|
final Card c = sa.getSourceCard();
|
||||||
|
if (!c.isCopiedSpell()) {
|
||||||
|
sa.setSourceCard(player.getGame().getAction().moveToStack(c));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
boolean x = sa.getSourceCard().getManaCost().getShardCount(ManaCostShard.X) > 0;
|
||||||
|
|
||||||
|
player.getGame().getStack().add(sa, x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* playSpellAbility_NoStack.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param sa
|
||||||
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
|
* @param skipTargeting
|
||||||
|
* a boolean.
|
||||||
|
*/
|
||||||
|
public final static void playSpellAbilityNoStack(final Player player, final SpellAbility sa) {
|
||||||
|
playSpellAbilityNoStack(player, sa, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final static void playSpellAbilityNoStack(final Player player, final SpellAbility sa, boolean useOldTargets) {
|
||||||
|
sa.setActivatingPlayer(player);
|
||||||
|
|
||||||
|
if (sa.getPayCosts() != null) {
|
||||||
|
final HumanPlaySpellAbility req = new HumanPlaySpellAbility(sa, new CostPayment(sa.getPayCosts(), sa));
|
||||||
|
|
||||||
|
req.fillRequirements(useOldTargets, false, true);
|
||||||
|
} else {
|
||||||
|
if (payManaCostIfNeeded(player, sa)) {
|
||||||
|
AbilityUtils.resolve(sa, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,222 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
package forge.game.player;
|
package forge.game.player;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import forge.Card;
|
|
||||||
import forge.FThreads;
|
|
||||||
import forge.card.ability.AbilityUtils;
|
|
||||||
import forge.card.ability.ApiType;
|
|
||||||
import forge.card.ability.effects.CharmEffect;
|
|
||||||
import forge.card.cost.Cost;
|
|
||||||
import forge.card.cost.CostPayment;
|
|
||||||
import forge.card.mana.ManaCost;
|
|
||||||
import forge.card.mana.ManaCostBeingPaid;
|
|
||||||
import forge.card.mana.ManaCostShard;
|
|
||||||
import forge.card.spellability.Ability;
|
|
||||||
import forge.card.spellability.HumanPlaySpellAbility;
|
|
||||||
import forge.card.spellability.SpellAbility;
|
|
||||||
import forge.card.spellability.Target;
|
|
||||||
import forge.control.input.InputPayManaBase;
|
|
||||||
import forge.control.input.InputPayManaSimple;
|
|
||||||
import forge.game.GameActionUtil;
|
|
||||||
import forge.game.GameState;
|
import forge.game.GameState;
|
||||||
|
|
||||||
public class HumanPlayer extends Player {
|
public class HumanPlayer extends Player {
|
||||||
public HumanPlayer(final LobbyPlayerHuman player, GameState game) {
|
private HumanPlayer(final LobbyPlayerHuman player, GameState game) {
|
||||||
super(player, game);
|
super(player, game);
|
||||||
controller = new PlayerControllerHuman(game, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Write javadoc for this method.
|
|
||||||
* @param card
|
|
||||||
* @param ab
|
|
||||||
*/
|
|
||||||
public static void playSpellAbility(Player p, Card c, SpellAbility ab) {
|
|
||||||
if (ab == Ability.PLAY_LAND_SURROGATE)
|
|
||||||
p.playLand(c);
|
|
||||||
else {
|
|
||||||
HumanPlayer.playSpellAbility(p, ab);
|
|
||||||
}
|
|
||||||
p.getGame().getPhaseHandler().setPriority(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* playSpellAbility.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param sa
|
|
||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
|
||||||
*/
|
|
||||||
public final static void playSpellAbility(Player p, SpellAbility sa) {
|
|
||||||
FThreads.assertExecutedByEdt(false);
|
|
||||||
sa.setActivatingPlayer(p);
|
|
||||||
|
|
||||||
final Card source = sa.getSourceCard();
|
|
||||||
|
|
||||||
source.setSplitStateToPlayAbility(sa);
|
|
||||||
|
|
||||||
if (sa.getApi() == ApiType.Charm && !sa.isWrapper()) {
|
|
||||||
CharmEffect.makeChoices(sa);
|
|
||||||
}
|
|
||||||
|
|
||||||
sa = chooseOptionalAdditionalCosts(p, sa);
|
|
||||||
|
|
||||||
if (sa == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Need to check PayCosts, and Ability + All SubAbilities for Target
|
|
||||||
boolean newAbility = sa.getPayCosts() != null;
|
|
||||||
SpellAbility ability = sa;
|
|
||||||
while ((ability != null) && !newAbility) {
|
|
||||||
final Target tgt = ability.getTarget();
|
|
||||||
|
|
||||||
newAbility |= tgt != null;
|
|
||||||
ability = ability.getSubAbility();
|
|
||||||
}
|
|
||||||
|
|
||||||
// System.out.println("Playing:" + sa.getDescription() + " of " + sa.getSourceCard() + " new = " + newAbility);
|
|
||||||
if (newAbility) {
|
|
||||||
CostPayment payment = null;
|
|
||||||
if (sa.getPayCosts() == null) {
|
|
||||||
payment = new CostPayment(new Cost("0", sa.isAbility()), sa);
|
|
||||||
} else {
|
|
||||||
payment = new CostPayment(sa.getPayCosts(), sa);
|
|
||||||
}
|
|
||||||
|
|
||||||
final HumanPlaySpellAbility req = new HumanPlaySpellAbility(sa, payment);
|
|
||||||
req.fillRequirements(false, false, false);
|
|
||||||
} else {
|
|
||||||
if (payManaCostIfNeeded(p, sa)) {
|
|
||||||
if (sa.isSpell() && !source.isCopiedSpell()) {
|
|
||||||
sa.setSourceCard(p.getGame().getAction().moveToStack(source));
|
|
||||||
}
|
|
||||||
p.getGame().getStack().add(sa);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* choose optional additional costs. For HUMAN only
|
|
||||||
* @param activator
|
|
||||||
*
|
|
||||||
* @param original
|
|
||||||
* the original sa
|
|
||||||
* @return an ArrayList<SpellAbility>.
|
|
||||||
*/
|
|
||||||
private static SpellAbility chooseOptionalAdditionalCosts(Player p, final SpellAbility original) {
|
|
||||||
//final HashMap<String, SpellAbility> map = new HashMap<String, SpellAbility>();
|
|
||||||
final List<SpellAbility> abilities = GameActionUtil.getOptionalCosts(original);
|
|
||||||
|
|
||||||
if (!original.isSpell()) {
|
|
||||||
return original;
|
|
||||||
}
|
|
||||||
|
|
||||||
return p.getController().getAbilityToPlay(abilities);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean payManaCostIfNeeded(final Player p, final SpellAbility sa) {
|
|
||||||
final ManaCostBeingPaid manaCost;
|
|
||||||
if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) {
|
|
||||||
manaCost = new ManaCostBeingPaid(ManaCost.ZERO);
|
|
||||||
} else {
|
|
||||||
manaCost = new ManaCostBeingPaid(sa.getPayCosts().getTotalMana());
|
|
||||||
manaCost.applySpellCostChange(sa);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isPaid = manaCost.isPaid();
|
|
||||||
|
|
||||||
if( !isPaid ) {
|
|
||||||
InputPayManaBase inputPay = new InputPayManaSimple(p.getGame(), sa, manaCost);
|
|
||||||
FThreads.setInputAndWait(inputPay);
|
|
||||||
isPaid = inputPay.isPaid();
|
|
||||||
}
|
|
||||||
return isPaid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Write javadoc for this method.
|
|
||||||
* @param humanPlayer
|
|
||||||
* @param c
|
|
||||||
*/
|
|
||||||
public static final void playCardWithoutPayingManaCost(Player player, Card c) {
|
|
||||||
final List<SpellAbility> choices = c.getBasicSpells();
|
|
||||||
// TODO add Buyback, Kicker, ... , spells here
|
|
||||||
|
|
||||||
SpellAbility sa = player.getController().getAbilityToPlay(choices);
|
|
||||||
|
|
||||||
if (sa != null) {
|
|
||||||
sa.setActivatingPlayer(player);
|
|
||||||
playSaWithoutPayingManaCost(player, sa);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* playSpellAbilityForFree.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param sa
|
|
||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
|
||||||
*/
|
|
||||||
public static final void playSaWithoutPayingManaCost(final Player player, final SpellAbility sa) {
|
|
||||||
FThreads.assertExecutedByEdt(false);
|
|
||||||
final Card source = sa.getSourceCard();
|
|
||||||
|
|
||||||
source.setSplitStateToPlayAbility(sa);
|
|
||||||
|
|
||||||
if (sa.getPayCosts() != null) {
|
|
||||||
if (sa.getApi() == ApiType.Charm && !sa.isWrapper()) {
|
|
||||||
CharmEffect.makeChoices(sa);
|
|
||||||
}
|
|
||||||
final CostPayment payment = new CostPayment(sa.getPayCosts(), sa);
|
|
||||||
|
|
||||||
final HumanPlaySpellAbility req = new HumanPlaySpellAbility(sa, payment);
|
|
||||||
req.fillRequirements(false, true, false);
|
|
||||||
} else {
|
|
||||||
if (sa.isSpell()) {
|
|
||||||
final Card c = sa.getSourceCard();
|
|
||||||
if (!c.isCopiedSpell()) {
|
|
||||||
sa.setSourceCard(player.getGame().getAction().moveToStack(c));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
boolean x = sa.getSourceCard().getManaCost().getShardCount(ManaCostShard.X) > 0;
|
|
||||||
|
|
||||||
player.getGame().getStack().add(sa, x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* playSpellAbility_NoStack.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param sa
|
|
||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
|
||||||
* @param skipTargeting
|
|
||||||
* a boolean.
|
|
||||||
*/
|
|
||||||
public final static void playSpellAbilityNoStack(final Player player, final SpellAbility sa) {
|
|
||||||
playSpellAbilityNoStack(player, sa, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final static void playSpellAbilityNoStack(final Player player, final SpellAbility sa, boolean useOldTargets) {
|
|
||||||
sa.setActivatingPlayer(player);
|
|
||||||
|
|
||||||
if (sa.getPayCosts() != null) {
|
|
||||||
final HumanPlaySpellAbility req = new HumanPlaySpellAbility(sa, new CostPayment(sa.getPayCosts(), sa));
|
|
||||||
|
|
||||||
req.fillRequirements(useOldTargets, false, true);
|
|
||||||
} else {
|
|
||||||
if (payManaCostIfNeeded(player, sa)) {
|
|
||||||
AbilityUtils.resolve(sa, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end HumanPlayer class
|
} // end HumanPlayer class
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ public class LobbyPlayerHuman extends LobbyPlayer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Player getPlayer(GameState game) {
|
public Player getPlayer(GameState game) {
|
||||||
return new HumanPlayer(this, game);
|
Player player = new Player(this, game);
|
||||||
|
player.setController(new PlayerControllerHuman(game, player));
|
||||||
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hear(LobbyPlayer player, String message) {
|
public void hear(LobbyPlayer player, String message) {
|
||||||
|
|||||||
@@ -49,13 +49,13 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
private final Input blockInput;
|
private final Input blockInput;
|
||||||
private final Input cleanupInput;
|
private final Input cleanupInput;
|
||||||
private final Input autoPassPriorityInput;
|
private final Input autoPassPriorityInput;
|
||||||
private final HumanPlayer player;
|
private final Player player;
|
||||||
|
|
||||||
public final Input getDefaultInput() {
|
public final Input getDefaultInput() {
|
||||||
return defaultInput;
|
return defaultInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerControllerHuman(GameState game0, HumanPlayer p) {
|
public PlayerControllerHuman(GameState game0, Player p) {
|
||||||
super(game0);
|
super(game0);
|
||||||
player = p;
|
player = p;
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
*/
|
*/
|
||||||
public void playFromSuspend(Card c) {
|
public void playFromSuspend(Card c) {
|
||||||
c.setSuspendCast(true);
|
c.setSuspendCast(true);
|
||||||
HumanPlayer.playCardWithoutPayingManaCost(player, c);
|
HumanPlay.playCardWithoutPayingManaCost(player, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -124,7 +124,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
|
|
||||||
boolean result = GuiDialog.confirm(cascadedCard, question.toString());
|
boolean result = GuiDialog.confirm(cascadedCard, question.toString());
|
||||||
if ( result )
|
if ( result )
|
||||||
HumanPlayer.playCardWithoutPayingManaCost(player, cascadedCard);
|
HumanPlay.playCardWithoutPayingManaCost(player, cascadedCard);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void playSpellAbilityForFree(SpellAbility copySA) {
|
public void playSpellAbilityForFree(SpellAbility copySA) {
|
||||||
HumanPlayer.playSaWithoutPayingManaCost(player, copySA);
|
HumanPlay.playSaWithoutPayingManaCost(player, copySA);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -373,14 +373,14 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
@Override
|
@Override
|
||||||
public void playMiracle(SpellAbility miracle, Card card) {
|
public void playMiracle(SpellAbility miracle, Card card) {
|
||||||
if (GuiDialog.confirm(card, card + " - Drawn. Play for Miracle Cost?")) {
|
if (GuiDialog.confirm(card, card + " - Drawn. Play for Miracle Cost?")) {
|
||||||
HumanPlayer.playSpellAbility(player, miracle);
|
HumanPlay.playSpellAbility(player, miracle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playMadness(SpellAbility madness) {
|
public void playMadness(SpellAbility madness) {
|
||||||
if (GuiDialog.confirm(madness.getSourceCard(), madness.getSourceCard() + " - Discarded. Pay Madness Cost?")) {
|
if (GuiDialog.confirm(madness.getSourceCard(), madness.getSourceCard() + " - Discarded. Pay Madness Cost?")) {
|
||||||
HumanPlayer.playSpellAbility(player, madness);
|
HumanPlay.playSpellAbility(player, madness);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ import forge.game.ai.ComputerUtilCost;
|
|||||||
import forge.game.event.SpellResolvedEvent;
|
import forge.game.event.SpellResolvedEvent;
|
||||||
import forge.game.phase.PhaseType;
|
import forge.game.phase.PhaseType;
|
||||||
import forge.game.player.AIPlayer;
|
import forge.game.player.AIPlayer;
|
||||||
import forge.game.player.HumanPlayer;
|
import forge.game.player.HumanPlay;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.gui.GuiChoose;
|
import forge.gui.GuiChoose;
|
||||||
import forge.util.MyObservable;
|
import forge.util.MyObservable;
|
||||||
@@ -1062,7 +1062,7 @@ public class MagicStack extends MyObservable {
|
|||||||
for (int i = size - 1; i >= 0; i--) {
|
for (int i = size - 1; i >= 0; i--) {
|
||||||
SpellAbility next = orderedSAs.get(i);
|
SpellAbility next = orderedSAs.get(i);
|
||||||
if (next.isTrigger()) {
|
if (next.isTrigger()) {
|
||||||
HumanPlayer.playSpellAbility(activePlayer, next);
|
HumanPlay.playSpellAbility(activePlayer, next);
|
||||||
} else {
|
} else {
|
||||||
this.add(next);
|
this.add(next);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import forge.card.spellability.SpellAbility;
|
|||||||
import forge.card.trigger.TriggerType;
|
import forge.card.trigger.TriggerType;
|
||||||
import forge.game.GameState;
|
import forge.game.GameState;
|
||||||
import forge.game.PlanarDice;
|
import forge.game.PlanarDice;
|
||||||
|
import forge.game.player.HumanPlay;
|
||||||
import forge.game.player.HumanPlayer;
|
import forge.game.player.HumanPlayer;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.PlayerZone;
|
import forge.game.zone.PlayerZone;
|
||||||
@@ -637,7 +638,7 @@ public final class GuiDisplayUtil {
|
|||||||
game.getAction().moveToHand(forgeCard); // this is really needed (for rollbacks at least)
|
game.getAction().moveToHand(forgeCard); // this is really needed (for rollbacks at least)
|
||||||
// Human player is choosing targets for an ability controlled by chosen player.
|
// Human player is choosing targets for an ability controlled by chosen player.
|
||||||
sa.setActivatingPlayer(p);
|
sa.setActivatingPlayer(p);
|
||||||
HumanPlayer.playSaWithoutPayingManaCost(Singletons.getControl().getPlayer(), sa);
|
HumanPlay.playSaWithoutPayingManaCost(Singletons.getControl().getPlayer(), sa);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import forge.card.spellability.SpellAbility;
|
|||||||
import forge.control.input.Input;
|
import forge.control.input.Input;
|
||||||
import forge.control.input.InputPayManaBase;
|
import forge.control.input.InputPayManaBase;
|
||||||
import forge.game.GameState;
|
import forge.game.GameState;
|
||||||
|
import forge.game.player.HumanPlay;
|
||||||
import forge.game.player.HumanPlayer;
|
import forge.game.player.HumanPlayer;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
@@ -150,7 +151,7 @@ public class CField implements ICDoc {
|
|||||||
final SpellAbility ab = CField.this.playerViewer.getController().getAbilityToPlay(game.getAbilitesOfCard(c, CField.this.playerViewer));
|
final SpellAbility ab = CField.this.playerViewer.getController().getAbilityToPlay(game.getAbilitesOfCard(c, CField.this.playerViewer));
|
||||||
if ( null != ab) {
|
if ( null != ab) {
|
||||||
FThreads.invokeInNewThread(new Runnable(){ @Override public void run(){
|
FThreads.invokeInNewThread(new Runnable(){ @Override public void run(){
|
||||||
HumanPlayer.playSpellAbility(CField.this.playerViewer, c, ab);
|
HumanPlay.playSpellAbility(CField.this.playerViewer, c, ab);
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user