Here is my test code:
Code: Select all
$toughness = 3.
$sensitivity = 1.
$tough_win=False
$tough_pass=False
$sensi_pass=False
$sensi_win=False
init python:
def check_toughness():
tough_score = round((toughness / (toughness + sensitivity)) * 100, 2)
if tough_score < 25: #from 1% upto 24% toughness = mostly sensitive, sensitivity wins!
tough_win=False
tough_pass=False
sensi_pass=False
sensi_win=True
elif tough_score >= 25 and tough_score < 50: #from 25% upto 49% toughness = more sensitive, sensitivity passes.
tough_win=False
tough_pass=False
sensi_pass=True
sensi_win=False
elif tough_score >= 50 and tough_score < 75: #from 50% upto 74% toughness = more tough, toughness passes.
tough_win=False
tough_pass=True
sensi_pass=False
sensi_win=False
elif tough_score >= 75: #from 75% upto 100% toughness = mostly tough, toughness wins!
tough_win=True
tough_pass=False
sensi_pass=False
sensi_win=False
else:
pass
config.python_callbacks.append(check_toughness)
Can someone help me figure out how to make this work?
*** Originally, I wanted to do a continuous check for my Stat class, where $tough = Stat() and contains "up" and "down" variables rather than "toughness" and "sensitivity" as they're presented here outside of a class. That way, I could have all Stat() stats checked and updated at once. That seemed to fail due to the check method being check(self) and "self" needing to be defined. Dunno if I explained that properly; I'll post that Class code below if anyone asks for it.