Merge pull request #3170 from kevlahnota/newmaster2

update mobile gamestate options
This commit is contained in:
Anthony Calosa
2023-05-31 12:38:38 +08:00
committed by GitHub
6 changed files with 45 additions and 18 deletions

View File

@@ -107,7 +107,7 @@ public abstract class GameState {
public GameState() { public GameState() {
} }
public abstract IPaperCard getPaperCard(String cardName); public abstract IPaperCard getPaperCard(String cardName, String setCode, int artID);
@Override @Override
public String toString() { public String toString() {
@@ -258,9 +258,12 @@ public abstract class GameState {
if (c.hasMergedCard()) { if (c.hasMergedCard()) {
// we have to go by the current top card name here // we have to go by the current top card name here
newText.append(c.getTopMergedCard().getPaperCard().getName()); newText.append(c.getTopMergedCard().getPaperCard().getName()).append("|Set:")
.append(c.getTopMergedCard().getPaperCard().getEdition()).append("|Art:")
.append(c.getTopMergedCard().getPaperCard().getArtIndex());
} else { } else {
newText.append(c.getPaperCard().getName()); newText.append(c.getPaperCard().getName()).append("|Set:").append(c.getPaperCard().getEdition())
.append("|Art:").append(c.getPaperCard().getArtIndex());
} }
} }
if (c.isCommander()) { if (c.isCommander()) {
@@ -735,9 +738,11 @@ public abstract class GameState {
String id = rememberedEnts.getValue(); String id = rememberedEnts.getValue();
Card exiledWith = idToCard.get(Integer.parseInt(id)); Card exiledWith = idToCard.get(Integer.parseInt(id));
exiledWith.addExiledCard(c); if (exiledWith != null) {
c.setExiledWith(exiledWith); exiledWith.addExiledCard(c);
c.setExiledBy(exiledWith.getController()); c.setExiledWith(exiledWith);
c.setExiledBy(exiledWith.getController());
}
} }
} }
@@ -1196,6 +1201,18 @@ public abstract class GameState {
} }
} }
int artID = -1;
for (final String info : cardinfo) {
if (info.startsWith("Art:")) {
try {
artID = Integer.parseInt(info.substring(info.indexOf(':') + 1));
} catch (Exception e) {
break;
}
break;
}
}
Card c; Card c;
boolean hasSetCurSet = false; boolean hasSetCurSet = false;
if (cardinfo[0].startsWith("t:")) { if (cardinfo[0].startsWith("t:")) {
@@ -1212,7 +1229,7 @@ public abstract class GameState {
} }
c = Card.fromPaperCard(token, player, player.getGame()); c = Card.fromPaperCard(token, player, player.getGame());
} else { } else {
PaperCard pc = StaticData.instance().getCommonCards().getCard(cardinfo[0], setCode); PaperCard pc = StaticData.instance().getCommonCards().getCard(cardinfo[0], setCode, artID);
if (pc == null) { if (pc == null) {
System.err.println("ERROR: Tried to create a non-existent card named " + cardinfo[0] + " (set: " + (setCode == null ? "any" : setCode) + ") when loading game state!"); System.err.println("ERROR: Tried to create a non-existent card named " + cardinfo[0] + " (set: " + (setCode == null ? "any" : setCode) + ") when loading game state!");
continue; continue;

View File

@@ -29,12 +29,14 @@ import forge.toolbox.GuiChoose;
import forge.util.*; import forge.util.*;
import java.io.File; import java.io.File;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
public class GuiMobile implements IGuiBase { public class GuiMobile implements IGuiBase {
private final String assetsDir; private final String assetsDir;
private ImageFetcher imageFetcher = new LibGDXImageFetcher(); private ImageFetcher imageFetcher = new LibGDXImageFetcher();
private List<Integer> integerChoices = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
public GuiMobile(final String assetsDir0) { public GuiMobile(final String assetsDir0) {
assetsDir = assetsDir0; assetsDir = assetsDir0;
@@ -256,12 +258,20 @@ public class GuiMobile implements IGuiBase {
@Override @Override
public String showFileDialog(final String title, final String defaultDir) { public String showFileDialog(final String title, final String defaultDir) {
return ForgeConstants.USER_GAMES_DIR + "Test.fgs"; //TODO: Show dialog //TODO Android FilePicker varies, since we cant test all possible android versions, just return a selection..
List<Integer> v = getChoices(title, 0, 1, integerChoices, null, null);
if (v == null || v.isEmpty())
return null;
return defaultDir + "state" + v.get(0) + ".txt";
} }
@Override @Override
public File getSaveFile(final File defaultFile) { public File getSaveFile(final File defaultFile) {
return defaultFile; //TODO: Show dialog //TODO Android FilePicker varies, since we cant test all possible android versions, just return a selection..
List<Integer> v = getChoices(Localizer.getInstance().getMessage("lblSelectGameStateFile"), 0, 1, integerChoices, null, null);
if (v == null || v.isEmpty())
return null;
return new File(ForgeConstants.USER_GAMES_DIR + "state" + v.get(0) + ".txt");
} }
@Override @Override

View File

@@ -262,9 +262,9 @@ public class MatchController extends AbstractGuiGame {
if (ph != null && saveState && ph.isMain()) { if (ph != null && saveState && ph.isMain()) {
phaseGameState = new GameState() { phaseGameState = new GameState() {
@Override //todo get specific card edition for this function? @Override
public IPaperCard getPaperCard(final String cardName) { public IPaperCard getPaperCard(final String cardName, final String setCode, final int artID) {
return FModel.getMagicDb().getCommonCards().getCard(cardName); return FModel.getMagicDb().getCommonCards().getCard(cardName, setCode, artID);
} }
}; };
try { try {

View File

@@ -2094,8 +2094,8 @@ lblHowManyAdditionalVotesDoYouWant=How many additional votes do you want?
lblUnlimitedLands=Play Unlimited Lands lblUnlimitedLands=Play Unlimited Lands
lblGenerateMana=Generate Mana lblGenerateMana=Generate Mana
lblViewAll=View All Cards lblViewAll=View All Cards
lblSetupGame=Setup Game State lblSetupGame=Load Game State
lblDumpGame=Dump Game State lblDumpGame=Save Game State
lblTutor=Tutor for Card lblTutor=Tutor for Card
lblRollbackPhase=Rollback Phase lblRollbackPhase=Rollback Phase
lblAddCounterPermanent=Add Counters to Card lblAddCounterPermanent=Add Counters to Card

View File

@@ -98,8 +98,8 @@ public class Puzzle extends GameState implements InventoryItem, Comparable<Puzzl
this.parse(stateLines); this.parse(stateLines);
} }
public IPaperCard getPaperCard(final String cardName) { public IPaperCard getPaperCard(final String cardName, final String setCode, final int artID) {
return FModel.getMagicDb().getCommonCards().getCard(cardName); return FModel.getMagicDb().getCommonCards().getCard(cardName, setCode, artID);
} }
public void setupMaxPlayerHandSize(Game game, int maxHandSize) { public void setupMaxPlayerHandSize(Game game, int maxHandSize) {

View File

@@ -2451,8 +2451,8 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
private GameState createGameStateObject() { private GameState createGameStateObject() {
return new GameState() { return new GameState() {
@Override @Override
public IPaperCard getPaperCard(final String cardName) { public IPaperCard getPaperCard(final String cardName, final String setCode, final int artID) {
return FModel.getMagicDb().getCommonCards().getCard(cardName); return FModel.getMagicDb().getCommonCards().getCard(cardName, setCode, artID);
} }
}; };
} }