Hoping someone can help me with a switch. I don't use switches very often, though when I do I've never had a problem like this before. Basically, the switch is just going to the default case every time.
A couple notes on the code: artillery=0, brute=1, ..., soldier=6. These correspond to entries in a select box. role is the value of that select box.
I've already verified that role is being set correctly, there used to be an alert in the default case which told the value of role. I also tried replacing the variables with the actual numbers, and it still didn't work.
Code:
Turns out it was a stupid issue with the type of the variable. One of the annoying bits when working with a weakly-typed language, I guess. I fixed it by multiplying role by 1, forcing javascript to interpret it as a number.
A couple notes on the code: artillery=0, brute=1, ..., soldier=6. These correspond to entries in a select box. role is the value of that select box.
I've already verified that role is being set correctly, there used to be an alert in the default case which told the value of role. I also tried replacing the variables with the actual numbers, and it still didn't work.
Code:
hp=0
switch (role) {
case artillery:
hp=6 + con.value + (level*6)
break
case brute:
hp=10 + con.value + (level*10)
break
case controller:
hp=8 + con.value + (level*8)
break
case lurker:
hp=8 + con.value + (level*8)
break
case minion:
hp=1
break
case skirmisher:
hp=8 + con.value + (level*8)
break
case soldier:
hp=8 + con.value + (level*8)
break
default:
break
}Turns out it was a stupid issue with the type of the variable. One of the annoying bits when working with a weakly-typed language, I guess. I fixed it by multiplying role by 1, forcing javascript to interpret it as a number.
