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 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.abilityFactory.AbilityFactory;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.GamePlayerRating;
|
import forge.game.GamePlayerRating;
|
||||||
@@ -16,7 +25,7 @@ import forge.quest.data.QuestData;
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class Input_Mulligan extends Input {
|
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 long serialVersionUID = -8112954303001155622L;
|
||||||
|
|
||||||
private static final int MAGIC_NUMBER_OF_SHUFFLES = 100;
|
private static final int MAGIC_NUMBER_OF_SHUFFLES = 100;
|
||||||
@@ -24,7 +33,7 @@ public class Input_Mulligan extends Input {
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public void showMessage() {
|
public final void showMessage() {
|
||||||
ButtonUtil.enableAll();
|
ButtonUtil.enableAll();
|
||||||
AllZone.getDisplay().getButtonOK().setText("No");
|
AllZone.getDisplay().getButtonOK().setText("No");
|
||||||
AllZone.getDisplay().getButtonCancel().setText("Yes");
|
AllZone.getDisplay().getButtonCancel().setText("Yes");
|
||||||
@@ -33,11 +42,18 @@ public class Input_Mulligan extends Input {
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public void selectButtonOK() {
|
public final void selectButtonOK() {
|
||||||
end();
|
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);
|
CardList hand = AllZoneUtil.getPlayerHand(player);
|
||||||
for (Card c : hand) { AllZone.getGameAction().moveToLibrary(c); }
|
for (Card c : hand) { AllZone.getGameAction().moveToLibrary(c); }
|
||||||
for (int i = 0; i < MAGIC_NUMBER_OF_SHUFFLES; i++) { player.shuffle(); }
|
for (int i = 0; i < MAGIC_NUMBER_OF_SHUFFLES; i++) { player.shuffle(); }
|
||||||
@@ -50,7 +66,7 @@ public class Input_Mulligan extends Input {
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public void selectButtonCancel() {
|
public final void selectButtonCancel() {
|
||||||
GamePlayerRating humanRating = AllZone.getGameInfo().getPlayerRating(PlayerIndex.HUMAN);
|
GamePlayerRating humanRating = AllZone.getGameInfo().getPlayerRating(PlayerIndex.HUMAN);
|
||||||
Player humanPlayer = AllZone.getHumanPlayer();
|
Player humanPlayer = AllZone.getHumanPlayer();
|
||||||
|
|
||||||
@@ -65,12 +81,12 @@ public class Input_Mulligan extends Input {
|
|||||||
if (newHand == 0) {
|
if (newHand == 0) {
|
||||||
end();
|
end();
|
||||||
}
|
}
|
||||||
}//selectButtonOK()
|
} //selectButtonOK()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>end.</p>
|
* <p>end.</p>
|
||||||
*/
|
*/
|
||||||
void end() {
|
final void end() {
|
||||||
//Computer mulligan
|
//Computer mulligan
|
||||||
Player aiPlayer = AllZone.getComputerPlayer();
|
Player aiPlayer = AllZone.getComputerPlayer();
|
||||||
GamePlayerRating aiRating = AllZone.getGameInfo().getPlayerRating(PlayerIndex.AI);
|
GamePlayerRating aiRating = AllZone.getGameInfo().getPlayerRating(PlayerIndex.AI);
|
||||||
@@ -95,51 +111,51 @@ public class Input_Mulligan extends Input {
|
|||||||
|
|
||||||
for (Card c : humanOpeningHand) {
|
for (Card c : humanOpeningHand) {
|
||||||
ArrayList<String> kws = c.getKeyword();
|
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);
|
String kw = kws.get(i);
|
||||||
|
|
||||||
if(kw.startsWith("MayEffectFromOpeningHand"))
|
if (kw.startsWith("MayEffectFromOpeningHand")) {
|
||||||
{
|
|
||||||
String effName = kw.split(":")[1];
|
String effName = kw.split(":")[1];
|
||||||
|
|
||||||
SpellAbility effect = af.getAbility(c.getSVar(effName), c);
|
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.
|
//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);
|
AllZone.getGameAction().playSpellAbility_NoStack(effect, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (c.getName().startsWith("Leyline")) {
|
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);
|
AllZone.getGameAction().moveToPlay(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Computer Leylines & Chancellors
|
//Computer Leylines & Chancellors
|
||||||
CardList aiOpeningHand = AllZoneUtil.getPlayerHand(AllZone.getComputerPlayer());
|
CardList aiOpeningHand = AllZoneUtil.getPlayerHand(AllZone.getComputerPlayer());
|
||||||
for (Card c : aiOpeningHand) {
|
for (Card c : aiOpeningHand) {
|
||||||
if (!c.getName().startsWith("Leyline")) {
|
if (!c.getName().startsWith("Leyline")) {
|
||||||
ArrayList<String> kws = c.getKeyword();
|
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);
|
String kw = kws.get(i);
|
||||||
|
|
||||||
if(kw.startsWith("MayEffectFromOpeningHand"))
|
if (kw.startsWith("MayEffectFromOpeningHand")) {
|
||||||
{
|
|
||||||
String effName = kw.split(":")[1];
|
String effName = kw.split(":")[1];
|
||||||
|
|
||||||
SpellAbility effect = af.getAbility(c.getSVar(effName), c);
|
SpellAbility effect = af.getAbility(c.getSVar(effName), c);
|
||||||
|
|
||||||
if(effect.doTrigger(false)) //Is there a better way for the AI to decide this?
|
//Is there a better way for the AI to decide this?
|
||||||
{
|
if (effect.doTrigger(false)) {
|
||||||
GameActionUtil.showInfoDialg("Computer reveals " + c.getName() + "(" + c.getUniqueNumber() + ").");
|
GameActionUtil.showInfoDialg("Computer reveals "
|
||||||
|
+ c.getName() + "(" + c.getUniqueNumber() + ").");
|
||||||
ComputerUtil.playNoStack(effect);
|
ComputerUtil.playNoStack(effect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (c.getName().startsWith("Leyline") && !(c.getName().startsWith("Leyline of Singularity")
|
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().moveToPlay(c);
|
||||||
AllZone.getGameAction().checkStateEffects();
|
AllZone.getGameAction().checkStateEffects();
|
||||||
}
|
}
|
||||||
@@ -148,9 +164,12 @@ public class Input_Mulligan extends Input {
|
|||||||
|
|
||||||
|
|
||||||
if (AllZone.getGameAction().isStartCut() && !(humanOpeningHand.contains(AllZone.getGameAction().getHumanCut())
|
if (AllZone.getGameAction().isStartCut() && !(humanOpeningHand.contains(AllZone.getGameAction().getHumanCut())
|
||||||
|| aiOpeningHand.contains(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().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();
|
AllZone.getGameAction().checkStateEffects();
|
||||||
Phase.setGameBegins(1);
|
Phase.setGameBegins(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user