mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
Fixed handling of cards that exist multiple times for Unstable.
This commit is contained in:
parent
48e6b475f3
commit
88b06137be
4 changed files with 32 additions and 29 deletions
|
|
@ -4,7 +4,6 @@ import java.io.File;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.Proxy;
|
import java.net.Proxy;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.constants.Constants;
|
import mage.client.constants.Constants;
|
||||||
|
|
@ -122,17 +121,17 @@ public final class CardImageUtils {
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String prepareCardNameForFile(String cardName){
|
public static String prepareCardNameForFile(String cardName) {
|
||||||
return cardName.replace(":", "").replace("\"", "").replace("//", "-");
|
return cardName.replace(":", "").replace("\"", "").replace("//", "-");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getImagesDir(){
|
public static String getImagesDir() {
|
||||||
// return real images dir (path without separator)
|
// return real images dir (path without separator)
|
||||||
|
|
||||||
String path = null;
|
String path = null;
|
||||||
|
|
||||||
// user path
|
// user path
|
||||||
if (!PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true").equals("true")){
|
if (!PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true").equals("true")) {
|
||||||
path = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
|
path = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,8 +140,7 @@ public final class CardImageUtils {
|
||||||
path = Constants.IO.DEFAULT_IMAGES_DIR;
|
path = Constants.IO.DEFAULT_IMAGES_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(path.endsWith(File.separator))
|
while (path.endsWith(File.separator)) {
|
||||||
{
|
|
||||||
path = path.substring(0, path.length() - 1);
|
path = path.substring(0, path.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,7 +150,6 @@ public final class CardImageUtils {
|
||||||
public static String buildImagePathToTokens() {
|
public static String buildImagePathToTokens() {
|
||||||
String imagesPath = getImagesDir() + File.separator;
|
String imagesPath = getImagesDir() + File.separator;
|
||||||
|
|
||||||
|
|
||||||
if (PreferencesDialog.isSaveImagesToZip()) {
|
if (PreferencesDialog.isSaveImagesToZip()) {
|
||||||
return imagesPath + "TOK.zip" + File.separator;
|
return imagesPath + "TOK.zip" + File.separator;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -198,20 +195,25 @@ public final class CardImageUtils {
|
||||||
String setPath = buildImagePathToSet(card);
|
String setPath = buildImagePathToSet(card);
|
||||||
|
|
||||||
String prefixType = "";
|
String prefixType = "";
|
||||||
if(card.getType() != 0){
|
if (card.getType() != 0) {
|
||||||
prefixType = " " + Integer.toString(card.getType());
|
prefixType = " " + Integer.toString(card.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
String cardName = card.getFileName();
|
String cardName = card.getFileName();
|
||||||
if (cardName.isEmpty()){
|
if (cardName.isEmpty()) {
|
||||||
cardName = prepareCardNameForFile(card.getName());
|
cardName = prepareCardNameForFile(card.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
String finalFileName = "";
|
String finalFileName = "";
|
||||||
if (card.getUsesVariousArt()){
|
if (card.getUsesVariousArt()) {
|
||||||
finalFileName = cardName + '.' + card.getCollectorId() + ".full.jpg";
|
finalFileName = cardName + '.' + card.getCollectorId() + ".full.jpg";
|
||||||
}else{
|
} else {
|
||||||
finalFileName = cardName + prefixType + ".full.jpg";
|
int len = card.getCollectorId().length();
|
||||||
|
if (Character.isLetter(card.getCollectorId().charAt(len - 1))) {
|
||||||
|
finalFileName = cardName + card.getCollectorId().charAt(len - 1) + ".full.jpg";
|
||||||
|
} else {
|
||||||
|
finalFileName = cardName + prefixType + ".full.jpg";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if image file exists, correct name (for case sensitive systems)
|
// if image file exists, correct name (for case sensitive systems)
|
||||||
|
|
@ -219,17 +221,17 @@ public final class CardImageUtils {
|
||||||
TFile dirFile = new TFile(setPath);
|
TFile dirFile = new TFile(setPath);
|
||||||
TFile imageFile = new TFile(setPath + finalFileName);
|
TFile imageFile = new TFile(setPath + finalFileName);
|
||||||
// warning, zip files can be broken
|
// warning, zip files can be broken
|
||||||
try{
|
try {
|
||||||
if (dirFile.exists() && !imageFile.exists()) {
|
if (dirFile.exists() && !imageFile.exists()) {
|
||||||
// search like names
|
// search like names
|
||||||
for (String fileName: dirFile.list()) {
|
for (String fileName : dirFile.list()) {
|
||||||
if (fileName.toLowerCase().equals(finalFileName.toLowerCase())) {
|
if (fileName.toLowerCase().equals(finalFileName.toLowerCase())) {
|
||||||
finalFileName = fileName;
|
finalFileName = fileName;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error("Can't read card name from file, may be it broken: " + setPath);
|
log.error("Can't read card name from file, may be it broken: " + setPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.SubType;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.predicate.permanent.CounterPredicate;
|
import mage.filter.predicate.permanent.CounterPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
@ -48,12 +49,12 @@ import mage.players.Player;
|
||||||
*
|
*
|
||||||
* @author spjspj
|
* @author spjspj
|
||||||
*/
|
*/
|
||||||
public class GarbageElemental extends CardImpl {
|
public class GarbageElementalC extends CardImpl {
|
||||||
|
|
||||||
public GarbageElemental(UUID ownerId, CardSetInfo setInfo) {
|
public GarbageElementalC(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{R}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{R}");
|
||||||
|
|
||||||
this.subtype.add("Elemental");
|
this.subtype.add(SubType.ELEMENTAL);
|
||||||
this.power = new MageInt(3);
|
this.power = new MageInt(3);
|
||||||
this.toughness = new MageInt(2);
|
this.toughness = new MageInt(2);
|
||||||
|
|
||||||
|
|
@ -68,13 +69,13 @@ public class GarbageElemental extends CardImpl {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GarbageElemental(final GarbageElemental card) {
|
public GarbageElementalC(final GarbageElementalC card) {
|
||||||
super(card);
|
super(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GarbageElemental copy() {
|
public GarbageElementalC copy() {
|
||||||
return new GarbageElemental(this);
|
return new GarbageElementalC(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ import mage.target.common.TargetCreaturePermanent;
|
||||||
*
|
*
|
||||||
* @author spjspj
|
* @author spjspj
|
||||||
*/
|
*/
|
||||||
public class VeryCrypticCommand extends CardImpl {
|
public class VeryCrypticCommandD extends CardImpl {
|
||||||
|
|
||||||
private static final FilterStackObject filter = new FilterStackObject("spell or ability with a single target");
|
private static final FilterStackObject filter = new FilterStackObject("spell or ability with a single target");
|
||||||
private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent("nontoken creature");
|
private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent("nontoken creature");
|
||||||
|
|
@ -69,7 +69,7 @@ public class VeryCrypticCommand extends CardImpl {
|
||||||
filter2.add(Predicates.not(new TokenPredicate()));
|
filter2.add(Predicates.not(new TokenPredicate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public VeryCrypticCommand(UUID ownerId, CardSetInfo setInfo) {
|
public VeryCrypticCommandD(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}{U}{U}");
|
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}{U}{U}");
|
||||||
|
|
||||||
// Choose two -
|
// Choose two -
|
||||||
|
|
@ -101,13 +101,13 @@ public class VeryCrypticCommand extends CardImpl {
|
||||||
this.getSpellAbility().getModes().addMode(mode);
|
this.getSpellAbility().getModes().addMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VeryCrypticCommand(final VeryCrypticCommand card) {
|
public VeryCrypticCommandD(final VeryCrypticCommandD card) {
|
||||||
super(card);
|
super(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VeryCrypticCommand copy() {
|
public VeryCrypticCommandD copy() {
|
||||||
return new VeryCrypticCommand(this);
|
return new VeryCrypticCommandD(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,7 +60,7 @@ public class Unstable extends ExpansionSet {
|
||||||
cards.add(new SetCardInfo("Earl of Squirrel", 108, Rarity.RARE, mage.cards.e.EarlOfSquirrel.class));
|
cards.add(new SetCardInfo("Earl of Squirrel", 108, Rarity.RARE, mage.cards.e.EarlOfSquirrel.class));
|
||||||
cards.add(new SetCardInfo("Forest", 216, Rarity.LAND, mage.cards.basiclands.Forest.class, new CardGraphicInfo(FrameStyle.UNH_FULL_ART_BASIC, false)));
|
cards.add(new SetCardInfo("Forest", 216, Rarity.LAND, mage.cards.basiclands.Forest.class, new CardGraphicInfo(FrameStyle.UNH_FULL_ART_BASIC, false)));
|
||||||
cards.add(new SetCardInfo("GO TO JAIL", 8, Rarity.COMMON, mage.cards.g.GOTOJAIL.class));
|
cards.add(new SetCardInfo("GO TO JAIL", 8, Rarity.COMMON, mage.cards.g.GOTOJAIL.class));
|
||||||
cards.add(new SetCardInfo("Garbage Elemental", 82, Rarity.UNCOMMON, mage.cards.g.GarbageElemental.class));
|
cards.add(new SetCardInfo("Garbage Elemental", "82c", Rarity.UNCOMMON, mage.cards.g.GarbageElementalC.class));
|
||||||
cards.add(new SetCardInfo("Ground Pounder", 110, Rarity.COMMON, mage.cards.g.GroundPounder.class));
|
cards.add(new SetCardInfo("Ground Pounder", 110, Rarity.COMMON, mage.cards.g.GroundPounder.class));
|
||||||
cards.add(new SetCardInfo("Hammer Helper", 85, Rarity.COMMON, mage.cards.h.HammerHelper.class));
|
cards.add(new SetCardInfo("Hammer Helper", 85, Rarity.COMMON, mage.cards.h.HammerHelper.class));
|
||||||
cards.add(new SetCardInfo("Hydradoodle", 112, Rarity.RARE, mage.cards.h.Hydradoodle.class));
|
cards.add(new SetCardInfo("Hydradoodle", 112, Rarity.RARE, mage.cards.h.Hydradoodle.class));
|
||||||
|
|
@ -81,7 +81,7 @@ public class Unstable extends ExpansionSet {
|
||||||
cards.add(new SetCardInfo("Sword of Dungeons & Dragons", 1, Rarity.MYTHIC, mage.cards.s.SwordOfDungeonsAndDragons.class));
|
cards.add(new SetCardInfo("Sword of Dungeons & Dragons", 1, Rarity.MYTHIC, mage.cards.s.SwordOfDungeonsAndDragons.class));
|
||||||
cards.add(new SetCardInfo("Target Minotaur", 98, Rarity.COMMON, mage.cards.t.TargetMinotaur.class));
|
cards.add(new SetCardInfo("Target Minotaur", 98, Rarity.COMMON, mage.cards.t.TargetMinotaur.class));
|
||||||
cards.add(new SetCardInfo("Time Out", 48, Rarity.COMMON, mage.cards.t.TimeOut.class));
|
cards.add(new SetCardInfo("Time Out", 48, Rarity.COMMON, mage.cards.t.TimeOut.class));
|
||||||
cards.add(new SetCardInfo("Very Cryptic Command", 49, Rarity.RARE, mage.cards.v.VeryCrypticCommand.class));
|
cards.add(new SetCardInfo("Very Cryptic Command", "49d", Rarity.RARE, mage.cards.v.VeryCrypticCommandD.class));
|
||||||
cards.add(new SetCardInfo("Willing Test Subject", 126, Rarity.COMMON, mage.cards.w.WillingTestSubject.class));
|
cards.add(new SetCardInfo("Willing Test Subject", 126, Rarity.COMMON, mage.cards.w.WillingTestSubject.class));
|
||||||
cards.add(new SetCardInfo("capital offense", 52, Rarity.COMMON, mage.cards.c.CapitalOffense.class));
|
cards.add(new SetCardInfo("capital offense", 52, Rarity.COMMON, mage.cards.c.CapitalOffense.class));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue