forked from External/mage
Added downloading flipped card images. Removed counting images for ignored sets.
This commit is contained in:
parent
20c57ef2d6
commit
3df5466d8a
16 changed files with 77 additions and 33 deletions
|
|
@ -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, boolean isFlipCard) throws Exception;
|
||||
String generateURL(Integer collectorId, String cardName, String cardSet, boolean twoFacedCard, boolean secondFace, boolean isFlipCard, boolean flippedView) throws Exception;
|
||||
String generateTokenUrl(String name, String set);
|
||||
Float getAverageSize();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class MagicCardsImageSource implements CardImageSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String generateURL(Integer collectorId, String cardName, String cardSet, boolean twoFacedCard, boolean secondSide, boolean isFlipCard) throws Exception {
|
||||
public String generateURL(Integer collectorId, String cardName, String cardSet, boolean twoFacedCard, boolean secondSide, boolean isFlipCard, boolean flippedView) throws Exception {
|
||||
if (collectorId == null || cardSet == null) {
|
||||
throw new Exception("Wrong parameters for image: collector id: " + collectorId + ",card set: " + cardSet);
|
||||
}
|
||||
|
|
@ -73,7 +73,11 @@ public class MagicCardsImageSource implements CardImageSource {
|
|||
url.append(secondSide ? "b" : "a");
|
||||
}
|
||||
if (isFlipCard) {
|
||||
url.append("a");
|
||||
if (flippedView) { // download rotated by 180 degree image
|
||||
url.append("b");
|
||||
} else {
|
||||
url.append("a");
|
||||
}
|
||||
}
|
||||
url.append(".jpg");
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -91,10 +92,13 @@ public class WizardCardsImageSource implements CardImageSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String generateURL(Integer collectorId, String cardName, String cardSet, boolean twoFacedCard, boolean secondSide, boolean isFlipCard) throws Exception {
|
||||
public String generateURL(Integer collectorId, String cardName, String cardSet, boolean twoFacedCard, boolean secondSide, boolean isFlipCard, boolean flippedView) throws Exception {
|
||||
if (collectorId == null || cardSet == null) {
|
||||
throw new Exception("Wrong parameters for image: collector id: " + collectorId + ",card set: " + cardSet);
|
||||
}
|
||||
if (flippedView) { //doesn't support rotated images
|
||||
return null;
|
||||
}
|
||||
if (setsAliases.get(cardSet) != null) {
|
||||
Map<String, String> setLinks = (Map<String, String>) sets.get(cardSet);
|
||||
if (setLinks == null) {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ public class CardInfo {
|
|||
private boolean twoFacedCard;
|
||||
private boolean secondSide;
|
||||
private boolean flipCard;
|
||||
private boolean flippedSide;
|
||||
private boolean usesVariousArt;
|
||||
|
||||
public CardInfo(String name, String set, Integer collectorId, boolean usesVariousArt, Integer type) {
|
||||
|
|
@ -158,4 +159,11 @@ public class CardInfo {
|
|||
return usesVariousArt;
|
||||
}
|
||||
|
||||
public boolean isFlippedSide() {
|
||||
return flippedSide;
|
||||
}
|
||||
|
||||
public void setFlippedSide(boolean flippedSide) {
|
||||
this.flippedSide = flippedSide;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,14 +228,16 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
* read all card names and urls
|
||||
*/
|
||||
ArrayList<CardInfo> allCardsUrls = new ArrayList<CardInfo>();
|
||||
HashSet<String> ignoreUrls = SettingsManager.getIntance().getIgnoreUrls();
|
||||
|
||||
try {
|
||||
offlineMode = true;
|
||||
|
||||
for (Card card : allCards) {
|
||||
if (card.getCardNumber() > 0 && !card.getExpansionSetCode().isEmpty()) {
|
||||
if (card.getCardNumber() > 0 && !card.getExpansionSetCode().isEmpty()
|
||||
&& !ignoreUrls.contains(card.getExpansionSetCode())) {
|
||||
String cardName = card.getName();
|
||||
CardInfo url = new CardInfo(cardName, card.getExpansionSetCode(),card.getCardNumber(), card.getUsesVariousArt(), 0, false, card.canTransform(), card.isNightCard());
|
||||
CardInfo url = new CardInfo(cardName, card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), 0, false, card.canTransform(), card.isNightCard());
|
||||
if (url.getUsesVariousArt()) {
|
||||
url.setDownloadName(card.getClass().getName().replace(card.getClass().getPackage().getName() + ".", ""));
|
||||
}
|
||||
|
|
@ -251,6 +253,15 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
url = new CardInfo(secondSide.getName(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), 0, false, card.canTransform(), true);
|
||||
allCardsUrls.add(url);
|
||||
}
|
||||
if (card.isFlipCard()) {
|
||||
if (card.getFlipCardName() == null || card.getFlipCardName().trim().isEmpty()) {
|
||||
throw new IllegalStateException("Flipped card can't have empty name.");
|
||||
}
|
||||
url = new CardInfo(card.getFlipCardName(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), 0, false, card.canTransform(), card.isNightCard());
|
||||
url.setFlipCard(true);
|
||||
url.setFlippedSide(true);
|
||||
allCardsUrls.add(url);
|
||||
}
|
||||
} else {
|
||||
if (card.getCardNumber() < 1) {
|
||||
System.err.println("There was a critical error!");
|
||||
|
|
@ -406,7 +417,7 @@ 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(), card.isFlipCard());
|
||||
card.isTwoFacedCard(), card.isSecondSide(), card.isFlipCard(), card.isFlippedSide());
|
||||
}
|
||||
|
||||
if (url != null) {
|
||||
|
|
@ -417,6 +428,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
update(cardIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
log.error(ex, ex);
|
||||
}
|
||||
|
|
@ -554,7 +566,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
int count = DownloadPictures.this.cards.size();
|
||||
|
||||
if (cardIndex < count) {
|
||||
float mb = ((count - card) * cardImageSource.getAverageSize()) / 1024;
|
||||
float mb = ((count - card) * cardImageSource.getAverageSize()) / 1024;
|
||||
bar.setString(String.format("%d of %d cards finished! Please wait! [%.1f Mb]",
|
||||
card, count, mb));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@
|
|||
|
||||
package mage.sets.betrayersofkamigawa;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Duration;
|
||||
|
|
@ -38,10 +37,7 @@ import mage.Constants.Rarity;
|
|||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.OnEventTriggeredAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.common.SpellCastTriggeredAbility;
|
||||
import mage.abilities.common.*;
|
||||
import mage.abilities.condition.common.FlippedCondition;
|
||||
import mage.abilities.condition.common.HasCounterCondition;
|
||||
import mage.abilities.costs.common.RemoveCountersSourceCost;
|
||||
|
|
@ -59,6 +55,8 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.permanent.token.Token;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
|
|
@ -76,10 +74,13 @@ public class FaithfulSquire extends CardImpl<FaithfulSquire> {
|
|||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(2);
|
||||
this.flipCard = true;
|
||||
this.flipCardName = "Kaiso, Memory of Loyalty";
|
||||
|
||||
// Whenever you cast a Spirit or Arcane spell, you may put a ki counter on Faithful Squire.
|
||||
this.addAbility(new SpellCastTriggeredAbility(new AddCountersSourceEffect(CounterType.KI.createInstance()), filter, true));
|
||||
|
||||
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.KI.createInstance(2)), false));
|
||||
|
||||
// At the beginning of the end step, if there are two or more ki counters on Faithful Squire, you may flip it
|
||||
this.addAbility(new ConditionalTriggeredAbility(
|
||||
new OnEventTriggeredAbility(GameEvent.EventType.END_TURN_STEP_PRE, "beginning of the end step", true, new FlipSourceEffect()),
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ public class AkkiLavarunner extends CardImpl<AkkiLavarunner> {
|
|||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
this.flipCard = true;
|
||||
this.flipCardName = "Tok-Tok, Volcano Born";
|
||||
this.addAbility(HasteAbility.getInstance());
|
||||
this.addAbility(new AkkiLavarunnerAbility());
|
||||
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new ConditionalContinousEffect(new CopyTokenEffect(new TokTokVolcanoBorn()), FlippedCondition.getInstance(), "")));
|
||||
|
|
|
|||
|
|
@ -27,12 +27,7 @@
|
|||
*/
|
||||
package mage.sets.championsofkamigawa;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Duration;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.Constants.*;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
|
|
@ -57,6 +52,8 @@ import mage.game.permanent.Permanent;
|
|||
import mage.game.permanent.token.Token;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
/**
|
||||
* @author Loki
|
||||
|
|
@ -72,6 +69,7 @@ public class BudokaGardener extends CardImpl<BudokaGardener> {
|
|||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(1);
|
||||
this.flipCard = true;
|
||||
this.flipCardName = "Dokai, Weaver of Life";
|
||||
|
||||
// {T}: You may put a land card from your hand onto the battlefield. If you control ten or more lands, flip Budoka Gardener.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BudokaGardenerEffect(), new TapSourceCost());
|
||||
|
|
|
|||
|
|
@ -67,12 +67,11 @@ public class BushiTenderfoot extends CardImpl<BushiTenderfoot> {
|
|||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
this.flipCard = true;
|
||||
this.flipCardName = "Kenzo the Hardhearted";
|
||||
|
||||
// When that creature is put into a graveyard this turn, flip Initiate of Blood.
|
||||
this.addAbility(new DiesAndDealtDamageThisTurnTriggeredAbility(new FlipSourceEffect()));
|
||||
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new ConditionalContinousEffect(new CopyTokenEffect(new KenzoTheHardhearted()), FlippedCondition.getInstance(), "")));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public BushiTenderfoot(final BushiTenderfoot card) {
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ public class InitiateOfBlood extends CardImpl<InitiateOfBlood> {
|
|||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(2);
|
||||
this.flipCard = true;
|
||||
this.flipCardName = "Goka the Unjust";
|
||||
|
||||
// {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());
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ public class NezumiGraverobber extends CardImpl<NezumiGraverobber> {
|
|||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(1);
|
||||
this.flipCard = true;
|
||||
this.flipCardName = "Nighteyes The Desecrator";
|
||||
|
||||
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")));
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ public class OrochiEggwatcher extends CardImpl<OrochiEggwatcher> {
|
|||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
this.flipCard = true;
|
||||
this.flipCardName = "Shidako, Broodmistress";
|
||||
|
||||
// {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;
|
||||
|
|
|
|||
|
|
@ -28,9 +28,6 @@
|
|||
|
||||
package mage.cards;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageObject;
|
||||
|
|
@ -42,6 +39,10 @@ import mage.counters.Counters;
|
|||
import mage.game.Game;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Card extends MageObject {
|
||||
|
||||
UUID getOwnerId();
|
||||
|
|
@ -61,6 +62,7 @@ public interface Card extends MageObject {
|
|||
void setFaceDown(boolean value);
|
||||
boolean isFaceDown();
|
||||
boolean isFlipCard();
|
||||
String getFlipCardName();
|
||||
|
||||
boolean canTransform();
|
||||
Card getSecondCardFace();
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@
|
|||
|
||||
package mage.cards;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.*;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
|
|
@ -49,6 +47,9 @@ import mage.game.stack.Spell;
|
|||
import mage.watchers.Watcher;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T> implements Card {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
@ -66,6 +67,7 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
|||
protected boolean nightCard;
|
||||
protected SpellAbility spellAbility;
|
||||
protected boolean flipCard;
|
||||
protected String flipCardName;
|
||||
protected int zoneChangeCounter = 1;
|
||||
protected Map<String, String> info;
|
||||
protected boolean usesVariousArt = false;
|
||||
|
|
@ -490,6 +492,11 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
|||
return flipCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFlipCardName() {
|
||||
return flipCardName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZoneChangeCounter() {
|
||||
return zoneChangeCounter;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public enum CardRepository {
|
|||
instance;
|
||||
|
||||
private static final String JDBC_URL = "jdbc:sqlite:db/cards.db";
|
||||
private static final long DB_VERSION = 1;
|
||||
private static final long DB_VERSION = 2;
|
||||
|
||||
private Random random = new Random();
|
||||
private Dao<CardInfo, Object> cardDao;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
package mage.game.stack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
|
|
@ -45,16 +44,17 @@ import mage.abilities.costs.mana.ManaCosts;
|
|||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.Counters;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.Counters;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -332,6 +332,11 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFlipCardName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTransform() {
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue