It is currently 29 Oct 2025, 07:27
   
Text Size

Set Compatibility Work

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins

Set Compatibility Work

Postby friarsol » 10 Oct 2010, 03:52

Hey guys,

While I've already loaded my plate with a bunch of stuff (mostly related to streamlining abilities), I'm curious if anyone wants to take on Set Compatibility. I have a local Python script that has been sitting around for a few weeks ready to insert sets into the data files in cardsfolder/. I think I'm going to submit it with the set inserting commented out, since the Script hasn't been functional since the cards.txt to cardsfolder/ transition. Whoever wants to work on it can uncomment the spots so they can see how the Sets will be created in the data files.
I figure I'll submit it with the sets commented out so we can use it again for automated image and rarity updating. We have been pretty good about updating these lately, but its way easier to let a script handle that type of work.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Set Compatibility Work

Postby Sloth » 10 Oct 2010, 09:29

friarsol wrote:I figure I'll submit it with the sets commented out so we can use it again for automated image and rarity updating. We have been pretty good about updating these lately, but its way easier to let a script handle that type of work.
Thanks Sol, a little more laziness is always welcome. And good to know that sets can be supported if someone wants to use them.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Set Compatibility Work

Postby Rob Cashwalker » 10 Oct 2010, 13:14

It will be easier for me to implement at least the data structure side of things if I have the raw information available. We discussed the format previously, I assume that's what you based the script on. It won't harm anything if the data is in the files without definite purpose.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Set Compatibility Work

Postby Rob Cashwalker » 30 Oct 2010, 03:38

I just added a first draft of a SetInfo object and a list of Sets in the Card object.

giant_growth.txt:
Code: Select all

Name:Giant Growth
ManaCost:G
Types:Instant
Text:no text
# K:spPumpTgt:+3/+3
A:SP$Pump|Cost$G|ValidTgts$Creature|NumAtt$+3|NumDef$+3|SpellDescription$Target creature gets +3/+3 until end of turn.|TgtPrompt$Select target creature.
SVar:Rarity:Common
SVar:Picture:http://www.wizards.com/global/images/magic/general/giant_growth.jpg
SetInfo:LEA|Common|http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=153&type=card
SetInfo:LEB|Common|http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=448&type=card
SetInfo:2ED|Common|http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=750&type=card
SetInfo:3ED|Common|http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=1248&type=card
SetInfo:4ED|Common|http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=2215&type=card
SetInfo:5ED|Common|http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=3982&type=card
SetInfo:6ED|Common|http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=14683&type=card
SetInfo:7ED|Common|http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=11301&type=card
SetInfo:8ED|Common|http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=45414&type=card
SetInfo:9ED|Common|http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=83103&type=card
SetInfo:XED|Common|http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=129568&type=card
SetInfo:M10|Common|http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=189879&type=card
SetInfo:M11|Common|http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=205224&type=card
SetInfo:ICE|Common|http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=2570&type=card
End
Set codes are based on this reference:
http://mtg.wikia.com/wiki/Sets
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Set Compatibility Work

Postby friarsol » 30 Oct 2010, 03:43

Is that how I wrote the script to create the objects? It was such a long time ago I don't even remember, but that doesn't look familiar.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Set Compatibility Work

Postby Rob Cashwalker » 30 Oct 2010, 16:22

I have no idea how the script does it, this is based on the discussion from the other thread.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Set Compatibility Work

Postby Rob Cashwalker » 31 Oct 2010, 03:33

OK, so now I can see exactly what python is good at.... Nice work, BTW, I never read through it before.

So, yes, what I've settled on isn't going to work with the script as-is. It shouldn't be difficult at all to make the necessary changes.

The above design, is based on the "advances" from the past 2 months, with less reliance on SVar's. Which is really part of the fundamental change in order to read each card as its own file....

The above example actually sucks. The new gatherer images all come with the border. If we're using magiccards.info for card data, we might as well also use their URLs.

Come to think of it, the better thing for the script is, leave the existing URL and rarity SVar's alone for a while. Just modify the set description part. I will have to write another image downloader anyway....
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Set Compatibility Work

Postby friarsol » 31 Oct 2010, 03:56

Yea Python tears through the files quickly, and even without knowing the language it's not too hard to see what's going on. I had written that before we really had fleshed out the Set discussion, so I'm not opposed to fixing it up for the new style.

I recently found out about the CardSets file that Hellfish is using to compare what cards we have by Set. So I can use that instead of scraping a website.

We do however need a reliable source for getting the image sans border for each card per set. Currently, we were using the wizards main image, which I guess is the most recent release of the card.

I don't know where we could get those images, so the card would be the appropriate art per set. I'd have to think it's somewhere, we would just need to figure out where to take advantage of it. Anyone have any ideas? Strong preference toward a naming convention that is 100% predictable so the Script can just fill in a URL and test if it exists.

There are a ton of advantages to having Set/Rarity/Image all on the same line and multiples per file so it'll be great to start making that progress soon.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Set Compatibility Work

Postby Rob Cashwalker » 31 Oct 2010, 05:24

The advantage to scraping the website is that the results are dynamic... as soon as they update their data, ours gets up to date too....

magiccards.info uses a mix of 2 and 3 character set codes, then the collector number. Similar to the HQ pics...
I was thinking of storing the files under pics/{Code}/{CleanedPictureName}. While I was thinking the 3 letter code would be best, if a mix seems to be more universally mirrored, then by all means we should stick to it.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Set Compatibility Work

Postby Rob Cashwalker » 07 Nov 2010, 03:53

I have gotten random set images to work as expected. Since Giant Growth is the only one with set info, I used it as an example.
GiantGrowthHand.jpg

I manually downloaded them, and placed them in folders with 3-letter set codes. (ie: /res/pics/M10/giant_growth.jpg)

I've added a SetInfoUtil class, which will be used to translate 2 letter and 3 letter set codes to the full set names. The array is set up with the sets in release order, according to a post in the HQ Pictures forum. (I'm thinking that the deck editor picture may want to always be from the most recent release, unless it's from a draft, which is about the only time that the set picture is necessary anyway)
Code: Select all

package forge;

import java.util.ArrayList;

public class SetInfoUtil {
   
   private static String[][] sets = {
      {"A"}, {"LEA"}, {"Limited Edition Alpha"},
      {"B"}, {"LEB"}, {"Limited Edition Beta"},
      {"U"}, {"2ED"}, {"Unlimited"},
      {"AN"}, {"ARN"}, {"Arabian Nights"},
      {"AQ"}, {"ATQ"}, {"Antiquities"},
      {"R"}, {"3ED"}, {"Revised Edition"},
      {"LG"}, {"LEG"}, {"Legends"},
      {"FE"}, {"FEM"}, {"Fallen Empires"},
      {"DK"}, {"DRK"}, {"The Dark"},
      {"4E"}, {"4ED"}, {"Fourth Edition"},
      {"IA"}, {"ICE"}, {"Ice Age"},
      {"CH"}, {"CHR"}, {"Chronicles"},
      {"HL"}, {"HML"}, {"Homelands"},
      {"AL"}, {"ALL"}, {"Alliances"},
      {"MI"}, {"MIR"}, {"Mirage"},
      {"VI"}, {"VIS"}, {"Visions"},
      {"5E"}, {"5ED"}, {"Fifth Edition"},
      {"PT"}, {"POR"}, {"Portal"},
      {"WL"}, {"WTH"}, {"Weatherlight"},
      {"TE"}, {"TMP"}, {"Tempest"},
      {"SH"}, {"STH"}, {"Stronghold"},
      {"EX"}, {"EXO"}, {"Exodus"},
      {"P2"}, {"P02"}, {"Portal Second Age"},
      {"US"}, {"USG"}, {"Urza's Saga"},
      {"UL"}, {"ULG"}, {"Urza's Legacy"},
      {"6E"}, {"6ED"}, {"Classic (Sixth Edition)"},
      {"UD"}, {"UDS"}, {"Urza's Destiny"},
      {"P3"}, {"PTK"}, {"Portal Three Kingdoms"},
      {"ST"}, {"S99"}, {"Starter 1999"},
      {"MM"}, {"MMQ"}, {"Mercadian Masques"},
      {"NE"}, {"NMS"}, {"Nemesis"},
      {"S2K"}, {"S00"}, {"Starter 2000"},
      {"PY"}, {"PCY"}, {"Prophecy"},
      {"IN"}, {"INV"}, {"Invasion"},
      {"PS"}, {"PLS"}, {"Planeshift"},
      {"7E"}, {"7ED"}, {"Seventh Edition"},
      {"AP"}, {"APC"}, {"Apocalypse"},
      {"OD"}, {"ODY"}, {"Odyssey"},
      {"TO"}, {"TOR"}, {"Torment"},
      {"JU"}, {"JUD"}, {"Judgment"},
      {"ON"}, {"ONS"}, {"Onslaught"},
      {"LE"}, {"LGN"}, {"Legions"},
      {"SC"}, {"SCG"}, {"Scourge"},
      {"8E"}, {"8ED"}, {"Core Set - Eighth Edition"},
      {"MR"}, {"MRD"}, {"Mirrodin"},
      {"DS"}, {"DST"}, {"Darksteel"},
      {"FD"}, {"5DN"}, {"Fifth Dawn"},
      {"CHK"}, {"CHK"}, {"Champions of Kamigawa"},
      {"BOK"}, {"BOK"}, {"Betrayers of Kamigawa"},
      {"SOK"}, {"SOK"}, {"Saviors of Kamigawa"},
      {"9E"}, {"9ED"}, {"Core Set - Ninth Edition"},
      {"RAV"}, {"RAV"}, {"Ravnica: City of Guilds"},
      {"GP"}, {"GPT"}, {"Guildpact"},
      {"DIS"}, {"DIS"}, {"Dissension"},
      {"CS"}, {"CSP"}, {"Coldsnap"},
      {"TSP"}, {"TSP"}, {"Time Spiral"},
      {"TSB"}, {"TSB"}, {"Time Spiral Timeshifted"},
      {"PLC"}, {"PLC"}, {"Planar Chaos"},
      {"FUT"}, {"FUT"}, {"Future Sight"},
      {"10E"}, {"10E"}, {"Core Set - Tenth Edition"},
      {"LRW"}, {"LRW"}, {"Lorwyn"},
      {"MOR"}, {"MOR"}, {"Morningtide"},
      {"SHM"}, {"SHM"}, {"Shadowmoor"},
      {"EVE"}, {"EVE"}, {"Eventide"},
      {"ALA"}, {"ALA"}, {"Shards of Alara"},
      {"CFX"}, {"CFX"}, {"Conflux"},
      {"ARB"}, {"ARB"}, {"Alara Reborn"},
      {"M10"}, {"M10"}, {"Magic The Gathering 2010"},
      {"ZEN"}, {"ZEN"}, {"Zendikar"},
      {"WWK"}, {"WWK"}, {"Worldwake"},
      {"ROE"}, {"ROE"}, {"Rise of the Eldrazi"},
      {"M11"}, {"M11"}, {"Magic The Gathering 2011"},
      {"SOM"}, {"SOM"}, {"Scars of Mirrodin"}      
   };
   
   public static ArrayList<String> getSetCode2List()
   {
      ArrayList<String> scl = new ArrayList<String>();
      
      for (int i=0; i<sets.length; i++)
         scl.add(sets[i][0]);
      
      return scl;
   }
   
   public static ArrayList<String> getSetCode3List()
   {
      ArrayList<String> scl = new ArrayList<String>();
      
      for (int i=0; i<sets.length; i++)
         scl.add(sets[i][1]);
   
      return scl;
   }
   
   public static ArrayList<String> getSetNameList()
   {
      ArrayList<String> snl = new ArrayList<String>();
      
      for (int i=0; i<sets.length; i++)
         snl.add(sets[i][2]);
      
      return snl;
   }
   
   public static String getSetCode2_SetName(String SetName)
   {
      for (int i=0; i<sets.length; i++)
         if (sets[i][2].equals(SetName))
            return sets[i][0];
      
      return "";
   }

   public static String getSetCode3_SetName(String SetName)
   {
      for (int i=0; i<sets.length; i++)
         if (sets[i][2].equals(SetName))
            return sets[i][1];
      
      return "";
   }

   public static String getSetCode2_SetCode3(String SetCode3)
   {
      for (int i=0; i<sets.length; i++)
         if (sets[i][1].equals(SetCode3))
            return sets[i][0];
      
      return "";
   }
   
   public static String getSetCode3_SetCode2(String SetCode2)
   {
      for (int i=0; i<sets.length; i++)
         if (sets[i][0].equals(SetCode2))
            return sets[i][1];
      
      return "";
   }

   public static String getSetName_SetCode2(String SetCode2)
   {
      for (int i=0; i<sets.length; i++)
         if (sets[i][0].equals(SetCode2))
            return sets[i][2];
      
      return "";
   }

   public static String getSetName_SetCode3(String SetCode3)
   {
      for (int i=0; i<sets.length; i++)
         if (sets[i][1].equals(SetCode3))
            return sets[i][2];
      
      return "";
   }

}
Yes, I considered reading this from a file... this was simpler to get something working.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Set Compatibility Work

Postby Hellfish » 07 Nov 2010, 09:25

Ooh, I like where this is going. I think externalizing (Is that a word? It should be!) as much as possible into a settings file or the like would be the way to go.Set Codes,card name format, even search path. I once had a project similar to the GoodROM tools (catalogues and indexes dumps of console games) that renamed the files it indexed according to a string in the vein of
Code: Select all
$MOVIENUMBER $ROMNAME - $TIME by $AUTHORS
where the $words where replaced by the appropriate data for that file. Something similar here could be like
Code: Select all
res\pics\$SET3CODE\$CARDFULLNAME.full.jpg
or
res\pics\$SETNAME\$CARDFRIENDLYNAME.jpg
where the first one for Giant Growth would end up as "res\pics\LEA\Giant Growth.full.jpg" and "res\pics\Limited Edition Alpha\giant_growth.jpg". I believe this would really help those who (like me :P) already have almost all card pics downloaded avoid a lot of extra renaming work. Default settings could of course be almost like it is now.
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 7 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 7 users online :: 0 registered, 0 hidden and 7 guests (based on users active over the past 10 minutes)
Most users ever online was 9298 on 10 Oct 2025, 12:54

Users browsing this forum: No registered users and 7 guests

Login Form