alias as_20141212 add_state
def add_state(id)
levels = STATE_UPGRADE[id]
return as_20141212(id) unless levels
index = levels.index { |state| state?(state) } # 当前等级
return as_20141212(id) unless index
return if index == levels.size - 1 # 已经达到最高等级
remove_state levels[index]
as_20141212 levels[index + 1]
end
alias rs_20211117 remove_state
def remove_state(state_id)
for i in STATE_UPGRADE
levels = i[1] if i[1].include?(state_id)
end
return rs_20211117(state_id) unless levels
index = levels.index { |state| state?(state) }
return rs_20211117(state_id) unless index
rs_20211117(levels[index])
return if index == 0
add_state(levels[index - 1])
end
end