Web game with Rails: attack behavior -
the following code responsible perform attacks against mobs (aka. monsters) , want know if best way place behavior in player's model.
class player < activerecord::base belongs_to :kind, dependent: :destroy def attack(mob, min_damage, max_damage) [mob.find(mob).name, rand(min_damage..max_damage)] end end thinking in logic: players attack monsters.
am right turning idea code through player's model? or should create specific model perform kind of behaviors?
i think move model can game. action model, can specify magical or physical attack, can apply modifiers in terms of residual damage, critical hits, etc.
also, believe monster can attack player too, separate model, need create , instance of passing parameters/modifiers want.
Comments
Post a Comment