mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
Added downloading and displaying emblem images
This commit is contained in:
parent
09bd74f26e
commit
e34ee2e7f6
10 changed files with 75 additions and 23 deletions
|
@ -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;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -15,6 +16,7 @@ public class MagicCardsImageSource implements CardImageSource {
|
|||
|
||||
{
|
||||
put("AVR", "avacyn-restored");
|
||||
put("DDI", "duel-decks-venser-vs-koth");
|
||||
put("DKA", "dark-ascension");
|
||||
put("ISD", "innistrad");
|
||||
put("DDH", "duel-decks-ajani-vs-nicol-bolas");
|
||||
|
@ -76,7 +78,7 @@ public class MagicCardsImageSource implements CardImageSource {
|
|||
|
||||
@Override
|
||||
public String generateTokenUrl(String name, String set) {
|
||||
String _name = name.replaceAll(" ", "-").toLowerCase();
|
||||
String _name = name.replaceAll(" ", "-").replace(",", "").toLowerCase();
|
||||
String _set = "not-supported-set";
|
||||
if (setNameReplacement.containsKey(set)) {
|
||||
_set = setNameReplacement.get(set);
|
||||
|
|
|
@ -337,6 +337,10 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
String set = params[2].substring(4);
|
||||
CardInfo card = new CardInfo(params[3], set, 0, 0, true);
|
||||
list.add(card);
|
||||
} else if (params[1].toLowerCase().equals("generate") && params[2].startsWith("EMBLEM:")) {
|
||||
String set = params[2].substring(7);
|
||||
CardInfo card = new CardInfo("Emblem " + params[3], set, 0, 0, true);
|
||||
list.add(card);
|
||||
}
|
||||
} else {
|
||||
log.error("wrong format for image urls: " + line);
|
||||
|
|
|
@ -146,10 +146,11 @@ public class CardImageUtils {
|
|||
|
||||
public static String getImagePath(CardInfo card, boolean withCollector, String imagesPath) {
|
||||
String type = card.getType() != 0 ? " " + Integer.toString(card.getType()) : "";
|
||||
String name = card.getName();
|
||||
if (withCollector) {
|
||||
return getImageDir(card, imagesPath) + File.separator + card.getName() + "." + card.getCollectorId() + ".full.jpg";
|
||||
return getImageDir(card, imagesPath) + File.separator + name + "." + card.getCollectorId() + ".full.jpg";
|
||||
} else {
|
||||
return getImageDir(card, imagesPath) + File.separator + card.getName() + type + ".full.jpg";
|
||||
return getImageDir(card, imagesPath) + File.separator + name + type + ".full.jpg";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
|Generate|EMBLEM:AVR|Tamiyo, the Moon Sage|
|
||||
|
||||
|Generate|TOK:AVR|Angel|
|
||||
|Generate|TOK:AVR|Human 1|
|
||||
|Generate|TOK:AVR|Spirit 1|
|
||||
|
@ -6,6 +8,9 @@
|
|||
|Generate|TOK:AVR|Zombie|
|
||||
|Generate|TOK:AVR|Human 2|
|
||||
|
||||
|Generate|EMBLEM:DDI|Venser, the Sojourner|
|
||||
|Generate|EMBLEM:DDI|Koth of the Hammer|
|
||||
|
||||
|Generate|TOK:DKA|Human|
|
||||
|Generate|TOK:DKA|Vampire|
|
||||
|
||||
|
|
|
@ -56,6 +56,6 @@ leg=lg
|
|||
ptk=p3k
|
||||
gur=guru
|
||||
mpr=mprp
|
||||
ignore.urls=TOK
|
||||
ignore.urls=TOK,EMBLEM
|
||||
# sets ordered by release time (newest goes first)
|
||||
token.lookup.order=NPH,MBS,SOM,M11,ROE,PVC,WWK,ZEN,M10,GVL,ARB,DVD,CFX,JVC,ALA,EVE,SHM,EVG,MOR,LRW,10E,CLS,CHK
|
||||
token.lookup.order=AVR,DDI,DKA,ISD,M12,NPH,MBS,SOM,M11,ROE,PVC,WWK,ZEN,M10,GVL,ARB,DVD,CFX,JVC,ALA,EVE,SHM,EVG,MOR,LRW,10E,CLS,CHK
|
|
@ -157,11 +157,11 @@ public class CardView extends SimpleCardView {
|
|||
this.rules = ((PermanentToken) card).getRules();
|
||||
this.type = ((PermanentToken)card).getToken().getTokenType();
|
||||
}
|
||||
if (name.equals("") && card instanceof StackAbility) {
|
||||
if (this.rarity == null && card instanceof StackAbility) {
|
||||
StackAbility stackAbility = (StackAbility)card;
|
||||
if (stackAbility.getZone().equals(Constants.Zone.COMMAND)) {
|
||||
this.name = "Emblem";
|
||||
this.rarity = Rarity.NA;
|
||||
this.expansionSetCode = stackAbility.getExpansionSetCode();
|
||||
this.rules = new ArrayList<String>();
|
||||
this.rules.add(stackAbility.getRule());
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import mage.game.ExileZone;
|
|||
import mage.game.Game;
|
||||
import mage.game.GameState;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.command.CommandObject;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackAbility;
|
||||
|
@ -44,7 +45,10 @@ import mage.game.stack.StackObject;
|
|||
import mage.players.Player;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -89,6 +93,15 @@ public class GameView implements Serializable {
|
|||
} else if (object != null) {
|
||||
StackAbility stackAbility = ((StackAbility)object);
|
||||
stackAbility.newId();
|
||||
MageObject emblem = game.getEmblem(stackAbility.getSourceId());
|
||||
if (emblem != null) {
|
||||
Card sourceCard = game.getCard(((CommandObject)emblem).getSourceId());
|
||||
if (sourceCard != null) {
|
||||
stackAbility.setName("Emblem " + sourceCard.getName());
|
||||
stackAbility.setExpansionSetCode(sourceCard.getExpansionSetCode());
|
||||
}
|
||||
}
|
||||
|
||||
stack.put(stackObject.getId(), new CardView(stackAbility));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ public interface Game extends MageItem, Serializable {
|
|||
public void setCustomData(Object data);
|
||||
public GameOptions getOptions();
|
||||
public MageObject getObject(UUID objectId);
|
||||
public MageObject getEmblem(UUID objectId);
|
||||
public UUID getControllerId(UUID objectId);
|
||||
public Permanent getPermanent(UUID permanentId);
|
||||
public Card getCard(UUID cardId);
|
||||
|
|
|
@ -266,6 +266,18 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
return object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MageObject getEmblem(UUID objectId) {
|
||||
if (objectId == null)
|
||||
return null;
|
||||
for (CommandObject commandObject : state.getCommand()) {
|
||||
if (commandObject.getId().equals(objectId)) {
|
||||
return commandObject;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getControllerId(UUID objectId) {
|
||||
if (objectId == null) {
|
||||
|
|
|
@ -68,6 +68,8 @@ public class StackAbility implements StackObject, Ability {
|
|||
|
||||
private Ability ability;
|
||||
private UUID controllerId;
|
||||
private String name = "";
|
||||
private String expansionSetCode;
|
||||
|
||||
public StackAbility(Ability ability, UUID controllerId) {
|
||||
this.ability = ability;
|
||||
|
@ -77,6 +79,8 @@ public class StackAbility implements StackObject, Ability {
|
|||
public StackAbility(final StackAbility spell) {
|
||||
this.ability = spell.ability.copy();
|
||||
this.controllerId = spell.controllerId;
|
||||
this.name = spell.name;
|
||||
this.expansionSetCode = spell.expansionSetCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -101,7 +105,11 @@ public class StackAbility implements StackObject, Ability {
|
|||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "";
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getExpansionSetCode() {
|
||||
return expansionSetCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -276,7 +284,13 @@ public class StackAbility implements StackObject, Ability {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) { }
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setExpansionSetCode(String expansionSetCode) {
|
||||
this.expansionSetCode = expansionSetCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustCosts(Ability ability, Game game) {}
|
||||
|
|
Loading…
Reference in a new issue