fixed downloading images from flip cards according to changes on magiccards.info site

This commit is contained in:
magenoxx 2012-04-28 03:27:36 +04:00
parent 850103c694
commit 42108ef59c
15 changed files with 96 additions and 73 deletions

View file

@ -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();
}

View file

@ -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();

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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;
}
}

View file

@ -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) {

View file

@ -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<AkkiLavarunner> {
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(), "")));

View file

@ -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<BudokaGardener> {
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);

View file

@ -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<BushiTenderfoot> {
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()));

View file

@ -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<InitiateOfBlood> {
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());

View file

@ -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<NezumiGraverobber> {
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());

View file

@ -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<OrochiEggwatcher> {
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;

View file

@ -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();

View file

@ -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<T extends CardImpl<T>> extends MageObjectImpl<T> implements Card {
private static final long serialVersionUID = 1L;
@ -64,6 +65,7 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
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<T extends CardImpl<T>> extends MageObjectImpl<T>
return this.nightCard;
}
public boolean isFlipCard() {
return flipCard;
}
}

View file

@ -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<T extends Spell<T>> implements StackObject, Card {
return false;
}
@Override
public boolean isFlipCard() {
return false;
}
@Override
public boolean canTransform() {
return false;
@ -437,5 +443,7 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
public Zone getFromZone() {
return this.fromZone;
}
}