자유게시판

#==============================================================================
# ● RPG::Armor
#==============================================================================

class Armor
  #--------------------------------------------------------------------------
  # ● MaxHP 변화량을 메모로부터 취득한다. ex) maxhp(n)
  #--------------------------------------------------------------------------
  def maxhp
    text = @note[/maxhp(-*d+)/]
    return 0 if text == nil
    result = text[/d+/].to_i
    return (text.include?("-") ? -result : result)
  end
  #--------------------------------------------------------------------------
  # ● MaxTP 변화량을 메모로부터 취득한다. ex) maxmp(n)
  #--------------------------------------------------------------------------
  def maxmp
    text = @note[/maxmp(-*d+)/]
    return 0 if text == nil
    result = text[/d+/].to_i
    return (text.include?("-") ? -result : result)
  end
  #--------------------------------------------------------------------------
  # ● PDP 추가치를 메모로부터 취득한다. ex) pdp(n)
  #--------------------------------------------------------------------------
  def pdp
    text = @note[/pdp(-*d+)/]
    return 0 if text == nil
    result = text[/d+/].to_i
    return (text.include?("-") ? -result : result)
  end
  #--------------------------------------------------------------------------
  # ● MDP 추가치를 메모로부터 취득한다. ex) mdp(n)
  #--------------------------------------------------------------------------
  def mdp
    text = @note[/mdp(-*d+)/]
    return 0 if text == nil
    result = text[/d+/].to_i
    return (text.include?("-") ? -result : result)
  end
  #--------------------------------------------------------------------------
  # ● WP 추가치를 메모로부터 취득한다. ex) wp(n)
  #--------------------------------------------------------------------------
  def wp
    text = @note[/wp(-*d+)/]
    return 0 if text == nil
    result = text[/d+/].to_i
    return (text.include?("-") ? -result : result)
  end
  #--------------------------------------------------------------------------
  # ● PEV 추가치를 메모로부터 취득한다. ex) pev(n)
  #--------------------------------------------------------------------------
  def pev
    text = @note[/pev(-*d+)/]
    return 0 if text == nil
    result = text[/d+/].to_i
    return (text.include?("-") ? -result : result)
  end
  #--------------------------------------------------------------------------
  # ● MEV 추가치를 메모로부터 취득한다. ex) mev(n)
  #--------------------------------------------------------------------------
  def mev
    text = @note[/mev(-*d+)/]
    return 0 if text == nil
    result = text[/d+/].to_i
    return (text.include?("-") ? -result : result)
  end
end

 

이렇게 하면 뭐가 되냐면

방어구(class Armor)의 메모(@note)를 검색해서 가령 mev(3)이란 문자열이 있을 때

mev는 검색판별로 사용하고 실질값 3을 구해서 armor.mev등으로 추가하는거죠.

즉 그경우 armor(game_actor에선 armor_id를 @item으로 넣어버리므로 @item.mev).mev는 3이 됩니다.