Issue 157: which classes do we need?
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
66 posts
• Page 2 of 5 • 1, 2, 3, 4, 5
Re: Issue 157: which classes do we need?
by Max mtg » 25 Aug 2011, 07:19
I am not sure about reading PrintedCard from individual txt files. All these data can be read fast enough from mtg-data.txt files (by Arch) - this should be faster (without that much io operations), yet we have to track somehow which cards are supported actually.
I'm already in the middle of the way refactoring deck editors, the decks themselves and quest inventory. It looks nice, but will take some time. CardList instances are banned where possible, avoiding to touch heavy Card class with its factories until battle begins.
I'm already in the middle of the way refactoring deck editors, the decks themselves and quest inventory. It looks nice, but will take some time. CardList instances are banned where possible, avoiding to touch heavy Card class with its factories until battle begins.
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Issue 157: which classes do we need?
by Rob Cashwalker » 25 Aug 2011, 13:26
Please stick to the cardname.txt files. Where would you load the card scripts from? Or the SetInfo? Then you would need a separate list anyway... just use what we already have working.
The PrintedCard for Forge's purposes is lightweight - it only contains strings and maybe a few integers. It essentially encapsulates the cardname.txt in memory. These can be stored in one master ArrayList, but multiple maps could be pre-built with particular keys, like a DB index to make access very quick.
Decklists, quest collections, sideboards, etc. should only store the card name and minimal meta data, like quantity, set code and foiling.
Fully Active Cards only need to exist in the battlefield part of the game.
The PrintedCard for Forge's purposes is lightweight - it only contains strings and maybe a few integers. It essentially encapsulates the cardname.txt in memory. These can be stored in one master ArrayList, but multiple maps could be pre-built with particular keys, like a DB index to make access very quick.
Decklists, quest collections, sideboards, etc. should only store the card name and minimal meta data, like quantity, set code and foiling.
Fully Active Cards only need to exist in the battlefield part of the game.
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: Issue 157: which classes do we need?
by Braids » 25 Aug 2011, 22:40
this sounds mostly like an agreement to Max mtg's original proposal to me. this is my understanding:Rob Cashwalker wrote:Please stick to the cardname.txt files. Where would you load the card scripts from? Or the SetInfo? Then you would need a separate list anyway... just use what we already have working.
The PrintedCard for Forge's purposes is lightweight - it only contains strings and maybe a few integers. It essentially encapsulates the cardname.txt in memory. These can be stored in one master ArrayList, but multiple maps could be pre-built with particular keys, like a DB index to make access very quick.
Decklists, quest collections, sideboards, etc. should only store the card name and minimal meta data, like quantity, set code and foiling.
Fully Active Cards only need to exist in the battlefield part of the game.
#1 - for deck lists, quest collections, etc.
#2 - load from res/x/{cardname}.txt mixed with mtg-data.txt and store all instances in memory for fast deck editor searches.
#3 - only instantiate when needed in a game.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. 

-
Braids - Programmer
- Posts: 556
- Joined: 22 Jun 2011, 00:39
- Location: Unknown. Hobby: Driving myself and others to constructive madness.
- Has thanked: 1 time
- Been thanked: 1 time
Re: Issue 157: which classes do we need?
by Max mtg » 25 Aug 2011, 23:29
Hurray! We have agreed on datatypes.
1. read cardname
2. read and parse types
3. if creature, save p/t; if walker, write down loyalty.
4. save everying except last line as rules.
5. last line is sets info.
I have little idea on how can one extract rules from cardname.txt: looks like he should keep the K: lines, get the last part from the S: lines after description$, replace CARDNAME with actual card name... and this is yet the beginning.
I suppose, oracle rules from mtg-data.txt are much easier and faster to parse:friarsol wrote:Is there a need to do double parsing? Is there a disadvantage to having the Oracle text in the cards.txt files?
1. read cardname
2. read and parse types
3. if creature, save p/t; if walker, write down loyalty.
4. save everying except last line as rules.
5. last line is sets info.
I have little idea on how can one extract rules from cardname.txt: looks like he should keep the K: lines, get the last part from the S: lines after description$, replace CARDNAME with actual card name... and this is yet the beginning.
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Issue 157: which classes do we need?
by Braids » 25 Aug 2011, 23:42
because we're using a zip file for reading the txt files, i see neither a significant advantage nor a significant disadvantage.friarsol wrote:Is there a need to do double parsing? Is there a disadvantage to having the Oracle text in the cards.txt files?
what kinds of Forge-specific information will Max mtg need to add to the #2 style cards? i remember a flag about whether the AI can use the card or not. where do we presently store that information? is there anything else that the deck generators and editors would need?
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. 

-
Braids - Programmer
- Posts: 556
- Joined: 22 Jun 2011, 00:39
- Location: Unknown. Hobby: Driving myself and others to constructive madness.
- Has thanked: 1 time
- Been thanked: 1 time
Re: Issue 157: which classes do we need?
by friarsol » 26 Aug 2011, 01:50
Rules aren't yet in cards.txt because I've been holding off running the script I have to extract and add Oracle data to them due to this and previous discussions on this topic. When added there will be a line starting with Oracle: that will have all Rules text of the card.Max mtg wrote:I have little idea on how can one extract rules from cardname.txt: looks like he should keep the K: lines, get the last part from the S: lines after description$, replace CARDNAME with actual card name... and this is yet the beginning.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Issue 157: which classes do we need?
by Rob Cashwalker » 26 Aug 2011, 03:08
No, not quite. Only need 2 classes, basically combine #1 and #2. One holds the raw text from the cardname.txt files and is used for display, searching and sorting purposes. The Active one is used only in game.Braids wrote:this sounds mostly like an agreement to Max mtg's original proposal to me. this is my understanding:
#1 - for deck lists, quest collections, etc.
#2 - load from res/x/{cardname}.txt mixed with mtg-data.txt and store all instances in memory for fast deck editor searches.
#3 - only instantiate when needed in a game.
Decks don't contain objects, they contain plain text, which is why #1 isn't necessary.
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: Issue 157: which classes do we need?
by Rob Cashwalker » 26 Aug 2011, 03:15
Not yet...Max mtg wrote:Hurray! We have agreed on datatypes.
No need to parse oracle text. We parse cardname.txt perfectly well right now. Just change CardReader.loadCard to not directly instantiate abilities and triggers. Just populate the basic card object with plain text.I suppose, oracle rules from mtg-data.txt are much easier and faster to parse:
1. read cardname
2. read and parse types
3. if creature, save p/t; if walker, write down loyalty.
4. save everying except last line as rules.
5. last line is sets info.
I have little idea on how can one extract rules from cardname.txt: looks like he should keep the K: lines, get the last part from the S: lines after description$, replace CARDNAME with actual card name... and this is yet the beginning.
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: Issue 157: which classes do we need?
by Max mtg » 26 Aug 2011, 20:26
The process is advancing well. I came from compile time errors to runtime errors, logical yet to come.
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Issue 157: which classes do we need?
by Braids » 27 Aug 2011, 01:38
how do we differentiate card art, then? at first, it sounds like you're suggesting that the primary key for a database of #2 instances be {name + set + artIndex}. then we'd be copying Oracle text for every printing of every card. it would be very heap-wasteful. i think the primary key for a database of #2 instances would be just the canonical ASCII card name instead. that would be much more efficient, and easier to perform lookups.Rob Cashwalker wrote:No, not quite. Only need 2 classes, basically combine #1 and #2. One holds the raw text from the cardname.txt files and is used for display, searching and sorting purposes. The Active one is used only in game.Braids wrote:this sounds mostly like an agreement to Max mtg's original proposal to me. this is my understanding:
#1 - for deck lists, quest collections, etc.
#2 - load from res/x/{cardname}.txt mixed with mtg-data.txt and store all instances in memory for fast deck editor searches.
#3 - only instantiate when needed in a game.
Decks don't contain objects, they contain plain text, which is why #1 isn't necessary.
but i think you realize this. so, instead of #1, we just pass Strings around for deck contents? it's fairly standard practice to create an abstract data type {class} from a string with distinct parts: name, set, and art index. i think we should leave this up to Max mtg. i think Max just doesn't want to represent #1 as a single string, but rather break it up into its component pieces.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. 

-
Braids - Programmer
- Posts: 556
- Joined: 22 Jun 2011, 00:39
- Location: Unknown. Hobby: Driving myself and others to constructive madness.
- Has thanked: 1 time
- Been thanked: 1 time
Re: Issue 157: which classes do we need?
by Max mtg » 27 Aug 2011, 15:34
Decks already used by forge do contain objects, by the way, in lines like CardName|Edition... it's somwhat ugly, don't you think so?Rob Cashwalker wrote:No, not quite. Only need 2 classes, basically combine #1 and #2. One holds the raw text from the cardname.txt files and is used for display, searching and sorting purposes. The Active one is used only in game.
Decks don't contain objects, they contain plain text, which is why #1 isn't necessary.
In the same way artIndex and foiling might be added separated by pipes, though I would prefer xml for that:
- Code: Select all
<card name="Plains" set="M11" artIndex="1" foil="0" quantity="3" />
- Code: Select all
<c n="Island" s="CMD" i="2" q="3" />
<c n="Jace, the Mind Sculptor" q="1" f="1" />
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Issue 157: which classes do we need?
by friarsol » 27 Aug 2011, 17:24
I'd prefer JSON to XML. XML is so bloated.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Issue 157: which classes do we need?
by Max mtg » 27 Aug 2011, 17:38
QuestData is saved in XML anyway. As for other decks, unrelated to quest, they don't need to switch and may still use common format.friarsol wrote:I'd prefer JSON to XML. XML is so bloated.
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Issue 157: which classes do we need?
by Braids » 27 Aug 2011, 17:42
instead of creating yet another decklist format, i think the mwDeck format would suit our needs.
sample lines:
in regex/BNF:
in extended Perl regex format where spaces are ignored:
group 2 is the quantity.
group 3 is the set identifier.
group 4 is the card name.
group 5 must be ignored.
group 6 is either the art index or empty.
edit: i'd be happy to create load/save code for this format.
edit2: i know we don't (yet) support sideboards, so group 1 would be empty until we do.
sample lines:
- Code: Select all
SB: 4 [OD] Mountain (2)
1 [WWK] Jace, the Mind Sculptor
in regex/BNF:
- Code: Select all
deckListEntry := space* (sideboard)? space* quantity space+ "[" setName "]" space+ cardName (space+ "(" artIndex ")")? space* newline
sideboard := "SB:"
space := " "
quantity := postiveInteger
positiveInteger := [1-9]+[0-9]*
setName := [^]]+
cardName := .+?
artIndex := positiveInteger
newLine := \r\n?
in extended Perl regex format where spaces are ignored:
- Code: Select all
^ \s* (SB:)? \s* ([1-9]+[0-9]*) \s+ \[ ([^]]+) \] \s+ (.+?) ( \s+ "(" ([1-9]+[0-9]*) ")" )? \s* $
group 2 is the quantity.
group 3 is the set identifier.
group 4 is the card name.
group 5 must be ignored.
group 6 is either the art index or empty.
edit: i'd be happy to create load/save code for this format.
edit2: i know we don't (yet) support sideboards, so group 1 would be empty until we do.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. 

-
Braids - Programmer
- Posts: 556
- Joined: 22 Jun 2011, 00:39
- Location: Unknown. Hobby: Driving myself and others to constructive madness.
- Has thanked: 1 time
- Been thanked: 1 time
66 posts
• Page 2 of 5 • 1, 2, 3, 4, 5
Who is online
Users browsing this forum: No registered users and 36 guests