It is currently 30 Oct 2025, 20:39
   
Text Size

Pictures and Rarity as SVars and Conversion Scripts

Post MTG Forge Related Programming Questions Here

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

Pictures and Rarity as SVars and Conversion Scripts

Postby friarsol » 10 Aug 2010, 04:54

So I'm almost done writing the migration script to go through the rarity & pictures files and add them in as SVars inside the cards.txt file and have found a few more cards that seem to exist in the text files, but are no longer in cards.txt

These are:
Warp Artifact
Feedback
Fiery Mantle

I'm not sure exactly why these are gone. But once we move over to a single file system, those remains will be lost. Nothing major, but if they were in there as reminders, I guess this will be the last one.

Here's a sample of one of the entries in cards.txt after the migration has taken place:
Code: Select all
Wild Nacatl
G
Creature Cat Warrior
Wild Nacatl gets +1/+1 as long as you control a Mountain. Wild Nacatl gets +1/+1 as long as you control a Plains.
1/1
SVar:Rarity:Common
SVar:Picture:http://www.wizards.com/global/images/magic/general/wild_nacatl.jpg
There's two main things from a scripting stand point left to accomplish.
One: What should we do for alternate pictures? All the basic and snow basic lands have like 3 additional pictures. Do we want to take them on as a comma delimited list?

So we would have
SVar:Picture:http://gatherer.wizards.com/handlers/image.ashx?type=card&multiverseid=159285,http://gatherer.wizards.com/handlers/image.ashx?type=card&multiverseid=159286,http://gatherer.wizards.com/handlers/image.ashx?type=card&multiverseid=159284,http://resources.wizards.com/magic/cards/unh/en-us/card73958.jpg
For the 10 basic lands.

And when Picture is parsed, it would just have to split(',') the String into an Array (or ArrayList). And do whatever it does now to choose.

Two: The not very old, but soon to be obsolete python script needs to be updated to insert into cards.txt, but grabbing the same info it already does. This shouldn't be all that difficult to accomplish, and when I find some time will be able to get that up.


The main other thing needed to be done is change code to look for Picture and Rarity SVars and properly use them. I think Rob said he was already looking into that which is great. It's easy when you only have to do half the work :D

Maybe we could split up the Card class into a CardBase with a lookup to a CardDetail. The CardBase could be used for things like the Deck Editor and the Card Shop, since all it really needs is things found in cards.txt (Name, CC, Image, Rarity, Card Text) but doesn't need all of the bloat of the in-game related stuff. And then while playing in game, we can just load in 120 or so Card Details we need when we start up the game? We might take a decent load of the heap by doing it this way.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Pictures and Rarity as SVars and Conversion Scripts

Postby Rob Cashwalker » 10 Aug 2010, 11:56

At the moement I'm not sure how to go about things. The way the system works now, is that the rarity.txt files are read in order to get a card name which is passed to the CardFactory. As of yet I haven't confirmed that there is a single, global list of cards, which may help solve a couple issues.

I may do the URL part first, since that's a property that's read in from the beginning, as opposed to during the course of launching games.
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: Pictures and Rarity as SVars and Conversion Scripts

Postby Chris H. » 10 Aug 2010, 14:18

friarisol wrote:So I'm almost done writing the migration script to go through the rarity & pictures files and add them in as SVars inside the cards.txt file and have found a few more cards that seem to exist in the text files, but are no longer in cards.txt

These are:
Warp Artifact
Feedback
Fiery Mantle

I'm not sure exactly why these are gone. But once we move over to a single file system, those remains will be lost. Nothing major, but if they were in there as reminders, I guess this will be the last one.
`
At one point some new auras were being added to the code base and we updated the card-pictures.txt file. Unfortunately, problems came up with the new auras and we deleted the cards but forgot to delete the pic urls.

The code which displays cards as an offset pile of cards was written before auras and equips were added. In many cases, the pics will stack correctly, yet we sometimes add a new aura and once again see the problem.

Spreading Seas is currently an example of what can happen. It works well with some lands but when enchanting other lands we get some display type bugs.

We can safely delete these three pic urls at this point. Some talented individual may re-write these display routines in the future. :mrgreen:
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Pictures and Rarity as SVars and Conversion Scripts

Postby friarsol » 10 Aug 2010, 14:48

Sounds good to me. They aren't really doing any harm, so we can just leave them until the full migration process is done and the pics/rarity files are just nuked altogether. I just wanted to post a note since I'm sure noone goes through these huge files.

Edit: Oh while I'm in here scripting, I think I'm going to have Mythics be labeled as Mythics for the SVar. Until we are ready to use them any differently, we could just have the parsing in game treat Mythic exactly the same as it treats Rare.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Pictures and Rarity as SVars and Conversion Scripts

Postby friarsol » 10 Aug 2010, 21:49

So I got a little carried away and edited the Python script to be able to pull sets down too. A few weeks back I had been musing about how hard would it be to do a quest mode that progressed through the timeline of Magic sets. Well, apparently it wasn't all that difficult to pull off data about the cards.

The only downside is this script will need to be updated every time a set is released. (In fact, I already have the next two sets filled in) But it does all the heavy lifting besides that, so it's probably worth having in there for the future if we want to use Sets for something.

I probably won't run or submit this for a bit. But it won't take long to go through and add Set information to all the cards we have right now.

There will also need to be a secondary script that can grab a checklist of card names for the new set, and for each reprinted card already in cards.txt, add the new set onto the list of sets. I'll put that together at some point. Although testing it will probably have to wait till the next set comes out.

Here's a sample of what Mountain looks like in cards.txt with the latest version of the script.
Code: Select all
Mountain
no cost
Basic Land Mountain
no text
tap: add R
SVar:Rarity:Land
SVar:Picture:http://resources.wizards.com/magic/cards/unh/en-us/card73958.jpg
SVar:Sets:Limited Edition Beta,Unlimited Edition,Revised Edition,Fourth Edition,Fifth Edition,Classic Sixth Edition,Seventh Edition,Eighth Edition,Ninth Edition,Tenth Edition,Magic 2010,Magic 2011,Portal,Portal Second Age,Portal Three Kingdoms,Starter 1999,Arabian Nights,Ice Age,Mirage,Tempest,Urza's Saga,Mercadian Masques,Invasion,Odyssey,Onslaught,Mirrodin,Champions of Kamigawa,Ravnica: City of Guilds,Time Spiral,Lorwyn,Shadowmoor,Shards of Alara,Zendikar,Rise of the Eldrazi
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Pictures and Rarity as SVars and Conversion Scripts

Postby DennisBergkamp » 10 Aug 2010, 21:55

Looks a bit wordy, but whatever, it's great to finally have a way of dividing cards into sets :)

Perhaps we could use abbreviations for the sets though?
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Pictures and Rarity as SVars and Conversion Scripts

Postby friarsol » 11 Aug 2010, 02:12

DennisBergkamp wrote:Looks a bit wordy, but whatever, it's great to finally have a way of dividing cards into sets :)

Perhaps we could use abbreviations for the sets though?
Abbreviations for sets works. The lookup needs to have the full name, but I can just make a dictionary for the abbreviation and write that out instead of the full name.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Pictures and Rarity as SVars and Conversion Scripts

Postby Rob Cashwalker » 11 Aug 2010, 04:38

Agreed on using the standard 3-letter codes. Easier to pattern match and stuff.
Basic lands appear in ALL sets, so why not just shortcut it, and hope that "ALL" is never used as a set code....

I think the URLs need to assume that they all begin with "http://". (I can add that in when parsing the list) this is because the keywords use ":" to split the parameters.
Also, I intend to support the downloading of multiple images, even if the graphics code doesn't yet support it for cards other than lands, as I'm sure it would be easy enough to hack in.
The delimiter between URL's needs to be an illegal URL character. "# % & * { } \ : < > ? / +" Comma is a possible character. I suggest "\".

Can we call the SVar "URLs"?

I've begun hacking Gui_DownloadPictures_LQ, which is the only place where the card picture file is read.
CardFactory claims to have a getAllCards() method which only transcribes a private card Array... so I'm starting with that to see if it has more or less than what I'm expecting, if it pans out, then I should easily be able to make the rarity hacks later.
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: Pictures and Rarity as SVars and Conversion Scripts

Postby Hellfish » 11 Aug 2010, 07:02

%,&,? and + are not illegal URL characters though admittedly not likely to appear in this case. \ would probably work, yeah.
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

Re: Pictures and Rarity as SVars and Conversion Scripts

Postby friarsol » 11 Aug 2010, 13:50

Rob Cashwalker wrote:Agreed on using the standard 3-letter codes. Easier to pattern match and stuff.
Basic lands appear in ALL sets, so why not just shortcut it, and hope that "ALL" is never used as a set code....

I think the URLs need to assume that they all begin with "http://". (I can add that in when parsing the list) this is because the keywords use ":" to split the parameters.
Also, I intend to support the downloading of multiple images, even if the graphics code doesn't yet support it for cards other than lands, as I'm sure it would be easy enough to hack in.
The delimiter between URL's needs to be an illegal URL character. "# % & * { } \ : < > ? / +" Comma is a possible character. I suggest "\".

Can we call the SVar "URLs"?

I've begun hacking Gui_DownloadPictures_LQ, which is the only place where the card picture file is read.
CardFactory claims to have a getAllCards() method which only transcribes a private card Array... so I'm starting with that to see if it has more or less than what I'm expecting, if it pans out, then I should easily be able to make the rarity hacks later.
Well, basic lands don't appear in every set. For years they only appeared in the first set of a block, so that's not true at all. I think Rise of Eldrazi was the first time they appeared in a non-first set. And Alliances set abbreviation is actually ALL, so that doesn't really work. (I believe it was AI, when set abbreviations were only two letters back in the day) If it's mostly a bloat of cards.txt thing, we can change the abbreviation to BASIC. Which would never be used as a three letter abbreviation of a set.

Yea as long as we have lists of Picture URLs it shouldn't really matter what the card is that we are adding multiple pictures of, since it'll all be running through the same code for it.

As for as splitting SVars, shouldn't we be able to just do this to limit the amount of splits done? This way we don't have to just "assume" the url came from an http source as opposed to an https source (or really any web protocol source that might be around)
Code: Select all
String k[] = parse.split(":",2);
if(k.length == 3) card.setSVar(k[1], k[2]);
I can swap the commas out for backslashes. When I was writing up the script, I apparently wasn't thinking of the URL legality of the delimiter.

I don't think just URLs is descriptive enough. How about PicURLs?
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Pictures and Rarity as SVars and Conversion Scripts

Postby Rob Cashwalker » 11 Aug 2010, 14:48

Lorwyn/Shadowmoor block had two sets of land. Good point though. BASIC is fine with me. Basic land is never going to not be available in some form or another for draft, sealed, random, quest, set-quest, etc.... The only instance in which set-specific land would be used is for set-specific booster packs, and only if we felt the need to include a land in it... which we probably don't need.
Giant Growth and other core staples are likely to also be a lengthy list, but unavoidable.

I have a rough game plan for modifying the ImageCache to handle multiple images for cards other than basic land.

As for rarity - we currently have potentially different rarity for draft/sealed and quests. Should this be done with unique SVars or parse a single one?

I had never considered that syntax....

PicURLs it is. The characters I listed came from a quick google search for "illegal URL characters". They're certainly not completely illegal. "#" is used for paragraph anchors in html documents. "%" is used for hex character codes. "?" is used to delineate parameters to PHP or perl, using "&" as a delimiter between them.
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: Pictures and Rarity as SVars and Conversion Scripts

Postby silly freak » 11 Aug 2010, 18:18

umm... is it really necessary to keep the full URL? as I haven't seen any non-gatherer sources yet, wouldn't it be enough to store the multiverse ID?
___

where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
silly freak
DEVELOPER
 
Posts: 598
Joined: 26 Mar 2009, 07:18
Location: Vienna, Austria
Has thanked: 93 times
Been thanked: 25 times

Re: Pictures and Rarity as SVars and Conversion Scripts

Postby Chris H. » 11 Aug 2010, 18:31

silly freak wrote:umm... is it really necessary to keep the full URL? as I haven't seen any non-gatherer sources yet, wouldn't it be enough to store the multiverse ID?
`
The SVar's for Portal images are not using a wotc based url.
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Pictures and Rarity as SVars and Conversion Scripts

Postby silly freak » 11 Aug 2010, 18:57

good to know ;)

on my own project, I'm storing all the Multiverse-IDs for the cards, as this is also a unique identifier for the picture. for non-gatherer pictures, I will use a lookup table, so the URL is not stored with the card directly, but with the multiverse ID in a separate list.
maybe this thought helps you? I know the main concern is to get rid of the extra picture file, but from an OO perspective, the picture URLs are not really parts of the card. suppose you want to add a new mirror for the pictures. the format proposed here won't make that easy
___

where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
silly freak
DEVELOPER
 
Posts: 598
Joined: 26 Mar 2009, 07:18
Location: Vienna, Austria
Has thanked: 93 times
Been thanked: 25 times

Re: Pictures and Rarity as SVars and Conversion Scripts

Postby Rob Cashwalker » 11 Aug 2010, 19:46

A mirror site would have different URLs anyway, probably not using the multiverse ID either.

We could also write our own "multiverse" of sorts - a script running on a server that is able to translate our own ID numbers to known URLs on assorted hosts.... This reduces maintenance of these lists as they only need to be changed in one location, without clogging up the cards.txt even more.

It's interesting you brought up the object-orientedness. As I was trying to figure out the URL parsing, it kept referring to a "Card" object... but it was using a constructor I had never seen in Card.java. Turns out that at the bottom of the Gui_DownloadPictures_LQ file, is a private Card class, with two properties - Name and URL. Because I need actual Card objects to iterate a CardList, I renamed the private class and all references to it to "mCard".
This is precisely why I think the Card object should carry as much information as possible.

The multiple images support is limited to 4 images currently, but with a very slight tweak could be made to support more. This would require another SVar to indicate the number of images available for the card.
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

Next

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 41 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 41 users online :: 0 registered, 0 hidden and 41 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 41 guests

Login Form