mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
HumanPlayer: all specific methods converted to static, preparing to delete the enclosing class.
This commit is contained in:
@@ -240,7 +240,7 @@ public class ReplacementHandler {
|
||||
Player player = replacementEffect.getHostCard().getController();
|
||||
//player.getController().playNoStack()
|
||||
if (player.isHuman()) {
|
||||
((HumanPlayer)player).playSpellAbilityNoStack(effectSA);
|
||||
HumanPlayer.playSpellAbilityNoStack(player, effectSA);
|
||||
} else {
|
||||
ComputerUtil.playNoStack((AIPlayer) player, effectSA, game);
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ public class TriggerHandler {
|
||||
|
||||
if (regtrig.isStatic()) {
|
||||
if (wrapperAbility.getActivatingPlayer().isHuman()) {
|
||||
((HumanPlayer)wrapperAbility.getActivatingPlayer()).playSpellAbilityNoStack(wrapperAbility);
|
||||
HumanPlayer.playSpellAbilityNoStack(wrapperAbility.getActivatingPlayer(), wrapperAbility);
|
||||
} else {
|
||||
wrapperAbility.doTrigger(isMandatory, (AIPlayer)wrapperAbility.getActivatingPlayer());
|
||||
ComputerUtil.playNoStack((AIPlayer)wrapperAbility.getActivatingPlayer(), wrapperAbility, game);
|
||||
|
||||
@@ -365,7 +365,7 @@ public class WrappedAbility extends Ability implements ISpellAbility {
|
||||
return;
|
||||
|
||||
if (getActivatingPlayer().isHuman()) {
|
||||
((HumanPlayer)getActivatingPlayer()).playSpellAbilityNoStack(sa, true);
|
||||
HumanPlayer.playSpellAbilityNoStack(getActivatingPlayer(), sa, true);
|
||||
} else {
|
||||
// commented out because i don't think this should be called
|
||||
// again here
|
||||
|
||||
@@ -1435,7 +1435,7 @@ public class GameAction {
|
||||
if (GuiDialog.confirm(c, "Use " + c +"'s ability?")) {
|
||||
// If we ever let the AI memorize cards in the players
|
||||
// hand, this would be a place to do so.
|
||||
((HumanPlayer)p).playSpellAbilityNoStack(effect);
|
||||
HumanPlayer.playSpellAbilityNoStack(p, effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ public final class GameActionUtil {
|
||||
|
||||
if (p.isHuman()) {
|
||||
if (GuiDialog.confirm(rippledCards[i], "Cast " + rippledCards[i].getName() + "?")) {
|
||||
((HumanPlayer)p).playCardWithoutManaCost(rippledCards[i]);
|
||||
HumanPlayer.playCardWithoutPayingManaCost(((HumanPlayer)p), rippledCards[i]);
|
||||
revealed.remove(rippledCards[i]);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -155,45 +155,20 @@ public class HumanPlayer extends Player {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* playSpellAbility_NoStack.
|
||||
* </p>
|
||||
*
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* @param skipTargeting
|
||||
* a boolean.
|
||||
* TODO: Write javadoc for this method.
|
||||
* @param humanPlayer
|
||||
* @param c
|
||||
*/
|
||||
public final void playSpellAbilityNoStack( final SpellAbility sa) {
|
||||
playSpellAbilityNoStack(sa, false);
|
||||
}
|
||||
public final void playSpellAbilityNoStack(final SpellAbility sa, boolean useOldTargets) {
|
||||
sa.setActivatingPlayer(this);
|
||||
|
||||
if (sa.getPayCosts() != null) {
|
||||
final HumanPlaySpellAbility req = new HumanPlaySpellAbility(sa, new CostPayment(sa.getPayCosts(), sa));
|
||||
|
||||
req.fillRequirements(useOldTargets, false, true);
|
||||
} else {
|
||||
if (payManaCostIfNeeded(this, sa)) {
|
||||
AbilityUtils.resolve(sa, false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public final void playCardWithoutManaCost(final Card c) {
|
||||
public static final void playCardWithoutPayingManaCost(Player player, Card c) {
|
||||
final List<SpellAbility> choices = c.getBasicSpells();
|
||||
// TODO add Buyback, Kicker, ... , spells here
|
||||
|
||||
SpellAbility sa = controller.getAbilityToPlay(choices);
|
||||
SpellAbility sa = player.getController().getAbilityToPlay(choices);
|
||||
|
||||
if (sa == null) {
|
||||
return;
|
||||
if (sa != null) {
|
||||
sa.setActivatingPlayer(player);
|
||||
playSaWithoutPayingManaCost(player, sa);
|
||||
}
|
||||
|
||||
sa.setActivatingPlayer(this);
|
||||
this.playSpellAbilityWithoutPayingManaCost(sa);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -204,7 +179,7 @@ public class HumanPlayer extends Player {
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
*/
|
||||
public final void playSpellAbilityWithoutPayingManaCost(final SpellAbility sa) {
|
||||
public static final void playSaWithoutPayingManaCost(final Player player, final SpellAbility sa) {
|
||||
FThreads.assertExecutedByEdt(false);
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
@@ -222,12 +197,41 @@ public class HumanPlayer extends Player {
|
||||
if (sa.isSpell()) {
|
||||
final Card c = sa.getSourceCard();
|
||||
if (!c.isCopiedSpell()) {
|
||||
sa.setSourceCard(game.getAction().moveToStack(c));
|
||||
sa.setSourceCard(player.getGame().getAction().moveToStack(c));
|
||||
}
|
||||
}
|
||||
boolean x = sa.getSourceCard().getManaCost().getShardCount(ManaCostShard.X) > 0;
|
||||
|
||||
game.getStack().add(sa, x);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
*/
|
||||
public void playFromSuspend(Card c) {
|
||||
c.setSuspendCast(true);
|
||||
player.playCardWithoutManaCost(c);
|
||||
HumanPlayer.playCardWithoutPayingManaCost(player, c);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -124,7 +124,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
|
||||
boolean result = GuiDialog.confirm(cascadedCard, question.toString());
|
||||
if ( result )
|
||||
player.playCardWithoutManaCost(cascadedCard);
|
||||
HumanPlayer.playCardWithoutPayingManaCost(player, cascadedCard);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
*/
|
||||
@Override
|
||||
public void playSpellAbilityForFree(SpellAbility copySA) {
|
||||
player.playSpellAbilityWithoutPayingManaCost(copySA);
|
||||
HumanPlayer.playSaWithoutPayingManaCost(player, copySA);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -637,7 +637,7 @@ public final class GuiDisplayUtil {
|
||||
game.getAction().moveToHand(forgeCard); // this is really needed (for rollbacks at least)
|
||||
// Human player is choosing targets for an ability controlled by chosen player.
|
||||
sa.setActivatingPlayer(p);
|
||||
Singletons.getControl().getPlayer().playSpellAbilityWithoutPayingManaCost(sa);
|
||||
HumanPlayer.playSaWithoutPayingManaCost(Singletons.getControl().getPlayer(), sa);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user