Support creating gauntlets from contests

This commit is contained in:
drdev
2014-08-09 05:22:20 +00:00
parent 0eb50905f8
commit ce95b9e8ac
5 changed files with 64 additions and 37 deletions

1
.gitattributes vendored
View File

@@ -1186,7 +1186,6 @@ forge-gui-mobile/src/forge/screens/constructed/ConstructedScreen.java -text
forge-gui-mobile/src/forge/screens/draft/DraftScreen.java -text forge-gui-mobile/src/forge/screens/draft/DraftScreen.java -text
forge-gui-mobile/src/forge/screens/draft/DraftingProcessScreen.java -text forge-gui-mobile/src/forge/screens/draft/DraftingProcessScreen.java -text
forge-gui-mobile/src/forge/screens/gauntlet/GauntletScreen.java -text forge-gui-mobile/src/forge/screens/gauntlet/GauntletScreen.java -text
forge-gui-mobile/src/forge/screens/gauntlet/NewGauntletScreen.java -text
forge-gui-mobile/src/forge/screens/home/HomeScreen.java -text forge-gui-mobile/src/forge/screens/home/HomeScreen.java -text
forge-gui-mobile/src/forge/screens/match/FControl.java -text forge-gui-mobile/src/forge/screens/match/FControl.java -text
forge-gui-mobile/src/forge/screens/match/MatchScreen.java -text forge-gui-mobile/src/forge/screens/match/MatchScreen.java -text

View File

@@ -63,7 +63,6 @@ public enum CSubmenuGauntletContests implements ICDoc {
view.getGauntletLister().setSelectedIndex(0); view.getGauntletLister().setSelectedIndex(0);
} }
private void updateData() { private void updateData() {
final File[] files = GauntletIO.getGauntletFilesLocked(); final File[] files = GauntletIO.getGauntletFilesLocked();
final List<GauntletData> data = new ArrayList<GauntletData>(); final List<GauntletData> data = new ArrayList<GauntletData>();
@@ -108,7 +107,6 @@ public enum CSubmenuGauntletContests implements ICDoc {
starter.add(new RegisteredPlayer(aiDeck).setPlayer(fc.createAiPlayer())); starter.add(new RegisteredPlayer(aiDeck).setPlayer(fc.createAiPlayer()));
fc.startMatch(GameType.Gauntlet, starter); fc.startMatch(GameType.Gauntlet, starter);
} }
/* (non-Javadoc) /* (non-Javadoc)

View File

@@ -210,7 +210,35 @@ public class GauntletScreen extends LaunchScreen {
} }
private void createGauntletContest() { private void createGauntletContest() {
final File[] files = GauntletIO.getGauntletFilesLocked();
final List<GauntletData> contests = new ArrayList<GauntletData>();
for (final File f : files) {
contests.add(GauntletIO.loadGauntlet(f));
}
GuiChoose.oneOrNone("Select Gauntlet Contest", contests, new Callback<GauntletData>() {
@Override
public void run(final GauntletData contest) {
if (contest == null) { return; }
FDeckChooser.promptForDeck("Select Your Deck", GameType.Gauntlet, false, new Callback<Deck>() {
@Override
public void run(final Deck userDeck) {
if (userDeck == null) { return; }
//create copy of contest to use as gauntlet
GauntletData gauntlet = new GauntletData();
gauntlet.setDecks(new ArrayList<Deck>(contest.getDecks()));
gauntlet.setEventNames(new ArrayList<String>(contest.getEventNames()));
gauntlet.setUserDeck(userDeck);
GauntletUtil.setDefaultGauntletName(gauntlet, contest.getDisplayName() + "_");
FModel.setGauntletData(gauntlet);
gauntlet.reset();
lstGauntlets.addGauntlet(gauntlet);
}
});
}
});
} }
@Override @Override

View File

@@ -1,15 +0,0 @@
package forge.screens.gauntlet;
import forge.screens.FScreen;
public class NewGauntletScreen extends FScreen {
public NewGauntletScreen() {
super("New Gauntlet");
}
@Override
protected void doLayout(float startY, float width, float height) {
}
}

View File

@@ -4,6 +4,7 @@ import com.thoughtworks.xstream.annotations.XStreamOmitField;
import forge.deck.Deck; import forge.deck.Deck;
import forge.properties.ForgeConstants; import forge.properties.ForgeConstants;
import java.io.File; import java.io.File;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@@ -47,10 +48,10 @@ public final class GauntletData {
*/ */
public void rename(final String newName) { public void rename(final String newName) {
File newpath = new File(ForgeConstants.GAUNTLET_DIR.userPrefLoc, newName + ".dat"); File newpath = new File(ForgeConstants.GAUNTLET_DIR.userPrefLoc, newName + ".dat");
File oldpath = new File(ForgeConstants.GAUNTLET_DIR.userPrefLoc, this.name + ".dat"); File oldpath = new File(ForgeConstants.GAUNTLET_DIR.userPrefLoc, name + ".dat");
oldpath.renameTo(newpath); oldpath.renameTo(newpath);
this.name = newName; name = newName;
GauntletIO.saveGauntlet(this); GauntletIO.saveGauntlet(this);
} }
@@ -58,42 +59,49 @@ public final class GauntletData {
return name; return name;
} }
public String getDisplayName() {
if (name.startsWith(GauntletIO.PREFIX_LOCKED)) { //trim locked prefix if needed
return name.substring(GauntletIO.PREFIX_LOCKED.length());
}
return name;
}
public void stamp() { public void stamp() {
final DateFormat dateFormat = new SimpleDateFormat("MM-dd-yy, H:m"); final DateFormat dateFormat = new SimpleDateFormat("MM-dd-yy, H:m");
this.timestamp = dateFormat.format(new Date()).toString(); timestamp = dateFormat.format(new Date()).toString();
} }
/** Resets a gauntlet data to an unplayed state, then stamps and saves. */ /** Resets a gauntlet data to an unplayed state, then stamps and saves. */
public void reset() { public void reset() {
this.completed = 0; completed = 0;
this.stamp(); stamp();
this.eventRecords.clear(); eventRecords.clear();
for (int i = 0; i < decks.size(); i++) { for (int i = 0; i < decks.size(); i++) {
this.eventRecords.add(""); eventRecords.add("");
} }
GauntletIO.saveGauntlet(this); GauntletIO.saveGauntlet(this);
} }
public String getTimestamp() { public String getTimestamp() {
return this.timestamp; return timestamp;
} }
public void setCompleted(final int i0) { public void setCompleted(final int i0) {
this.completed = i0; completed = i0;
} }
public int getCompleted() { public int getCompleted() {
return this.completed; return completed;
} }
public void setUserDeck(final Deck d0) { public void setUserDeck(final Deck d0) {
this.userDeck = d0; userDeck = d0;
} }
public Deck getUserDeck() { public Deck getUserDeck() {
return this.userDeck; return userDeck;
} }
public List<String> getDeckNames() { public List<String> getDeckNames() {
@@ -103,26 +111,35 @@ public final class GauntletData {
} }
public void setEventRecords(final List<String> records0) { public void setEventRecords(final List<String> records0) {
this.eventRecords = records0; eventRecords = records0;
} }
public List<String> getEventRecords() { public List<String> getEventRecords() {
return this.eventRecords; return eventRecords;
} }
public void setEventNames(final List<String> names0) { public void setEventNames(final List<String> names0) {
this.eventNames = names0; eventNames = names0;
} }
public List<String> getEventNames() { public List<String> getEventNames() {
return this.eventNames; return eventNames;
} }
public void setDecks(final List<Deck> decks0) { public void setDecks(final List<Deck> decks0) {
this.decks = decks0; decks = decks0;
} }
public List<Deck> getDecks() { public List<Deck> getDecks() {
return this.decks; return decks;
}
@Override
public String toString() {
String str = getDisplayName();
if (decks != null) {
str += " (" + decks.size() + " opponents)";
}
return str;
} }
} }