CardFactory Keywords
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
5 posts
• Page 1 of 1
CardFactory Keywords
by friarsol » 08 Sep 2010, 19:21
So I'm thinking it might be better if we moved all of the keywords we have piled up in the last few months into their own class. Since the keywords have crept up to 5k I think it'd be easier to have them separate for Organizational reasons.
Our primary CardFactory would handle base card setup, run it through the keyword parser, then call the appropriate Factory for whatever card type we have. And all the other Factories wouldn't have to worry about parsing keywords at all. Just handling specific cards of their own type.
I was going to do this today, but if anyone is working in the CardFactory files I can wait before pulling this out.
Our primary CardFactory would handle base card setup, run it through the keyword parser, then call the appropriate Factory for whatever card type we have. And all the other Factories wouldn't have to worry about parsing keywords at all. Just handling specific cards of their own type.
I was going to do this today, but if anyone is working in the CardFactory files I can wait before pulling this out.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: CardFactory Keywords
by Chris H. » 08 Sep 2010, 19:31
`friarisol wrote:So I'm thinking it might be better if we moved all of the keywords we have piled up in the last few months into their own class. Since the keywords have crept up to 5k I think it'd be easier to have them separate for Organizational reasons.
Our primary CardFactory would handle base card setup, run it through the keyword parser, then call the appropriate Factory for whatever card type we have. And all the other Factories wouldn't have to worry about parsing keywords at all. Just handling specific cards of their own type.
I was going to do this today, but if anyone is working in the CardFactory files I can wait before pulling this out.
Rob has mentioned something similar in the past. A keyword Factory would possibly allow cards like the broken Resuscitate spell to be re-written and this spell would finally work. I will hold off of any additional keyword work until this settles down as there are other areas for me to work on in the meantime.

-
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: CardFactory Keywords
by Rob Cashwalker » 08 Sep 2010, 19:32
I was just thinking about that too, though I would rather see the non-keyword code in the bottom half of CardFactory be moved into an appropriate class.
Either way, it's inevitable, that the amount of keyword code will eventually grow too.
edit:
Chris is speaking of the other solution - that keywords become parsed on their own entirely, on the fly. In many respects, this is the better long term solution, and if we're going to do it, we should do it soon, before the number of keyworded actions gets to be overwhelming.
It would be more accurate to call it a SpellAbilityFactory. Pass it the keyword line and the source card, and it returns a complete SpellAbility object to make that keyword work. It would take some substantial restructuring to do this, though most of the keyword-specific code can be copied. At the same rate, just about every keyword starts with the same few lines using the same variables, so there is some duped code that can be eliminated.
In the same sweeping change we could revise the keyword delimiter issue. Instead of expecting keyword parameters in a specific array element, we could use named parameters instead... ie:
Either way, it's inevitable, that the amount of keyword code will eventually grow too.
edit:
Chris is speaking of the other solution - that keywords become parsed on their own entirely, on the fly. In many respects, this is the better long term solution, and if we're going to do it, we should do it soon, before the number of keyworded actions gets to be overwhelming.
It would be more accurate to call it a SpellAbilityFactory. Pass it the keyword line and the source card, and it returns a complete SpellAbility object to make that keyword work. It would take some substantial restructuring to do this, though most of the keyword-specific code can be copied. At the same rate, just about every keyword starts with the same few lines using the same variables, so there is some duped code that can be eliminated.
In the same sweeping change we could revise the keyword delimiter issue. Instead of expecting keyword parameters in a specific array element, we could use named parameters instead... ie:
- Code: Select all
spPumpTgt:PTK$+1/+1/Flying:Drawback$YouGainLife/1:SpDesc$Target creature gets +1/+1 and gains flying until end of turn. You gain 1 life.
spDestroyTgt:Valid$Creature.nonBlack,Creature.nonArtifact:Regen$No
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: CardFactory Keywords
by friarsol » 08 Sep 2010, 20:45
Oh I like that way better than just migrating code out of CardFactory. While it would be good to clean up the keywords, if we can streamline our keywords at the same time we clean up CardFactory I think it's worth it.Rob Cashwalker wrote:Chris is speaking of the other solution - that keywords become parsed on their own entirely, on the fly. In many respects, this is the better long term solution, and if we're going to do it, we should do it soon, before the number of keyworded actions gets to be overwhelming.
It would be more accurate to call it a SpellAbilityFactory. Pass it the keyword line and the source card, and it returns a complete SpellAbility object to make that keyword work. It would take some substantial restructuring to do this, though most of the keyword-specific code can be copied. At the same rate, just about every keyword starts with the same few lines using the same variables, so there is some duped code that can be eliminated.
The way Keyword parsing would look after that change may makes the migration a very temporary solution. So I guess I'll hold off on just migrating if we're going to do something else with the keywords.
Were you already in the process of looking into this Rob? If you aren't, I can poke around a bit instead of moving to the other features I was going to work on.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: CardFactory Keywords
by Rob Cashwalker » 09 Sep 2010, 02:04
It's one of those architectural things that makes perfect sense to me in theory, but I'm not about to try to implement on my own.... Certainly not as long as the way we do it now is good enough.
I'm game to work on conversion once the basic structure is ready and some sample is operational.
Furthering the work on the alternative cost handling is important though, if that's the kind of stuff you were thinking of.
I'm game to work on conversion once the basic structure is ready and some sample is operational.
Furthering the work on the alternative cost handling is important though, if that's the kind of stuff you were thinking of.
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
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 64 guests