It is currently 13 Nov 2025, 20:51
   
Text Size

AbilityFactory for counterspells

Post MTG Forge Related Programming Questions Here

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

AbilityFactory for counterspells

Postby slapshot5 » 26 Nov 2010, 07:52

Hi all,

I have some working code for counterspells. I didn't convert or add any cards yet pending feedback.

You can use Counterspell by changing it to:
Code: Select all
A:SP$Counter|Cost$U U|Type$Spell|Destination$Graveyard|SpellDescription$Counter target spell.
or Lifeforce by changing it to:
Code: Select all
A:AB$Counter|Cost$G G|Type$Spell|Destination$Graveyard|CounterValid$Card.Black|SpellDescription$Counter target black spell.
That should give an example of what I'm trying to accomplish anyway.

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

Re: AbilityFactory for counterspells

Postby Hellfish » 26 Nov 2010, 09:39

Nice job, though I don't see it handling counterspells that counter spells that target specific things (Avoid Fate / Rebuff the Wicked / Turn Aside). What are your thoughts on those?

EDIT: A rename would probably also be good. I spent a confused minute reading AbilityFactory_Counters before I caught on. :lol: Maybe AbilityFactory_Counterspell instead?
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times

Re: AbilityFactory for counterspells

Postby zerker2000 » 26 Nov 2010, 11:11

.Ambiguity :)
They should probably be refactored to "AbilityFactory_AddCounters" and "AbilityFactory_CounterMagic".
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
zerker2000
Programmer
 
Posts: 569
Joined: 09 May 2009, 21:40
Location: South Pasadena, CA
Has thanked: 0 time
Been thanked: 0 time

Re: AbilityFactory for counterspells

Postby Hellfish » 26 Nov 2010, 11:44

Counters and Counterspell/Countermagic is probably better since AF_Counters should not only add but subtract as well.
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times

Re: AbilityFactory for counterspells

Postby slapshot5 » 26 Nov 2010, 17:00

Hellfish wrote:Nice job, though I don't see it handling counterspells that counter spells that target specific things (Avoid Fate / Rebuff the Wicked / Turn Aside). What are your thoughts on those?
Yeah, it won't handle that yet. I just wanted to get the basics working and get feedback before throwing everything in there. I've never played any of those cards, so I'd have to look at how it's handled now. (Is it handled now?)

Hellfish wrote:EDIT: A rename would probably also be good. I spent a confused minute reading AbilityFactory_Counters before I caught on. :lol: Maybe AbilityFactory_Counterspell instead?
Yes, I thought of that when I was first saving the file. Then I thought maybe the Counters stuff should be added to AF_PermState. Either way, a rename is trivial when we come up with a good name. Reading other posts, I like CounterMagic.

Hellfish wrote:Counters and Counterspell/Countermagic is probably better since AF_Counters should not only add but subtract as well.
And I think it does proliferate as well. I added that? Who knows.

The biggest things I wanted to gain right away were:
1) the syntax for what kind of spells could be countered was outside of my comprehension. Now, it uses "valid" card stuff. (Though, it may need to be expanded a la Hellfish.
2) now, there is a Counter ability, not just spell
3) the ExtraActions stuff can now be implemented as Drawbacks/SubAbilities.

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

Re: AbilityFactory for counterspells

Postby slapshot5 » 26 Nov 2010, 17:04

Oh, and the one known issue from my testing is this:
The targeting doesn't work in the correct order when it's used in spells that have a choice, like Blue Elemental Blast.

Mostly because the input is wedged in there. It should probably use some kind of trick like AF_Retrieve, but I couldn't figure out how to do that last night.

What would be nice is to have the ability to click on the thing in the Stack pane instead of a popup. This would probably help for things like Fork too.

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

Re: AbilityFactory for counterspells

Postby slapshot5 » 26 Nov 2010, 17:06

Oh, and I didn't convert cards because I didn't want to break anything for the impending beta. As soon as that's been out for a couple days (and no patch is necessary...), then I'll start converting cards. I may see if there are a couple that I can add before the beta so this can be vetted in the wild to some extent in this beta.

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

Re: AbilityFactory for counterspells

Postby Hellfish » 26 Nov 2010, 17:17

Yep, Avoid Fate and the others are handled.

Yeah, the Valid-syntax doesn't handle targets (yet?). I havn't looked around that code but I might.

1) the syntax for what kind of spells could be countered was outside of my comprehension. Now, it uses "valid" card stuff. (Though, it may need to be expanded a la Hellfish.
2) now, there is a Counter ability, not just spell
3) the ExtraActions stuff can now be implemented as Drawbacks/SubAbilities.
1) Much much better than the previous syntax. Once it gets a "Targets" equivalent, we're set 8)
2) Sweet as.
3) Yeah, that has basically been drawback's uglier sister this whole time :lol:
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times

Re: AbilityFactory for counterspells

Postby PhoenixAvenger » 26 Nov 2010, 20:07

Excellent. This finishes off the remaining AbilityFactories the team wanted done before the next beta.

Quick question, though: How would this AbilityFactory handle countering a spell unless its caster paid an amount of mana, like Mana Leak, Spiketail Hatchling or Syncopate? There are enough of those floating around Magic that it could potentially be worthwhile to convert those to AF_CounterMagic, depending how similar the hardcode Forge currently has for cards like Mana Leak, Force Spike et al. is...
User avatar
PhoenixAvenger
 
Posts: 62
Joined: 31 Aug 2010, 23:34
Location: NorCal
Has thanked: 0 time
Been thanked: 0 time

Re: AbilityFactory for counterspells

Postby slapshot5 » 26 Nov 2010, 22:24

PhoenixAvenger wrote:Excellent. This finishes off the remaining AbilityFactories the team wanted done before the next beta.

Quick question, though: How would this AbilityFactory handle countering a spell unless its caster paid an amount of mana, like Mana Leak, Spiketail Hatchling or Syncopate? There are enough of those floating around Magic that it could potentially be worthwhile to convert those to AF_CounterMagic, depending how similar the hardcode Forge currently has for cards like Mana Leak, Force Spike et al. is...
Ideally, it would handle it the same as it currently does for the user. I think that stuff is currently hard-coded, isn't it? If so, I'll just move it in to another param in SP/AB$Counter, and have the code read from there. I'll look at this later tonight.

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

Re: AbilityFactory for counterspells

Postby friarsol » 27 Nov 2010, 01:51

I haven't been able to look at any code for this yet, so I'm just asking instead: does Destination$ default to the Graveyard? For Spell Countering, it usually goes to the grave. For Ability Countering, it's unnecessary.

I like Countermagic. It uses the flavor of what's going on.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: AbilityFactory for counterspells

Postby slapshot5 » 27 Nov 2010, 03:08

It doesn't default to Graveyard only because I wanted to be consistent for behavior between Spells and Abilities. Default is currently nothing.

I suppose, if the countered thing is a spell, default could be Graveyard.
If countered thing is an ability, then ignore Destination altogether? There should never be an instance where a countered ability needs a destination.

If everyone is ok with this, I'll go ahead and make the change.

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

Re: AbilityFactory for counterspells

Postby slapshot5 » 27 Nov 2010, 03:42

I lied. It is defaulting to Graveyard. I will double check that it is doing what I describe in my last post.

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

Re: AbilityFactory for counterspells

Postby slapshot5 » 27 Nov 2010, 03:57

Renamed to AbilityFactory_CounterMagic.

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


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 24 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 24 users online :: 0 registered, 0 hidden and 24 guests (based on users active over the past 10 minutes)
Most users ever online was 9824 on 10 Nov 2025, 04:33

Users browsing this forum: No registered users and 24 guests

Login Form