- Fixed Cumulative Upkeep code.

- Fixed a small bug with Fastbond (it would sometimes subtract more than 1 life).
- Fixed some big bugs with Fastbond, Exploration, Azusa, Lost but Seeking (computer won't be able to use them if it doesn't control them).
- AI should lose life when using Fastbond now.
This commit is contained in:
jendave
2011-08-06 03:16:05 +00:00
parent a63d99da52
commit 465449c814
18 changed files with 147 additions and 63 deletions

1
.gitattributes vendored
View File

@@ -144,6 +144,7 @@ src/forge/GUI_PictureHQ.java -text svneol=native#text/plain
src/forge/GUI_Quest_Filter.java -text svneol=native#text/plain
src/forge/GameAction.java svneol=native#text/plain
src/forge/GameActionUtil.java svneol=native#text/plain
src/forge/GameInfo.java -text svneol=native#text/plain
src/forge/GenerateConstructedDeck.java svneol=native#text/plain
src/forge/GenerateConstructedMultiColorDeck.java -text svneol=native#text/plain
src/forge/GenerateDraftDeck.java svneol=native#text/plain

View File

@@ -25,6 +25,7 @@ public class AllZone implements NewConstants {
public static final InputControl InputControl = new InputControl();
public static final GameAction GameAction = new GameAction();
public static final StateBasedEffects StateBasedEffects = new StateBasedEffects();
public static final GameInfo GameInfo = new GameInfo();
//initialized at Runtime since it has to be the last object constructed

View File

@@ -301,7 +301,10 @@ public class Card extends MyObservable
if (k.startsWith("Scry"))
{
String kk[] = k.split(" ");
sb.append("Scry " + kk[1] + " (To scry X, look at the top X cards of your library, then put any number of them on the bottom of your library and the rest on top in any order.)\r\n");
//sb.append("Scry " + kk[1] + " (To scry X, look at the top X cards of your library, then put any number of them on the bottom of your library and the rest on top in any order.)\r\n");
sb.append("Scry ");
sb.append(kk[1]);
sb.append(" (To scry X, look at the top X cards of your library, then put any number of them on the bottom of your library and the rest on top in any order.)\r\n");
}
}

View File

@@ -17967,7 +17967,7 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase();
}
};
bounce.setDescription("You may return two Islands you control to their owner's hand rather than pay Thwart's mana cost.");
bounce.setDescription("You may return three Islands you control to their owner's hand rather than pay Thwart's mana cost.");
bounce.setStackDescription(card.getName() + " - Counter target spell.");
bounce.setManaCost("0");

View File

@@ -2158,20 +2158,25 @@ public class CardFactoryUtil
sb.append(tokenized[0]);
}
else {
for (int i=0; i<multiplier; i++)
for (int i=0; i<multiplier; i++) {
//tokenized[0] = tokenized[0] + " " + tokenized[0];
sb.append((" "));
sb.append(tokenized[0]);
}
}
for (int i=1;i<tokenized.length;i++){
for (int j=0;j<multiplier;j++)
{
//tokenized[i] = tokenized[i] + " " + tokenized[i];
sb.append(tokenized[0]);
sb.append((" "));
sb.append(tokenized[i]);
}
}
String result = sb.toString();
System.out.println("result: " + result);
result = result.trim();
return result;
}

View File

@@ -13,8 +13,5 @@ public interface Computer
public void main2();
public void end_of_turn();//end of Human's turn
public void addNumberPlayLands(int n);
public void setNumberPlayLands(int n);
public void stack_not_empty();
}

View File

@@ -9,7 +9,7 @@ import java.util.TreeSet;
public class ComputerAI_General implements Computer {
//private boolean playLand = true;
//private int numberPlayLand = 1;
public int numberPlayLand = CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Computer);
//private int numberPlayLand = CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Computer);
private Collection<Card> playMain1Cards;
@SuppressWarnings("unchecked")
@@ -20,8 +20,8 @@ public class ComputerAI_General implements Computer {
}
public void main1() {
if(numberPlayLand > 0) {
numberPlayLand--;
if(AllZone.GameInfo.getComputerCanPlayNumberOfLands() > 0) {
AllZone.GameInfo.addComputerCanPlayNumberOfLands(-1);
ComputerUtil.playLand();
for(String effect:AllZone.StateBasedEffects.getStateBasedMap().keySet()) {
Command com = GameActionUtil.commands.get(effect);
@@ -35,9 +35,9 @@ public class ComputerAI_General implements Computer {
playCards(Constant.Phase.Main1);
//for cards like Exploration, Fastbond, Azusa, ...
while(numberPlayLand > 0)
while(AllZone.GameInfo.getComputerCanPlayNumberOfLands() > 0)
{
numberPlayLand--;
AllZone.GameInfo.addComputerCanPlayNumberOfLands(-1);
ComputerUtil.playLand();
for(String effect:AllZone.StateBasedEffects.getStateBasedMap().keySet()) {
@@ -49,7 +49,7 @@ public class ComputerAI_General implements Computer {
}//main1()
public void main2() {
numberPlayLand = CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Computer);
AllZone.GameInfo.setComputerCanPlayNumberOfLands(CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Computer));
playCards(Constant.Phase.Main2);
}
@@ -313,16 +313,6 @@ public class ComputerAI_General implements Computer {
return library.toArray();
}
public void addNumberPlayLands(int n)
{
numberPlayLand += n;
}
public void setNumberPlayLands(int n)
{
numberPlayLand = n;
}
public void stack_not_empty() {
//same as Input.stop() method
//ends the method

View File

@@ -335,6 +335,15 @@ public class ComputerUtil
AllZone.Computer_Hand.remove(landList.get(0));
AllZone.Computer_Play.add(landList.get(0));
if (!AllZone.GameInfo.computerPlayedFirstLandThisTurn()) {
AllZone.GameInfo.setComputerPlayedFirstLandThisTurn(true);
}
else
{
if (CardFactoryUtil.getFastbonds(Constant.Player.Computer).size() > 0)
AllZone.GameAction.getPlayerLife(Constant.Player.Computer).subtractLife(1);
}
AllZone.GameAction.checkStateEffects();
}
}

View File

@@ -945,8 +945,8 @@ private Card getCurrentCard(int ID)
//System.gc(); //garbage collection... does it make a difference though?
lastPlayerToDraw = Constant.Player.Human;
Input_Main.canPlayNumberOfLands = 1;
AllZone.Computer.getComputer().setNumberPlayLands(1);
AllZone.GameInfo.setComputerCanPlayNumberOfLands(1);
AllZone.GameInfo.setHumanCanPlayNumberOfLands(1);
AllZone.Computer_Life.setLife(20);
AllZone.Human_Life.setLife(20);
@@ -1277,7 +1277,7 @@ private int getDifferentLand(CardList list, String land)
ArrayList<String> choices = new ArrayList<String>();
if (Input_Main.canPlayNumberOfLands > 0 && AllZone.Stack.size() == 0 &&
if (AllZone.GameInfo.getHumanCanPlayNumberOfLands() > 0 && AllZone.Stack.size() == 0 &&
(AllZone.Phase.getPhase().equals(Constant.Phase.Main1) || AllZone.Phase.getPhase().equals(Constant.Phase.Main2)) )
choices.add("Play land");
@@ -1304,8 +1304,8 @@ private int getDifferentLand(CardList list, String land)
{
AllZone.Human_Hand.remove(c);
AllZone.Human_Play.add(c);
Input_Main.canPlayNumberOfLands--;
Input_Main.firstLandHasBeenPlayed = true;
AllZone.GameInfo.addHumanCanPlayNumberOfLands(-1);
AllZone.GameInfo.setHumanPlayedFirstLandThisTurn(true);
}
else
{
@@ -1343,11 +1343,13 @@ private int getDifferentLand(CardList list, String land)
SpellAbility sa;
//TODO: add Buyback, Kicker, ... , spells here
/*
ArrayList<SpellAbility> additional = c.getAdditionalCostSpells();
for (SpellAbility s : additional)
{
}
*/
/*
System.out.println(choices.length);
for(int i = 0; i < choices.length; i++)

View File

@@ -2715,7 +2715,9 @@ public class GameActionUtil
{
String k[] = a.get(i).toString().split(":");
c.addCounter(Counters.AGE, 1);
c.setUpkeepCost(CardFactoryUtil.multiplyManaCost(k[1], c.getCounters(Counters.AGE)));
String upkeepCost = CardFactoryUtil.multiplyManaCost(k[1], c.getCounters(Counters.AGE));
c.setUpkeepCost(upkeepCost);
System.out.println("Multiplied cost: " + upkeepCost);
//c.setUpkeepCost(k[1]);
return true;
}

67
src/forge/GameInfo.java Normal file
View File

@@ -0,0 +1,67 @@
package forge;
public class GameInfo {
private int computerCanPlayNumberOfLands;
private int humanCanPlayNumberOfLands;
private boolean computerPlayedFirstLandThisTurn;
private boolean humanPlayedFirstLandThisTurn;
private boolean preventCombatDamageThisTurn;
public void setComputerCanPlayNumberOfLands(int n) {
computerCanPlayNumberOfLands = n;
}
public int getComputerCanPlayNumberOfLands() {
return computerCanPlayNumberOfLands;
}
public void addComputerCanPlayNumberOfLands(int n)
{
computerCanPlayNumberOfLands += n;
}
public void setHumanCanPlayNumberOfLands(int n) {
humanCanPlayNumberOfLands = n;
}
public int getHumanCanPlayNumberOfLands() {
return humanCanPlayNumberOfLands;
}
public void addHumanCanPlayNumberOfLands(int n)
{
humanCanPlayNumberOfLands += n;
}
public void setComputerPlayedFirstLandThisTurn(boolean b) {
computerPlayedFirstLandThisTurn = b;
}
public boolean computerPlayedFirstLandThisTurn() {
return computerPlayedFirstLandThisTurn;
}
public void setHumanPlayedFirstLandThisTurn(boolean b) {
humanPlayedFirstLandThisTurn = b;
}
public boolean humanPlayedFirstLandThisTurn() {
return humanPlayedFirstLandThisTurn;
}
public void setPreventCombatDamageThisTurn(boolean b) {
preventCombatDamageThisTurn = b;
}
public boolean isPreventCombatDamageThisTurn() {
return preventCombatDamageThisTurn;
}
}

View File

@@ -185,7 +185,7 @@ import java.util.*;
}
else if(phase.equals(Constant.Phase.End_Of_Turn))
{
System.out.println("Cache size: " + ImageCache.cache.size());
//System.out.println("Cache size: " + ImageCache.cache.size());
/*
CardList visibleCards = new CardList();

View File

@@ -33,16 +33,17 @@ public class InputUtil
{
AllZone.Human_Hand.remove(card);
AllZone.Human_Play.add(card);
Input_Main.canPlayNumberOfLands--;
Input_Main.firstLandHasBeenPlayed = true;
AllZone.GameInfo.addHumanCanPlayNumberOfLands(-1);
AllZone.GameInfo.setHumanPlayedFirstLandThisTurn(true);
}
}
else //play the land
{
AllZone.Human_Hand.remove(card);
AllZone.Human_Play.add(card);
Input_Main.canPlayNumberOfLands--;
Input_Main.firstLandHasBeenPlayed = true;
AllZone.GameInfo.addHumanCanPlayNumberOfLands(-1);
AllZone.GameInfo.setHumanPlayedFirstLandThisTurn(true);
}
} //land
else if(zone.is(Constant.Zone.Hand, Constant.Player.Human) &&

View File

@@ -22,9 +22,7 @@ public void showMessage()
if (!c.getKeyword().contains("Vigilance"))
c.tap();
}
}
}
public void selectButtonOK()
{

View File

@@ -24,8 +24,8 @@ package forge;
if(AllZone.Phase.getPhase().equals(Constant.Phase.Draw) && humanSkipsDrawPhase){
//Input_Main.canPlayLand = true;
Input_Main.canPlayNumberOfLands = CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Human);
Input_Main.firstLandHasBeenPlayed = false;
AllZone.GameInfo.setHumanCanPlayNumberOfLands(CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Human));
AllZone.GameInfo.setHumanPlayedFirstLandThisTurn(false);
AllZone.Phase.setNeedToNextPhase(true);
}
@@ -60,9 +60,9 @@ package forge;
if(AllZone.Phase.getPhase().equals(Constant.Phase.Draw))
{
//Input_Main.canPlayLand = true;
Input_Main.canPlayNumberOfLands = CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Human);
Input_Main.firstLandHasBeenPlayed = false;
AllZone.GameInfo.setHumanCanPlayNumberOfLands(CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Human));
AllZone.GameInfo.setHumanPlayedFirstLandThisTurn(false);
//AllZone.Phase.nextPhase();
//for debugging: System.out.println("need to nextPhase(from Input_Draw on human's draw) = true");
AllZone.Phase.setNeedToNextPhase(true);

View File

@@ -1,14 +1,12 @@
package forge;
import java.util.*;
@SuppressWarnings("unused") // java.util.*
public class Input_Main extends Input
{
private static final long serialVersionUID = -2162856359060870957L;
//Input_Draw changes this
//public static boolean canPlayLand;
public static boolean firstLandHasBeenPlayed;
public static int canPlayNumberOfLands;
//public static boolean firstLandHasBeenPlayed;
//public static int canPlayNumberOfLands;
public void showMessage()
{
@@ -30,16 +28,13 @@ public class Input_Main extends Input
//these if statements cannot be combined
if(card.isLand() && zone.is(Constant.Zone.Hand, Constant.Player.Human))
{
if(canPlayNumberOfLands > 0 )
if(AllZone.GameInfo.getHumanCanPlayNumberOfLands() > 0 )
{
CardList fastbonds = CardFactoryUtil.getFastbonds(Constant.Player.Human);
if (fastbonds.size() > 0){
if (firstLandHasBeenPlayed)
if (AllZone.GameInfo.humanPlayedFirstLandThisTurn())
{
for ( Card vard : fastbonds)
{
AllZone.GameAction.getPlayerLife(Constant.Player.Human).subtractLife(1);
}
AllZone.GameAction.getPlayerLife(Constant.Player.Human).subtractLife(1);
}
}
InputUtil.playAnyCard(card, zone);

View File

@@ -201,6 +201,7 @@ public class Phase extends MyObservable
}
else if (is(Constant.Phase.Untap, Constant.Player.Computer))
{
AllZone.GameInfo.setComputerPlayedFirstLandThisTurn(false);
turn++;
/*
if (computerExtraTurns > 0)

View File

@@ -28,16 +28,22 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone
//cannot use addComesIntoPlayCommand - trigger might be set to false;
if (c.getName().equals("Exploration")) {
Input_Main.canPlayNumberOfLands++;
AllZone.Computer.getComputer().addNumberPlayLands(1);
if (c.getController().equals(Constant.Player.Human))
AllZone.GameInfo.addHumanCanPlayNumberOfLands(1);
else
AllZone.GameInfo.addComputerCanPlayNumberOfLands(1);
}
else if (c.getName().equals("Azusa, Lost but Seeking")) {
Input_Main.canPlayNumberOfLands+=2;
AllZone.Computer.getComputer().addNumberPlayLands(2);
if (c.getController().equals(Constant.Player.Human))
AllZone.GameInfo.addHumanCanPlayNumberOfLands(2);
else
AllZone.GameInfo.addComputerCanPlayNumberOfLands(2);
}
else if( c.getName().equals("Fastbond")) {
Input_Main.canPlayNumberOfLands+=100;
AllZone.Computer.getComputer().addNumberPlayLands(100);
if (c.getController().equals(Constant.Player.Human))
AllZone.GameInfo.addHumanCanPlayNumberOfLands(100);
else
AllZone.GameInfo.addComputerCanPlayNumberOfLands(100);
}
if (trigger)
@@ -198,16 +204,22 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone
//cannot use addLeavesPlayCommand - trigger might be set to false
if (c.getName().equals("Exploration")) {
Input_Main.canPlayNumberOfLands--;
AllZone.Computer.getComputer().addNumberPlayLands(-1);
if (c.getController().equals(Constant.Player.Human))
AllZone.GameInfo.addHumanCanPlayNumberOfLands(-1);
else
AllZone.GameInfo.addComputerCanPlayNumberOfLands(-1);
}
else if (c.getName().equals("Azusa, Lost but Seeking")) {
Input_Main.canPlayNumberOfLands-=2;
AllZone.Computer.getComputer().addNumberPlayLands(-2);
if (c.getController().equals(Constant.Player.Human))
AllZone.GameInfo.addHumanCanPlayNumberOfLands(-2);
else
AllZone.GameInfo.addComputerCanPlayNumberOfLands(-2);
}
else if( c.getName().equals("Fastbond")) {
Input_Main.canPlayNumberOfLands-=100;
AllZone.Computer.getComputer().addNumberPlayLands(-100);
if (c.getController().equals(Constant.Player.Human))
AllZone.GameInfo.addHumanCanPlayNumberOfLands(-100);
else
AllZone.GameInfo.addComputerCanPlayNumberOfLands(-100);
}