I want a method for checking if an object has one of several states and if so checks their current TP and modifies that state dependent on the current TP value. the objects can only have one of the states at a time they need to replace eachother. I want this code to run one time per round so it should figure out a value and set a state then exit.
I was thinking something along the lines of..
edit update: fixed some errors but still not functioning properly. after applying state 25 and increasing TP nothing changes.
edit2: reached the second case statement but having trouble applying the state now..
edit3: nearly there but still finding a type error with certain tp values.. not sure why yet.
edit4: removed the ranges to try to solve the type error.. seems to be related to state rather than the ranges.
edit5: attempted to move from state 26 back to state 25 by reducing TP.. same error.
any thoughts?
I was thinking something along the lines of..
Code:
def tp_state_update
if state?(25||26||27)
case
when self.tp <= 30
set_state = 25
when self.tp >= 31 && self.tp <= 80
set_state = 26
when self.tp >= 81 && self.tp <=100
set_state = 27
end
end
case
when state?(25) && set_state !=25
self.remove_state(25)
self.add_state(set_state)
when state?(26) && set_state !=26
self.remove_state(26)
self.add_state(set_state)
when state?(27) && set_state !=27
self.remove_state(27)
self.add_state(set_state)
end
end
edit update: fixed some errors but still not functioning properly. after applying state 25 and increasing TP nothing changes.
edit2: reached the second case statement but having trouble applying the state now..
edit3: nearly there but still finding a type error with certain tp values.. not sure why yet.
edit4: removed the ranges to try to solve the type error.. seems to be related to state rather than the ranges.
edit5: attempted to move from state 26 back to state 25 by reducing TP.. same error.
any thoughts?