Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nicol authored and nicol committed Dec 9, 2024
1 parent 76a59b6 commit 57a4d8f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ public String build(MTGCrit<?>... crits) {
else
temp.append("not:").append(c.getAtt());
}
else if(c.getType()==Integer.class)
{
var separator =";";

switch(c.getOperator())
{
case GREATER: separator=">";break;
case GREATER_EQ: separator=">=";break;
case LOWER: separator="<";break;
case LOWER_EQ: separator="<=";break;
default : separator=":";break;
}
temp.append(c.getAtt()).append(separator).append(c.getFirst());

}
else
{
temp.append(c.getAtt()).append(":").append(c.getFirst());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.magic.api.beans.enums.EnumLayout;
import org.magic.api.beans.enums.EnumPromoType;
import org.magic.api.beans.enums.EnumRarity;
import org.magic.api.beans.enums.EnumSecurityStamp;
import org.magic.api.criterias.MTGCrit;
import org.magic.api.criterias.MTGQueryBuilder;
import org.magic.api.criterias.QueryAttribute;
Expand Down Expand Up @@ -89,6 +90,7 @@ protected void initBuilder(MTGQueryBuilder<?> b)
b.addConvertor(EnumCardVariation.class,(EnumCardVariation source)->source.name().toLowerCase());
b.addConvertor(EnumPromoType.class,(EnumPromoType source)->source.name().toLowerCase());
b.addConvertor(EnumFinishes.class,(EnumFinishes source)->source.name().toLowerCase());
b.addConvertor(EnumSecurityStamp.class, (EnumSecurityStamp source)->source.name().toLowerCase());
}


Expand Down
12 changes: 11 additions & 1 deletion src/main/java/org/magic/api/providers/impl/ScryFallProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,21 @@ public MTGCard call() throws Exception {

private List<MTGCard> execute(RequestBuilder q) throws IOException {
var obj = q.toJson().getAsJsonObject();

logger.debug("execute q={}, results ={}",q,obj);

List<MTGCard> list = new ArrayList<>();

if(obj.get("error")!=null)
throw new IOException(obj.get("error").getAsString());

if(obj.get("object").getAsString().equals("error"))
{
logger.error(obj.get("details").getAsString());
return list;
}



var hasMore = true;

Expand Down Expand Up @@ -310,7 +320,7 @@ protected List<QueryAttribute> loadQueryableAttributs() {
arr.add(new QueryAttribute(s,Boolean.class));
}

arr.add(new QueryAttribute(SET,MTGEdition.class));

arr.add(new QueryAttribute(COLOR, EnumColors.class));
arr.add(new QueryAttribute(COLOR_IDENTITY, EnumColors.class));
arr.add(new QueryAttribute(LAYOUT,EnumLayout.class));
Expand Down
24 changes: 7 additions & 17 deletions src/main/java/org/magic/gui/components/ImagePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,34 +133,24 @@ public void init(MTGCard mc)
if(mc == null)
return;

if (!mc.isDoubleFaced())
{
imgBack = getEnabledPlugin(MTGPictureProvider.class).getBackPicture(mc);
}
else
{
try {
MTGCard rcard =mc.getRotatedCard();
imgBack = getEnabledPlugin(MTGPictureProvider.class).getPicture(rcard);
} catch (Exception e) {
logger.error("error loading rotated card : {}",mc.getRotatedCard(),e);

}
}


ThreadManager.getInstance().executeThread(new MTGRunnable() {

@Override
protected void auditedRun() {
try {
imgFront = getEnabledPlugin(MTGPictureProvider.class).getPicture(mc);

imgFront = getEnabledPlugin(MTGPictureProvider.class).getPicture(mc);

if (mc.isDoubleFaced())
imgBack = getEnabledPlugin(MTGPictureProvider.class).getPicture(mc.getRotatedCard());
else
imgBack = getEnabledPlugin(MTGPictureProvider.class).getBackPicture(mc);

if(mc.isFlippable())
imgBack = ImageTools.rotate(printed, 180);


if(mc.getLayout()==EnumLayout.SPLIT)
imgFront= ImageTools.rotate(printed, 90);

Expand All @@ -185,7 +175,7 @@ protected void auditedRun() {
public void paintComponent(Graphics g) {
super.paintComponent(g);

Graphics2D g2 = (Graphics2D) g;
var g2 = (Graphics2D) g;
ImageTools.initGraphics(g2);

if (printed == null)
Expand Down

0 comments on commit 57a4d8f

Please sign in to comment.