mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
the remaining 2 methods used to play human's spells also moved to HumanPlayer
GameActionPlay.java eliminated.
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -13891,7 +13891,6 @@ src/main/java/forge/deck/package-info.java svneol=native#text/plain
|
|||||||
src/main/java/forge/error/ExceptionHandler.java svneol=native#text/plain
|
src/main/java/forge/error/ExceptionHandler.java svneol=native#text/plain
|
||||||
src/main/java/forge/error/package-info.java svneol=native#text/plain
|
src/main/java/forge/error/package-info.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/GameAction.java svneol=native#text/plain
|
src/main/java/forge/game/GameAction.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/GameActionPlay.java -text
|
|
||||||
src/main/java/forge/game/GameActionUtil.java svneol=native#text/plain
|
src/main/java/forge/game/GameActionUtil.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/GameEndReason.java -text
|
src/main/java/forge/game/GameEndReason.java -text
|
||||||
src/main/java/forge/game/GameFormat.java -text
|
src/main/java/forge/game/GameFormat.java -text
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import forge.control.input.InputSelectCardsFromList;
|
|||||||
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.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.GuiChoose;
|
import forge.gui.GuiChoose;
|
||||||
@@ -225,7 +226,7 @@ public class CardFactorySorceries {
|
|||||||
JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.INFORMATION_MESSAGE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Singletons.getModel().getGame().getActionPlay().playCardWithoutManaCost(playing, card.getController());
|
((HumanPlayer)card.getController()).playCardWithoutManaCost(playing);
|
||||||
}
|
}
|
||||||
chosen.remove(playing);
|
chosen.remove(playing);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import javax.swing.WindowConstants;
|
|||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.control.KeyboardShortcuts.Shortcut;
|
import forge.control.KeyboardShortcuts.Shortcut;
|
||||||
import forge.game.ai.AiProfileUtil;
|
import forge.game.ai.AiProfileUtil;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.HumanPlayer;
|
||||||
import forge.gui.SOverlayUtils;
|
import forge.gui.SOverlayUtils;
|
||||||
import forge.gui.deckeditor.CDeckEditorUI;
|
import forge.gui.deckeditor.CDeckEditorUI;
|
||||||
import forge.gui.deckeditor.VDeckEditorUI;
|
import forge.gui.deckeditor.VDeckEditorUI;
|
||||||
@@ -284,8 +284,8 @@ public enum FControl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @return {@link forge.game.player.Player} */
|
/** @return {@link forge.game.player.Player} */
|
||||||
private Player localPlayer;
|
private HumanPlayer localPlayer;
|
||||||
public Player getPlayer() {
|
public HumanPlayer getPlayer() {
|
||||||
return localPlayer;
|
return localPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +305,7 @@ public enum FControl {
|
|||||||
* TODO: Write javadoc for this method.
|
* TODO: Write javadoc for this method.
|
||||||
* @param localHuman
|
* @param localHuman
|
||||||
*/
|
*/
|
||||||
public void setPlayer(Player localHuman) {
|
public void setPlayer(HumanPlayer localHuman) {
|
||||||
localPlayer = localHuman;
|
localPlayer = localHuman;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,75 +0,0 @@
|
|||||||
package forge.game;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import forge.Card;
|
|
||||||
import forge.FThreads;
|
|
||||||
import forge.card.ability.ApiType;
|
|
||||||
import forge.card.ability.effects.CharmEffect;
|
|
||||||
import forge.card.cost.CostPayment;
|
|
||||||
import forge.card.mana.ManaCostShard;
|
|
||||||
import forge.card.spellability.SpellAbility;
|
|
||||||
import forge.card.spellability.HumanPlaySpellAbility;
|
|
||||||
import forge.game.player.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Write javadoc for this type.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class GameActionPlay {
|
|
||||||
|
|
||||||
private final GameState game;
|
|
||||||
|
|
||||||
|
|
||||||
public GameActionPlay(final GameState game0) {
|
|
||||||
game = game0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void playCardWithoutManaCost(final Card c, Player player) {
|
|
||||||
final List<SpellAbility> choices = c.getBasicSpells();
|
|
||||||
// TODO add Buyback, Kicker, ... , spells here
|
|
||||||
|
|
||||||
SpellAbility sa = player.getController().getAbilityToPlay(choices);
|
|
||||||
|
|
||||||
if (sa == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sa.setActivatingPlayer(player);
|
|
||||||
this.playSpellAbilityWithoutPayingManaCost(sa);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* playSpellAbilityForFree.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param sa
|
|
||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
|
||||||
*/
|
|
||||||
public final void playSpellAbilityWithoutPayingManaCost(final SpellAbility sa) {
|
|
||||||
FThreads.checkEDT("GameActionPlay.playSpellAbilityWithoutPayingManaCost", 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(game.getAction().moveToStack(c));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
boolean x = sa.getSourceCard().getManaCost().getShardCount(ManaCostShard.X) > 0;
|
|
||||||
|
|
||||||
game.getStack().add(sa, x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -66,6 +66,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.HumanPlayer;
|
||||||
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;
|
||||||
@@ -274,7 +275,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() + "?")) {
|
||||||
game.getActionPlay().playCardWithoutManaCost(rippledCards[i], p);
|
((HumanPlayer)p).playCardWithoutManaCost(rippledCards[i]);
|
||||||
revealed.remove(rippledCards[i]);
|
revealed.remove(rippledCards[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ public class GameState {
|
|||||||
|
|
||||||
private long timestamp = 0;
|
private long timestamp = 0;
|
||||||
public final GameAction action;
|
public final GameAction action;
|
||||||
public final GameActionPlay actionPlay;
|
|
||||||
private final MatchController match;
|
private final MatchController match;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -109,7 +108,6 @@ public class GameState {
|
|||||||
allPlayers = Collections.unmodifiableList(players);
|
allPlayers = Collections.unmodifiableList(players);
|
||||||
roIngamePlayers = Collections.unmodifiableList(ingamePlayers);
|
roIngamePlayers = Collections.unmodifiableList(ingamePlayers);
|
||||||
action = new GameAction(this);
|
action = new GameAction(this);
|
||||||
actionPlay = new GameActionPlay(this);
|
|
||||||
stack = new MagicStack(this);
|
stack = new MagicStack(this);
|
||||||
phaseHandler = new PhaseHandler(this);
|
phaseHandler = new PhaseHandler(this);
|
||||||
|
|
||||||
@@ -663,15 +661,6 @@ public class GameState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Write javadoc for this method.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public GameActionPlay getActionPlay() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return actionPlay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean mulliganned = false;
|
public boolean mulliganned = false;
|
||||||
public boolean hasMulliganned(){ return mulliganned; }
|
public boolean hasMulliganned(){ return mulliganned; }
|
||||||
public void setMulliganned(boolean value) { mulliganned = value; }
|
public void setMulliganned(boolean value) { mulliganned = value; }
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import forge.card.ability.effects.CharmEffect;
|
|||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
import forge.card.cost.CostPayment;
|
import forge.card.cost.CostPayment;
|
||||||
import forge.card.mana.ManaCostBeingPaid;
|
import forge.card.mana.ManaCostBeingPaid;
|
||||||
|
import forge.card.mana.ManaCostShard;
|
||||||
import forge.card.spellability.Ability;
|
import forge.card.spellability.Ability;
|
||||||
import forge.card.spellability.HumanPlaySpellAbility;
|
import forge.card.spellability.HumanPlaySpellAbility;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
@@ -229,5 +230,52 @@ public class HumanPlayer extends Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public final void playCardWithoutManaCost(final Card c) {
|
||||||
|
final List<SpellAbility> choices = c.getBasicSpells();
|
||||||
|
// TODO add Buyback, Kicker, ... , spells here
|
||||||
|
|
||||||
|
SpellAbility sa = controller.getAbilityToPlay(choices);
|
||||||
|
|
||||||
|
if (sa == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sa.setActivatingPlayer(this);
|
||||||
|
this.playSpellAbilityWithoutPayingManaCost(sa);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* playSpellAbilityForFree.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param sa
|
||||||
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
|
*/
|
||||||
|
public final void playSpellAbilityWithoutPayingManaCost(final SpellAbility sa) {
|
||||||
|
FThreads.checkEDT("GameActionPlay.playSpellAbilityWithoutPayingManaCost", 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(game.getAction().moveToStack(c));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
boolean x = sa.getSourceCard().getManaCost().getShardCount(ManaCostShard.X) > 0;
|
||||||
|
|
||||||
|
game.getStack().add(sa, x);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // end HumanPlayer class
|
} // end HumanPlayer class
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class PlayerControllerAi extends PlayerController {
|
|||||||
} else if (abilities.size() == 1) {
|
} else if (abilities.size() == 1) {
|
||||||
return abilities.get(0);
|
return abilities.get(0);
|
||||||
} else {
|
} else {
|
||||||
return GuiChoose.oneOrNone("Choose", abilities); // some day network interaction will be here
|
return GuiChoose.oneOrNone("Choose ability for AI to play", abilities); // some day network interaction will be here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
*/
|
*/
|
||||||
public void playFromSuspend(Card c) {
|
public void playFromSuspend(Card c) {
|
||||||
c.setSuspendCast(true);
|
c.setSuspendCast(true);
|
||||||
game.getActionPlay().playCardWithoutManaCost(c, c.getOwner());
|
player.playCardWithoutManaCost(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -122,7 +122,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
|
|
||||||
boolean result = GuiDialog.confirm(cascadedCard, question.toString());
|
boolean result = GuiDialog.confirm(cascadedCard, question.toString());
|
||||||
if ( result )
|
if ( result )
|
||||||
game.getActionPlay().playCardWithoutManaCost(cascadedCard, getPlayer());
|
player.playCardWithoutManaCost(cascadedCard);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void playSpellAbilityForFree(SpellAbility copySA) {
|
public void playSpellAbilityForFree(SpellAbility copySA) {
|
||||||
game.getActionPlay().playSpellAbilityWithoutPayingManaCost(copySA);
|
player.playSpellAbilityWithoutPayingManaCost(copySA);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -632,9 +632,10 @@ public final class GuiDisplayUtil {
|
|||||||
FThreads.invokeInNewThread(new Runnable() {
|
FThreads.invokeInNewThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
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);
|
sa.setActivatingPlayer(p);
|
||||||
game.getAction().moveToHand(forgeCard); // this is really needed
|
Singletons.getControl().getPlayer().playSpellAbilityWithoutPayingManaCost(sa);
|
||||||
game.getActionPlay().playSpellAbilityWithoutPayingManaCost(sa);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user