Scripts for LQ Pictures and Rarity
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
17 posts
• Page 1 of 2 • 1, 2
Scripts for LQ Pictures and Rarity
by friarsol » 25 Jul 2010, 14:48
Alright guys, instead of manually inserting cards into 5 different files, we really should be automating as much as the process as possible.
So I'll start looking into the script sometime on Monday. And see if I can punch it out in a day or two.
Basically the script will sift through the cards.txt file and make a list of actual card names. Then, it'll go through each of the other files and insert in cards to the top of the file based on the current conventions. Nothing too complex, but just a way to automate a process that should be automated. Anyone adding cards and then running the script should still probably make a quick game to confirm the rarity and image worked out appropriately, but the less manual labor the better, right?
I figure for this we should probably move the basic land in the card-pictures.txt to the bottom, so new cards can appear on the top.
So which files should I be looking at for the script?
I was thinking:
[*]cards.txt
[*]cards-pictures.txt
[*]common.txt
[*]uncommon.txt
[*]rare.txt
[*]quest/common.txt
[*]quest/uncommon.txt
[*]quest/rare.txt
So I'll start looking into the script sometime on Monday. And see if I can punch it out in a day or two.
Basically the script will sift through the cards.txt file and make a list of actual card names. Then, it'll go through each of the other files and insert in cards to the top of the file based on the current conventions. Nothing too complex, but just a way to automate a process that should be automated. Anyone adding cards and then running the script should still probably make a quick game to confirm the rarity and image worked out appropriately, but the less manual labor the better, right?
I figure for this we should probably move the basic land in the card-pictures.txt to the bottom, so new cards can appear on the top.
So which files should I be looking at for the script?
I was thinking:
[*]cards.txt
[*]cards-pictures.txt
[*]common.txt
[*]uncommon.txt
[*]rare.txt
[*]quest/common.txt
[*]quest/uncommon.txt
[*]quest/rare.txt
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Scripts for LQ Pictures and Rarity
by Chris H. » 25 Jul 2010, 16:22
Sounds like a great idea although there are a couple of issues that need to be considered. Less work is a good thing.
I own a Mac and do not have easy access to a Win box. I think that most of the people here use Windows and would not face the same issue when it comes to running scripts.
The url www.wizards.com/global/images/magic/general/ which is used for most of the LQ pics does not include pics from the portal series. We are using other servers for these cards.
We tend to use the most common rarity for cards the have different rarity values. We also convert all mythic rares to rares.

I own a Mac and do not have easy access to a Win box. I think that most of the people here use Windows and would not face the same issue when it comes to running scripts.
The url www.wizards.com/global/images/magic/general/ which is used for most of the LQ pics does not include pics from the portal series. We are using other servers for these cards.
We tend to use the most common rarity for cards the have different rarity values. We also convert all mythic rares to rares.
-
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: Scripts for LQ Pictures and Rarity
by friarsol » 25 Jul 2010, 16:54
I was going to write the script in Python, which will run on whatever OS you want it to. Although, we could even just let one person be in charge of the script and run it once a week/right before releases to clean up any added cards. Good to know about the rarity preference as I would have probably just gone for however the card was printed most recently. (Like Pestilence used to be a common in Alpha-5th, but showed up as an Uncommon in 5th)
Also, good to know about the Portal issue. I'll find a secondary lookup for those cards that won't appear in global images.
I figured since there was no Mythic Rare file, that they were just merged in.
Also, good to know about the Portal issue. I'll find a secondary lookup for those cards that won't appear in global images.
I figured since there was no Mythic Rare file, that they were just merged in.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Scripts for LQ Pictures and Rarity
by Huggybaby » 27 Jul 2010, 05:14
Thanks, this is a great idea!friarisol wrote:Alright guys, instead of manually inserting cards into 5 different files, we really should be automating as much as the process as possible.
So I'll start looking into the script sometime on Monday. And see if I can punch it out in a day or two.
-
Huggybaby - Administrator
- Posts: 3227
- Joined: 15 Jan 2006, 19:44
- Location: Finally out of Atlanta
- Has thanked: 750 times
- Been thanked: 601 times
Re: Scripts for LQ Pictures and Rarity
by friarsol » 27 Jul 2010, 15:27
So the first part of the script is finished (parsing the files and seeing which pictures/rarities are missing) and I'm looking at the cards with missing parts and there seems to be some fake/test cards in here that probably shouldn't be.
Here are the culprits: Klaas, Elf Friend; Tortuga; Test Destroy. I'm not sure where they came from, but I think if they aren't official cards, they should probably be yanked from the default card list. Thoughts?
Here are the culprits: Klaas, Elf Friend; Tortuga; Test Destroy. I'm not sure where they came from, but I think if they aren't official cards, they should probably be yanked from the default card list. Thoughts?
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Scripts for LQ Pictures and Rarity
by Sloth » 27 Jul 2010, 16:38
Yes, these cards shouldn't appear for the regular user. (I think they are from the very early versions of the game when it was still a solo project by mtgrares. They were probably for testing purposes)friarisol wrote:So the first part of the script is finished (parsing the files and seeing which pictures/rarities are missing) and I'm looking at the cards with missing parts and there seems to be some fake/test cards in here that probably shouldn't be.
Here are the culprits: Klaas, Elf Friend; Tortuga; Test Destroy. I'm not sure where they came from, but I think if they aren't official cards, they should probably be yanked from the default card list. Thoughts?
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Scripts for LQ Pictures and Rarity
by mtgrares » 27 Jul 2010, 17:32
Feel free to remove Klaas, Elf Friend; Tortuga; Test Destroy.
I coded Test Destroy to save time, so I could destroy creatures on turn 1 instead of on turn 3 or something. I thought Tortuga was funny and Klaas, Elf Friend was added for one specific user as an inside joke.
I coded Test Destroy to save time, so I could destroy creatures on turn 1 instead of on turn 3 or something. I thought Tortuga was funny and Klaas, Elf Friend was added for one specific user as an inside joke.
- mtgrares
- DEVELOPER
- Posts: 1352
- Joined: 08 Sep 2008, 22:10
- Has thanked: 3 times
- Been thanked: 12 times
Re: Scripts for LQ Pictures and Rarity
by mtgrares » 27 Jul 2010, 17:38
The idea was to make everything as flexible as possible, so there are some duplicate files (common.txt, etc..) forfriarisol wrote:Alright guys, instead of manually inserting cards into 5 different files, we really should be automating as much as the process as possible.
1. generating a random deck
2. quest
3. sealed
4. draft
I personally don't mind using all of the cards for everything.
- mtgrares
- DEVELOPER
- Posts: 1352
- Joined: 08 Sep 2008, 22:10
- Has thanked: 3 times
- Been thanked: 12 times
Re: Scripts for LQ Pictures and Rarity
by Rob Cashwalker » 27 Jul 2010, 18:52
We could use an SVar keyword in the cards.txt. One or more of them as necessary, to define rarity, set(s), picture(s)/URL(s), AI-disabled, etc. Completely eliminate the need for all these extra files... though I guess it would make this script nearly impossible.
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: Scripts for LQ Pictures and Rarity
by Chris H. » 27 Jul 2010, 19:34
`Rob Cashwalker wrote:We could use an SVar keyword in the cards.txt. One or more of them as necessary, to define rarity, set(s), picture(s)/URL(s), AI-disabled, etc. Completely eliminate the need for all these extra files... though I guess it would make this script nearly impossible.
An interesting idea. I guess that ultimately, the cards.txt file could then be split up into individual files, one for each card.

-
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: Scripts for LQ Pictures and Rarity
by friarsol » 27 Jul 2010, 19:43
Well the script wouldn't be able to do the AI-disabled part. But it could possibly do the others. It might make the script I'm currently writing unneeded, but that's not to say this one couldn't be altered for a "one text file to rule them all" mentality.Rob Cashwalker wrote:We could use an SVar keyword in the cards.txt. One or more of them as necessary, to define rarity, set(s), picture(s)/URL(s), AI-disabled, etc. Completely eliminate the need for all these extra files... though I guess it would make this script nearly impossible.
The script doesn't touch any cards that already have pictures or rarity set in any of the existing files. So the flexibility of multiple files is still available. The script is mostly just there so people can keyword in cards via cards.txt, and then the script can be run to add info to the pictures file as well as the rarity file. If later on it seems like a certain card should be common instead of uncommon (or really whatever), then we can manually go in for specific circumstances.mtgrares wrote:The idea was to make everything as flexible as possible, so there are some duplicate files (common.txt, etc..) for
1. generating a random deck
2. quest
3. sealed
4. draft
I personally don't mind using all of the cards for everything.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Scripts for LQ Pictures and Rarity
by Chris H. » 29 Jul 2010, 15:12
My Apple computer has the Snow Leopard OS. Python comes as part of the installation, although I have never used Python before the new script. When I double click cardsScript.py a window named Python Shell appears and displays the following:
I also get a 2nd window which displays the contents of the cardsScript.py file. I am connected to the internet with a slow speed modem dial-up connection. Do I need to enter in a command at the Python Shell to run/execute this script?
`Python 2.6.1 (r261:67515, Dec 6 2008, 16:42:21)
[GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin
Type "copyright", "credits" or "license()" for more information.
****************************************************************
Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface. This connection is not visible on any external
interface and no data is sent to or received from the Internet.
****************************************************************
IDLE 2.6.1
>>>
I also get a 2nd window which displays the contents of the cardsScript.py file. I am connected to the internet with a slow speed modem dial-up connection. Do I need to enter in a command at the Python Shell to run/execute this script?
-
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: Scripts for LQ Pictures and Rarity
by friarsol » 29 Jul 2010, 20:09
Well, I've never played with the Mac/Python combination but from the docs:
http://docs.python.org/using/mac.html
You really have two main options:
The first:
From within IDLE (the Python Shell), goto the open .py script and then choose Run->Run Module from the Menu bar.
The second is trying to get the script to run straight when double clicking.
The docs say
"To run your script from the Terminal window you must make sure that /usr/local/bin is in your shell search path.
To run your script from the Finder you have two options:
* Drag it to PythonLauncher
* Select PythonLauncher as the default application to open your script (or any .py script) through the finder Info window and double-click it. PythonLauncher has various preferences to control how your script is launched. Option-dragging allows you to change these for one invocation, or use its Preferences menu to change things globally."
Either way-
The Script doesn't have any console output text so it should run for a few seconds and then finish returning your >>> prompt. Since you are on dial-up it might be a bit slower for grabbing the pictures and rarity. After the prompt returns check cardsScript.log for errors and the pictures or rarity files for any changes.
http://docs.python.org/using/mac.html
You really have two main options:
The first:
From within IDLE (the Python Shell), goto the open .py script and then choose Run->Run Module from the Menu bar.
The second is trying to get the script to run straight when double clicking.
The docs say
"To run your script from the Terminal window you must make sure that /usr/local/bin is in your shell search path.
To run your script from the Finder you have two options:
* Drag it to PythonLauncher
* Select PythonLauncher as the default application to open your script (or any .py script) through the finder Info window and double-click it. PythonLauncher has various preferences to control how your script is launched. Option-dragging allows you to change these for one invocation, or use its Preferences menu to change things globally."
Either way-
The Script doesn't have any console output text so it should run for a few seconds and then finish returning your >>> prompt. Since you are on dial-up it might be a bit slower for grabbing the pictures and rarity. After the prompt returns check cardsScript.log for errors and the pictures or rarity files for any changes.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Scripts for LQ Pictures and Rarity
by Chris H. » 29 Jul 2010, 20:53
Thank you for the info. I spent a little time with the Python preferences and discovered that the F5 key will run the script. The script ran and updated the card-pictures.txt file and I was able to download the card pics for the new cards found in rev 1581.
The cardsScript.log states:
Bad magiccards.info Query: Archon of Redemption
Bad magiccards.info Query: Inspired Sprite
Bad magiccards.info Query: Baloth Woodcrasher
Bad magiccards.info Query: Deepwood Wolverine
Bad magiccards.info Query: Scion of the Wild
Bad magiccards.info Query: Harbor Guardian
Bad magiccards.info Query: Glassdust Hulk
Bad magiccards.info Query: Citanul Druid
Bad magiccards.info Query: Rabid Wolverines
Bad magiccards.info Query: Terra Eternal
Bad magiccards.info Query: Dwarven Berserker
Bad magiccards.info Query: Battle Squadron
Apparently, the script was not able to find the rarity values?

The cardsScript.log states:
Bad magiccards.info Query: Archon of Redemption
Bad magiccards.info Query: Inspired Sprite
Bad magiccards.info Query: Baloth Woodcrasher
Bad magiccards.info Query: Deepwood Wolverine
Bad magiccards.info Query: Scion of the Wild
Bad magiccards.info Query: Harbor Guardian
Bad magiccards.info Query: Glassdust Hulk
Bad magiccards.info Query: Citanul Druid
Bad magiccards.info Query: Rabid Wolverines
Bad magiccards.info Query: Terra Eternal
Bad magiccards.info Query: Dwarven Berserker
Bad magiccards.info Query: Battle Squadron
Apparently, the script was not able to find the rarity values?
-
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: Scripts for LQ Pictures and Rarity
by friarsol » 29 Jul 2010, 21:27
I ran the script on my end and was able to pull the rarities. I'm guessing the query timed out before it finished loading the whole page and then couldn't find the rarity since the page wasn't loaded. Maybe we'll see if there's some a different page that we can use instead of magiccards.info so it doesn't timeout for you. Either that or make the timeout be longer so it doesn't die when looking it up with a slower connection.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
17 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 46 guests