From 42108ef59ca57ae5b1afa9ea3458faa0504d8994 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Sat, 28 Apr 2012 03:27:36 +0400 Subject: [PATCH] fixed downloading images from flip cards according to changes on magiccards.info site --- .../card/dl/sources/CardImageSource.java | 2 +- .../dl/sources/MagicCardsImageSource.java | 8 ++- .../dl/sources/MtgatheringRuImageSource.java | 5 +- .../dl/sources/WizardCardsImageSource.java | 9 +-- .../mage/plugins/card/images/CardInfo.java | 9 +++ .../plugins/card/images/DownloadPictures.java | 72 +++++++------------ .../championsofkamigawa/AkkiLavarunner.java | 4 +- .../championsofkamigawa/BudokaGardener.java | 5 +- .../championsofkamigawa/BushiTenderfoot.java | 4 +- .../championsofkamigawa/InitiateOfBlood.java | 4 +- .../NezumiGraverobber.java | 10 ++- .../championsofkamigawa/OrochiEggwatcher.java | 4 +- Mage/src/mage/cards/Card.java | 6 +- Mage/src/mage/cards/CardImpl.java | 15 ++-- Mage/src/mage/game/stack/Spell.java | 12 +++- 15 files changed, 96 insertions(+), 73 deletions(-) diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/CardImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/CardImageSource.java index 4170239606..cc19b0364c 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/CardImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/CardImageSource.java @@ -6,7 +6,7 @@ package org.mage.plugins.card.dl.sources; */ public interface CardImageSource { - String generateURL(Integer collectorId, String cardName, String cardSet, boolean twoFacedCard, boolean secondFace) throws Exception; + String generateURL(Integer collectorId, String cardName, String cardSet, boolean twoFacedCard, boolean secondFace, boolean isFlipCard) throws Exception; String generateTokenUrl(String name, String set); Float getAverageSize(); } diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MagicCardsImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MagicCardsImageSource.java index 127d71e573..9b5669e38b 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MagicCardsImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MagicCardsImageSource.java @@ -1,8 +1,9 @@ package org.mage.plugins.card.dl.sources; +import org.mage.plugins.card.utils.CardImageUtils; + import java.util.HashMap; import java.util.Map; -import org.mage.plugins.card.utils.CardImageUtils; /** * @@ -54,7 +55,7 @@ public class MagicCardsImageSource implements CardImageSource { } @Override - public String generateURL(Integer collectorId, String cardName, String cardSet, boolean twoFacedCard, boolean secondSide) throws Exception { + public String generateURL(Integer collectorId, String cardName, String cardSet, boolean twoFacedCard, boolean secondSide, boolean isFlipCard) throws Exception { if (collectorId == null || cardSet == null) { throw new Exception("Wrong parameters for image: collector id: " + collectorId + ",card set: " + cardSet); } @@ -65,6 +66,9 @@ public class MagicCardsImageSource implements CardImageSource { if (twoFacedCard) { url.append(secondSide ? "b" : "a"); } + if (isFlipCard) { + url.append("a"); + } url.append(".jpg"); return url.toString(); diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgatheringRuImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgatheringRuImageSource.java index e9214c9ed5..07d9acf476 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgatheringRuImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgatheringRuImageSource.java @@ -4,9 +4,10 @@ */ package org.mage.plugins.card.dl.sources; +import org.mage.plugins.card.utils.CardImageUtils; + import java.util.HashMap; import java.util.Map; -import org.mage.plugins.card.utils.CardImageUtils; /** * @@ -51,7 +52,7 @@ public class MtgatheringRuImageSource implements CardImageSource { } @Override - public String generateURL(Integer collectorId, String cardName, String cardSet, boolean twoFacedCard, boolean secondSide) throws Exception { + public String generateURL(Integer collectorId, String cardName, String cardSet, boolean twoFacedCard, boolean secondSide, boolean isFlipCard) throws Exception { if (collectorId == null || cardSet == null) { throw new Exception("Wrong parameters for image: collector id: " + collectorId + ",card set: " + cardSet); } diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/WizardCardsImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/WizardCardsImageSource.java index a153eb48d9..b5230ec9c6 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/WizardCardsImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/WizardCardsImageSource.java @@ -1,11 +1,12 @@ package org.mage.plugins.card.dl.sources; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.select.Elements; + import java.io.IOException; import java.util.HashMap; import java.util.Map; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; -import org.jsoup.select.Elements; /** * @@ -85,7 +86,7 @@ public class WizardCardsImageSource implements CardImageSource { } @Override - public String generateURL(Integer collectorId, String cardName, String cardSet, boolean twoFacedCard, boolean secondSide) throws Exception { + public String generateURL(Integer collectorId, String cardName, String cardSet, boolean twoFacedCard, boolean secondSide, boolean isFlipCard) throws Exception { if (collectorId == null || cardSet == null) { throw new Exception("Wrong parameters for image: collector id: " + collectorId + ",card set: " + cardSet); } diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/images/CardInfo.java b/Mage.Client/src/main/java/org/mage/plugins/card/images/CardInfo.java index 7c512d2b6c..7f8bfbeb6b 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/images/CardInfo.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/images/CardInfo.java @@ -13,6 +13,7 @@ public class CardInfo { private boolean token; private boolean twoFacedCard; private boolean secondSide; + private boolean flipCard; public CardInfo(String name, String set, Integer collectorId) { this.name = name; @@ -135,4 +136,12 @@ public class CardInfo { public void setDownloadName(String downloadName) { this.downloadName = downloadName; } + + public boolean isFlipCard() { + return flipCard; + } + + public void setFlipCard(boolean flipCard) { + this.flipCard = flipCard; + } } diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPictures.java b/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPictures.java index 2ecbd62f41..e1fc47179e 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPictures.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPictures.java @@ -1,51 +1,6 @@ package org.mage.plugins.card.images; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.image.BufferedImage; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.InetSocketAddress; -import java.net.Proxy; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import javax.imageio.IIOImage; -import javax.imageio.ImageIO; -import javax.imageio.ImageWriteParam; -import javax.imageio.ImageWriter; -import javax.imageio.stream.FileImageOutputStream; -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.ComboBoxModel; -import javax.swing.DefaultBoundedRangeModel; -import javax.swing.DefaultComboBoxModel; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JProgressBar; - import mage.cards.Card; - import mage.client.dialog.PreferencesDialog; import mage.remote.Connection; import org.apache.log4j.Logger; @@ -57,6 +12,27 @@ import org.mage.plugins.card.dl.sources.WizardCardsImageSource; import org.mage.plugins.card.properties.SettingsManager; import org.mage.plugins.card.utils.CardImageUtils; +import javax.imageio.IIOImage; +import javax.imageio.ImageIO; +import javax.imageio.ImageWriteParam; +import javax.imageio.ImageWriter; +import javax.imageio.stream.FileImageOutputStream; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; +import java.io.*; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + public class DownloadPictures extends DefaultBoundedRangeModel implements Runnable { private JProgressBar bar; @@ -270,6 +246,9 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab if (cardName.equals("Forest") || cardName.equals("Swamp") || cardName.equals("Mountain") || cardName.equals("Island") || cardName.equals("Plains")) { url.setDownloadName(card.getClass().getName().replace(card.getClass().getPackage().getName() + ".", "")); } + if (card.isFlipCard()) { + url.setFlipCard(true); + } allCardsUrls.add(url); if (card.canTransform()) { // add second side for downloading @@ -434,7 +413,8 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab } url = cardImageSource.generateTokenUrl(card.getName(), card.getSet()); } else { - url = cardImageSource.generateURL(card.getCollectorId(), card.getDownloadName(), card.getSet(), card.isTwoFacedCard(), card.isSecondSide()); + url = cardImageSource.generateURL(card.getCollectorId(), card.getDownloadName(), card.getSet(), + card.isTwoFacedCard(), card.isSecondSide(), card.isFlipCard()); } if (url != null) { diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/AkkiLavarunner.java b/Mage.Sets/src/mage/sets/championsofkamigawa/AkkiLavarunner.java index d9f2e48ac8..1eb8644725 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/AkkiLavarunner.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/AkkiLavarunner.java @@ -1,6 +1,5 @@ package mage.sets.championsofkamigawa; -import java.util.UUID; import mage.Constants; import mage.MageInt; import mage.ObjectColor; @@ -23,6 +22,8 @@ import mage.game.events.DamagedPlayerEvent; import mage.game.events.GameEvent; import mage.game.permanent.token.Token; +import java.util.UUID; + /** * @author Loki */ @@ -36,6 +37,7 @@ public class AkkiLavarunner extends CardImpl { this.color.setRed(true); this.power = new MageInt(1); this.toughness = new MageInt(1); + this.flipCard = true; this.addAbility(HasteAbility.getInstance()); this.addAbility(new AkkiLavarunnerAbility()); this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new ConditionalContinousEffect(new CopyTokenEffect(new TokTokVolcanoBorn()), FlippedCondition.getInstance(), ""))); diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/BudokaGardener.java b/Mage.Sets/src/mage/sets/championsofkamigawa/BudokaGardener.java index 3544ca9c07..81c893821a 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/BudokaGardener.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/BudokaGardener.java @@ -27,8 +27,6 @@ */ package mage.sets.championsofkamigawa; -import java.util.UUID; - import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; @@ -55,6 +53,8 @@ import mage.game.permanent.Permanent; import mage.game.permanent.token.Token; import mage.target.common.TargetCardInHand; +import java.util.UUID; + /** * @author Loki */ @@ -67,6 +67,7 @@ public class BudokaGardener extends CardImpl { this.color.setGreen(true); this.power = new MageInt(2); this.toughness = new MageInt(1); + this.flipCard = true; Ability ability = new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new BudokaGardenerEffect(), new TapSourceCost()); ability.addTarget(new TargetCardInHand(new FilterLandCard())); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/BushiTenderfoot.java b/Mage.Sets/src/mage/sets/championsofkamigawa/BushiTenderfoot.java index 6b3cf65f3c..a6ef5c428b 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/BushiTenderfoot.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/BushiTenderfoot.java @@ -30,7 +30,6 @@ package mage.sets.championsofkamigawa; -import java.util.UUID; import mage.Constants; import mage.MageInt; import mage.abilities.common.DiesAndDealtDamageThisTurnTriggeredAbility; @@ -45,6 +44,8 @@ import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; import mage.game.permanent.token.Token; +import java.util.UUID; + /** * @author LevelX */ @@ -65,6 +66,7 @@ public class BushiTenderfoot extends CardImpl { this.color.setWhite(true); this.power = new MageInt(1); this.toughness = new MageInt(1); + this.flipCard = true; // When that creature is put into a graveyard this turn, flip Initiate of Blood. this.addAbility(new DiesAndDealtDamageThisTurnTriggeredAbility(new FlipSourceEffect())); diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/InitiateOfBlood.java b/Mage.Sets/src/mage/sets/championsofkamigawa/InitiateOfBlood.java index 6cce6a78a0..05eeeab92c 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/InitiateOfBlood.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/InitiateOfBlood.java @@ -29,7 +29,6 @@ */ package mage.sets.championsofkamigawa; -import java.util.UUID; import mage.Constants; import mage.Constants.Zone; import mage.MageInt; @@ -48,6 +47,8 @@ import mage.filter.common.FilterCreaturePermanent; import mage.game.permanent.token.Token; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** * @author LevelX */ @@ -68,6 +69,7 @@ public class InitiateOfBlood extends CardImpl { this.color.setRed(true); this.power = new MageInt(2); this.toughness = new MageInt(2); + this.flipCard = true; // {T}: Initiate of Blood deals 1 damage to target creature that was dealt damage this turn. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), new TapSourceCost()); diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/NezumiGraverobber.java b/Mage.Sets/src/mage/sets/championsofkamigawa/NezumiGraverobber.java index af4c7a85f8..602b623cbc 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/NezumiGraverobber.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/NezumiGraverobber.java @@ -27,8 +27,6 @@ */ package mage.sets.championsofkamigawa; -import java.util.UUID; - import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; @@ -40,7 +38,9 @@ import mage.abilities.condition.common.FlippedCondition; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.decorator.ConditionalContinousEffect; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.*; +import mage.abilities.effects.common.CopyTokenEffect; +import mage.abilities.effects.common.ExileTargetEffect; +import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.filter.FilterCard; @@ -52,6 +52,8 @@ import mage.players.Player; import mage.target.common.TargetCardInGraveyard; import mage.target.common.TargetCardInOpponentsGraveyard; +import java.util.UUID; + /** * @author Loki */ @@ -65,6 +67,8 @@ public class NezumiGraverobber extends CardImpl { this.color.setBlack(true); this.power = new MageInt(2); this.toughness = new MageInt(1); + this.flipCard = true; + Ability ability = new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new ExileTargetEffect(), new ManaCostsImpl("{1}{B}")); ability.addTarget(new TargetCardInOpponentsGraveyard(new FilterCard("card from an opponent's graveyard"))); ability.addEffect(new NezumiGraverobberFlipEffect()); diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/OrochiEggwatcher.java b/Mage.Sets/src/mage/sets/championsofkamigawa/OrochiEggwatcher.java index 0fdefc0022..610ca88fd4 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/OrochiEggwatcher.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/OrochiEggwatcher.java @@ -30,7 +30,6 @@ package mage.sets.championsofkamigawa; -import java.util.UUID; import mage.Constants; import mage.Constants.CardType; import mage.Constants.Duration; @@ -58,6 +57,8 @@ import mage.game.permanent.token.Token; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** * @author LevelX */ @@ -71,6 +72,7 @@ public class OrochiEggwatcher extends CardImpl { this.color.setGreen(true); this.power = new MageInt(1); this.toughness = new MageInt(1); + this.flipCard = true; // {2}{G}, {T}: Put a 1/1 green Snake creature token onto the battlefield. If you control ten or more creatures, flip Orochi Eggwatcher. Ability ability; diff --git a/Mage/src/mage/cards/Card.java b/Mage/src/mage/cards/Card.java index 8ae839815e..ec330fcf17 100644 --- a/Mage/src/mage/cards/Card.java +++ b/Mage/src/mage/cards/Card.java @@ -28,8 +28,6 @@ package mage.cards; -import java.util.List; -import java.util.UUID; import mage.Constants.Rarity; import mage.Constants.Zone; import mage.MageObject; @@ -39,6 +37,9 @@ import mage.abilities.SpellAbility; import mage.game.Game; import mage.watchers.Watcher; +import java.util.List; +import java.util.UUID; + public interface Card extends MageObject { public UUID getOwnerId(); @@ -57,6 +58,7 @@ public interface Card extends MageObject { public void setExpansionSetCode(String expansionSetCode); public void setFaceDown(boolean value); public boolean isFaceDown(); + public boolean isFlipCard(); public boolean canTransform(); public Card getSecondCardFace(); diff --git a/Mage/src/mage/cards/CardImpl.java b/Mage/src/mage/cards/CardImpl.java index a14eb831f4..3b2567c411 100644 --- a/Mage/src/mage/cards/CardImpl.java +++ b/Mage/src/mage/cards/CardImpl.java @@ -28,11 +28,6 @@ package mage.cards; -import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Rarity; import mage.Constants.Zone; @@ -49,6 +44,12 @@ import mage.game.stack.Spell; import mage.watchers.Watcher; import org.apache.log4j.Logger; +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; + public abstract class CardImpl> extends MageObjectImpl implements Card { private static final long serialVersionUID = 1L; @@ -64,6 +65,7 @@ public abstract class CardImpl> extends MageObjectImpl protected Card secondSideCard; protected boolean nightCard; protected SpellAbility spellAbility; + protected boolean flipCard; public CardImpl(UUID ownerId, int cardNumber, String name, Rarity rarity, CardType[] cardTypes, String costs) { this(ownerId, name); @@ -407,4 +409,7 @@ public abstract class CardImpl> extends MageObjectImpl return this.nightCard; } + public boolean isFlipCard() { + return flipCard; + } } diff --git a/Mage/src/mage/game/stack/Spell.java b/Mage/src/mage/game/stack/Spell.java index f5f5ceea20..314af62ccf 100644 --- a/Mage/src/mage/game/stack/Spell.java +++ b/Mage/src/mage/game/stack/Spell.java @@ -28,8 +28,6 @@ package mage.game.stack; -import java.util.List; -import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Rarity; import mage.Constants.Zone; @@ -53,6 +51,9 @@ import mage.players.Player; import mage.target.Target; import mage.watchers.Watcher; +import java.util.List; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -339,6 +340,11 @@ public class Spell> implements StackObject, Card { return false; } + @Override + public boolean isFlipCard() { + return false; + } + @Override public boolean canTransform() { return false; @@ -437,5 +443,7 @@ public class Spell> implements StackObject, Card { public Zone getFromZone() { return this.fromZone; } + + }