Moved images from cardforge.org to cardforge.link and added missing sets/some product images.

This commit is contained in:
Krazy
2015-06-01 03:44:10 +00:00
parent cceee98a0d
commit 5886f43f8b
179 changed files with 2019 additions and 2101 deletions

View File

@@ -17,17 +17,16 @@
*/
package forge.download;
import java.io.File;
import java.util.Map;
import java.util.TreeMap;
import org.apache.commons.lang3.StringUtils;
import forge.card.CardRules;
import forge.item.PaperCard;
import forge.model.FModel;
import forge.properties.ForgeConstants;
import forge.util.ImageUtil;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.util.Map;
import java.util.TreeMap;
public class GuiDownloadPicturesLQ extends GuiDownloadService {
@Override
@@ -37,7 +36,7 @@ public class GuiDownloadPicturesLQ extends GuiDownloadService {
@Override
protected final Map<String, String> getNeededFiles() {
final Map<String, String> downloads = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
final Map<String, String> downloads = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
for (final PaperCard c : FModel.getMagicDb().getCommonCards().getAllCards()) {
addDLObject(c, downloads, false);
@@ -78,7 +77,7 @@ public class GuiDownloadPicturesLQ extends GuiDownloadService {
final String urlToDownload;
int urlIndex = 0;
int allUrlsLen = 1;
if (urls.indexOf("\\") < 0) {
if (!urls.contains("\\")) {
urlToDownload = urls;
} else {
final String[] allUrls = urls.split("\\\\");
@@ -87,7 +86,7 @@ public class GuiDownloadPicturesLQ extends GuiDownloadService {
urlToDownload = allUrls[urlIndex];
}
//System.out.println(c.getName() + "|" + c.getEdition() + " - " + c.getArtIndex() + " -> " + urlIndex + "/" + allUrlsLen + " === " + filename + " <<< " + urlToDownload);
System.out.println(c.getName() + "|" + c.getEdition() + " - " + c.getArtIndex() + " -> " + urlIndex + "/" + allUrlsLen + " === " + filename + " <<< " + urlToDownload);
downloads.put(destFile.getAbsolutePath(), urlToDownload);
}
}

View File

@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -31,10 +31,9 @@ public class GuiDownloadQuestImages extends GuiDownloadService {
@Override
protected final Map<String, String> getNeededFiles() {
// read all card names and urls
final Map<String, String> urls = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
final Map<String, String> urls = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
addMissingItems(urls, ForgeConstants.IMAGE_LIST_QUEST_OPPONENT_ICONS_FILE, ForgeConstants.CACHE_ICON_PICS_DIR);
addMissingItems(urls, ForgeConstants.IMAGE_LIST_QUEST_PET_SHOP_ICONS_FILE, ForgeConstants.CACHE_ICON_PICS_DIR);
addMissingItems(urls, ForgeConstants.IMAGE_LIST_QUEST_BOOSTERS_FILE, ForgeConstants.CACHE_BOOSTER_PICS_DIR);
addMissingItems(urls, ForgeConstants.IMAGE_LIST_QUEST_FATPACKS_FILE, ForgeConstants.CACHE_FATPACK_PICS_DIR);
addMissingItems(urls, ForgeConstants.IMAGE_LIST_QUEST_BOOSTERBOXES_FILE, ForgeConstants.CACHE_BOOSTERBOX_PICS_DIR);

View File

@@ -6,36 +6,18 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.download;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.ConnectException;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.MalformedURLException;
import java.net.Proxy;
import java.net.URL;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import org.apache.commons.lang3.tuple.Pair;
import com.esotericsoftware.minlog.Log;
import forge.FThreads;
import forge.GuiBase;
import forge.UiCommand;
@@ -44,7 +26,12 @@ import forge.interfaces.IButton;
import forge.interfaces.IProgressBar;
import forge.interfaces.ITextField;
import forge.util.FileUtil;
import forge.util.MyRandom;
import org.apache.commons.lang3.tuple.Pair;
import java.io.*;
import java.net.*;
import java.util.Map;
import java.util.Map.Entry;
@SuppressWarnings("serial")
public abstract class GuiDownloadService implements Runnable {
@@ -183,7 +170,7 @@ public abstract class GuiDownloadService implements Runnable {
numNonzero--;
}
}
tptr++;
return tTime / Math.max(1, numNonzero);
}
@@ -201,7 +188,7 @@ public abstract class GuiDownloadService implements Runnable {
final int a = getAverageTimePerObject();
if (count != files.size()) {
sb.append(count + "/" + files.size() + " - ");
sb.append(count).append("/").append(files.size()).append(" - ");
long t2Go = (files.size() - count) * a;
@@ -215,7 +202,7 @@ public abstract class GuiDownloadService implements Runnable {
} else {
sb.append("00:");
}
sb.append(String.format("%02d remaining.", t2Go / 1000));
}
else {
@@ -240,8 +227,7 @@ public abstract class GuiDownloadService implements Runnable {
@Override
public void run() {
final Random r = MyRandom.getRandom();
Proxy p = getProxy();
int bufferLength;
@@ -270,6 +256,7 @@ public abstract class GuiDownloadService implements Runnable {
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
conn.disconnect();
System.out.println(url);
System.out.println("Skipped Download for: " + fileDest.getPath());
update(++iCard, fileDest);
skipped++;
@@ -308,12 +295,6 @@ public abstract class GuiDownloadService implements Runnable {
update(++iCard, fileDest);
// throttle to reduce load on the server
try {
Thread.sleep(r.nextInt(50) + 50);
} catch (final InterruptedException e) {
Log.error("GuiDownloader", "Sleep Error", e);
}
}
}

View File

@@ -17,19 +17,17 @@
*/
package forge.download;
import java.io.File;
import java.util.Map;
import java.util.TreeMap;
import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Iterables;
import forge.card.CardEdition;
import forge.item.PaperCard;
import forge.model.FModel;
import forge.properties.ForgeConstants;
import forge.util.ImageUtil;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.util.Map;
import java.util.TreeMap;
public class GuiDownloadSetPicturesLQ extends GuiDownloadService {
@Override
@@ -39,7 +37,7 @@ public class GuiDownloadSetPicturesLQ extends GuiDownloadService {
@Override
protected final Map<String, String> getNeededFiles() {
final Map<String, String> downloads = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
final Map<String, String> downloads = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
for (final PaperCard c : Iterables.concat(FModel.getMagicDb().getCommonCards().getAllCards(), FModel.getMagicDb().getVariantCards().getAllCards())) {
final String setCode3 = c.getEdition();

View File

@@ -17,27 +17,12 @@
*/
package forge.limited;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Stack;
import java.util.TreeMap;
import org.apache.commons.lang3.ArrayUtils;
import com.google.common.base.Supplier;
import forge.card.CardEdition;
import forge.card.IUnOpenedProduct;
import forge.card.UnOpenedProduct;
import forge.deck.CardPool;
import forge.deck.Deck;
import forge.game.card.Card;
import forge.item.IPaperCard;
import forge.item.PaperCard;
import forge.item.SealedProduct;
import forge.model.CardBlock;
@@ -45,11 +30,14 @@ import forge.model.FModel;
import forge.properties.ForgeConstants;
import forge.properties.ForgePreferences;
import forge.util.FileUtil;
import forge.util.HttpUtil;
import forge.util.ItemPool;
import forge.util.gui.SGuiChoose;
import forge.util.gui.SOptionPane;
import forge.util.storage.IStorage;
import org.apache.commons.lang3.ArrayUtils;
import java.io.File;
import java.util.*;
/**
* Booster Draft Format.
@@ -65,10 +53,10 @@ public class BoosterDraft implements IBoosterDraft {
private List<List<PaperCard>> pack; // size 8
/** The draft picks. */
private final Map<String, Float> draftPicks = new TreeMap<String, Float>();
private final Map<String, Float> draftPicks = new TreeMap<>();
protected LimitedPoolType draftFormat;
protected final List<Supplier<List<PaperCard>>> product = new ArrayList<Supplier<List<PaperCard>>>();
protected final List<Supplier<List<PaperCard>>> product = new ArrayList<>();
public static BoosterDraft createDraft(final LimitedPoolType draftType) {
final BoosterDraft draft = new BoosterDraft(draftType);
@@ -89,7 +77,7 @@ public class BoosterDraft implements IBoosterDraft {
case Block: // Draft from cards by block or set
case FantasyBlock:
final List<CardBlock> blocks = new ArrayList<CardBlock>();
final List<CardBlock> blocks = new ArrayList<>();
final IStorage<CardBlock> storage = this.draftFormat == LimitedPoolType.Block
? FModel.getBlocks()
: FModel.getFantasyBlocks();
@@ -109,7 +97,7 @@ public class BoosterDraft implements IBoosterDraft {
return false;
}
final Stack<String> sets = new Stack<String>();
final Stack<String> sets = new Stack<>();
for (int k = cardSets.size() - 1; k >= 0; k--) {
sets.add(cardSets.get(k).getCode());
}
@@ -167,10 +155,8 @@ public class BoosterDraft implements IBoosterDraft {
public static BoosterDraft createDraft(final LimitedPoolType draftType, final CardBlock block, final String[] boosters) {
final BoosterDraft draft = new BoosterDraft(draftType);
final int nPacks = boosters.length;
for (int i = 0; i < nPacks; i++) {
draft.product.add(block.getBooster(boosters[i]));
for (String booster : boosters) {
draft.product.add(block.getBooster(booster));
}
IBoosterDraft.LAND_SET_CODE[0] = block.getLandSet();
@@ -215,7 +201,7 @@ public class BoosterDraft implements IBoosterDraft {
/** Looks for draft files, reads them, returns a list. */
private static List<CustomLimited> loadCustomDrafts() {
String[] dList;
final List<CustomLimited> customs = new ArrayList<CustomLimited>();
final List<CustomLimited> customs = new ArrayList<>();
// get list of custom draft files
final File dFolder = new File(ForgeConstants.DRAFT_DIR);
@@ -247,7 +233,7 @@ public class BoosterDraft implements IBoosterDraft {
*/
@Override
public CardPool nextChoice() {
if (this.pack.get(this.getCurrentBoosterIndex()).size() == 0) {
if (this.pack.get(this.getCurrentBoosterIndex()).isEmpty()) {
this.pack = this.get8BoosterPack();
}
@@ -269,7 +255,7 @@ public class BoosterDraft implements IBoosterDraft {
return null;
}
final List<List<PaperCard>> list = new ArrayList<List<PaperCard>>();
final List<List<PaperCard>> list = new ArrayList<>();
for (int i = 0; i < 8; i++) {
list.add(this.product.get(this.nextBoosterGroup).get());
}
@@ -298,12 +284,7 @@ public class BoosterDraft implements IBoosterDraft {
final int iHumansBooster = this.getCurrentBoosterIndex();
int iPlayer = 0;
for (int i = 1; i < this.pack.size(); i++) {
final List<Card> forAi = new ArrayList<Card>();
final List<PaperCard> booster = this.pack.get((iHumansBooster + i) % this.pack.size());
for (final IPaperCard cr : booster) {
forAi.add(Card.getCardForUi(cr)); // ai is supposed to analyze it only
}
final PaperCard aiPick = this.draftAI.choose(booster, iPlayer++);
booster.remove(aiPick);
}
@@ -348,7 +329,7 @@ public class BoosterDraft implements IBoosterDraft {
final PaperCard cc = thisBooster.get(i);
final String cnBk = cc.getName() + "|" + cc.getEdition();
float pickValue = 0;
float pickValue;
if (cc.equals(c)) {
pickValue = thisBooster.size()
* (1f - (((float) this.currentBoosterPick / this.currentBoosterSize) * 2f));
@@ -372,21 +353,6 @@ public class BoosterDraft implements IBoosterDraft {
this.currentBoosterPick++;
} // setChoice()
/** This will upload drafting picks to cardforge HQ. */
@Override
public void finishedDrafting() {
if (!ForgePreferences.UPLOAD_DRAFT || 1 >= draftPicks.size()) {
return;
}
final List<String> outDraftData = new ArrayList<String>();
for (final Entry<String, Float> key : draftPicks.entrySet()) {
outDraftData.add(key.getValue() + "|" + key.getKey());
}
Collections.sort(outDraftData);
HttpUtil.upload(ForgeConstants.URL_DRAFT_UPLOAD + "?fmt=" + draftFormat, outDraftData);
}
@Override
public boolean isPileDraft() {
return false;
@@ -394,7 +360,7 @@ public class BoosterDraft implements IBoosterDraft {
private static List<String> getSetCombos(final List<String> setz) {
final String[] sets = setz.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
final List<String> setCombos = new ArrayList<String>();
final List<String> setCombos = new ArrayList<>();
if (sets.length >= 2) {
setCombos.add(String.format("%s/%s/%s", sets[0], sets[0], sets[0]));
setCombos.add(String.format("%s/%s/%s", sets[0], sets[0], sets[1]));

View File

@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -26,7 +26,7 @@ import forge.item.PaperCard;
* <p>
* BoosterDraft interface.
* </p>
*
*
* @author Forge
* @version $Id$
*/
@@ -35,8 +35,8 @@ public interface IBoosterDraft {
* <p>
* nextChoice.
* </p>
*
* @return a {@link forge.CardList} object.
*
* @return a {@link CardPool} object.
*/
CardPool nextChoice();
@@ -44,7 +44,7 @@ public interface IBoosterDraft {
* <p>
* setChoice.
* </p>
*
*
* @param c
* a {@link forge.game.card.Card} object.
*/
@@ -54,7 +54,7 @@ public interface IBoosterDraft {
* <p>
* hasNextChoice.
* </p>
*
*
* @return a boolean.
*/
boolean hasNextChoice();
@@ -63,7 +63,7 @@ public interface IBoosterDraft {
* <p>
* getDecks.
* </p>
*
*
* @return an array of {@link forge.deck.Deck} objects.
*/
Deck[] getDecks(); // size 7, all the computers decks
@@ -71,11 +71,6 @@ public interface IBoosterDraft {
/** Constant <code>LandSetCode="{}"</code>. */
CardEdition[] LAND_SET_CODE = { null };
/**
* Called when drafting is over - to upload picks.
*/
void finishedDrafting();
boolean isPileDraft();
}

View File

@@ -17,21 +17,12 @@
*/
package forge.model;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import forge.CardStorageReader;
import forge.CardStorageReader.ProgressObserver;
import forge.FThreads;
import forge.ImageKeys;
import forge.StaticData;
import forge.achievement.AchievementCollection;
import forge.achievement.ConstructedAchievements;
import forge.achievement.DraftAchievements;
import forge.achievement.QuestAchievements;
import forge.achievement.SealedAchievements;
import forge.achievement.*;
import forge.ai.AiProfileUtil;
import forge.card.CardPreferences;
import forge.card.CardType;
@@ -57,6 +48,11 @@ import forge.util.Localizer;
import forge.util.storage.IStorage;
import forge.util.storage.StorageBase;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* The default Model implementation for Forge.
*
@@ -66,7 +62,7 @@ import forge.util.storage.StorageBase;
* In case we need to convert it into an interface in the future, all fields of
* this class must be either private or public static final.
*/
public class FModel {
public final class FModel {
private FModel() { } //don't allow creating instance
private static StaticData magicDb;
@@ -152,14 +148,14 @@ public class FModel {
}
ForgePreferences.DEV_MODE = preferences.getPrefBoolean(FPref.DEV_MODE_ENABLED);
ForgePreferences.UPLOAD_DRAFT = ForgePreferences.NET_CONN; // && preferences.getPrefBoolean(FPref.UI_UPLOAD_DRAFT);
ForgePreferences.UPLOAD_DRAFT = ForgePreferences.NET_CONN;
formats = new GameFormat.Collection(new GameFormat.Reader(new File(ForgeConstants.BLOCK_DATA_DIR + "formats.txt")));
blocks = new StorageBase<CardBlock>("Block definitions", new CardBlock.Reader(ForgeConstants.BLOCK_DATA_DIR + "blocks.txt", magicDb.getEditions()));
blocks = new StorageBase<>("Block definitions", new CardBlock.Reader(ForgeConstants.BLOCK_DATA_DIR + "blocks.txt", magicDb.getEditions()));
questPreferences = new QuestPreferences();
conquestPreferences = new ConquestPreferences();
fantasyBlocks = new StorageBase<CardBlock>("Custom blocks", new CardBlock.Reader(ForgeConstants.BLOCK_DATA_DIR + "fantasyblocks.txt", magicDb.getEditions()));
worlds = new StorageBase<QuestWorld>("Quest worlds", new QuestWorld.Reader(ForgeConstants.QUEST_WORLD_DIR + "worlds.txt"));
fantasyBlocks = new StorageBase<>("Custom blocks", new CardBlock.Reader(ForgeConstants.BLOCK_DATA_DIR + "fantasyblocks.txt", magicDb.getEditions()));
worlds = new StorageBase<>("Quest worlds", new QuestWorld.Reader(ForgeConstants.QUEST_WORLD_DIR + "worlds.txt"));
loadDynamicGamedata();
@@ -180,7 +176,7 @@ public class FModel {
DeckPreferences.load();
ItemManagerConfig.load();
achievements = new HashMap<GameType, AchievementCollection>();
achievements = new HashMap<>();
achievements.put(GameType.Constructed, new ConstructedAchievements());
achievements.put(GameType.Draft, new DraftAchievements());
achievements.put(GameType.Sealed, new SealedAchievements());
@@ -209,7 +205,7 @@ public class FModel {
List<String> tList = null;
if (typeListFile.size() > 0) {
if (!typeListFile.isEmpty()) {
for (final String s : typeListFile) {
if (s.equals("[BasicTypes]")) {
tList = CardType.Constant.BASIC_TYPES;
@@ -226,7 +222,9 @@ public class FModel {
} else if (s.equals("[WalkerTypes]")) {
tList = CardType.Constant.WALKER_TYPES;
} else if (s.length() > 1) {
tList.add(s);
if (tList != null) {
tList.add(s);
}
}
}
}

View File

@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -33,7 +33,6 @@ public final class ForgeConstants {
public static final String TYPE_LIST_FILE = LISTS_DIR + "TypeLists.txt";
public static final String IMAGE_LIST_TOKENS_FILE = LISTS_DIR + "token-images.txt";
public static final String IMAGE_LIST_QUEST_OPPONENT_ICONS_FILE = LISTS_DIR + "quest-opponent-icons.txt";
public static final String IMAGE_LIST_QUEST_PET_SHOP_ICONS_FILE = LISTS_DIR + "quest-pet-shop-icons.txt";
public static final String IMAGE_LIST_QUEST_TOKENS_FILE = LISTS_DIR + "quest-pet-token-images.txt";
public static final String IMAGE_LIST_QUEST_BOOSTERS_FILE = LISTS_DIR + "booster-images.txt";
public static final String IMAGE_LIST_QUEST_FATPACKS_FILE = LISTS_DIR + "fatpack-images.txt";
@@ -74,12 +73,12 @@ public final class ForgeConstants {
public static final String SKINS_DIR = RES_DIR + "skins/";
public static final String DEFAULT_SKINS_DIR = SKINS_DIR + "default/";
//don't associate these skin files with a directory since skin directory will be determined later
public static final String SPRITE_ICONS_FILE = "sprite_icons.png";
public static final String SPRITE_ICONS_FILE = "sprite_icons.png";
public static final String SPRITE_FOILS_FILE = "sprite_foils.png";
public static final String SPRITE_OLD_FOILS_FILE = "sprite_old_foils.png";
public static final String SPRITE_TROPHIES_FILE = "sprite_trophies.png";
public static final String SPRITE_AVATARS_FILE = "sprite_avatars.png";
public static final String SPRITE_PLANAR_CONQUEST_FILE = "sprite_planar_conquest.png";
public static final String SPRITE_PLANAR_CONQUEST_FILE = "sprite_planar_conquest.png";
public static final String FONT_FILE = "font1.ttf";
public static final String SPLASH_BG_FILE = "bg_splash.png";
public static final String MATCH_BG_FILE = "bg_match.jpg";
@@ -175,8 +174,7 @@ public final class ForgeConstants {
CACHE_TOURNAMENTPACK_PICS_DIR };
// URLs
private static final String URL_CARDFORGE = "http://cardforge.org";
public static final String URL_DRAFT_UPLOAD = URL_CARDFORGE + "/draftAI/submitDraftData.php";
public static final String URL_PIC_DOWNLOAD = URL_CARDFORGE + "/fpics/";
public static final String URL_PRICE_DOWNLOAD = URL_CARDFORGE + "/MagicInfo/pricegen.php";
private static final String URL_CARDFORGE = "http://downloads.cardforge.link";
public static final String URL_PIC_DOWNLOAD = URL_CARDFORGE + "/images/cards/";
public static final String URL_PRICE_DOWNLOAD = "http://www.cardforge.org/MagicInfo/pricegen.php";
}