diff --git a/res/cards.txt b/res/cards.txt index ce2661ef6d3..95f060f72f0 100644 --- a/res/cards.txt +++ b/res/cards.txt @@ -1,3 +1,14 @@ +Magus of the Tabernacle +3 W +Creature Human Wizard +All creatures have "At the beginning of your upkeep, sacrifice this creature unless you pay 1." +2/6 + +The Tabernacle at Pendrell Vale +no cost +Legendary Land +All creatures have "At the beginning of your upkeep, destroy this creature unless you pay 1." + Donate 2 U Sorcery @@ -3260,7 +3271,7 @@ no text 1,tap: add WU Bog Initiate -B +1 B Creature Human Wizard no text 1/1 diff --git a/res/gui/display_layout.xml b/res/gui/display_layout.xml index 989e8a1e88a..bccfaa3c994 100644 --- a/res/gui/display_layout.xml +++ b/res/gui/display_layout.xml @@ -16,7 +16,7 @@ 0 0 - 244 + 245 827 @@ -27,8 +27,8 @@ 0 0 - 244 - 138 + 245 + 132 @@ -47,8 +47,8 @@ 0 - 138 - 244 + 132 + 245 10 @@ -62,9 +62,9 @@ 0 - 148 - 244 - 190 + 142 + 245 + 196 @@ -84,7 +84,7 @@ 0 338 - 244 + 245 10 @@ -99,7 +99,7 @@ 0 348 - 244 + 245 113 @@ -120,7 +120,7 @@ 0 461 - 244 + 245 10 @@ -135,7 +135,7 @@ 0 471 - 244 + 245 107 @@ -156,7 +156,7 @@ 0 578 - 244 + 245 10 @@ -171,7 +171,7 @@ 0 588 - 244 + 245 239 @@ -202,7 +202,7 @@ - 244 + 245 0 10 827 @@ -217,9 +217,9 @@ - 254 + 255 0 - 926 + 901 827 @@ -228,9 +228,9 @@ - 254 + 255 0 - 926 + 901 147 @@ -249,9 +249,9 @@ - 254 + 255 147 - 926 + 901 10 @@ -264,9 +264,9 @@ - 254 + 255 157 - 926 + 901 169 @@ -285,9 +285,9 @@ - 254 + 255 326 - 926 + 901 10 @@ -300,9 +300,9 @@ - 254 + 255 336 - 926 + 901 187 @@ -321,9 +321,9 @@ - 254 + 255 523 - 926 + 901 10 @@ -336,9 +336,9 @@ - 254 + 255 533 - 926 + 901 145 @@ -357,9 +357,9 @@ - 254 + 255 678 - 926 + 901 10 @@ -372,9 +372,9 @@ - 254 + 255 688 - 926 + 901 139 @@ -408,7 +408,7 @@ - 1180 + 1156 0 10 827 @@ -423,9 +423,9 @@ - 1190 + 1166 0 - 250 + 274 827 @@ -434,9 +434,9 @@ - 1190 + 1166 0 - 250 + 274 409 @@ -455,9 +455,9 @@ - 1190 + 1166 409 - 250 + 274 10 @@ -470,9 +470,9 @@ - 1190 + 1166 419 - 250 + 274 408 diff --git a/src/forge/Card.java b/src/forge/Card.java index 5396f7080cf..9b54815a6b5 100644 --- a/src/forge/Card.java +++ b/src/forge/Card.java @@ -81,6 +81,8 @@ public class Card extends MyObservable private String text = ""; private String manaCost = ""; private String upkeepCost = ""; + private String tabernacleUpkeepCost = ""; + private String magusTabernacleUpkeepCost = ""; private String echoCost = ""; private String chosenType = ""; private String chosenColor = ""; @@ -254,6 +256,12 @@ public class Card extends MyObservable public String getUpkeepCost() {return upkeepCost;} public boolean hasUpkeepCost(){return upkeepCost.length() > 0 && !upkeepCost.equals("0");} + public void setTabernacleUpkeepCost(String s) { tabernacleUpkeepCost = s; } + public String getTabernacleUpkeepCost() { return tabernacleUpkeepCost; } + + public void setMagusTabernacleUpkeepCost(String s) { magusTabernacleUpkeepCost = s; } + public String getMagusTabernacleUpkeepCost() { return magusTabernacleUpkeepCost; } + //used for cards like Belbe's Portal, Conspiracy, Cover of Darkness, etc. public String getChosenType() { return chosenType;} public void setChosenType(String s) {chosenType = s;} diff --git a/src/forge/CardFactory_Creatures.java b/src/forge/CardFactory_Creatures.java index 62da62076f6..fce33d65b95 100644 --- a/src/forge/CardFactory_Creatures.java +++ b/src/forge/CardFactory_Creatures.java @@ -7826,8 +7826,8 @@ public class CardFactory_Creatures { if(AllZone.GameAction.isCardInZone(target[0], grave)) { PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); - AllZone.GameAction.moveTo(play, target[0]); target[0].setController(card.getController()); + AllZone.GameAction.moveTo(play, target[0]); } } }); diff --git a/src/forge/CardFactory_Lands.java b/src/forge/CardFactory_Lands.java index e76d63fc0c0..df944ae68a8 100644 --- a/src/forge/CardFactory_Lands.java +++ b/src/forge/CardFactory_Lands.java @@ -1625,7 +1625,7 @@ class CardFactory_Lands { } } - if (cards.size() > 0 && AllZone.GameAction.isCardInPlay(card) && card.isUntapped()) + if (super.canPlay() && cards.size() > 0 && AllZone.GameAction.isCardInPlay(card) && card.isUntapped()) return true; else return false; diff --git a/src/forge/GameAction.java b/src/forge/GameAction.java index fa2ba7edfea..c18c92afd88 100644 --- a/src/forge/GameAction.java +++ b/src/forge/GameAction.java @@ -134,8 +134,8 @@ private Card getCurrentCard(int ID) public void discardHand(String player) { PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player); - for (int i=0;i a = c.getKeyword(); for (int i = 0; i < a.size(); i++) { - if (a.get(i).toString().startsWith("At the beginning of your upkeep, sacrifice ")) + if (a.get(i).toString().startsWith("At the beginning of your upkeep, destroy this creature unless you pay")) { - String k[] = a.get(i).toString().split(":"); - c.setUpkeepCost(k[1]); + String k[] = a.get(i).toString().split("pay "); + k[1] = k[1].substring(0, k[1].length()-1); + c.setTabernacleUpkeepCost(k[1]); return true; } } @@ -2498,7 +2501,7 @@ public class GameActionUtil { final Card c = list.get(i); - final Ability sacAbility = new Ability(c, c.getUpkeepCost()) + final Ability destroyAbility = new Ability(c, c.getTabernacleUpkeepCost()) { public void resolve() { @@ -2511,7 +2514,7 @@ public class GameActionUtil private static final long serialVersionUID = -8737736216222268696L; public void execute() { - AllZone.GameAction.sacrifice(c); + AllZone.GameAction.destroy(c); } }; @@ -2525,17 +2528,86 @@ public class GameActionUtil //AllZone.Stack.add(sacAbility); if (c.getController().equals(Constant.Player.Human)) { - AllZone.InputControl.setInput(new Input_PayManaCost_Ability("Upkeep for "+ c +"\r\n", sacAbility.getManaCost(), paidCommand, unpaidCommand)); + AllZone.InputControl.setInput(new Input_PayManaCost_Ability("Tabernacle Upkeep for "+ c +"\r\n", destroyAbility.getManaCost(), paidCommand, unpaidCommand)); } else //computer { - if (ComputerUtil.canPayCost(sacAbility)) - ComputerUtil.playNoStack(sacAbility); + if (ComputerUtil.canPayCost(destroyAbility)) + ComputerUtil.playNoStack(destroyAbility); + else + AllZone.GameAction.destroy(c); + } + } + }//TabernacleUpkeepCost + + public static void upkeep_MagusTabernacleUpkeepCost() + { + String player = AllZone.Phase.getActivePlayer(); + + PlayerZone play = AllZone.getZone(Constant.Zone.Play, player); + CardList list = new CardList(); + list.addAll(play.getCards()); + //list = list.getType("Creature"); + list = list.filter(new CardListFilter() + { + public boolean addCard(Card c) + { + ArrayList a = c.getKeyword(); + for (int i = 0; i < a.size(); i++) + { + if (a.get(i).toString().startsWith("At the beginning of your upkeep, sacrifice this creature unless you pay")) + { + String k[] = a.get(i).toString().split("pay "); + k[1] = k[1].substring(0, k[1].length()-1); + c.setMagusTabernacleUpkeepCost(k[1]); + return true; + } + } + return false; + } + }); + + for (int i=0; i a = c.getKeyword(); + for (int i = 0; i < a.size(); i++) + { + if (a.get(i).toString().startsWith("At the beginning of your upkeep, sacrifice " +c.getName())) + { + String k[] = a.get(i).toString().split(":"); + c.setUpkeepCost(k[1]); + return true; + } + } + return false; + } + }); + + for (int i=0; i a = c.getKeyword(); + for (String s : a) + { + if (s.startsWith(keyword)) + c.removeExtrinsicKeyword(s); + } + } + + list.clear(); + PlayerZone cPlay = AllZone.Computer_Play; + PlayerZone hPlay = AllZone.Human_Play; + CardList clist = new CardList(); + clist.addAll(cPlay.getCards()); + clist.addAll(hPlay.getCards()); + clist = clist.filter(new CardListFilter(){ + public boolean addCard(Card c) + { + return c.getName().equals("The Tabernacle at Pendrell Vale"); /*|| c.getName().equals("Magus of the Tabernacle");*/ + } + }); + + int number = clist.size(); + //System.out.println("Tabernacle Number:" + number); + if (number > 0) { + CardList creature = new CardList(); + creature.addAll(AllZone.Human_Play.getCards()); + creature.addAll(AllZone.Computer_Play.getCards()); + creature = creature.getType("Creature"); + + for (int i = 0; i < creature.size(); i++) + { + c = creature.get(i); + c.addExtrinsicKeyword(keyword + " " + number + "."); + gloriousAnthemList.add(c); + }// for inner + } + }// execute() + }; + + public static Command Magus_of_the_Tabernacle = new Command() + { + private static final long serialVersionUID = -249708982895077034L; + CardList gloriousAnthemList = new CardList(); + + public void execute() + { + String keyword = "At the beginning of your upkeep, sacrifice this creature unless you pay"; + + CardList list = gloriousAnthemList; + Card c; + // reset all cards in list - aka "old" cards + for (int i = 0; i < list.size(); i++) + { + c = list.get(i); + ArrayList a = c.getKeyword(); + for (String s : a) + { + if (s.startsWith(keyword)) + c.removeExtrinsicKeyword(s); + } + } + + list.clear(); + PlayerZone cPlay = AllZone.Computer_Play; + PlayerZone hPlay = AllZone.Human_Play; + CardList clist = new CardList(); + clist.addAll(cPlay.getCards()); + clist.addAll(hPlay.getCards()); + clist = clist.filter(new CardListFilter(){ + public boolean addCard(Card c) + { + return c.getName().equals("Magus of the Tabernacle"); + } + }); + + int number = clist.size(); + //System.out.println("Tabernacle Number:" + number); + if (number > 0) { + CardList creature = new CardList(); + creature.addAll(AllZone.Human_Play.getCards()); + creature.addAll(AllZone.Computer_Play.getCards()); + creature = creature.getType("Creature"); + + for (int i = 0; i < creature.size(); i++) + { + c = creature.get(i); + c.addExtrinsicKeyword(keyword + " " + number + "."); + gloriousAnthemList.add(c); + }// for inner + } + }// execute() + }; public static Command Serras_Blessing = new Command() @@ -15731,6 +15981,8 @@ public class GameActionUtil commands.put("Knighthood", Knighthood); commands.put("Absolute_Law", Absolute_Law); commands.put("Absolute_Grace", Absolute_Grace); + commands.put("Tabernacle", Tabernacle); + commands.put("Magus_of_the_Tabernacle", Magus_of_the_Tabernacle); commands.put("Mobilization", Mobilization); commands.put("Serras_Blessing", Serras_Blessing); commands.put("Cover_of_Darkness", Cover_of_Darkness); diff --git a/src/forge/GuiDisplay3.java b/src/forge/GuiDisplay3.java index 88c6e7c6f20..7afbbf192e4 100644 --- a/src/forge/GuiDisplay3.java +++ b/src/forge/GuiDisplay3.java @@ -82,6 +82,9 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon public Color c2 = new Color(50,50,50); public Color c3 = new Color(204,204,204); */ + + private String current_picture = ""; + private int count = 0; public static Color c1 = new Color(204, 204, 204); public static Color c2 = new Color(204, 204, 204); @@ -256,7 +259,10 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon if(choices[0] instanceof Card) { list.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent ev) { - if(list.getSelectedValue() instanceof Card) updateCardDetail((Card) list.getSelectedValue()); + if(list.getSelectedValue() instanceof Card){ + updateCardDetailText((Card) list.getSelectedValue()); + updateCardDetailPicture((Card) list.getSelectedValue()); + } } }); } @@ -272,7 +278,10 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon if(choices[0] instanceof Card) { list.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent ev) { - if(list.getSelectedValue() instanceof Card) updateCardDetail((Card) list.getSelectedValue()); + if(list.getSelectedValue() instanceof Card) { + updateCardDetailText((Card) list.getSelectedValue()); + updateCardDetailPicture((Card) list.getSelectedValue()); + } } }); } @@ -402,7 +411,7 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon }//addListener() - public void updateCardDetail(Card c) { + public void updateCardDetailText(Card c) { // if(! c.isToken()) // System.out.println(c +" " +c.getSpellAbility()[0].canPlay() +" " +c.getSpellAbility()[0].getManaCost()); @@ -530,14 +539,24 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon cdPanel.setBorder(GuiDisplayUtil.getBorder(c)); cCardHQ = c; - - + } + public void updateCardDetailPicture(Card c) + { + + if (c.getImageName().equals(current_picture) /*&& !c.isBasicLand()*/) + return; + //picture + System.out.println("UPDATING PICTURE!!! #:" + count++); + current_picture = c.getImageName(); picturePanel.removeAll(); JPanel pic = GuiDisplayUtil.getPicture(c); pic.setSize(300, 300); picturePanel.add(pic); picturePanel.revalidate(); + System.gc(); + + //System.out.println(picturePanel.getComponentCount()); }//updateCardDetail() private void addObservers() { @@ -632,7 +651,8 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon @Override public void mouseMoved(MouseEvent me) { - GuiDisplay3.this.updateCardDetail(cardPanel.getCard()); + GuiDisplay3.this.updateCardDetailText(cardPanel.getCard()); + GuiDisplay3.this.updateCardDetailPicture(cardPanel.getCard()); }//mouseMoved }); @@ -1377,7 +1397,10 @@ class Gui_MultipleBlockers3 extends JFrame { AllZone.GameAction.addAssignedDamage(c, att, /*c.getTotalAssignedDamage() +*/ 1); - if(guiDisplay != null) guiDisplay.updateCardDetail(c); + if(guiDisplay != null) { + guiDisplay.updateCardDetailText(c); + guiDisplay.updateCardDetailPicture(c); + } } //reduce damage, show new user message, exit if necessary assignDamage--; @@ -1395,7 +1418,11 @@ class Gui_MultipleBlockers3 extends JFrame { CardPanel cardPanel = (CardPanel) o; Card c = cardPanel.getCard(); - if(guiDisplay != null) guiDisplay.updateCardDetail(c); + if(guiDisplay != null) { + guiDisplay.updateCardDetailText(c); + guiDisplay.updateCardDetailPicture(c); + } + } } diff --git a/src/forge/GuiDisplayUtil.java b/src/forge/GuiDisplayUtil.java index e6e8c095c73..4df4fdfd210 100644 --- a/src/forge/GuiDisplayUtil.java +++ b/src/forge/GuiDisplayUtil.java @@ -159,7 +159,8 @@ public class GuiDisplayUtil implements NewConstants { if((o != null) && (o instanceof CardPanel)) { CardPanel cardPanel = (CardPanel) o; - visual.updateCardDetail(cardPanel.getCard()); + visual.updateCardDetailText(cardPanel.getCard()); + visual.updateCardDetailPicture(cardPanel.getCard()); } }//mouseMoved }; @@ -199,6 +200,80 @@ public class GuiDisplayUtil implements NewConstants { return returnString; } + public static ImageIcon getImageIcon(Card c) + { + String suffix = ".jpg"; + String filename = ""; + if(!c.isFaceDown()) { + String basicLandSuffix = ""; + if(c.isBasicLand()) { + if(c.getRandomPicture() != 0) basicLandSuffix = Integer.toString(c.getRandomPicture()); + } + + filename = cleanString(c.getImageName()) + basicLandSuffix + suffix; + } else filename = "morph" + suffix; + + String loc = ""; + if (!c.isToken()) + loc = IMAGE_BASE; + else + loc = IMAGE_TOKEN; + + File file = new File(ForgeProps.getFile(loc), filename); + + //try current directory + if(!file.exists()) { + filename = cleanString(c.getName()) + suffix; + file = new File(filename); + } + + + if(file.exists()) { + if(c.isFaceDown()){ + return new ImageIcon(filename); + }else{ + int cWidth = 0; + int cHeight = 0; + try { + cWidth = GuiDisplayUtil.getPictureHQwidth(c); + } catch (IOException e) { + + e.printStackTrace(); + } + + try { + cHeight = GuiDisplayUtil.getPictureHQheight(c); + } catch (IOException e) { + + e.printStackTrace(); + } + + if(cWidth<=312 || cHeight<=445) { + return new ImageIcon(filename); + }else{ + return new ImageIcon(filename); + } + } + } + /*else { + ImageIcon i = new ImageIcon(); + + JTextArea text = new JTextArea("\r\n\r\n" + filename, 10, 15); + Font f = text.getFont(); + f = f.deriveFont(f.getSize() + 2.0f); + text.setFont(f); + text.setBackground(p.getBackground()); + + i.add(text); + + if(c.isToken()) return new ImageIcon(); + + return i; + }//else + */ + return new ImageIcon(); + } + public static JPanel getPicture(Card c) { if(AllZone.NameChanger.shouldChangeCardName()) return new JPanel(); @@ -208,10 +283,13 @@ public class GuiDisplayUtil implements NewConstants { if(!c.isFaceDown()) { String basicLandSuffix = ""; if(c.isBasicLand()) { - if(c.getRandomPicture() != 0) basicLandSuffix = Integer.toString(c.getRandomPicture()); + if(c.getRandomPicture() != 0) { + basicLandSuffix = Integer.toString(c.getRandomPicture()); + //c.setImageName(c.getImageName() + basicLandSuffix); + } + } - - filename = cleanString(c.getImageName()) + basicLandSuffix + suffix; + filename = cleanString(c.getImageName())+ basicLandSuffix + suffix; } else filename = "morph" + suffix; String loc = ""; diff --git a/src/forge/StateBasedEffects.java b/src/forge/StateBasedEffects.java index f8f2134daab..616c9889ced 100644 --- a/src/forge/StateBasedEffects.java +++ b/src/forge/StateBasedEffects.java @@ -127,6 +127,8 @@ public class StateBasedEffects cardToEffectsList.put("Knighthood", new String[] {"Knighthood"}); cardToEffectsList.put("Absolute Law", new String[] {"Absolute_Law"}); cardToEffectsList.put("Absolute Grace", new String[] {"Absolute_Grace"}); + cardToEffectsList.put("The Tabernacle at Pendrell Vale", new String[] {"Tabernacle"}); + cardToEffectsList.put("Magus of the Tabernacle", new String[] {"Magus_of_the_Tabernacle"}); cardToEffectsList.put("Mobilization", new String[] {"Mobilization"}); cardToEffectsList.put("Serra's Blessing", new String[] {"Serras_Blessing"}); cardToEffectsList.put("Cover of Darkness", new String[] {"Cover_of_Darkness"});