From 73c98b0e33344f86d8c9b22b0bba574562c0c4fa Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 16:01:39 +0000 Subject: [PATCH] Enable use of per-set PicCount... hopefully. --- src/forge/GameAction.java | 32 +++++++++++------- src/forge/Gui_BoosterDraft.java | 22 +++++++----- src/forge/Gui_CardShop.java | 45 ++++++++++++++----------- src/forge/Gui_DeckEditor.java | 51 ++++++++++++++++------------ src/forge/Gui_Quest_DeckEditor.java | 52 +++++++++++++++++------------ src/forge/SetInfo.java | 15 +++++++++ 6 files changed, 133 insertions(+), 84 deletions(-) diff --git a/src/forge/GameAction.java b/src/forge/GameAction.java index 1f99b221b99..315b8243ef7 100644 --- a/src/forge/GameAction.java +++ b/src/forge/GameAction.java @@ -2294,14 +2294,17 @@ public class GameAction { card.setUniqueNumber(nextUniqueNumber++); //if(card.isBasicLand()) { - String PC = card.getSVar("PicCount"); - int n = 0; - if (PC.matches("[0-9][0-9]?")) - n = Integer.parseInt(PC); - if (n > 1) - card.setRandomPicture(generator.nextInt(n)); + //String PC = card.getSVar("PicCount"); + //if (PC.matches("[0-9][0-9]?")) + // n = Integer.parseInt(PC); + if ((card.getSets().size() > 0) && card.getCurSetCode().equals("")) card.setRandomSetCode(); + + int n = SetInfoUtil.getSetInfo_Code(card.getSets(), card.getCurSetCode()).PicCount; + if (n > 1) + card.setRandomPicture(generator.nextInt(n)); + card.setImageFilename(CardUtil.buildFilename(card)); //System.out.println("human random number:" + card.getRandomPicture()); @@ -2321,16 +2324,21 @@ public class GameAction { card.setUniqueNumber(nextUniqueNumber++); //if(card.isBasicLand()) { - String PC = card.getSVar("PicCount"); - int n = 0; - if (PC.matches("[0-9][0-9]?")) - n = Integer.parseInt(PC); - if (n > 1) - card.setRandomPicture(generator.nextInt(n)); + //String PC = card.getSVar("PicCount"); + //int n = 0; + //if (PC.matches("[0-9][0-9]?")) + // n = Integer.parseInt(PC); + //if (n > 1) + // card.setRandomPicture(generator.nextInt(n)); //System.out.println("computer random number:" + card.getRandomPicture()); //} if ((card.getSets().size() > 0) && card.getCurSetCode().equals("")) card.setRandomSetCode(); + + int n = SetInfoUtil.getSetInfo_Code(card.getSets(), card.getCurSetCode()).PicCount; + if (n > 1) + card.setRandomPicture(generator.nextInt(n)); + card.setImageFilename(CardUtil.buildFilename(card)); AllZone.Computer_Library.add(card); diff --git a/src/forge/Gui_BoosterDraft.java b/src/forge/Gui_BoosterDraft.java index 7a8cff284e0..7f6c9849281 100644 --- a/src/forge/Gui_BoosterDraft.java +++ b/src/forge/Gui_BoosterDraft.java @@ -507,19 +507,23 @@ public class Gui_BoosterDraft extends JFrame implements CardContainer, NewConsta c = list.get(i); c.setRarity(pack.getRarity(c.getName())); - String PC = c.getSVar("PicCount"); + //String PC = c.getSVar("PicCount"); Random r = new Random(); - int n = 0; - if (PC.matches("[0-9][0-9]?")) - n = Integer.parseInt(PC); + //int n = 0; + //if (PC.matches("[0-9][0-9]?")) + // n = Integer.parseInt(PC); + //if (n > 1) + // c.setRandomPicture(r.nextInt(n)); + + if (c.getCurSetCode().equals("")) + c.setCurSetCode(c.getMostRecentSet()); + + int n = SetInfoUtil.getSetInfo_Code(c.getSets(), c.getCurSetCode()).PicCount; if (n > 1) c.setRandomPicture(r.nextInt(n)); - if (c.getCurSetCode().equals("")) - { - c.setCurSetCode(c.getMostRecentSet()); - c.setImageFilename(CardUtil.buildFilename(c)); - } + c.setImageFilename(CardUtil.buildFilename(c)); + allCardModel.addCard(c); } diff --git a/src/forge/Gui_CardShop.java b/src/forge/Gui_CardShop.java index e8204c521c9..5b85575748e 100644 --- a/src/forge/Gui_CardShop.java +++ b/src/forge/Gui_CardShop.java @@ -118,20 +118,23 @@ public class Gui_CardShop extends JFrame implements CardContainer, DeckDisplay, c.setRarity(pack.getRarity(cardName)); } - String PC = c.getSVar("PicCount"); + //String PC = c.getSVar("PicCount"); Random r = new Random(); - int n = 0; - if (PC.matches("[0-9][0-9]?")) - n = Integer.parseInt(PC); - if (n > 1) - c.setRandomPicture(r.nextInt(n)); + //int n = 0; + //if (PC.matches("[0-9][0-9]?")) + // n = Integer.parseInt(PC); + //if (n > 1) + // c.setRandomPicture(r.nextInt(n)); if (c.getCurSetCode().equals("")) - { c.setCurSetCode(c.getMostRecentSet()); - c.setImageFilename(CardUtil.buildFilename(c)); - } - + + int n = SetInfoUtil.getSetInfo_Code(c.getSets(), c.getCurSetCode()).PicCount; + if (n > 1) + c.setRandomPicture(r.nextInt(n)); + + c.setImageFilename(CardUtil.buildFilename(c)); + topModel.addCard(c); @@ -144,19 +147,23 @@ public class Gui_CardShop extends JFrame implements CardContainer, DeckDisplay, // add rarity to card if this is a sealed card pool if(!customMenu.getGameType().equals(Constant.GameType.Constructed)) c.setRarity(pack.getRarity(c.getName())); - String PC = c.getSVar("PicCount"); + //String PC = c.getSVar("PicCount"); Random r = new Random(); - int n = 0; - if (PC.matches("[0-9][0-9]?")) - n = Integer.parseInt(PC); + //int n = 0; + //if (PC.matches("[0-9][0-9]?")) + // n = Integer.parseInt(PC); + //if (n > 1) + // c.setRandomPicture(r.nextInt(n)); + + if (c.getCurSetCode().equals("")) + c.setCurSetCode(c.getMostRecentSet()); + + int n = SetInfoUtil.getSetInfo_Code(c.getSets(), c.getCurSetCode()).PicCount; if (n > 1) c.setRandomPicture(r.nextInt(n)); - if (c.getCurSetCode().equals("")) - { - c.setCurSetCode(c.getMostRecentSet()); - c.setImageFilename(CardUtil.buildFilename(c)); - } + c.setImageFilename(CardUtil.buildFilename(c)); + bottomModel.addCard(c); }// for diff --git a/src/forge/Gui_DeckEditor.java b/src/forge/Gui_DeckEditor.java index 86b55c97302..8ee1b997a2c 100644 --- a/src/forge/Gui_DeckEditor.java +++ b/src/forge/Gui_DeckEditor.java @@ -182,21 +182,24 @@ public class Gui_DeckEditor extends JFrame implements CardContainer, DeckDisplay filteredOut = filterByType(c); } - String PC = c.getSVar("PicCount"); + //String PC = c.getSVar("PicCount"); Random r = new Random(); - int n = 0; - if (!PC.equals("")) { - if (PC.matches("[0-9][0-9]?")) - n = Integer.parseInt(PC); - if (n > 1) - c.setRandomPicture(r.nextInt(n)); - } + //int n = 0; + //if (!PC.equals("")) { + // if (PC.matches("[0-9][0-9]?")) + // n = Integer.parseInt(PC); + // if (n > 1) + // c.setRandomPicture(r.nextInt(n)); + //} if (c.getCurSetCode().equals("")) - { c.setCurSetCode(c.getMostRecentSet()); - c.setImageFilename(CardUtil.buildFilename(c)); - } + + int n = SetInfoUtil.getSetInfo_Code(c.getSets(), c.getCurSetCode()).PicCount; + if (n > 1) + c.setRandomPicture(r.nextInt(n)); + + c.setImageFilename(CardUtil.buildFilename(c)); if(!filteredOut) { @@ -211,21 +214,25 @@ public class Gui_DeckEditor extends JFrame implements CardContainer, DeckDisplay // add rarity to card if this is a sealed card pool if(!customMenu.getGameType().equals(Constant.GameType.Constructed)) c.setRarity(pack.getRarity(c.getName())); - String PC = c.getSVar("PicCount"); + //String PC = c.getSVar("PicCount"); Random r = new Random(); - int n = 0; - if (!PC.equals("")) { - if (PC.matches("[0-9][0-9]?")) - n = Integer.parseInt(PC); - if (n > 1) - c.setRandomPicture(r.nextInt(n)); - } + //int n = 0; + //if (!PC.equals("")) { + // if (PC.matches("[0-9][0-9]?")) + // n = Integer.parseInt(PC); + // if (n > 1) + // c.setRandomPicture(r.nextInt(n)); + //} if (c.getCurSetCode().equals("")) - { c.setCurSetCode(c.getMostRecentSet()); - c.setImageFilename(CardUtil.buildFilename(c)); - } + + int n = SetInfoUtil.getSetInfo_Code(c.getSets(), c.getCurSetCode()).PicCount; + if (n > 1) + c.setRandomPicture(r.nextInt(n)); + + c.setImageFilename(CardUtil.buildFilename(c)); + bottomModel.addCard(c); }// for diff --git a/src/forge/Gui_Quest_DeckEditor.java b/src/forge/Gui_Quest_DeckEditor.java index 16a0893b7b0..d8079b53622 100644 --- a/src/forge/Gui_Quest_DeckEditor.java +++ b/src/forge/Gui_Quest_DeckEditor.java @@ -141,21 +141,25 @@ public class Gui_Quest_DeckEditor extends JFrame implements CardContainer, DeckD if(addedList.contains(cardName)) c.setRarity("new"); - String PC = c.getSVar("PicCount"); + //String PC = c.getSVar("PicCount"); Random r = new Random(); - int n = 0; - if (!PC.equals("")) { - if (PC.matches("[0-9][0-9]?")) - n = Integer.parseInt(PC); - if (n > 1) - c.setRandomPicture(r.nextInt(n)); - } + //int n = 0; + //if (!PC.equals("")) { + // if (PC.matches("[0-9][0-9]?")) + // n = Integer.parseInt(PC); + // if (n > 1) + // c.setRandomPicture(r.nextInt(n)); + //} if (c.getCurSetCode().equals("")) - { c.setCurSetCode(c.getMostRecentSet()); - c.setImageFilename(CardUtil.buildFilename(c)); - } + + int n = SetInfoUtil.getSetInfo_Code(c.getSets(), c.getCurSetCode()).PicCount; + if (n > 1) + c.setRandomPicture(r.nextInt(n)); + + c.setImageFilename(CardUtil.buildFilename(c)); + topModel.addCard(c); @@ -167,21 +171,25 @@ public class Gui_Quest_DeckEditor extends JFrame implements CardContainer, DeckD c.setRarity(pack.getRarity(c.getName()));; - String PC = c.getSVar("PicCount"); + //String PC = c.getSVar("PicCount"); Random r = new Random(); - int n = 0; - if (!PC.equals("")){ - if (PC.matches("[0-9][0-9]?")) - n = Integer.parseInt(PC); - if (n > 1) - c.setRandomPicture(r.nextInt(n)); - } + //int n = 0; + //if (!PC.equals("")){ + // if (PC.matches("[0-9][0-9]?")) + // n = Integer.parseInt(PC); + // if (n > 1) + // c.setRandomPicture(r.nextInt(n)); + //} if (c.getCurSetCode().equals("")) - { c.setCurSetCode(c.getMostRecentSet()); - c.setImageFilename(CardUtil.buildFilename(c)); - } + + int n = SetInfoUtil.getSetInfo_Code(c.getSets(), c.getCurSetCode()).PicCount; + if (n > 1) + c.setRandomPicture(r.nextInt(n)); + + c.setImageFilename(CardUtil.buildFilename(c)); + bottomModel.addCard(c); }//for diff --git a/src/forge/SetInfo.java b/src/forge/SetInfo.java index 4da9a4fe9c2..c3f2eac9343 100644 --- a/src/forge/SetInfo.java +++ b/src/forge/SetInfo.java @@ -4,12 +4,14 @@ public class SetInfo{ public String Code; public String Rarity; public String URL; + public int PicCount; public SetInfo() { Code = ""; Rarity = ""; URL = ""; + PicCount = 0; } public SetInfo(String c, String r, String u) @@ -17,6 +19,15 @@ public class SetInfo{ Code = c; Rarity = r; URL = u; + PicCount = 0; + } + + public SetInfo(String c, String r, String u, int p) + { + Code = c; + Rarity = r; + URL = u; + PicCount = p; } public SetInfo(String parse) @@ -25,6 +36,10 @@ public class SetInfo{ Code = pp[0]; Rarity = pp[1]; URL = pp[2]; + if (pp.length > 3) + PicCount = Integer.parseInt(pp[3]); + else + PicCount = 0; } public String toString()