• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] [debug request] Somewhere a variables value gets doubled...

Status
Not open for further replies.
Level 6
Joined
Feb 18, 2005
Messages
263
Hi, i'm just creating a 1:1 (realtime) convertion of Magic the gathering. The famous cardgame.

I'm close to finishing the scripting, but, to my misery, a bug ha aproached with parsing the manacosts of the cards.
(for those not nowhing mtg: a cards costs consists out of 5 colors, and a fixed amount of color with no specific color like: 3R - 1 red mana and 3 mana that may be of any kind)

here the link to the alpha-map

if you use any of my code, please give credits.

the function that does not work is "manacosts"

the bug makes a unit that normaly costs something like 1G suddenly cost a total of 3 mana and a unit that costs 2B suddenly a total of 5. Therefore i guess its the number that gets doubled somewhere.

i use arrays to easy handling the different colors.
index = color
1 = black
2 = blue
3 = green
4 = red
5 = white
6 = mana with no color
7 = mana with every color

and here the part that, as far as i know, contains the bug:

Code:
set x = required_mana[6]
            set c = 0
            loop
               set c = c + 1
               if ( colorless_mana[c] > 0 ) then
                  set n = colorless_mana[c] - x
                  if ( n == 0 ) then
                     set required_mana[c] = existent_mana[c]
                     set x = 0
                  else
                     if (n < 0) then
                        set required_mana[c] = required_mana[c] + colorless_mana[c]
                        set x = x - colorless_mana[c]
                     else
                        set required_mana[c] = required_mana[c] + x
                        set x = 0
                     endif
                  endif
               endif
               exitwhen (c == 7) or (x == 0)
            endloop

this part is directly above the section where the 3 "endif" are (at the bottom of 'manacosts')

i would apreciate every help i can get.

- Raszul[/b]
 
Status
Not open for further replies.
Top