Thursday, July 28, 2011

Bugs and coding

Bugs, from this lovely site for getting rid of them
So after yesterdays coding tutorial I decided to work on combat project. It was a very fruitful endeavor in one way. Discovering horrible horrible bugs.

So I was working on spirited attack idea. It was an effect that happened when you attacked an opponent and manipulates their attack pool. It plainly removes the highest die that is under twice the edge you spent. I was going to allow multiple purchases with it, but for purposes of getting this done it's only one die at a time. Still if you pay enough you will get 1 success, possibly 2 removed from their pool which is very useful. Latter I'll put in one of two systems, multiple values to keep track of just how many dice and the values you are trying to remove or allow you to take multiple dice of the same value. Second one is easier to program in some regards and I like how it forces you to choose what dice to use instead of throwing as much edge as you can per turn to pick off dice. Either you choose to stick with low numbers and risk it taking no dice out, or you pay a lot for higher numbers.

This said it was looking good and I implemented it well. A few problem like not actually reducing edge points  a few times an a math glitch but nothing major. This was until I saw how the hit system was working.

The current system is that attack value and defense value is tallied between the ones engaged in battle. This is done by calling some methods with modifiers to the TN number on both sides and simply using subtraction to see who won. So it goes attack_success = attacker tally - defenders tally, if attack_success is greater than 0 it's a hit. Everything seemed fine until I looked at the method.

methods can pass variables by putting it in  between brackets. If you've done some math functions such as x(y) comes to mind. In programing you can stack this so x(y(z)) can happen. I made an error of forgetting a bracket running the code and getting an error saying I forgot a closing bracket, mindlessly looked at the code and slapped it after the defender tally method, containing it with the modifiers for the attacker method. This effectively made it so that the attacker was getting a bonus chance for extra successes based on how well the defender defended. A big whoops and invalidating a lot of how I thought the system was working.

So that's fixed and I'll be double checking it more, I may also think on solving some menu problems soon, because hitting enter a few times to skip over edge when I don't want it is anoying. One solution is to make a variable to serve as a flag if the user through the edge command sets it, without it set edge donation won't appear, but that seems rife with possible annoyance if you forget to set it, then after you get your edge you want to unset it. Possibly not the most elegant solution. Since I am using terminal based prompt I could include the flag in choice typing. Enter the action selection followed by a  - and you skip edge. That is for later though, I have to see if my system is fundementally broken after bug fixing though.