mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
madness moved to PlayerController
removed imports and sources of warnings
This commit is contained in:
@@ -45,7 +45,6 @@ import forge.card.replacement.ReplacementResult;
|
||||
import forge.card.spellability.Ability;
|
||||
import forge.card.spellability.AbilityActivated;
|
||||
import forge.card.spellability.AbilityStatic;
|
||||
import forge.card.spellability.Spell;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.card.staticability.StaticAbility;
|
||||
@@ -64,8 +63,6 @@ import forge.game.zone.PlayerZoneBattlefield;
|
||||
import forge.game.zone.Zone;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.GuiChoose;
|
||||
import forge.gui.GuiDialog;
|
||||
|
||||
|
||||
/**
|
||||
* Methods for common actions performed during a game.
|
||||
@@ -81,6 +78,7 @@ public class GameAction {
|
||||
*/
|
||||
|
||||
private final GameState game;
|
||||
|
||||
public GameAction(GameState game0) {
|
||||
game = game0;
|
||||
}
|
||||
@@ -120,8 +118,7 @@ public class GameAction {
|
||||
if (zoneFrom == null && !c.isToken()) {
|
||||
if (position == null) {
|
||||
zoneTo.add(c);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
zoneTo.add(c, position);
|
||||
}
|
||||
|
||||
@@ -201,8 +198,7 @@ public class GameAction {
|
||||
// but how to query for input here and continue later while the callers assume synchronous result?
|
||||
if (position == null) {
|
||||
zoneTo.add(copied);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
zoneTo.add(copied, position);
|
||||
}
|
||||
|
||||
@@ -246,7 +242,7 @@ public class GameAction {
|
||||
(!zoneTo.is(ZoneType.Battlefield) && !c.getName().equals("Skullbriar, the Walking Grave"))) {
|
||||
copied.clearCounters();
|
||||
}
|
||||
|
||||
|
||||
if (!zoneTo.is(ZoneType.Battlefield)) {
|
||||
copied.getCharacteristics().resetCardColor();
|
||||
}
|
||||
@@ -487,8 +483,7 @@ public class GameAction {
|
||||
}
|
||||
|
||||
private void handleRecoverAbility(final Card recoverable) {
|
||||
final String recoverCost = recoverable.getKeyword().get(recoverable.getKeywordPosition("Recover"))
|
||||
.split(":")[1];
|
||||
final String recoverCost = recoverable.getKeyword().get(recoverable.getKeywordPosition("Recover")).split(":")[1];
|
||||
final Cost cost = new Cost(recoverable, recoverCost, true);
|
||||
|
||||
final Command paidCommand = new Command() {
|
||||
@@ -793,16 +788,7 @@ public class GameAction {
|
||||
@Override
|
||||
public void resolve() {
|
||||
// pay madness cost here.
|
||||
if (card.getOwner().isHuman()) {
|
||||
if (GuiDialog.confirm(card, card + " - Discarded. Pay Madness Cost?")) {
|
||||
game.getActionPlay().playSpellAbility(madness, player);
|
||||
}
|
||||
} else {
|
||||
Spell spell = (Spell) madness;
|
||||
if (spell.canPlayFromEffectAI(false, false)) {
|
||||
ComputerUtil.playStack(madness, (AIPlayer) card.getOwner(), game);
|
||||
}
|
||||
}
|
||||
card.getOwner().getController().playMadness(madness);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -942,12 +928,12 @@ public class GameAction {
|
||||
return;
|
||||
}
|
||||
|
||||
// final JFrame frame = Singletons.getView().getFrame();
|
||||
// if (!frame.isDisplayable()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
if ( game.isGameOver() )
|
||||
// final JFrame frame = Singletons.getView().getFrame();
|
||||
// if (!frame.isDisplayable()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (game.isGameOver())
|
||||
return;
|
||||
|
||||
final boolean refreeze = game.getStack().isFrozen();
|
||||
@@ -963,7 +949,7 @@ public class GameAction {
|
||||
|
||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Always, runParams, false);
|
||||
|
||||
|
||||
for (Player p : game.getPlayers()) {
|
||||
for (Card c : p.getCardsIn(ZoneType.Battlefield)) {
|
||||
if (!c.getController().equals(p)) {
|
||||
@@ -1090,7 +1076,7 @@ public class GameAction {
|
||||
checkAgain = true;
|
||||
// Place triggers on stack
|
||||
}
|
||||
|
||||
|
||||
if (this.handleLegendRule()) {
|
||||
checkAgain = true;
|
||||
}
|
||||
@@ -1104,8 +1090,8 @@ public class GameAction {
|
||||
}
|
||||
} // for q=0;q<2
|
||||
|
||||
GameEndReason endGame = this.checkEndGameState(game);
|
||||
if ( endGame != null ) {
|
||||
GameEndReason endGame = this.checkEndGameState(game);
|
||||
if (endGame != null) {
|
||||
// Clear Simultaneous triggers at the end of the game
|
||||
game.setGameOver(endGame);
|
||||
game.getStack().clearSimultaneousStack();
|
||||
@@ -1191,15 +1177,15 @@ public class GameAction {
|
||||
game.getEvents().post(new CardDestroyedEvent());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return recheck;
|
||||
} // destroyLegendaryCreatures()
|
||||
|
||||
|
||||
public final boolean sacrifice(final Card c, final SpellAbility source) {
|
||||
if(!c.canBeSacrificedBy(source))
|
||||
if (!c.canBeSacrificedBy(source))
|
||||
return false;
|
||||
|
||||
|
||||
this.sacrificeDestroy(c);
|
||||
|
||||
// Play the Sacrifice sound
|
||||
@@ -1253,7 +1239,7 @@ public class GameAction {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean destroyNoRegeneration(final Card c) {
|
||||
if ( !c.canBeDestroyed() )
|
||||
if (!c.canBeDestroyed())
|
||||
return false;
|
||||
|
||||
if (c.isEnchanted()) {
|
||||
@@ -1366,7 +1352,7 @@ public class GameAction {
|
||||
|
||||
final boolean persist = (c.hasKeyword("Persist") && (c.getCounters(CounterType.M1M1) == 0)) && !c.isToken();
|
||||
final boolean undying = (c.hasKeyword("Undying") && (c.getCounters(CounterType.P1P1) == 0)) && !c.isToken();
|
||||
|
||||
|
||||
game.getCombat().removeFromCombat(c);
|
||||
|
||||
final Card newCard = this.moveToGraveyard(c);
|
||||
@@ -1433,5 +1419,5 @@ public class GameAction {
|
||||
* @param c
|
||||
* a {@link forge.Card} object.
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ import forge.card.mana.ManaCost;
|
||||
import forge.card.mana.ManaPool;
|
||||
import forge.card.replacement.ReplacementResult;
|
||||
import forge.card.spellability.Ability;
|
||||
import forge.card.spellability.Spell;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.card.staticability.StaticAbility;
|
||||
@@ -58,7 +57,6 @@ import forge.game.GameActionUtil;
|
||||
import forge.game.GameLossReason;
|
||||
import forge.game.GameState;
|
||||
import forge.game.GlobalRuleChange;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.event.CardDiscardedEvent;
|
||||
import forge.game.event.DrawCardEvent;
|
||||
import forge.game.event.LandPlayedEvent;
|
||||
|
||||
@@ -114,4 +114,5 @@ public abstract class PlayerController {
|
||||
public abstract Card chooseCardToDredge(List<Card> dredgers);
|
||||
|
||||
public abstract void playMiracle(SpellAbility miracle, Card card);
|
||||
public abstract void playMadness(SpellAbility madness);
|
||||
}
|
||||
|
||||
@@ -129,35 +129,23 @@ public class PlayerControllerAi extends PlayerController {
|
||||
return player;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.PlayerController#sideboard(forge.deck.Deck)
|
||||
*/
|
||||
@Override
|
||||
public Deck sideboard(Deck deck, GameType gameType) {
|
||||
// AI does not know how to sideboard
|
||||
return deck;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.PlayerController#assignCombatDamage(forge.Card, java.util.List, int, forge.GameEntity)
|
||||
*/
|
||||
@Override
|
||||
public Map<Card, Integer> assignCombatDamage(Card attacker, List<Card> blockers, int damageDealt, GameEntity defender) {
|
||||
return ComputerUtilCombat.distributeAIDamage(attacker, blockers, damageDealt, defender);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.PlayerController#announceRequirements()
|
||||
*/
|
||||
@Override
|
||||
public String announceRequirements(SpellAbility ability, String announce) {
|
||||
// For now, these "announcements" are made within the AI classes of the appropriate SA effects
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.PlayerController#choosePermanentsToSacrifice(java.util.List, int, forge.card.spellability.SpellAbility, boolean, boolean)
|
||||
*/
|
||||
@Override
|
||||
public List<Card> choosePermanentsToSacrifice(List<Card> validTargets, int amount, SpellAbility sa, boolean destroy, boolean isOptional) {
|
||||
return ComputerUtil.choosePermanentsToSacrifice(player, validTargets, amount, sa, destroy, isOptional);
|
||||
@@ -165,12 +153,12 @@ public class PlayerControllerAi extends PlayerController {
|
||||
|
||||
@Override
|
||||
public Card chooseSingleCardForEffect(List<Card> options, SpellAbility sa, String title, boolean isOptional) {
|
||||
return brains.chooseSingleCardForEffect(options, sa, title, isOptional);
|
||||
return getAi().chooseSingleCardForEffect(options, sa, title, isOptional);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean confirmAction(SpellAbility sa, String mode, String message) {
|
||||
return brains.confirmAction(sa, mode, message);
|
||||
return getAi().confirmAction(sa, mode, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -179,7 +167,7 @@ public class PlayerControllerAi extends PlayerController {
|
||||
}
|
||||
@Override
|
||||
public boolean confirmStaticApplication(Card hostCard, GameEntity affected, String logic, String message) {
|
||||
return brains.confirmStaticApplication(hostCard, affected, logic, message);
|
||||
return getAi().confirmStaticApplication(hostCard, affected, logic, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -234,7 +222,7 @@ public class PlayerControllerAi extends PlayerController {
|
||||
|
||||
@Override
|
||||
public Card chooseCardToDredge(List<Card> dredgers) {
|
||||
return brains.chooseCardToDredge(dredgers);
|
||||
return getAi().chooseCardToDredge(dredgers);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -242,4 +230,10 @@ public class PlayerControllerAi extends PlayerController {
|
||||
getAi().chooseAndPlaySa(false, false, miracle);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void playMadness(SpellAbility madness) {
|
||||
getAi().chooseAndPlaySa(false, false, madness);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -319,18 +319,12 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
return GuiDialog.confirm(c, "Where will you put " + c.getName() + " in your library", new String[]{"Top", "Bottom"} );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.PlayerController#chooseCardsToDiscardFrom(forge.game.player.Player, java.util.List, int)
|
||||
*/
|
||||
@Override
|
||||
public List<Card> chooseCardsToDiscardFrom(Player p, SpellAbility sa, List<Card> valid, int minDiscard) {
|
||||
int cntToKeepInHand = minDiscard == 0 ? -1 : valid.size() - minDiscard;
|
||||
return GuiChoose.order("Choose cards to Discard", "Discarded", cntToKeepInHand, valid, null, null);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.PlayerController#chooseCardToDredge(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public Card chooseCardToDredge(List<Card> dredgers) {
|
||||
if (GuiDialog.confirm(null, "Do you want to dredge?", false)) {
|
||||
@@ -339,13 +333,17 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.PlayerController#playMiracle(forge.card.spellability.SpellAbility, forge.Card)
|
||||
*/
|
||||
@Override
|
||||
public void playMiracle(SpellAbility miracle, Card card) {
|
||||
if (GuiDialog.confirm(card, card + " - Drawn. Play for Miracle Cost?")) {
|
||||
game.getActionPlay().playSpellAbility(miracle, getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playMadness(SpellAbility madness) {
|
||||
if (GuiDialog.confirm(madness.getSourceCard(), madness.getSourceCard() + " - Discarded. Pay Madness Cost?")) {
|
||||
game.getActionPlay().playSpellAbility(madness, getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +268,6 @@ public enum CSubmenuPreferences implements ICDoc {
|
||||
prefs.save();
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private void updateAIProfile() {
|
||||
final VSubmenuPreferences view = VSubmenuPreferences.SINGLETON_INSTANCE;
|
||||
final String name = view.getLstChooseAIProfile().getSelectedValue().toString();
|
||||
|
||||
Reference in New Issue
Block a user