本帖最后由 taroxd 于 2014-8-17 19:13 编辑
不妨用更统一的形式定义:
class Game_Battler def damage_valid? !(actor? ? actor : enemy).note.include?('<我不是杂鱼>') || friends_unit.alive_members == [self] end alias assign_hp_20140817 hp= def hp=(hp) assign_hp_20140817(hp) if hp >= @hp || damage_valid? end alias mdv_20140817 make_damage_value def make_damage_value(user, item) mdv_20140817(user, item) if damage_valid? end end
class Game_Battler
def damage_valid?
!(actor? ? actor : enemy).note.include?('<我不是杂鱼>') ||
friends_unit.alive_members == [self]
end
alias assign_hp_20140817 hp=
def hp=(hp)
assign_hp_20140817(hp) if hp >= @hp || damage_valid?
end
alias mdv_20140817 make_damage_value
def make_damage_value(user, item)
mdv_20140817(user, item) if damage_valid?
end
end
|