I'm having an issue where python is treating two distinct variables as one..
I have a class... in that class are various dictionaries... one of those dictionaries is called 'Delay'. and it's 5 variables: a 'main weapon' delay, a 'suport weapon' delay, the combined delay of those two, then a multiplier effected delay, a second-tier multiplier effected delay, and then the actual EFFECTIVE 'delay' that that character would have.
The reason I opted to do it like this is i wanted to be able to use player.Delay[n] for the various things, instead of player.delay1, player.multdelay,player.total_delay, etc. It works as intended for what i've needed so far.
Enter the issue.
I'm currently coding a module that is designed to actually be the 'fight' logic. so it imports the class def from a different .py, and does a 'fight'. so for testing, i have a name/main check where i can make settings and then test them without all the superfluous stuff from the main program.
My design theory was to just take two 'players' (represented as character class variables, CharClass() ) and just stuff them into a dictionary. so in the event I ever want to do more than 2 combatants i can just player[5], player[10] etc. for now it's just supposed to be player[0], and player[1]. When I set a stand-alone variable, it works fine (i.e. player[n].name), but for some reason, if i try to set a variable inside of an array (dictionary), with:
player[0].Delay[4] = 5
player[1].Delay[4] = 15
When run, both player[n].Delay[4]
's are 15
.
If I just discard the dictionary idea and do:
player[0].Delay = 5
player[1].Delay = 15
it works. But that doesn't achieve what i need. I've never run into this issue before that i can recall. And I've done a LLLLLoooottt of stuff with dictionaries. Perhaps I'm overthinking something, or just ignorant of something, but eitherway I'm stuck... I've been racking my head and looking at this for 30 minutes and i just don't see what the problem is. I just need some fresh eyes to tell me what's up.
if __name__== "__main__":
#print "This is a module. It's not intended to be run by the user."
player = []
player.append(CharClass())
player.append(CharClass())
player[0].name="Player 1"
player[1].name="Monster"
player[0].tDelay = 0
player[1].tDelay = 0
player[0].Target = 1
player[1].Target = 0
player[0].Delay = 50 #This block 'works' in that it treats player[n's] separatly.
player[1].Delay = 30
player[0].Delay[4] = 50 #but This block sets both player[n].Delay[4]'s to 30
player[1].Delay[4] = 30
print player[0].Delay,player[1].Delay
print player[0].tDelay,player[1].tDelay
#start()
Below is partially what CharClass() is coded as, but remember it's imported from a different .py, for clarity.
class CharClass():
name = ""
HP = 100
LVL = [99, 0]
base_combat_stats = []
Delay = [0,0,0,0,0] #wpn1,wpn2, combined, DW adjusted, Haste adjusted, combat_effective_delay