[CODE] Counter Improvements (Now Included in SVN)

All additions requested or suggested to improve the card coding language.

[CODE] Counter Improvements (Now Included in SVN)

Postby salmelo » Sat Mar 13, 2010 11:10 am

I have begun work on implementing named counters, for things like Thallids or the zendikar quests or whatnot.

Currently i've altered the corresponding section of the parser to essentially change counter(p/t,n) into counter(p/t,n,[name]) with name defaulting to "". This should maintain backwards compatibility, and my running of the test suite confirmed this (assuming any of the tests used counters, i'm pretty sure i saw unstable mutation though, and i know it does).

I haven't tested to see if the names actually work yet as there is currently nothing that can be done with them, that being my next step.

Before i move any further however, i would like to confirm my assumption that the name method of the Counter class in Counters.h is meant for such a purpose. I'm 99% sure it is not currently being used for anything after using Visual Studios "Find All References" command, and I can't think of anything else a name member of a Counter class could be used for, but I don't want to get too far into things only to find out I have redo it all because that member is for something else :).

[EDIT ABRA - renamed - Status update]
Last edited by salmelo on Wed Mar 24, 2010 1:52 am, edited 1 time in total.
salmelo
 
Posts: 47
Joined: Thu Mar 11, 2010 4:11 pm

Re: Named counters

Postby wololo » Sat Mar 13, 2010 12:05 pm

salmelo wrote:Before i move any further however, i would like to confirm my assumption that the name method of the Counter class in Counters.h is meant for such a purpose. I'm 99% sure it is not currently being used for anything after using Visual Studios "Find All References" command, and I can't think of anything else a name member of a Counter class could be used for, but I don't want to get too far into things only to find out I have redo it all because that member is for something else :).

I confirm, this is what "name" was initially made for in the Counter object :)
wololo
Site Admin
 
Posts: 3709
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: Named counters

Postby salmelo » Sat Mar 13, 2010 10:29 pm

I've nearly finished creating a CounterCost class, extending ExtraCost, however when I compile i get an error:
"Error 64 error C2143: syntax error : missing ';' before '*' ...\projects\mtg\include\extracost.h 56"
referring to the line
Counter * counter;

I normally see this error, or similair, when I forget to terminate the previous line with a ";", which was the case this time at first, but the error remains even after I fixed that. So, i'm stumped. I even tried restarting visual studio, just in case it was just being stupid.

So, maybe someone on here has some ideas what might be wrong?
salmelo
 
Posts: 47
Joined: Thu Mar 11, 2010 4:11 pm

Re: Named counters

Postby wololo » Sun Mar 14, 2010 12:06 am

That happens to me when thecompiler doesn't know what the class is about.

try to either include Counter.h in extracost.h, or define "class Counter" in Extracost.h
wololo
Site Admin
 
Posts: 3709
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: Named counters

Postby salmelo » Sun Mar 14, 2010 1:19 am

well, that fixed that error, thanks.

In hindsight, i probably should have done that from the beginning, so, yeah.

Theres still a few things I need to track down before i can test, but it looks like i'm on the right track.
salmelo
 
Posts: 47
Joined: Thu Mar 11, 2010 4:11 pm

Re: Named counters

Postby salmelo » Sun Mar 14, 2010 2:44 am

well, i've got it compiling now, but it's not giving the proper results when I click on a critter with a counter ability. I decided I would try and figure out what it was doing by running it in debug mode from vb, but when i click the little play button to run it it gives me an unhandled exception during JQuad:SetHotSpot, it only gives me this exception if i try to debug, if I run it normally from windows it will run perfectly fine.

I don't know that theres anything i can do to fix this, although if there is I will, but even if theres not I figured you might want to know about it.

Anyway, I think the problem may be in my setPayment and/or isPaymentSet functions.
I'm thinking that the engine calls isPaymentSet to check if payment can be done, then if it can't it calls setPayment, then it checks again, and if it can pay it calls doPay. If thats the case then my setPayment may not be working properly. or i could be entirely wrong on this, i wish i could debug and get a better picture for myself.

anyway, thanks for any help you may be able to give.
salmelo
 
Posts: 47
Joined: Thu Mar 11, 2010 4:11 pm

Re: Named counters

Postby wololo » Sun Mar 14, 2010 3:00 am

salmelo wrote:well, i've got it compiling now, but it's not giving the proper results when I click on a critter with a counter ability. I decided I would try and figure out what it was doing by running it in debug mode from vb, but when i click the little play button to run it it gives me an unhandled exception during JQuad:SetHotSpot, it only gives me this exception if i try to debug, if I run it normally from windows it will run perfectly fine.

In VC++, right click on the "mtg" project in the explorer window on the left
select "properties"
go to configuration properties > Debugging
in "Working Directory", enter "./bin", or browse to the "bin" directory.

This is because the "Res" folder in the "bin" folder, so the debugger needs to know that its "root" folder is bin instead of "."

if that doesn't work, copy the "Res" folder from bin to the root of the project (where the .sln is)
wololo
Site Admin
 
Posts: 3709
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: Named counters

Postby salmelo » Sun Mar 14, 2010 3:08 am

ah, that works.

Thank you very much, maybe now I can get back on track.
salmelo
 
Posts: 47
Joined: Thu Mar 11, 2010 4:11 pm

Re: Named counters

Postby salmelo » Sun Mar 14, 2010 4:36 am

ok, I've got using the counters as a cost working now.

there is one small problem though, if you try to use an ability with a counter cost and there aren't enough counters it will try to use anything and everything you click on for a target for the cost, the same thing it would do if it doesn't know who you want to take the counters from.

Now, for abilities where you take counters off of something other than the card with the ability, this could be desirable, "Oh, that card doesn't have enough counters, well try another one then," but if the counters do come from the card with the ability, then that just means that you can't use the ability yet, and all you can do is press X to cancel.

This can be somewhat annoying, so I'm wondering if there is someway to tell it, from within the isPaymentSet function, to cancel the ability, as if the user had pressed X? If not it's no big deal, just a minor inconvenience.

Anyway, the next step i think will be to try and get the asLongAs and forEach tags to use counters. I think, however, i will wait on that until I determine whether or not i can fix the previously mentioned annoyance, if i can I will if not, oh well, then I will finalize what I have now and submit a patch before I start work on foreach and aslongas.

Thanks for all the help you've given me trying to get this working, and hopefully my contribution will help some people to enjoy Wagic more.
salmelo
 
Posts: 47
Joined: Thu Mar 11, 2010 4:11 pm

Re: Named counters

Postby salmelo » Sun Mar 14, 2010 8:56 pm

I found a solution to my problem.

I've added a canPay() method to ExtraCost and its descendants, as well as ExtraCosts and a canPayExtras to ManaCost, these are queried during isReactingToClick in activatedability, and if they come up false then it never activates the ability, akin to if it has a tap cost and is already tapped. I am mildly worried that it could cause a problem somewhere else, but I ran the full test suite and everything worked, so I'm pretty sure it'll be okay.

Anyway i'm sending along a patch, hopefully things work well from there.
salmelo
 
Posts: 47
Joined: Thu Mar 11, 2010 4:11 pm

Advertising

Next

Return to Card Coding & Parser

Who is online

Users browsing this forum: No registered users and 0 guests