mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Checkstyle fixes in several files
This commit is contained in:
@@ -22,7 +22,7 @@ class CCnt {
|
||||
* @param clr a {@link java.lang.String} object.
|
||||
* @param cnt a int.
|
||||
*/
|
||||
public CCnt(String clr, int cnt) {
|
||||
public CCnt(final String clr, final int cnt) {
|
||||
Color = clr;
|
||||
Count = cnt;
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ public interface CardContainer {
|
||||
*
|
||||
* @param card a {@link forge.Card} object.
|
||||
*/
|
||||
public void setCard(Card card);
|
||||
void setCard(Card card);
|
||||
|
||||
/**
|
||||
* <p>getCard.</p>
|
||||
*
|
||||
* @return a {@link forge.Card} object.
|
||||
*/
|
||||
public Card getCard();
|
||||
Card getCard();
|
||||
}
|
||||
|
||||
@@ -23,21 +23,22 @@ public class Card_Type implements Comparable<Card_Type> {
|
||||
*
|
||||
* @return a long.
|
||||
*/
|
||||
public long getTimestamp() {
|
||||
public final long getTimestamp() {
|
||||
return timeStamp;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param types
|
||||
* @param removeSuperType
|
||||
* @param removeCardType
|
||||
* @param removeSubType
|
||||
* @param removeCreatureType
|
||||
* @param stamp
|
||||
* @param types an ArrayList<String>
|
||||
* @param removeSuperType a boolean
|
||||
* @param removeCardType a boolean
|
||||
* @param removeSubType a boolean
|
||||
* @param removeCreatureType a boolean
|
||||
* @param stamp a long
|
||||
*/
|
||||
Card_Type(ArrayList<String> types, boolean removeSuperType, boolean removeCardType, boolean removeSubType,
|
||||
boolean removeCreatureType, long stamp) {
|
||||
Card_Type(final ArrayList<String> types, final boolean removeSuperType, final boolean removeCardType,
|
||||
final boolean removeSubType, final boolean removeCreatureType, final long stamp)
|
||||
{
|
||||
type = types;
|
||||
removeSuperTypes = removeSuperType;
|
||||
removeCardTypes = removeCardType;
|
||||
@@ -46,34 +47,60 @@ public class Card_Type implements Comparable<Card_Type> {
|
||||
timeStamp = stamp;
|
||||
}
|
||||
|
||||
public ArrayList<String> getType() {
|
||||
/**
|
||||
*
|
||||
* TODO Write javadoc for this method.
|
||||
* @return type
|
||||
*/
|
||||
public final ArrayList<String> getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean isRemoveSuperTypes() {
|
||||
/**
|
||||
*
|
||||
* TODO Write javadoc for this method.
|
||||
* @return removeSuperTypes
|
||||
*/
|
||||
public final boolean isRemoveSuperTypes() {
|
||||
return removeSuperTypes;
|
||||
}
|
||||
|
||||
public boolean isRemoveCardTypes() {
|
||||
/**
|
||||
*
|
||||
* TODO Write javadoc for this method.
|
||||
* @return removeCardTypes
|
||||
*/
|
||||
public final boolean isRemoveCardTypes() {
|
||||
return removeCardTypes;
|
||||
}
|
||||
|
||||
public boolean isRemoveSubTypes() {
|
||||
/**
|
||||
*
|
||||
* TODO Write javadoc for this method.
|
||||
* @return removeSubTypes
|
||||
*/
|
||||
public final boolean isRemoveSubTypes() {
|
||||
return removeSubTypes;
|
||||
}
|
||||
|
||||
public boolean isRemoveCreatureTypes() {
|
||||
/**
|
||||
*
|
||||
* TODO Write javadoc for this method.
|
||||
* @return removeCreatureTypes
|
||||
*/
|
||||
public final boolean isRemoveCreatureTypes() {
|
||||
return removeCreatureTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(final Card_Type anotherCardType) {
|
||||
public final int compareTo(final Card_Type anotherCardType) {
|
||||
int returnValue = 0;
|
||||
long anotherTimeStamp = anotherCardType.getTimestamp();
|
||||
if (this.timeStamp < anotherTimeStamp)
|
||||
if (this.timeStamp < anotherTimeStamp) {
|
||||
returnValue = -1;
|
||||
else if (this.timeStamp > anotherTimeStamp)
|
||||
} else if (this.timeStamp > anotherTimeStamp) {
|
||||
returnValue = 1;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public enum Color {
|
||||
*
|
||||
* @param c a int.
|
||||
*/
|
||||
Color(int c) {
|
||||
Color(final int c) {
|
||||
flag = c;
|
||||
}
|
||||
|
||||
@@ -53,8 +53,9 @@ public enum Color {
|
||||
colors.add(ConvertFromString(s[i]));
|
||||
}
|
||||
|
||||
if (colors.size() > 1)
|
||||
if (colors.size() > 1) {
|
||||
colors.remove(Color.Colorless);
|
||||
}
|
||||
|
||||
return colors;
|
||||
}
|
||||
@@ -67,16 +68,17 @@ public enum Color {
|
||||
*/
|
||||
public static Color ConvertFromString(String s) {
|
||||
{
|
||||
if (s.equals(Constant.Color.White))
|
||||
if (s.equals(Constant.Color.White)) {
|
||||
return Color.White;
|
||||
else if (s.equals(Constant.Color.Green))
|
||||
} else if (s.equals(Constant.Color.Green)) {
|
||||
return Color.Green;
|
||||
else if (s.equals(Constant.Color.Red))
|
||||
} else if (s.equals(Constant.Color.Red)) {
|
||||
return Color.Red;
|
||||
else if (s.equals(Constant.Color.Black))
|
||||
} else if (s.equals(Constant.Color.Black)) {
|
||||
return Color.Black;
|
||||
else if (s.equals(Constant.Color.Blue))
|
||||
} else if (s.equals(Constant.Color.Blue)) {
|
||||
return Color.Blue;
|
||||
}
|
||||
|
||||
return Color.Colorless;
|
||||
}
|
||||
@@ -88,22 +90,28 @@ public enum Color {
|
||||
* @param m a {@link forge.card.mana.ManaCost} object.
|
||||
* @return a {@link java.util.EnumSet} object.
|
||||
*/
|
||||
public static EnumSet<Color> ConvertManaCostToColor(ManaCost m) {
|
||||
public static EnumSet<Color> ConvertManaCostToColor(final ManaCost m) {
|
||||
EnumSet<Color> colors = EnumSet.of(Color.Colorless);
|
||||
|
||||
if (m.isColor("W"))
|
||||
if (m.isColor("W")) {
|
||||
colors.add(Color.White);
|
||||
if (m.isColor("G"))
|
||||
}
|
||||
if (m.isColor("G")) {
|
||||
colors.add(Color.Green);
|
||||
if (m.isColor("R"))
|
||||
}
|
||||
if (m.isColor("R")) {
|
||||
colors.add(Color.Red);
|
||||
if (m.isColor("B"))
|
||||
}
|
||||
if (m.isColor("B")) {
|
||||
colors.add(Color.Black);
|
||||
if (m.isColor("U"))
|
||||
}
|
||||
if (m.isColor("U")) {
|
||||
colors.add(Color.Blue);
|
||||
}
|
||||
|
||||
if (colors.size() > 1)
|
||||
if (colors.size() > 1) {
|
||||
colors.remove(Color.Colorless);
|
||||
}
|
||||
|
||||
return colors;
|
||||
}
|
||||
@@ -114,17 +122,18 @@ public enum Color {
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String toString() {
|
||||
if (this.equals(Color.White))
|
||||
if (this.equals(Color.White)) {
|
||||
return Constant.Color.White;
|
||||
else if (this.equals(Color.Green))
|
||||
} else if (this.equals(Color.Green)) {
|
||||
return Constant.Color.Green;
|
||||
else if (this.equals(Color.Red))
|
||||
} else if (this.equals(Color.Red)) {
|
||||
return Constant.Color.Red;
|
||||
else if (this.equals(Color.Black))
|
||||
} else if (this.equals(Color.Black)) {
|
||||
return Constant.Color.Black;
|
||||
else if (this.equals(Color.Blue))
|
||||
} else if (this.equals(Color.Blue)) {
|
||||
return Constant.Color.Blue;
|
||||
else
|
||||
} else {
|
||||
return Constant.Color.Colorless;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,11 @@ import java.util.ArrayList;
|
||||
|
||||
import forge.card.mana.ManaCost;
|
||||
|
||||
/**
|
||||
* class ColorChanger.
|
||||
* TODO Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public class ColorChanger {
|
||||
private ArrayList<Card_Color> globalColorChanges = new ArrayList<Card_Color>();
|
||||
|
||||
@@ -17,7 +22,9 @@ public class ColorChanger {
|
||||
* @param bIncrease a boolean.
|
||||
* @return a long.
|
||||
*/
|
||||
public long addColorChanges(String s, Card c, boolean addToColors, boolean bIncrease) {
|
||||
public final long addColorChanges(final String s, final Card c, final boolean addToColors,
|
||||
final boolean bIncrease)
|
||||
{
|
||||
if (bIncrease) {
|
||||
Card_Color.increaseTimestamp();
|
||||
}
|
||||
@@ -33,7 +40,7 @@ public class ColorChanger {
|
||||
* @param addTo a boolean.
|
||||
* @param timestamp a long.
|
||||
*/
|
||||
public final void removeColorChanges(String s, Card c, boolean addTo, long timestamp) {
|
||||
public final void removeColorChanges(final String s, final Card c, final boolean addTo, final long timestamp) {
|
||||
Card_Color removeCol = null;
|
||||
for (Card_Color cc : globalColorChanges) {
|
||||
if (cc.equals(s, c, addTo, timestamp)) {
|
||||
|
||||
@@ -12,5 +12,5 @@ public interface CommandArgs extends java.io.Serializable {
|
||||
*
|
||||
* @param o a {@link java.lang.Object} object.
|
||||
*/
|
||||
public void execute(Object o);
|
||||
void execute(Object o);
|
||||
}
|
||||
|
||||
@@ -10,16 +10,25 @@ import java.util.Iterator;
|
||||
* @version $Id$
|
||||
*/
|
||||
public class CommandList implements java.io.Serializable, Command, Iterable<Command> {
|
||||
/** Constant <code>serialVersionUID=-1532687201812613302L</code> */
|
||||
/** Constant <code>serialVersionUID=-1532687201812613302L</code>. */
|
||||
private static final long serialVersionUID = -1532687201812613302L;
|
||||
|
||||
private ArrayList<Command> a = new ArrayList<Command>();
|
||||
|
||||
/**
|
||||
* default constructor
|
||||
* TODO Write javadoc for Constructor.
|
||||
*/
|
||||
public CommandList() {
|
||||
;
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
public CommandList(Command c) {
|
||||
/**
|
||||
* constructor
|
||||
* TODO Write javadoc for Constructor.
|
||||
* @param c a Command
|
||||
*/
|
||||
public CommandList(final Command c) {
|
||||
a.add(c);
|
||||
}
|
||||
|
||||
@@ -28,7 +37,7 @@ public class CommandList implements java.io.Serializable, Command, Iterable<Comm
|
||||
*
|
||||
* @return a {@link java.util.Iterator} object.
|
||||
*/
|
||||
public Iterator<Command> iterator() {
|
||||
public final Iterator<Command> iterator() {
|
||||
return a.iterator();
|
||||
}
|
||||
|
||||
@@ -40,7 +49,7 @@ public class CommandList implements java.io.Serializable, Command, Iterable<Comm
|
||||
*
|
||||
* @param c a {@link forge.Command} object.
|
||||
*/
|
||||
public void add(Command c) {
|
||||
public final void add(final Command c) {
|
||||
a.add(0, c);
|
||||
}
|
||||
|
||||
@@ -51,7 +60,7 @@ public class CommandList implements java.io.Serializable, Command, Iterable<Comm
|
||||
* @param i a int.
|
||||
* @return a {@link forge.Command} object.
|
||||
*/
|
||||
public Command get(int i) {
|
||||
public final Command get(final int i) {
|
||||
return (Command) a.get(i);
|
||||
}
|
||||
|
||||
@@ -61,7 +70,7 @@ public class CommandList implements java.io.Serializable, Command, Iterable<Comm
|
||||
* @param i a int.
|
||||
* @return a {@link forge.Command} object.
|
||||
*/
|
||||
public Command remove(int i) {
|
||||
public final Command remove(final int i) {
|
||||
return (Command) a.remove(i);
|
||||
}
|
||||
|
||||
@@ -70,23 +79,24 @@ public class CommandList implements java.io.Serializable, Command, Iterable<Comm
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public int size() {
|
||||
public final int size() {
|
||||
return a.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>clear.</p>
|
||||
*/
|
||||
public void clear() {
|
||||
public final void clear() {
|
||||
a.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>execute.</p>
|
||||
*/
|
||||
public void execute() {
|
||||
for (int i = 0; i < size(); i++)
|
||||
public final void execute() {
|
||||
for (int i = 0; i < size(); i++) {
|
||||
get(i).execute();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,5 +12,5 @@ public interface CommandReturn {
|
||||
*
|
||||
* @return a {@link java.lang.Object} object.
|
||||
*/
|
||||
public Object execute();
|
||||
Object execute();
|
||||
}
|
||||
|
||||
@@ -10,51 +10,51 @@ public interface Computer {
|
||||
/**
|
||||
* <p>main1.</p>
|
||||
*/
|
||||
public void main1();
|
||||
void main1();
|
||||
|
||||
/**
|
||||
* <p>begin_combat.</p>
|
||||
*/
|
||||
public void begin_combat();
|
||||
void begin_combat();
|
||||
|
||||
/**
|
||||
* <p>declare_attackers.</p>
|
||||
*/
|
||||
public void declare_attackers();
|
||||
void declare_attackers();
|
||||
|
||||
/**
|
||||
* <p>declare_attackers_after.</p>
|
||||
*/
|
||||
public void declare_attackers_after(); //can play Instants and Abilities
|
||||
void declare_attackers_after(); //can play Instants and Abilities
|
||||
|
||||
/**
|
||||
* <p>declare_blockers.</p>
|
||||
*/
|
||||
public void declare_blockers();//this is called after when the Human or Computer blocks
|
||||
void declare_blockers(); //this is called after when the Human or Computer blocks
|
||||
|
||||
/**
|
||||
* <p>declare_blockers_after.</p>
|
||||
*/
|
||||
public void declare_blockers_after();//can play Instants and Abilities
|
||||
void declare_blockers_after(); //can play Instants and Abilities
|
||||
|
||||
/**
|
||||
* <p>end_of_combat.</p>
|
||||
*/
|
||||
public void end_of_combat();
|
||||
void end_of_combat();
|
||||
|
||||
/**
|
||||
* <p>main2.</p>
|
||||
*/
|
||||
public void main2();
|
||||
void main2();
|
||||
|
||||
/**
|
||||
* <p>end_of_turn.</p>
|
||||
*/
|
||||
public void end_of_turn();//end of Human's turn
|
||||
void end_of_turn();//end of Human's turn
|
||||
|
||||
/**
|
||||
* <p>stack_not_empty.</p>
|
||||
*/
|
||||
public void stack_not_empty();
|
||||
void stack_not_empty();
|
||||
|
||||
}
|
||||
|
||||
@@ -28,26 +28,28 @@ public class ComputerAI_General implements Computer {
|
||||
/**
|
||||
* <p>main1.</p>
|
||||
*/
|
||||
public void main1() {
|
||||
public final void main1() {
|
||||
ComputerUtil.chooseLandsToPlay();
|
||||
|
||||
if (AllZone.getStack().size() == 0)
|
||||
if (AllZone.getStack().size() == 0) {
|
||||
playCards(Constant.Phase.Main1);
|
||||
else
|
||||
} else {
|
||||
stackResponse();
|
||||
}//main1()
|
||||
}
|
||||
} //main1()
|
||||
|
||||
/**
|
||||
* <p>main2.</p>
|
||||
*/
|
||||
public void main2() {
|
||||
public final void main2() {
|
||||
ComputerUtil.chooseLandsToPlay();
|
||||
|
||||
if (AllZone.getStack().size() == 0)
|
||||
if (AllZone.getStack().size() == 0) {
|
||||
playCards(Constant.Phase.Main2);
|
||||
else
|
||||
} else {
|
||||
stackResponse();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>playCards.</p>
|
||||
@@ -62,7 +64,7 @@ public class ComputerAI_General implements Computer {
|
||||
if (nextPhase) {
|
||||
AllZone.getPhase().passPriority();
|
||||
}
|
||||
}//playCards()
|
||||
} //playCards()
|
||||
|
||||
/**
|
||||
* <p>getMain1.</p>
|
||||
@@ -73,40 +75,52 @@ public class ComputerAI_General implements Computer {
|
||||
//Card list of all cards to consider
|
||||
CardList hand = AllZoneUtil.getPlayerHand(AllZone.getComputerPlayer());
|
||||
|
||||
if (AllZone.getComputerManaPool().isEmpty())
|
||||
if (AllZone.getComputerManaPool().isEmpty()) {
|
||||
hand = hand.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
public boolean addCard(final Card c) {
|
||||
|
||||
if (c.getSVar("PlayMain1").equals("TRUE"))
|
||||
if (c.getSVar("PlayMain1").equals("TRUE")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (c.isSorcery() || c.isAura()) //timing should be handled by the AF's
|
||||
//timing should be handled by the AF's
|
||||
if (c.isSorcery() || c.isAura()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (c.isCreature()
|
||||
&& (c.hasKeyword("Haste")) || c.hasKeyword("Exalted")) return true;
|
||||
if (c.isCreature() && (c.hasKeyword("Haste")) || c.hasKeyword("Exalted")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CardList buffed = AllZoneUtil.getPlayerCardsInPlay(AllZone.getComputerPlayer()); //get all cards the computer controls with BuffedBy
|
||||
//get all cards the computer controls with BuffedBy
|
||||
CardList buffed = AllZoneUtil.getPlayerCardsInPlay(AllZone.getComputerPlayer());
|
||||
for (int j = 0; j < buffed.size(); j++) {
|
||||
Card buffedcard = buffed.get(j);
|
||||
if (buffedcard.getSVar("BuffedBy").length() > 0) {
|
||||
String buffedby = buffedcard.getSVar("BuffedBy");
|
||||
String bffdby[] = buffedby.split(",");
|
||||
if (c.isValidCard(bffdby, c.getController(), c)) return true;
|
||||
String[] bffdby = buffedby.split(",");
|
||||
if (c.isValidCard(bffdby, c.getController(), c)) {
|
||||
return true;
|
||||
}
|
||||
}//BuffedBy
|
||||
}
|
||||
} //BuffedBy
|
||||
|
||||
CardList antibuffed = AllZoneUtil.getPlayerCardsInPlay(AllZone.getHumanPlayer()); //get all cards the human controls with AntiBuffedBy
|
||||
//get all cards the human controls with AntiBuffedBy
|
||||
CardList antibuffed = AllZoneUtil.getPlayerCardsInPlay(AllZone.getHumanPlayer());
|
||||
for (int k = 0; k < antibuffed.size(); k++) {
|
||||
Card buffedcard = antibuffed.get(k);
|
||||
if (buffedcard.getSVar("AntiBuffedBy").length() > 0) {
|
||||
String buffedby = buffedcard.getSVar("AntiBuffedBy");
|
||||
String bffdby[] = buffedby.split(",");
|
||||
if (c.isValidCard(bffdby, c.getController(), c)) return true;
|
||||
String[] bffdby = buffedby.split(",");
|
||||
if (c.isValidCard(bffdby, c.getController(), c)) {
|
||||
return true;
|
||||
}
|
||||
}//AntiBuffedBy
|
||||
}
|
||||
} //AntiBuffedBy
|
||||
|
||||
if (c.isLand()) return false;
|
||||
if (c.isLand()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CardList vengevines = AllZoneUtil.getPlayerGraveyard(AllZone.getComputerPlayer(), "Vengevine");
|
||||
if (vengevines.size() > 0) {
|
||||
@@ -120,18 +134,21 @@ public class ComputerAI_General implements Computer {
|
||||
}
|
||||
if (creatures2.size() + Phase.getComputerCreatureSpellCount() > 1
|
||||
&& c.isCreature()
|
||||
&& CardUtil.getConvertedManaCost(c.getManaCost()) <= 3) return true;
|
||||
&& CardUtil.getConvertedManaCost(c.getManaCost()) <= 3) {
|
||||
return true;
|
||||
}
|
||||
} // AI Improvement for Vengevine
|
||||
// Beached As End
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
CardList all = AllZoneUtil.getPlayerCardsInPlay(AllZone.getComputerPlayer());
|
||||
all.addAll(hand);
|
||||
|
||||
CardList humanPlayable = AllZoneUtil.getPlayerCardsInPlay(AllZone.getHumanPlayer());
|
||||
humanPlayable = humanPlayable.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
public boolean addCard(final Card c) {
|
||||
return (c.canAnyPlayerActivate());
|
||||
}
|
||||
});
|
||||
@@ -139,7 +156,7 @@ public class ComputerAI_General implements Computer {
|
||||
all.addAll(humanPlayable);
|
||||
|
||||
return getPlayable(all);
|
||||
}//getMain1()
|
||||
} //getMain1()
|
||||
|
||||
|
||||
/**
|
||||
@@ -152,12 +169,14 @@ public class ComputerAI_General implements Computer {
|
||||
CardList all = AllZoneUtil.getPlayerHand(AllZone.getComputerPlayer());
|
||||
//Don't play permanents with Flash before humans declare attackers step
|
||||
all = all.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
public boolean addCard(final Card c) {
|
||||
if (c.isPermanent()
|
||||
&& c.hasKeyword("Flash")
|
||||
&& (AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer())
|
||||
|| AllZone.getPhase().isBefore(Constant.Phase.Combat_Declare_Attackers_InstantAbility)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@@ -168,22 +187,24 @@ public class ComputerAI_General implements Computer {
|
||||
all = all.getNotKeyword("At the beginning of the end step, sacrifice CARDNAME.");
|
||||
|
||||
all = all.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
if (c.isLand()) return false;
|
||||
public boolean addCard(final Card c) {
|
||||
if (c.isLand()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
CardList humanPlayable = AllZoneUtil.getPlayerCardsInPlay(AllZone.getHumanPlayer());
|
||||
humanPlayable = humanPlayable.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
public boolean addCard(final Card c) {
|
||||
return (c.canAnyPlayerActivate());
|
||||
}
|
||||
});
|
||||
all.addAll(humanPlayable);
|
||||
|
||||
return getPlayable(all);
|
||||
}//getMain2()
|
||||
} //getMain2()
|
||||
|
||||
/**
|
||||
* <p>getAvailableSpellAbilities.</p>
|
||||
@@ -194,12 +215,14 @@ public class ComputerAI_General implements Computer {
|
||||
CardList all = AllZoneUtil.getPlayerHand(AllZone.getComputerPlayer());
|
||||
//Don't play permanents with Flash before humans declare attackers step
|
||||
all = all.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
public boolean addCard(final Card c) {
|
||||
if (c.isPermanent()
|
||||
&& c.hasKeyword("Flash")
|
||||
&& (AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer())
|
||||
|| AllZone.getPhase().isBefore(Constant.Phase.Combat_Declare_Attackers_InstantAbility)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@@ -209,7 +232,7 @@ public class ComputerAI_General implements Computer {
|
||||
|
||||
CardList humanPlayable = AllZoneUtil.getPlayerCardsInPlay(AllZone.getHumanPlayer());
|
||||
humanPlayable = humanPlayable.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
public boolean addCard(final Card c) {
|
||||
return (c.canAnyPlayerActivate());
|
||||
}
|
||||
});
|
||||
@@ -245,15 +268,15 @@ public class ComputerAI_General implements Computer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the spellAbilities from the card list that the computer is able to play
|
||||
* Returns the spellAbilities from the card list that the computer is able to play.
|
||||
*
|
||||
* @param l a {@link forge.CardList} object.
|
||||
* @return an array of {@link forge.card.spellability.SpellAbility} objects.
|
||||
*/
|
||||
private SpellAbility[] getPlayable(CardList l) {
|
||||
private SpellAbility[] getPlayable(final CardList l) {
|
||||
ArrayList<SpellAbility> spellAbility = new ArrayList<SpellAbility>();
|
||||
for (Card c : l)
|
||||
for (SpellAbility sa : c.getSpellAbility())
|
||||
for (Card c : l) {
|
||||
for (SpellAbility sa : c.getSpellAbility()) {
|
||||
// if SA is from AF_Counter don't add to getPlayable
|
||||
//This try/catch should fix the "computer is thinking" bug
|
||||
try {
|
||||
@@ -264,6 +287,8 @@ public class ComputerAI_General implements Computer {
|
||||
} catch (Exception ex) {
|
||||
showError(ex, "There is an error in the card code for %s:%n", c.getName(), ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
return spellAbility.toArray(new SpellAbility[spellAbility.size()]);
|
||||
}
|
||||
|
||||
@@ -273,15 +298,16 @@ public class ComputerAI_General implements Computer {
|
||||
* @param l a {@link forge.CardList} object.
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
private ArrayList<SpellAbility> getPlayableCounters(CardList l) {
|
||||
private ArrayList<SpellAbility> getPlayableCounters(final CardList l) {
|
||||
ArrayList<SpellAbility> spellAbility = new ArrayList<SpellAbility>();
|
||||
for (Card c : l) {
|
||||
for (SpellAbility sa : c.getSpellAbility()) {
|
||||
// Check if this AF is a Counterpsell
|
||||
if (sa.getAbilityFactory() != null && sa.getAbilityFactory().getAPI().equals("Counter"))
|
||||
if (sa.getAbilityFactory() != null && sa.getAbilityFactory().getAPI().equals("Counter")) {
|
||||
spellAbility.add(sa);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return spellAbility;
|
||||
}
|
||||
@@ -292,17 +318,18 @@ public class ComputerAI_General implements Computer {
|
||||
* @param l a {@link forge.CardList} object.
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
private ArrayList<SpellAbility> getETBCounters(CardList l) {
|
||||
private ArrayList<SpellAbility> getETBCounters(final CardList l) {
|
||||
ArrayList<SpellAbility> spellAbility = new ArrayList<SpellAbility>();
|
||||
for (Card c : l) {
|
||||
for (SpellAbility sa : c.getSpellAbility()) {
|
||||
// Or if this Permanent has an ETB ability with Counter
|
||||
if (sa instanceof Spell_Permanent) {
|
||||
if (Spell_Permanent.checkETBEffects(c, sa, "Counter"))
|
||||
if (Spell_Permanent.checkETBEffects(c, sa, "Counter")) {
|
||||
spellAbility.add(sa);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return spellAbility;
|
||||
}
|
||||
@@ -310,21 +337,22 @@ public class ComputerAI_General implements Computer {
|
||||
/**
|
||||
* <p>begin_combat.</p>
|
||||
*/
|
||||
public void begin_combat() {
|
||||
public final void begin_combat() {
|
||||
stackResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>declare_attackers.</p>
|
||||
*/
|
||||
public void declare_attackers() {
|
||||
public final void declare_attackers() {
|
||||
// 12/2/10(sol) the decision making here has moved to getAttackers()
|
||||
|
||||
AllZone.setCombat(ComputerUtil.getAttackers());
|
||||
|
||||
Card[] att = AllZone.getCombat().getAttackers();
|
||||
if (att.length > 0)
|
||||
if (att.length > 0) {
|
||||
AllZone.getPhase().setCombat(true);
|
||||
}
|
||||
|
||||
for (int i = 0; i < att.length; i++) {
|
||||
// tapping of attackers happens after Propaganda is paid for
|
||||
@@ -341,14 +369,14 @@ public class ComputerAI_General implements Computer {
|
||||
/**
|
||||
* <p>declare_attackers_after.</p>
|
||||
*/
|
||||
public void declare_attackers_after() {
|
||||
public final void declare_attackers_after() {
|
||||
stackResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>declare_blockers.</p>
|
||||
*/
|
||||
public void declare_blockers() {
|
||||
public final void declare_blockers() {
|
||||
CardList blockers = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer());
|
||||
|
||||
AllZone.setCombat(ComputerUtil_Block2.getBlockers(AllZone.getCombat(), blockers));
|
||||
@@ -361,14 +389,14 @@ public class ComputerAI_General implements Computer {
|
||||
/**
|
||||
* <p>declare_blockers_after.</p>
|
||||
*/
|
||||
public void declare_blockers_after() {
|
||||
public final void declare_blockers_after() {
|
||||
stackResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>end_of_combat.</p>
|
||||
*/
|
||||
public void end_of_combat() {
|
||||
public final void end_of_combat() {
|
||||
stackResponse();
|
||||
}
|
||||
|
||||
@@ -376,35 +404,37 @@ public class ComputerAI_General implements Computer {
|
||||
/**
|
||||
* <p>end_of_turn.</p>
|
||||
*/
|
||||
public void end_of_turn() {
|
||||
public final void end_of_turn() {
|
||||
stackResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>stack_not_empty.</p>
|
||||
*/
|
||||
public void stack_not_empty() {
|
||||
public final void stack_not_empty() {
|
||||
stackResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>stackResponse.</p>
|
||||
*/
|
||||
public void stackResponse() {
|
||||
public final void stackResponse() {
|
||||
// if top of stack is empty
|
||||
SpellAbility[] sas = null;
|
||||
if (AllZone.getStack().size() == 0) {
|
||||
sas = getOtherPhases();
|
||||
|
||||
boolean pass = (sas.length == 0) || AllZone.getPhase().is(Constant.Phase.Upkeep, AllZone.getComputerPlayer()) ||
|
||||
AllZone.getPhase().is(Constant.Phase.Draw, AllZone.getComputerPlayer()) ||
|
||||
AllZone.getPhase().is(Constant.Phase.End_Of_Turn, AllZone.getComputerPlayer());
|
||||
boolean pass = (sas.length == 0)
|
||||
|| AllZone.getPhase().is(Constant.Phase.Upkeep, AllZone.getComputerPlayer())
|
||||
|| AllZone.getPhase().is(Constant.Phase.Draw, AllZone.getComputerPlayer())
|
||||
|| AllZone.getPhase().is(Constant.Phase.End_Of_Turn, AllZone.getComputerPlayer());
|
||||
if (!pass) { // Each AF should check the phase individually
|
||||
pass = ComputerUtil.playCards(sas);
|
||||
}
|
||||
|
||||
if (pass)
|
||||
if (pass) {
|
||||
AllZone.getPhase().passPriority();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -435,9 +465,10 @@ public class ComputerAI_General implements Computer {
|
||||
sas = getOtherPhases();
|
||||
if (sas.length > 0) {
|
||||
// Spell not Countered
|
||||
if (!ComputerUtil.playCards(sas))
|
||||
if (!ComputerUtil.playCards(sas)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if this hasn't been covered above, just PassPriority()
|
||||
AllZone.getPhase().passPriority();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import forge.gui.input.Input;
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ComputerAI_Input extends Input {
|
||||
/** Constant <code>serialVersionUID=-3091338639571662216L</code> */
|
||||
/** Constant <code>serialVersionUID=-3091338639571662216L</code>. */
|
||||
private static final long serialVersionUID = -3091338639571662216L;
|
||||
|
||||
private final Computer computer;
|
||||
@@ -19,10 +19,10 @@ public class ComputerAI_Input extends Input {
|
||||
/**
|
||||
* <p>Constructor for ComputerAI_Input.</p>
|
||||
*
|
||||
* @param i_computer a {@link forge.Computer} object.
|
||||
* @param iComputer a {@link forge.Computer} object.
|
||||
*/
|
||||
public ComputerAI_Input(Computer i_computer) {
|
||||
computer = i_computer;
|
||||
public ComputerAI_Input(final Computer iComputer) {
|
||||
computer = iComputer;
|
||||
}
|
||||
|
||||
//wrapper method that ComputerAI_StackNotEmpty class calls
|
||||
@@ -30,29 +30,30 @@ public class ComputerAI_Input extends Input {
|
||||
/**
|
||||
* <p>stackNotEmpty.</p>
|
||||
*/
|
||||
public void stackNotEmpty() {
|
||||
public final void stackNotEmpty() {
|
||||
computer.stack_not_empty();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void showMessage() {
|
||||
public final void showMessage() {
|
||||
/*
|
||||
* //put this back in
|
||||
ButtonUtil.disableAll();
|
||||
AllZone.getDisplay().showMessage("Phase: "
|
||||
+ AllZone.getPhase().getPhase()
|
||||
+ "\nAn error may have occurred. Please send the \"Stack Report\" and the \"Detailed Error Trace\" to the Forge forum.");
|
||||
+ "\nAn error may have occurred. Please send the \"Stack Report\" and the
|
||||
\"Detailed Error Trace\" to the Forge forum.");
|
||||
*/
|
||||
think();
|
||||
}//getMessage();
|
||||
} //getMessage();
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>computer</code>.</p>
|
||||
*
|
||||
* @return a {@link forge.Computer} object.
|
||||
*/
|
||||
public Computer getComputer() {
|
||||
public final Computer getComputer() {
|
||||
return computer;
|
||||
}
|
||||
|
||||
@@ -60,12 +61,12 @@ public class ComputerAI_Input extends Input {
|
||||
* <p>think.</p>
|
||||
*/
|
||||
private void think() {
|
||||
//TODO: instead of setNextPhase, pass priority
|
||||
//TODO instead of setNextPhase, pass priority
|
||||
final String phase = AllZone.getPhase().getPhase();
|
||||
|
||||
if (AllZone.getStack().size() > 0)
|
||||
if (AllZone.getStack().size() > 0) {
|
||||
computer.stack_not_empty();
|
||||
else if (phase.equals(Constant.Phase.Main1)) {
|
||||
} else if (phase.equals(Constant.Phase.Main1)) {
|
||||
Log.debug("Computer main1");
|
||||
computer.main1();
|
||||
} else if (phase.equals(Constant.Phase.Combat_Begin)) {
|
||||
@@ -81,8 +82,9 @@ public class ComputerAI_Input extends Input {
|
||||
} else if (phase.equals(Constant.Phase.Main2)) {
|
||||
Log.debug("Computer main2");
|
||||
computer.main2();
|
||||
} else
|
||||
} else {
|
||||
computer.stack_not_empty();
|
||||
}
|
||||
|
||||
}//think
|
||||
} //think
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ComputerUtil_Attack2 {
|
||||
private final int randomInt = random.nextInt();
|
||||
|
||||
private CardList humanList; //holds human player creatures
|
||||
private CardList computerList;//holds computer creatures
|
||||
private CardList computerList; //holds computer creatures
|
||||
|
||||
private int aiAggression = 0; // added by Masher, how aggressive the ai attack will be depending on circumstances
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ComputerUtil_Attack2 {
|
||||
* @param possibleBlockers a {@link forge.CardList} object.
|
||||
* @param blockerLife a int.
|
||||
*/
|
||||
public ComputerUtil_Attack2(CardList possibleAttackers, CardList possibleBlockers, int blockerLife) {
|
||||
public ComputerUtil_Attack2(final CardList possibleAttackers, CardList possibleBlockers, int blockerLife) {
|
||||
humanList = new CardList(possibleBlockers.toArray());
|
||||
humanList = humanList.getType("Creature");
|
||||
|
||||
@@ -60,7 +60,7 @@ public class ComputerUtil_Attack2 {
|
||||
attackers = getPossibleAttackers(possibleAttackers);
|
||||
blockers = getPossibleBlockers(possibleBlockers, attackers);
|
||||
this.blockerLife = blockerLife;
|
||||
}//constructor
|
||||
} //constructor
|
||||
|
||||
/**
|
||||
* <p>sortAttackers.</p>
|
||||
@@ -68,7 +68,7 @@ public class ComputerUtil_Attack2 {
|
||||
* @param in a {@link forge.CardList} object.
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
public CardList sortAttackers(CardList in) {
|
||||
public final CardList sortAttackers(final CardList in) {
|
||||
CardList list = new CardList();
|
||||
|
||||
//Cards with triggers should come first (for Battle Cry)
|
||||
@@ -76,17 +76,20 @@ public class ComputerUtil_Attack2 {
|
||||
ArrayList<Trigger> registeredTriggers = AllZone.getTriggerHandler().getRegisteredTriggers();
|
||||
for (Trigger trigger : registeredTriggers) {
|
||||
HashMap<String, String> trigParams = trigger.getMapParams();
|
||||
if (trigParams.get("Mode").equals("Attacks") && trigger.getHostCard().equals(attacker))
|
||||
if (trigParams.get("Mode").equals("Attacks") && trigger.getHostCard().equals(attacker)) {
|
||||
list.add(attacker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Card attacker : in) {
|
||||
if (!list.contains(attacker)) list.add(attacker);
|
||||
if (!list.contains(attacker)) {
|
||||
list.add(attacker);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}//sortAttackers()
|
||||
} //sortAttackers()
|
||||
|
||||
//Is there any reward for attacking? (for 0/1 creatures there is not)
|
||||
/**
|
||||
@@ -96,19 +99,27 @@ public class ComputerUtil_Attack2 {
|
||||
* @param combat a {@link forge.Combat} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean isEffectiveAttacker(Card attacker, Combat combat) {
|
||||
public final boolean isEffectiveAttacker(final Card attacker, Combat combat) {
|
||||
|
||||
//if the attacker will die when attacking don't attack
|
||||
if (attacker.getNetDefense() + CombatUtil.predictToughnessBonusOfAttacker(attacker, null, combat) <= 0)
|
||||
if (attacker.getNetDefense() + CombatUtil.predictToughnessBonusOfAttacker(attacker, null, combat) <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (CombatUtil.damageIfUnblocked(attacker, AllZone.getHumanPlayer(), combat) > 0) return true;
|
||||
if (CombatUtil.poisonIfUnblocked(attacker, AllZone.getHumanPlayer(), combat) > 0) return true;
|
||||
if (CombatUtil.damageIfUnblocked(attacker, AllZone.getHumanPlayer(), combat) > 0) {
|
||||
return true;
|
||||
}
|
||||
if (CombatUtil.poisonIfUnblocked(attacker, AllZone.getHumanPlayer(), combat) > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ArrayList<Trigger> registeredTriggers = AllZone.getTriggerHandler().getRegisteredTriggers();
|
||||
for (Trigger trigger : registeredTriggers)
|
||||
for (Trigger trigger : registeredTriggers) {
|
||||
if (CombatUtil.combatTriggerWillTrigger(attacker, null, trigger, combat)
|
||||
&& trigger.getHostCard().getController().isComputer()) return true;
|
||||
&& trigger.getHostCard().getController().isComputer()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -122,12 +133,12 @@ public class ComputerUtil_Attack2 {
|
||||
public CardList getPossibleAttackers(CardList in) {
|
||||
CardList list = new CardList(in.toArray());
|
||||
list = list.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
public boolean addCard(final Card c) {
|
||||
return CombatUtil.canAttack(c);
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}//getPossibleAttackers()
|
||||
} //getPossibleAttackers()
|
||||
|
||||
/**
|
||||
* <p>getPossibleBlockers.</p>
|
||||
@@ -136,14 +147,18 @@ public class ComputerUtil_Attack2 {
|
||||
* @param attackers a {@link forge.CardList} object.
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
public CardList getPossibleBlockers(CardList blockers, CardList attackers) {
|
||||
public final CardList getPossibleBlockers(CardList blockers, CardList attackers) {
|
||||
CardList possibleBlockers = new CardList(blockers.toArray());
|
||||
final CardList attackerList = new CardList(attackers.toArray());
|
||||
possibleBlockers = possibleBlockers.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
if (!c.isCreature()) return false;
|
||||
public boolean addCard(final Card c) {
|
||||
if (!c.isCreature()) {
|
||||
return false;
|
||||
}
|
||||
for (Card attacker : attackerList) {
|
||||
if (CombatUtil.canBlock(attacker, c)) return true;
|
||||
if (CombatUtil.canBlock(attacker, c)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -161,7 +176,7 @@ public class ComputerUtil_Attack2 {
|
||||
* @param combat a {@link forge.Combat} object.
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
public CardList notNeededAsBlockers(CardList attackers, Combat combat) {
|
||||
public final CardList notNeededAsBlockers(CardList attackers, Combat combat) {
|
||||
CardList notNeededAsBlockers = new CardList(attackers.toArray());
|
||||
CardListUtil.sortAttackLowFirst(attackers);
|
||||
int blockersNeeded = attackers.size();
|
||||
@@ -173,7 +188,9 @@ public class ComputerUtil_Attack2 {
|
||||
if (!doesHumanAttackAndWin(i)) {
|
||||
blockersNeeded = i;
|
||||
break;
|
||||
} else notNeededAsBlockers.remove(list.get(i));
|
||||
} else {
|
||||
notNeededAsBlockers.remove(list.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
if (blockersNeeded == list.size()) {
|
||||
|
||||
Reference in New Issue
Block a user