mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
several Checkstyle fixes in Input_Mulligan
This commit is contained in:
@@ -2,7 +2,16 @@ package forge.gui.input;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import forge.*;
|
||||
import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.ButtonUtil;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.GameActionUtil;
|
||||
import forge.Phase;
|
||||
import forge.Player;
|
||||
import forge.card.abilityFactory.AbilityFactory;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GamePlayerRating;
|
||||
@@ -16,7 +25,7 @@ import forge.quest.data.QuestData;
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Input_Mulligan extends Input {
|
||||
/** Constant <code>serialVersionUID=-8112954303001155622L</code> */
|
||||
/** Constant <code>serialVersionUID=-8112954303001155622L</code>. */
|
||||
private static final long serialVersionUID = -8112954303001155622L;
|
||||
|
||||
private static final int MAGIC_NUMBER_OF_SHUFFLES = 100;
|
||||
@@ -24,7 +33,7 @@ public class Input_Mulligan extends Input {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void showMessage() {
|
||||
public final void showMessage() {
|
||||
ButtonUtil.enableAll();
|
||||
AllZone.getDisplay().getButtonOK().setText("No");
|
||||
AllZone.getDisplay().getButtonCancel().setText("Yes");
|
||||
@@ -33,11 +42,18 @@ public class Input_Mulligan extends Input {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void selectButtonOK() {
|
||||
public final void selectButtonOK() {
|
||||
end();
|
||||
}
|
||||
|
||||
public int doMulligan( Player player, GamePlayerRating playerRating ) {
|
||||
/**
|
||||
*
|
||||
* TODO Write javadoc for this method.
|
||||
* @param player a Player object
|
||||
* @param playerRating a GamePlayerRating object
|
||||
* @return an int
|
||||
*/
|
||||
public final int doMulligan(final Player player, final GamePlayerRating playerRating) {
|
||||
CardList hand = AllZoneUtil.getPlayerHand(player);
|
||||
for (Card c : hand) { AllZone.getGameAction().moveToLibrary(c); }
|
||||
for (int i = 0; i < MAGIC_NUMBER_OF_SHUFFLES; i++) { player.shuffle(); }
|
||||
@@ -50,7 +66,7 @@ public class Input_Mulligan extends Input {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void selectButtonCancel() {
|
||||
public final void selectButtonCancel() {
|
||||
GamePlayerRating humanRating = AllZone.getGameInfo().getPlayerRating(PlayerIndex.HUMAN);
|
||||
Player humanPlayer = AllZone.getHumanPlayer();
|
||||
|
||||
@@ -70,7 +86,7 @@ public class Input_Mulligan extends Input {
|
||||
/**
|
||||
* <p>end.</p>
|
||||
*/
|
||||
void end() {
|
||||
final void end() {
|
||||
//Computer mulligan
|
||||
Player aiPlayer = AllZone.getComputerPlayer();
|
||||
GamePlayerRating aiRating = AllZone.getGameInfo().getPlayerRating(PlayerIndex.AI);
|
||||
@@ -98,23 +114,22 @@ public class Input_Mulligan extends Input {
|
||||
for (int i = 0; i < kws.size(); i++) {
|
||||
String kw = kws.get(i);
|
||||
|
||||
if(kw.startsWith("MayEffectFromOpeningHand"))
|
||||
{
|
||||
if (kw.startsWith("MayEffectFromOpeningHand")) {
|
||||
String effName = kw.split(":")[1];
|
||||
|
||||
SpellAbility effect = af.getAbility(c.getSVar(effName), c);
|
||||
if(GameActionUtil.showYesNoDialog(c, "Use this card's ability?"))
|
||||
{
|
||||
if (GameActionUtil.showYesNoDialog(c, "Use this card's ability?")) {
|
||||
//If we ever let the AI memorize cards in the players hand, this would be a place to do so.
|
||||
AllZone.getGameAction().playSpellAbility_NoStack(effect, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (c.getName().startsWith("Leyline")) {
|
||||
if (GameActionUtil.showYesNoDialog(c, "Use this card's ability?"))
|
||||
if (GameActionUtil.showYesNoDialog(c, "Use this card's ability?")) {
|
||||
AllZone.getGameAction().moveToPlay(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Computer Leylines & Chancellors
|
||||
CardList aiOpeningHand = AllZoneUtil.getPlayerHand(AllZone.getComputerPlayer());
|
||||
@@ -124,22 +139,23 @@ public class Input_Mulligan extends Input {
|
||||
for (int i = 0; i < kws.size(); i++) {
|
||||
String kw = kws.get(i);
|
||||
|
||||
if(kw.startsWith("MayEffectFromOpeningHand"))
|
||||
{
|
||||
if (kw.startsWith("MayEffectFromOpeningHand")) {
|
||||
String effName = kw.split(":")[1];
|
||||
|
||||
SpellAbility effect = af.getAbility(c.getSVar(effName), c);
|
||||
|
||||
if(effect.doTrigger(false)) //Is there a better way for the AI to decide this?
|
||||
{
|
||||
GameActionUtil.showInfoDialg("Computer reveals " + c.getName() + "(" + c.getUniqueNumber() + ").");
|
||||
//Is there a better way for the AI to decide this?
|
||||
if (effect.doTrigger(false)) {
|
||||
GameActionUtil.showInfoDialg("Computer reveals "
|
||||
+ c.getName() + "(" + c.getUniqueNumber() + ").");
|
||||
ComputerUtil.playNoStack(effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (c.getName().startsWith("Leyline") && !(c.getName().startsWith("Leyline of Singularity")
|
||||
&& AllZoneUtil.getCardsInPlay("Leyline of Singularity").size() > 0)) {
|
||||
&& AllZoneUtil.getCardsInPlay("Leyline of Singularity").size() > 0))
|
||||
{
|
||||
AllZone.getGameAction().moveToPlay(c);
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
}
|
||||
@@ -148,9 +164,12 @@ public class Input_Mulligan extends Input {
|
||||
|
||||
|
||||
if (AllZone.getGameAction().isStartCut() && !(humanOpeningHand.contains(AllZone.getGameAction().getHumanCut())
|
||||
|| aiOpeningHand.contains(AllZone.getGameAction().getComputerCut()))) {
|
||||
AllZone.getGameAction().moveTo(AllZone.getZone(Constant.Zone.Library, AllZone.getHumanPlayer()), AllZone.getGameAction().getHumanCut());
|
||||
AllZone.getGameAction().moveTo(AllZone.getZone(Constant.Zone.Library, AllZone.getComputerPlayer()), AllZone.getGameAction().getComputerCut());
|
||||
|| aiOpeningHand.contains(AllZone.getGameAction().getComputerCut())))
|
||||
{
|
||||
AllZone.getGameAction().moveTo(AllZone.getZone(Constant.Zone.Library, AllZone.getHumanPlayer()),
|
||||
AllZone.getGameAction().getHumanCut());
|
||||
AllZone.getGameAction().moveTo(AllZone.getZone(Constant.Zone.Library, AllZone.getComputerPlayer()),
|
||||
AllZone.getGameAction().getComputerCut());
|
||||
}
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
Phase.setGameBegins(1);
|
||||
|
||||
Reference in New Issue
Block a user