several Checkstyle fixes in Input_Mulligan

This commit is contained in:
slapshot5
2011-09-15 00:56:17 +00:00
parent 42ebac91ff
commit e31e445a0d

View File

@@ -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();
@@ -65,12 +81,12 @@ public class Input_Mulligan extends Input {
if (newHand == 0) {
end();
}
}//selectButtonOK()
} //selectButtonOK()
/**
* <p>end.</p>
*/
void end() {
final void end() {
//Computer mulligan
Player aiPlayer = AllZone.getComputerPlayer();
GamePlayerRating aiRating = AllZone.getGameInfo().getPlayerRating(PlayerIndex.AI);
@@ -95,24 +111,23 @@ public class Input_Mulligan extends Input {
for (Card c : humanOpeningHand) {
ArrayList<String> kws = c.getKeyword();
for(int i = 0;i<kws.size();i++) {
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);
}
}
}
@@ -121,25 +136,26 @@ public class Input_Mulligan extends Input {
for (Card c : aiOpeningHand) {
if (!c.getName().startsWith("Leyline")) {
ArrayList<String> kws = c.getKeyword();
for(int i = 0;i<kws.size();i++) {
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)) {
if (c.getName().startsWith("Leyline") && !(c.getName().startsWith("Leyline of Singularity")
&& 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);