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 player = replacementEffect.getHostCard().getController();
|
||||||
//player.getController().playNoStack()
|
//player.getController().playNoStack()
|
||||||
if (player.isHuman()) {
|
if (player.isHuman()) {
|
||||||
((HumanPlayer)player).playSpellAbilityNoStack(effectSA);
|
HumanPlayer.playSpellAbilityNoStack(player, effectSA);
|
||||||
} else {
|
} else {
|
||||||
ComputerUtil.playNoStack((AIPlayer) player, effectSA, game);
|
ComputerUtil.playNoStack((AIPlayer) player, effectSA, game);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -430,7 +430,7 @@ public class TriggerHandler {
|
|||||||
|
|
||||||
if (regtrig.isStatic()) {
|
if (regtrig.isStatic()) {
|
||||||
if (wrapperAbility.getActivatingPlayer().isHuman()) {
|
if (wrapperAbility.getActivatingPlayer().isHuman()) {
|
||||||
((HumanPlayer)wrapperAbility.getActivatingPlayer()).playSpellAbilityNoStack(wrapperAbility);
|
HumanPlayer.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);
|
||||||
|
|||||||
@@ -365,7 +365,7 @@ public class WrappedAbility extends Ability implements ISpellAbility {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (getActivatingPlayer().isHuman()) {
|
if (getActivatingPlayer().isHuman()) {
|
||||||
((HumanPlayer)getActivatingPlayer()).playSpellAbilityNoStack(sa, true);
|
HumanPlayer.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
|
||||||
|
|||||||
@@ -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)p).playSpellAbilityNoStack(effect);
|
HumanPlayer.playSpellAbilityNoStack(p, effect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -282,7 +282,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)p).playCardWithoutManaCost(rippledCards[i]);
|
HumanPlayer.playCardWithoutPayingManaCost(((HumanPlayer)p), rippledCards[i]);
|
||||||
revealed.remove(rippledCards[i]);
|
revealed.remove(rippledCards[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -155,45 +155,20 @@ public class HumanPlayer extends Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* TODO: Write javadoc for this method.
|
||||||
* playSpellAbility_NoStack.
|
* @param humanPlayer
|
||||||
* </p>
|
* @param c
|
||||||
*
|
|
||||||
* @param sa
|
|
||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
|
||||||
* @param skipTargeting
|
|
||||||
* a boolean.
|
|
||||||
*/
|
*/
|
||||||
public final void playSpellAbilityNoStack( final SpellAbility sa) {
|
public static final void playCardWithoutPayingManaCost(Player player, Card c) {
|
||||||
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) {
|
|
||||||
final List<SpellAbility> choices = c.getBasicSpells();
|
final List<SpellAbility> choices = c.getBasicSpells();
|
||||||
// TODO add Buyback, Kicker, ... , spells here
|
// TODO add Buyback, Kicker, ... , spells here
|
||||||
|
|
||||||
SpellAbility sa = controller.getAbilityToPlay(choices);
|
SpellAbility sa = player.getController().getAbilityToPlay(choices);
|
||||||
|
|
||||||
if (sa == null) {
|
if (sa != null) {
|
||||||
return;
|
sa.setActivatingPlayer(player);
|
||||||
|
playSaWithoutPayingManaCost(player, sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
sa.setActivatingPlayer(this);
|
|
||||||
this.playSpellAbilityWithoutPayingManaCost(sa);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -204,7 +179,7 @@ public class HumanPlayer extends Player {
|
|||||||
* @param sa
|
* @param sa
|
||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* 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);
|
FThreads.assertExecutedByEdt(false);
|
||||||
final Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
|
|
||||||
@@ -222,12 +197,41 @@ public class HumanPlayer extends Player {
|
|||||||
if (sa.isSpell()) {
|
if (sa.isSpell()) {
|
||||||
final Card c = sa.getSourceCard();
|
final Card c = sa.getSourceCard();
|
||||||
if (!c.isCopiedSpell()) {
|
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;
|
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) {
|
public void playFromSuspend(Card c) {
|
||||||
c.setSuspendCast(true);
|
c.setSuspendCast(true);
|
||||||
player.playCardWithoutManaCost(c);
|
HumanPlayer.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 )
|
||||||
player.playCardWithoutManaCost(cascadedCard);
|
HumanPlayer.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) {
|
||||||
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)
|
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);
|
||||||
Singletons.getControl().getPlayer().playSpellAbilityWithoutPayingManaCost(sa);
|
HumanPlayer.playSaWithoutPayingManaCost(Singletons.getControl().getPlayer(), sa);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user