class MyState
def initialze
@users = []
end
def add_user(user, turn)
@users.push [user, turn]
end
# how much hp to change
def value
@users.inject(0) {|a, (user, _)| a + user.atk * (rand * 0.05 + 0.15) }
end
# should be invoked every turn
def update
@users.delete_if {|pair| (pair[1] -= 1) <= 0 }
end
# define state-like methods such as :priority, :restriction if necessary
end
class Game_BattlerBase
# when initialize
# @my_state = MyState.new
# when turn starts
# @my_state.update
# self.hp -= @my_statue.value.to_i
# override methods such as :states if necessary
# should be invoked in the formula
def add_my_state(user, turn)
@my_state.add_user user, turn
end
end
class MyState
def initialze
@users = []
end
def add_user(user, turn)
@users.push [user, turn]
end
# how much hp to change
def value
@users.inject(0) {|a, (user, _)| a + user.atk * (rand * 0.05 + 0.15) }
end
# should be invoked every turn
def update
@users.delete_if {|pair| (pair[1] -= 1) <= 0 }
end
# define state-like methods such as :priority, :restriction if necessary
end
class Game_BattlerBase
# when initialize
# @my_state = MyState.new
# when turn starts
# @my_state.update
# self.hp -= @my_statue.value.to_i
# override methods such as :states if necessary
# should be invoked in the formula
def add_my_state(user, turn)
@my_state.add_user user, turn
end
end