Tuesday, August 31, 2010

When you feel plainly dumb...

There are time when you work on a problem and nothing seems to help. You have checked everything, yet nothing works. And then you see the obvious answer. I had such a problem today. Until now, Laterna Magica only allowed you to pay costs in advance, first adding all the mana to the pool, then activating an ability or (more likely in LM) casting a spell.

The rules allow it, however, to play mana abilities while playing spells/abilities. So I wrote the code: A piece in the cost to ask the player for input, a piece in the player to handle the GUI. and it didn't work. Clicking on a card was just not recognized.

I first thought it could be that my legality checking code was not working while a spell is being cast, but I couldn't find any line in the code that even bothered about that. Next, I suspected that the asynchronous communication between game and GUI didn't work, and enabled a few debug statements, which in turn made clear that everything went like desired. So I thought to myself: where could I easily check if the action was successfully processed? Well, in the cost, where the player was asked in the first place.

But I never got to writing a debug statement; the bug was clear and simple: While I retrieved the activate action, I didn't execute it. These are the times when you feel plainly dumb...


Forge said...

At first Forge required you to pay mana cost BEFORE you chose the card's target. Internally Forge has two battlefield zones, one for your and one for the computer, which is incorrect.

And the icing on the cake is that I thought the Elvish Piper was a targeted ability, oops.

Hang in there.

Forge said...

I just remembered my biggest mistake. I actually coded Early Harvest THEN realized that I didn't have a mana pool, ha.

Technically Early Harvest is useable without having a mana pool but at the time I just deleted the card.

Early Harvest - 1GG, Instant, Target player untaps all basic lands he or she controls.

Forge said...

And about your previous post and threads. I understand threads but I've never used them. (I'm glad that at least somebody understands them.)

You seem to know a lot about programming and I'm guessing that you enjoy it.

Silly Freak said...

Yes, I'm really enjoying it a lot.
Threads are possibly the most complicated thing in the whole field, possibly competing only with memory management (and some people also think that pointers are complicated...)

The hard thing about multithreading is possibly that it opposes the way you code; line for line, which in turn means that you have to rethink your code more often as you progress. You can easily overlook or forget details in the progress.

Anonymous said...

Nice brief and this enter helped me alot in my college assignement. Thank you seeking your information.