mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
- Completed the initial implementation of the Setup Battlefield dev command (it uses an external file dev_battle.txt in the root folder of MTG Forge as data for how to set up the battlefield situation).
- Removed Chronicles (CHR) from the list of possible block drafts for now (see the discussion at the forum).
This commit is contained in:
@@ -4,6 +4,7 @@ package forge;
|
|||||||
|
|
||||||
import forge.card.cardFactory.CardFactoryUtil;
|
import forge.card.cardFactory.CardFactoryUtil;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
|
import forge.card.trigger.Trigger;
|
||||||
import forge.error.ErrorViewer;
|
import forge.error.ErrorViewer;
|
||||||
import forge.gui.ForgeAction;
|
import forge.gui.ForgeAction;
|
||||||
import forge.gui.GuiUtils;
|
import forge.gui.GuiUtils;
|
||||||
@@ -184,7 +185,7 @@ public class GuiDisplay3 extends JFrame implements CardContainer, Display, NewCo
|
|||||||
private static final long serialVersionUID = -6660930759092583160L;
|
private static final long serialVersionUID = -6660930759092583160L;
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
// Set up the battlefield here
|
devSetupBattlefield();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// - Battlefield setup -
|
// - Battlefield setup -
|
||||||
@@ -1091,6 +1092,133 @@ public class GuiDisplay3 extends JFrame implements CardContainer, Display, NewCo
|
|||||||
|
|
||||||
public static JCheckBoxMenuItem canLoseByDecking = new JCheckBoxMenuItem("Lose by Decking", true);
|
public static JCheckBoxMenuItem canLoseByDecking = new JCheckBoxMenuItem("Lose by Decking", true);
|
||||||
|
|
||||||
|
private void devSetupBattlefield() {
|
||||||
|
String t_humanLife = "20";
|
||||||
|
String t_computerLife = "20";
|
||||||
|
String t_humanSetupCardsInPlay = "";
|
||||||
|
String t_computerSetupCardsInPlay = "";
|
||||||
|
String t_humanSetupCardsInHand = "";
|
||||||
|
String t_computerSetupCardsInHand = "";
|
||||||
|
String t_end = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileInputStream fstream = new FileInputStream("dev_battle.txt");
|
||||||
|
DataInputStream in = new DataInputStream(fstream);
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
||||||
|
|
||||||
|
t_humanLife = br.readLine();
|
||||||
|
t_computerLife = br.readLine();
|
||||||
|
t_humanSetupCardsInPlay = br.readLine();
|
||||||
|
t_computerSetupCardsInPlay = br.readLine();
|
||||||
|
t_humanSetupCardsInHand = br.readLine();
|
||||||
|
t_computerSetupCardsInHand = br.readLine();
|
||||||
|
t_end = br.readLine();
|
||||||
|
|
||||||
|
in.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Error loading dev_battle.txt!\nError message: " + e.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((t_end == null) || (!t_end.toLowerCase().equals("end"))) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Error loading dev_battle.txt!\nError message: Can't find an end marker in dev_battle.txt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int setHumanLife = Integer.parseInt(t_humanLife);
|
||||||
|
int setComputerLife = Integer.parseInt(t_computerLife);
|
||||||
|
|
||||||
|
String humanSetupCardsInPlay[] = t_humanSetupCardsInPlay.split(";");
|
||||||
|
String computerSetupCardsInPlay[] = t_computerSetupCardsInPlay.split(";");
|
||||||
|
String humanSetupCardsInHand[] = t_humanSetupCardsInHand.split(";");
|
||||||
|
String computerSetupCardsInHand[] = t_computerSetupCardsInHand.split(";");
|
||||||
|
|
||||||
|
CardList humanDevSetup = new CardList();
|
||||||
|
CardList computerDevSetup = new CardList();
|
||||||
|
CardList humanDevHandSetup = new CardList();
|
||||||
|
CardList computerDevHandSetup = new CardList();
|
||||||
|
|
||||||
|
if (!t_humanSetupCardsInPlay.trim().equals("")) {
|
||||||
|
for (int i = 0; i < humanSetupCardsInPlay.length; i ++) {
|
||||||
|
Card c = AllZone.CardFactory.getCard(humanSetupCardsInPlay[i].trim(), AllZone.HumanPlayer);
|
||||||
|
for(Trigger trig : c.getTriggers()) {
|
||||||
|
AllZone.TriggerHandler.registerTrigger(trig);
|
||||||
|
}
|
||||||
|
|
||||||
|
c.setCurSetCode(c.getMostRecentSet());
|
||||||
|
c.setImageFilename(CardUtil.buildFilename(c));
|
||||||
|
|
||||||
|
humanDevSetup.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!t_humanSetupCardsInHand.trim().equals("")) {
|
||||||
|
for (int i = 0; i < humanSetupCardsInHand.length; i ++) {
|
||||||
|
Card c = AllZone.CardFactory.getCard(humanSetupCardsInHand[i].trim(), AllZone.HumanPlayer);
|
||||||
|
for(Trigger trig : c.getTriggers()) {
|
||||||
|
AllZone.TriggerHandler.registerTrigger(trig);
|
||||||
|
}
|
||||||
|
|
||||||
|
c.setCurSetCode(c.getMostRecentSet());
|
||||||
|
c.setImageFilename(CardUtil.buildFilename(c));
|
||||||
|
|
||||||
|
humanDevHandSetup.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!t_computerSetupCardsInPlay.trim().equals("")) {
|
||||||
|
for (int i = 0; i < computerSetupCardsInPlay.length; i ++) {
|
||||||
|
Card c = AllZone.CardFactory.getCard(computerSetupCardsInPlay[i].trim(), AllZone.ComputerPlayer);
|
||||||
|
|
||||||
|
c.setCurSetCode(c.getMostRecentSet());
|
||||||
|
c.setImageFilename(CardUtil.buildFilename(c));
|
||||||
|
for(Trigger trig : c.getTriggers()) {
|
||||||
|
AllZone.TriggerHandler.registerTrigger(trig);
|
||||||
|
}
|
||||||
|
|
||||||
|
computerDevSetup.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!t_computerSetupCardsInHand.trim().equals("")) {
|
||||||
|
for (int i = 0; i < computerSetupCardsInHand.length; i ++) {
|
||||||
|
Card c = AllZone.CardFactory.getCard(computerSetupCardsInHand[i].trim(), AllZone.ComputerPlayer);
|
||||||
|
|
||||||
|
c.setCurSetCode(c.getMostRecentSet());
|
||||||
|
c.setImageFilename(CardUtil.buildFilename(c));
|
||||||
|
for(Trigger trig : c.getTriggers()) {
|
||||||
|
AllZone.TriggerHandler.registerTrigger(trig);
|
||||||
|
}
|
||||||
|
|
||||||
|
computerDevHandSetup.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Card c : humanDevSetup)
|
||||||
|
{
|
||||||
|
AllZone.Human_Hand.add(c);
|
||||||
|
AllZone.GameAction.moveToPlay(c);
|
||||||
|
c.setSickness(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Card c: computerDevSetup)
|
||||||
|
{
|
||||||
|
AllZone.Computer_Hand.add(c);
|
||||||
|
AllZone.GameAction.moveToPlay(c);
|
||||||
|
c.setSickness(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (computerDevHandSetup.size() > 0)
|
||||||
|
AllZone.Computer_Hand.setCards(computerDevHandSetup.toArray());
|
||||||
|
if (humanDevHandSetup.size() > 0)
|
||||||
|
AllZone.Human_Hand.setCards(humanDevHandSetup.toArray());
|
||||||
|
|
||||||
|
AllZone.ComputerPlayer.setLife(setComputerLife, null);
|
||||||
|
AllZone.HumanPlayer.setLife(setHumanLife, null);
|
||||||
|
|
||||||
|
AllZone.GameAction.checkStateEffects();
|
||||||
|
}
|
||||||
|
|
||||||
// *****************************
|
// *****************************
|
||||||
|
|
||||||
JXMultiSplitPane pane = new JXMultiSplitPane();
|
JXMultiSplitPane pane = new JXMultiSplitPane();
|
||||||
|
|||||||
@@ -1058,94 +1058,6 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void devSetupBattlefield() {
|
|
||||||
// SET UP THE BATTLEFIELD HERE
|
|
||||||
// - define the life values for Human and AI;
|
|
||||||
// - list the cards that need to be placed on the human and the AI's battlefield, respectively;
|
|
||||||
// - list the cards to be placed in the human and AI hands instead of their current hands;
|
|
||||||
int setHumanLife = 10;
|
|
||||||
int setComputerLife = 6;
|
|
||||||
String humanSetupCardsInPlay[] = {"Mountain", "Raging Goblin"}; // cards to be placed on the human battlefield
|
|
||||||
String computerSetupCardsInPlay[] = {"Durkwood Boars", "Forest", "Forest", "Forest", "Forest", "Forest", "Forest"}; // cards to be placed on the AI battlefield
|
|
||||||
String humanSetupCardsInHand[] = {"Raging Goblin"}; // cards that will replace the current human hand
|
|
||||||
String computerSetupCardsInHand[] = {"Force of Nature"}; // cards that will replace the current AI hand
|
|
||||||
|
|
||||||
CardList humanDevSetup = new CardList();
|
|
||||||
CardList computerDevSetup = new CardList();
|
|
||||||
CardList humanDevHandSetup = new CardList();
|
|
||||||
CardList computerDevHandSetup = new CardList();
|
|
||||||
|
|
||||||
for (int i = 0; i < humanSetupCardsInPlay.length; i ++) {
|
|
||||||
Card c = AllZone.CardFactory.getCard(humanSetupCardsInPlay[i], AllZone.HumanPlayer);
|
|
||||||
for(Trigger trig : c.getTriggers())
|
|
||||||
{
|
|
||||||
AllZone.TriggerHandler.registerTrigger(trig);
|
|
||||||
}
|
|
||||||
|
|
||||||
c.setCurSetCode(c.getMostRecentSet());
|
|
||||||
c.setImageFilename(CardUtil.buildFilename(c));
|
|
||||||
|
|
||||||
humanDevSetup.add(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < humanSetupCardsInHand.length; i ++) {
|
|
||||||
Card c = AllZone.CardFactory.getCard(humanSetupCardsInHand[i], AllZone.HumanPlayer);
|
|
||||||
for(Trigger trig : c.getTriggers())
|
|
||||||
{
|
|
||||||
AllZone.TriggerHandler.registerTrigger(trig);
|
|
||||||
}
|
|
||||||
|
|
||||||
c.setCurSetCode(c.getMostRecentSet());
|
|
||||||
c.setImageFilename(CardUtil.buildFilename(c));
|
|
||||||
|
|
||||||
humanDevHandSetup.add(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < computerSetupCardsInPlay.length; i ++) {
|
|
||||||
Card c = AllZone.CardFactory.getCard(computerSetupCardsInPlay[i], AllZone.ComputerPlayer);
|
|
||||||
|
|
||||||
c.setCurSetCode(c.getMostRecentSet());
|
|
||||||
c.setImageFilename(CardUtil.buildFilename(c));
|
|
||||||
for(Trigger trig : c.getTriggers())
|
|
||||||
{
|
|
||||||
AllZone.TriggerHandler.registerTrigger(trig);
|
|
||||||
}
|
|
||||||
|
|
||||||
computerDevSetup.add(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < computerSetupCardsInHand.length; i ++) {
|
|
||||||
Card c = AllZone.CardFactory.getCard(computerSetupCardsInHand[i], AllZone.HumanPlayer);
|
|
||||||
|
|
||||||
c.setCurSetCode(c.getMostRecentSet());
|
|
||||||
c.setImageFilename(CardUtil.buildFilename(c));
|
|
||||||
for(Trigger trig : c.getTriggers())
|
|
||||||
{
|
|
||||||
AllZone.TriggerHandler.registerTrigger(trig);
|
|
||||||
}
|
|
||||||
|
|
||||||
computerDevHandSetup.add(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Card c : humanDevSetup)
|
|
||||||
{
|
|
||||||
AllZone.Human_Hand.add(c);
|
|
||||||
AllZone.GameAction.moveToPlay(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Card c: computerDevSetup)
|
|
||||||
{
|
|
||||||
AllZone.Computer_Hand.add(c);
|
|
||||||
AllZone.GameAction.moveToPlay(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
AllZone.Computer_Hand.setCards(computerDevHandSetup.toArray());
|
|
||||||
AllZone.Human_Hand.setCards(humanDevHandSetup.toArray());
|
|
||||||
|
|
||||||
AllZone.ComputerPlayer.setLife(setComputerLife, null);
|
|
||||||
AllZone.HumanPlayer.setLife(setHumanLife, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JCheckBoxMenuItem playsoundCheckboxForMenu = new JCheckBoxMenuItem("Play Sound", false);
|
public static JCheckBoxMenuItem playsoundCheckboxForMenu = new JCheckBoxMenuItem("Play Sound", false);
|
||||||
|
|
||||||
// Phases
|
// Phases
|
||||||
@@ -1167,6 +1079,133 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo
|
|||||||
|
|
||||||
public static JCheckBoxMenuItem canLoseByDecking = new JCheckBoxMenuItem("Lose by Decking", true);
|
public static JCheckBoxMenuItem canLoseByDecking = new JCheckBoxMenuItem("Lose by Decking", true);
|
||||||
|
|
||||||
|
private void devSetupBattlefield() {
|
||||||
|
String t_humanLife = "20";
|
||||||
|
String t_computerLife = "20";
|
||||||
|
String t_humanSetupCardsInPlay = "";
|
||||||
|
String t_computerSetupCardsInPlay = "";
|
||||||
|
String t_humanSetupCardsInHand = "";
|
||||||
|
String t_computerSetupCardsInHand = "";
|
||||||
|
String t_end = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileInputStream fstream = new FileInputStream("dev_battle.txt");
|
||||||
|
DataInputStream in = new DataInputStream(fstream);
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
||||||
|
|
||||||
|
t_humanLife = br.readLine();
|
||||||
|
t_computerLife = br.readLine();
|
||||||
|
t_humanSetupCardsInPlay = br.readLine();
|
||||||
|
t_computerSetupCardsInPlay = br.readLine();
|
||||||
|
t_humanSetupCardsInHand = br.readLine();
|
||||||
|
t_computerSetupCardsInHand = br.readLine();
|
||||||
|
t_end = br.readLine();
|
||||||
|
|
||||||
|
in.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Error loading dev_battle.txt!\nError message: " + e.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((t_end == null) || (!t_end.toLowerCase().equals("end"))) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Error loading dev_battle.txt!\nError message: Can't find an end marker in dev_battle.txt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int setHumanLife = Integer.parseInt(t_humanLife);
|
||||||
|
int setComputerLife = Integer.parseInt(t_computerLife);
|
||||||
|
|
||||||
|
String humanSetupCardsInPlay[] = t_humanSetupCardsInPlay.split(";");
|
||||||
|
String computerSetupCardsInPlay[] = t_computerSetupCardsInPlay.split(";");
|
||||||
|
String humanSetupCardsInHand[] = t_humanSetupCardsInHand.split(";");
|
||||||
|
String computerSetupCardsInHand[] = t_computerSetupCardsInHand.split(";");
|
||||||
|
|
||||||
|
CardList humanDevSetup = new CardList();
|
||||||
|
CardList computerDevSetup = new CardList();
|
||||||
|
CardList humanDevHandSetup = new CardList();
|
||||||
|
CardList computerDevHandSetup = new CardList();
|
||||||
|
|
||||||
|
if (!t_humanSetupCardsInPlay.trim().equals("")) {
|
||||||
|
for (int i = 0; i < humanSetupCardsInPlay.length; i ++) {
|
||||||
|
Card c = AllZone.CardFactory.getCard(humanSetupCardsInPlay[i].trim(), AllZone.HumanPlayer);
|
||||||
|
for(Trigger trig : c.getTriggers()) {
|
||||||
|
AllZone.TriggerHandler.registerTrigger(trig);
|
||||||
|
}
|
||||||
|
|
||||||
|
c.setCurSetCode(c.getMostRecentSet());
|
||||||
|
c.setImageFilename(CardUtil.buildFilename(c));
|
||||||
|
|
||||||
|
humanDevSetup.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!t_humanSetupCardsInHand.trim().equals("")) {
|
||||||
|
for (int i = 0; i < humanSetupCardsInHand.length; i ++) {
|
||||||
|
Card c = AllZone.CardFactory.getCard(humanSetupCardsInHand[i].trim(), AllZone.HumanPlayer);
|
||||||
|
for(Trigger trig : c.getTriggers()) {
|
||||||
|
AllZone.TriggerHandler.registerTrigger(trig);
|
||||||
|
}
|
||||||
|
|
||||||
|
c.setCurSetCode(c.getMostRecentSet());
|
||||||
|
c.setImageFilename(CardUtil.buildFilename(c));
|
||||||
|
|
||||||
|
humanDevHandSetup.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!t_computerSetupCardsInPlay.trim().equals("")) {
|
||||||
|
for (int i = 0; i < computerSetupCardsInPlay.length; i ++) {
|
||||||
|
Card c = AllZone.CardFactory.getCard(computerSetupCardsInPlay[i].trim(), AllZone.ComputerPlayer);
|
||||||
|
|
||||||
|
c.setCurSetCode(c.getMostRecentSet());
|
||||||
|
c.setImageFilename(CardUtil.buildFilename(c));
|
||||||
|
for(Trigger trig : c.getTriggers()) {
|
||||||
|
AllZone.TriggerHandler.registerTrigger(trig);
|
||||||
|
}
|
||||||
|
|
||||||
|
computerDevSetup.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!t_computerSetupCardsInHand.trim().equals("")) {
|
||||||
|
for (int i = 0; i < computerSetupCardsInHand.length; i ++) {
|
||||||
|
Card c = AllZone.CardFactory.getCard(computerSetupCardsInHand[i].trim(), AllZone.ComputerPlayer);
|
||||||
|
|
||||||
|
c.setCurSetCode(c.getMostRecentSet());
|
||||||
|
c.setImageFilename(CardUtil.buildFilename(c));
|
||||||
|
for(Trigger trig : c.getTriggers()) {
|
||||||
|
AllZone.TriggerHandler.registerTrigger(trig);
|
||||||
|
}
|
||||||
|
|
||||||
|
computerDevHandSetup.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Card c : humanDevSetup)
|
||||||
|
{
|
||||||
|
AllZone.Human_Hand.add(c);
|
||||||
|
AllZone.GameAction.moveToPlay(c);
|
||||||
|
c.setSickness(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Card c: computerDevSetup)
|
||||||
|
{
|
||||||
|
AllZone.Computer_Hand.add(c);
|
||||||
|
AllZone.GameAction.moveToPlay(c);
|
||||||
|
c.setSickness(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (computerDevHandSetup.size() > 0)
|
||||||
|
AllZone.Computer_Hand.setCards(computerDevHandSetup.toArray());
|
||||||
|
if (humanDevHandSetup.size() > 0)
|
||||||
|
AllZone.Human_Hand.setCards(humanDevHandSetup.toArray());
|
||||||
|
|
||||||
|
AllZone.ComputerPlayer.setLife(setComputerLife, null);
|
||||||
|
AllZone.HumanPlayer.setLife(setHumanLife, null);
|
||||||
|
|
||||||
|
AllZone.GameAction.checkStateEffects();
|
||||||
|
}
|
||||||
|
|
||||||
// *****************************
|
// *****************************
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ public class SetInfoUtil {
|
|||||||
{"FEM", "", "", "Fallen Empires", "5", "3ED"},
|
{"FEM", "", "", "Fallen Empires", "5", "3ED"},
|
||||||
{"4ED", "", "", "Fourth Edition", "3", "4ED"},
|
{"4ED", "", "", "Fourth Edition", "3", "4ED"},
|
||||||
{"ICE", "ALL", "CSP", "Ice Age", "3", "ICE"},
|
{"ICE", "ALL", "CSP", "Ice Age", "3", "ICE"},
|
||||||
{"CHR", "", "", "Chronicles", "4", "4ED"},
|
//{"CHR", "", "", "Chronicles", "4", "4ED"},
|
||||||
{"HML", "", "", "Homelands", "5", "4ED"},
|
{"HML", "", "", "Homelands", "5", "4ED"},
|
||||||
{"MIR", "VIS", "WTH", "Mirage", "3", "MIR"},
|
{"MIR", "VIS", "WTH", "Mirage", "3", "MIR"},
|
||||||
{"5ED", "", "", "Fifth Edition", "3", "5ED"},
|
{"5ED", "", "", "Fifth Edition", "3", "5ED"},
|
||||||
|
|||||||
Reference in New Issue
Block a user