1) Moved existing Dredge code from Input_Draw.java to the actual drawing of the card in GameAction.java so that drawing cards from things like Bazaar of Baghdad will trigger dredge. It seems to be working, but someone more familiar with the mechanic should test. This currently only works for the human. AI will probably need to dredge at random, say 50% of the time, so it doesn't mill itself...

1a) I didn't add it, but Dredge is a keyword of the form "Dredge:2"
2) added Greater Mossdog (from Ravnica: City of Guilds) using Dredge - requested by tchiseen
This commit is contained in:
jendave
2011-08-06 04:29:36 +00:00
parent 84fbd1bd3f
commit 5decb7093a
4 changed files with 61 additions and 51 deletions

View File

@@ -38,6 +38,7 @@ snow_covered_mountain.jpg http://www.wizards.com/global/images/magic/gene
snow_covered_mountain1.jpg http://www.wizards.com/global/images/magic/general/snow_covered_mountain.jpg snow_covered_mountain1.jpg http://www.wizards.com/global/images/magic/general/snow_covered_mountain.jpg
snow_covered_mountain2.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg snow_covered_mountain2.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg
snow_covered_mountain3.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg snow_covered_mountain3.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg
greater_mossdog.jpg http://www.wizards.com/global/images/magic/general/greater_mossdog.jpg
reanimate.jpg http://www.wizards.com/global/images/magic/general/reanimate.jpg reanimate.jpg http://www.wizards.com/global/images/magic/general/reanimate.jpg
sound_the_call.jpg http://www.wizards.com/global/images/magic/general/sound_the_call.jpg sound_the_call.jpg http://www.wizards.com/global/images/magic/general/sound_the_call.jpg
mana_vault.jpg http://www.wizards.com/global/images/magic/general/mana_vault.jpg mana_vault.jpg http://www.wizards.com/global/images/magic/general/mana_vault.jpg

View File

@@ -1,3 +1,10 @@
Greater Mossdog
3 G
Creature Plant Hound
no text
3/3
Dredge 3
Reanimate Reanimate
B B
Sorcery Sorcery

View File

@@ -833,7 +833,34 @@ public class GameAction {
PlayerZone library = AllZone.getZone(Constant.Zone.Library, player); PlayerZone library = AllZone.getZone(Constant.Zone.Library, player);
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player); PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player);
if(library.size() != 0) { if(0 < getDredge().size()) {
String choices[] = {"Yes", "No"};
Object o = AllZone.Display.getChoice("Do you want to dredge?", choices);
if(o.equals("Yes")) {
Card c = (Card) AllZone.Display.getChoice("Select card to dredge", getDredge().toArray());
//might have to make this more sophisticated
//dredge library, put card in hand
AllZone.Human_Hand.add(c);
AllZone.Human_Graveyard.remove(c);
for(int i = 0; i < getDredgeNumber(c); i++) {
Card c2 = AllZone.Human_Library.get(0);
AllZone.Human_Library.remove(0);
AllZone.Human_Graveyard.add(c2);
}
}
else {
doDraw(player, library, hand);
}
}//if(0 < getDredge().size())
else {
doDraw(player, library, hand);
}
}
private void doDraw(String player, PlayerZone library, PlayerZone hand) {
if(library.size() != 0) {
Card c = library.get(0); Card c = library.get(0);
library.remove(0); library.remove(0);
hand.add(c); hand.add(c);
@@ -854,6 +881,31 @@ public class GameAction {
} }
} }
private ArrayList<Card> getDredge() {
ArrayList<Card> dredge = new ArrayList<Card>();
Card c[] = AllZone.Human_Graveyard.getCards();
for(int outer = 0; outer < c.length; outer++) {
ArrayList<String> a = c[outer].getKeyword();
for(int i = 0; i < a.size(); i++)
if(a.get(i).toString().startsWith("Dredge")) {
if(AllZone.Human_Library.size() >= getDredgeNumber(c[outer])) dredge.add(c[outer]);
}
}
return dredge;
}//hasDredge()
private int getDredgeNumber(Card c) {
ArrayList<String> a = c.getKeyword();
for(int i = 0; i < a.size(); i++)
if(a.get(i).toString().startsWith("Dredge")) {
String s = a.get(i).toString();
return Integer.parseInt("" + s.charAt(s.length() - 1));
}
throw new RuntimeException("Input_Draw : getDredgeNumber() card doesn't have dredge - " + c.getName());
}//getDredgeNumber()
//is this card a permanent that is in play? //is this card a permanent that is in play?
public boolean isCardInPlay(Card c) { public boolean isCardInPlay(Card c) {
return PlayerZoneUtil.isCardInZone(AllZone.Computer_Play, c) return PlayerZoneUtil.isCardInZone(AllZone.Computer_Play, c)

View File

@@ -2,9 +2,6 @@
package forge; package forge;
import java.util.ArrayList;
public class Input_Draw extends Input { public class Input_Draw extends Input {
private static final long serialVersionUID = -2341125041806280507L; private static final long serialVersionUID = -2341125041806280507L;
@@ -13,7 +10,6 @@ public class Input_Draw extends Input {
if(AllZone.Phase.getActivePlayer().equals(Constant.Player.Computer)) { if(AllZone.Phase.getActivePlayer().equals(Constant.Player.Computer)) {
AllZone.GameAction.drawCard(Constant.Player.Computer); AllZone.GameAction.drawCard(Constant.Player.Computer);
//AllZone.Phase.nextPhase();
//for debugging: System.out.println("need to nextPhase(from Input_Draw on computer's draw) = true"); //for debugging: System.out.println("need to nextPhase(from Input_Draw on computer's draw) = true");
AllZone.Phase.setNeedToNextPhase(true); AllZone.Phase.setNeedToNextPhase(true);
return; return;
@@ -55,30 +51,9 @@ public class Input_Draw extends Input {
} }
} }
if(0 < getDredge().size()) {
String choices[] = {"Yes", "No"};
Object o = AllZone.Display.getChoice("Do you want to dredge?", choices);
if(o.equals("Yes")) {
drawCard = false;
Card c = (Card) AllZone.Display.getChoice("Select card to dredge", getDredge().toArray());
//might have to make this more sophisticated
//dredge library, put card in hand
AllZone.Human_Hand.add(c);
AllZone.Human_Graveyard.remove(c);
for(int i = 0; i < getDredgeNumber(c); i++) {
Card c2 = AllZone.Human_Library.get(0);
AllZone.Human_Library.remove(0);
AllZone.Human_Graveyard.add(c2);
}
}
}//if(0 < getDredge().size())
if(drawCard && AllZone.Phase.getTurn() > 1) AllZone.GameAction.drawCard(Constant.Player.Human); if(drawCard && AllZone.Phase.getTurn() > 1) AllZone.GameAction.drawCard(Constant.Player.Human);
if(AllZone.Phase.getPhase().equals(Constant.Phase.Draw)) { if(AllZone.Phase.getPhase().equals(Constant.Phase.Draw)) {
//Input_Main.canPlayLand = true;
AllZone.GameInfo.setHumanCanPlayNumberOfLands(CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Human)); AllZone.GameInfo.setHumanCanPlayNumberOfLands(CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Human));
AllZone.GameInfo.setHumanPlayedFirstLandThisTurn(false); AllZone.GameInfo.setHumanPlayedFirstLandThisTurn(false);
@@ -88,29 +63,4 @@ public class Input_Draw extends Input {
} else stop(); } else stop();
} }
} //end necro check } //end necro check
public ArrayList<Card> getDredge() {
ArrayList<Card> dredge = new ArrayList<Card>();
Card c[] = AllZone.Human_Graveyard.getCards();
for(int outer = 0; outer < c.length; outer++) {
ArrayList<String> a = c[outer].getKeyword();
for(int i = 0; i < a.size(); i++)
if(a.get(i).toString().startsWith("Dredge")) {
if(AllZone.Human_Library.size() >= getDredgeNumber(c[outer])) dredge.add(c[outer]);
}
}
return dredge;
}//hasDredge()
public int getDredgeNumber(Card c) {
ArrayList<String> a = c.getKeyword();
for(int i = 0; i < a.size(); i++)
if(a.get(i).toString().startsWith("Dredge")) {
String s = a.get(i).toString();
return Integer.parseInt("" + s.charAt(s.length() - 1));
}
throw new RuntimeException("Input_Draw : getDredgeNumber() card doesn't have dredge - " + c.getName());
}//getDredgeNumber()
} }