Splitting CardFactory
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Re: Splitting CardFactory
by Rob Cashwalker » 30 Dec 2009, 01:06
Charms - Shouldn't need it. Each effect on a charm is a separate ability. Forge should by default pop up the list of spell descriptions. Whether or not it's needs to say specifically "Choose one" or whatever it does say (don't recall off the top of my head) isn't critical.
The critical part of making charms work, by keyword or otherwise, is that the spellAbility list is cleared only once before any abilities are added. One way we could do this easily is splitting the spEffect code and the abEffect code into their own CardFactory_ files. Then the spEffect file would have a single Clearing of the card's SpellAbilities.
The critical part of making charms work, by keyword or otherwise, is that the spellAbility list is cleared only once before any abilities are added. One way we could do this easily is splitting the spEffect code and the abEffect code into their own CardFactory_ files. Then the spEffect file would have a single Clearing of the card's SpellAbilities.
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: Splitting CardFactory
by Chris H. » 30 Dec 2009, 01:16
I also noticed while looking at the code for Funeral Charm that there was a 50% chance that the computer would or would not use one of the two included effects.Rob Cashwalker wrote:The critical part of making charms work, by keyword or otherwise, is that the spellAbility list is cleared only once before any abilities are added. One way we could do this easily is splitting the spEffect code and the abEffect code into their own CardFactory_ files. Then the spEffect file would have a single Clearing of the card's SpellAbilities.
Otherwise, The computer would always use the first one, discard a card. The second effect to pump target creature would never get evaluated. Or am I just confused? I may not have had a chance to thoroughly examine how this would work.
-
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: Splitting CardFactory
by Rob Cashwalker » 30 Dec 2009, 15:02
Well, that's a different problem altogether, another good catch!
That may be a trickier behavior to correct. The AI needs some way of identifying multiple choice and to evaluate all choices before choosing.... Ugghh.
One thing I've been throwing around after playing with Count$ and Drawback$ and their handler functions... is to rewrite the keyword system again to build the abilities through a factory system like I know someone else suggested.... (maybe zerker?)
Then the charm (or command) is built as a wrapper around the three simple keyword-defined abilities that are generated dynamically. The wrapper ability's canPlayAI actually queries each sub-ability's canPlayAI and of the ones that return true, it picks one at random.
Another practical upshot of the keyword rewrite - you could actually give an ability (like regenerate) to a permanent dynamically.
That may be a trickier behavior to correct. The AI needs some way of identifying multiple choice and to evaluate all choices before choosing.... Ugghh.
One thing I've been throwing around after playing with Count$ and Drawback$ and their handler functions... is to rewrite the keyword system again to build the abilities through a factory system like I know someone else suggested.... (maybe zerker?)
Then the charm (or command) is built as a wrapper around the three simple keyword-defined abilities that are generated dynamically. The wrapper ability's canPlayAI actually queries each sub-ability's canPlayAI and of the ones that return true, it picks one at random.
Another practical upshot of the keyword rewrite - you could actually give an ability (like regenerate) to a permanent dynamically.
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: Splitting CardFactory
by Chris H. » 30 Dec 2009, 15:31
- Code: Select all
That may be a trickier behavior to correct. The AI needs some way of identifying multiple choice and to evaluate all choices before choosing.... Ugghh.
For a moment I considered including in my idea of a Charm keyword a function that would randomly re-order the other keywords. This way Funeral Charm would not always appear to have the discard keyword ahead of the two pump keywords. I am not sure if this approach would be practical or not. Just thinking out loud.
- Code: Select all
One thing I've been throwing around after playing with Count$ and Drawback$ and their handler functions... is to rewrite the keyword system again to build the abilities through a factory system like I know someone else suggested.... (maybe zerker?)
Then the charm (or command) is built as a wrapper around the three simple keyword-defined abilities that are generated dynamically. The wrapper ability's canPlayAI actually queries each sub-ability's canPlayAI and of the ones that return true, it picks one at random.
Another practical upshot of the keyword rewrite - you could actually give an ability (like regenerate) to a permanent dynamically.
This sounds like more work but it would give us additional cards that we could cover with our keywords.
-
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: Splitting CardFactory
by zerker2000 » 30 Dec 2009, 23:13
Yes, that was me, check page 2 of this thread(and I think I have a version of that class on svn as CardParser). I did get swamped with problems when I tried to get it working though .One thing I've been throwing around after playing with Count$ and Drawback$ and their handler functions... is to rewrite the keyword system again to build the abilities through a factory system like I know someone else suggested.... (maybe zerker?)
EDIT: Adding keywords dynamically wouldn't be hard if there was a KeywordFactory, which housed all of the keyword parsing code and was used by invoking KeywordFactory.addKeyword(Card c, String keyword), which was called for each keyword in readCard(and defaulted to adding the keyword). Hmm: I feel like I am repeating myself...
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.
--Eladamri, the Seed of Freyalise
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.
--Eladamri, the Seed of Freyalise
- zerker2000
- Programmer
- Posts: 569
- Joined: 09 May 2009, 21:40
- Location: South Pasadena, CA
- Has thanked: 0 time
- Been thanked: 0 time
65 posts
• Page 5 of 5 • 1, 2, 3, 4, 5
Who is online
Users browsing this forum: No registered users and 113 guests