It is currently 30 Oct 2025, 14:13
   
Text Size

Moving away from cards.txt

Post MTG Forge Related Programming Questions Here

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

Re: Moving away from cards.txt

Postby lord of 13 » 15 Sep 2010, 03:16

Images are the vast majority of it. 80/20 rule - 20% of the card class [images & associated data] takes 80% of the time to load. And vice versa. Eh... gotta live with it.
><><><><><><><
Currently developing Mindgames, for playing a rules-enforced game of MtG.
RECENT PROJECTS
->XMLScript
->Zwiel Platformer
User avatar
lord of 13
DEVELOPER
 
Posts: 79
Joined: 06 Jan 2010, 01:36
Has thanked: 0 time
Been thanked: 0 time

Re: Moving away from cards.txt

Postby Chris H. » 15 Sep 2010, 12:06

I made an effort last night to update the rarities for the recent card additions. I noticed that Elspeth Tirel has an K:SVar:Rarity:Mythic and has no rarity displayed in the deck editor.

We have 65 cards using K:SVar:Rarity:Mythic and they appear as a Rare in forge, yet Elspeth Tirel does not show it's rarity.
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: Moving away from cards.txt

Postby Rob Cashwalker » 15 Sep 2010, 14:02

make sure it's copying the svar during the card re-assignment
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: Moving away from cards.txt

Postby Rob Cashwalker » 15 Sep 2010, 15:33

Speaking of SVars...

One of the next steps I will take is to remove the SVar as a keyword (handled in CardFactory). With the way cards are parsed now, it's easy enough to just handle SVar's at a lower level.
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: Moving away from cards.txt

Postby friarsol » 15 Sep 2010, 16:27

I was just thinking that before. "We can just have Pic as it's own label instead of having it as an SVar, now that the cards data files have more structure."
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Moving away from cards.txt

Postby Rob Cashwalker » 15 Sep 2010, 18:31

At the moment, I want to keep the URL and rarity as SVars, just we won't need the "K:" prefix.

Why? I don't want the Card object to have a single string for URL and rarity, as both pieces of information will be better represented in a different sort of "tag" - "Set:{ExpCode}:{Rarity}:{optional URL}". "Set Membership" will be an ArrayList of some basic class to store the 3 values in one element.

At some point, I'm looking at replacing the "K:" with something like "Ability:", "Effect:", or "Spell:". Leaving "K:" for normal Keywords, like Flying. (definitely not until we get an AbilityFactory...)
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: Moving away from cards.txt

Postby Chris H. » 15 Sep 2010, 18:57

Rob Cashwalker wrote:make sure it's copying the svar during the card re-assignment
`
Thank you, adding this to the end of the card object for Elspeth Tirel did the trick:

Code: Select all
card2.setSVars(card.getSVars());
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: Moving away from cards.txt

Postby DennisBergkamp » 15 Sep 2010, 22:08

Implementation of sets would be an awesome thing... this wouldn't just be a major boon to drafting, but I could add different types of boosters to the (Shandalar clone) quest mode.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Moving away from cards.txt

Postby silly freak » 17 Sep 2010, 21:42

lord of 13 wrote:Is it possible to keep some sort of Dictionary<string, Card> in the class, then load from a file if the card is needed & its name [the key] isn't in the dictionary? While loading, you can use FileInfo to query the time last modified and compare it to the FileInfo of the application itself.
Rob Cashwalker wrote:Not without some significant change... I wasn't aware that it would keep hitting the disk other than first-load.
I have some code for card caching in my own project, maybe you can copy/paste something together to make it work. I don't know how applicable it really is - Laterna Magica has no such thing as CardFactory - but it could give you some directions:

AllCards - This is the real cards cache. it is filled at startup and then serves as the one point for getting cards. LM reads the cards from a zip archive, so there are some specific parts in it.
CompileAll - This class has a method compileAll which recursively iterates through a directory's files. you can use this to bring some structure in all the card files, and it will automatically fix the "big folder" performance hit.
___

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: Moving away from cards.txt

Postby Rob Cashwalker » 20 Sep 2010, 16:26

Today I submitted two changes in CardFactory and ReadCard to directly handle the SVars. I did not remove the keyword handler from CardFactory yet, to maintain some backwards compatibility for now.

I used a VB program to automatically remove the "K:" from "K:SVar:..."
I have begun committing cards, I'm hoping to have fewer errors because I'm using my office PC which is a dual core, with a direct LAN connection. (as opposed to my centrino laptop on WiFi.g)
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

Thousands of files

Postby mtgrares » 20 Sep 2010, 19:32

To improve performance, you could zip all of the card files. Of course you could zip all of the card files during development but it would have the drawbacks of a single, big file.

You guys are doing great work.
mtgrares
DEVELOPER
 
Posts: 1352
Joined: 08 Sep 2008, 22:10
Has thanked: 3 times
Been thanked: 12 times

Re: Moving away from cards.txt

Postby Rob Cashwalker » 20 Sep 2010, 19:38

I don't think performance would be better when zipped. It would have to be unzipped to be read, even if it's only unzipped in memory.... I definitely feel like the load time is a bit shorter in the card-per-file version.

Distribution is another story. cards.txt zipped up smaller than the cardsfolder does currently.
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: Moving away from cards.txt

Postby silly freak » 20 Sep 2010, 19:50

Laterna Magica uses zipping, but with the difference that the zip is not a simple copy but a "compiled" version of the cards (represented as java objects instead of text)

it could boost the performance because it only requires you to open one file and not one per card, but I think that the improvement is marginal
___

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: Moving away from cards.txt

Postby slapshot5 » 21 Sep 2010, 02:21

Rob Cashwalker wrote:Today I submitted two changes in CardFactory and ReadCard to directly handle the SVars. I did not remove the keyword handler from CardFactory yet, to maintain some backwards compatibility for now.

I used a VB program to automatically remove the "K:" from "K:SVar:..."
SVars aren't being set correctly for download URLs.

ReadCard.java
Code: Select all
else if (s.startsWith("SVar:"))
                {
                    String t[] = s.split(":");
                    System.out.println(t[1]+"-"+t[2]);
                    c.setSVar(t[1], t[2]);
                }
sets "Picture"="http". The rest of the URL would get set in t[3]. Not sure what kind of flexibility you're looking for here, so I didn't just go ahead and fix "s.split(":",3)"

-slapshot5
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: Moving away from cards.txt

Postby Rob Cashwalker » 21 Sep 2010, 02:55

That is the correct fix.
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

PreviousNext

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 27 guests

Main Menu

User Menu

Our Partners


Who is online

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

Login Form