Class: Stattr::Stat

Inherits:
Object
  • Object
show all
Defined in:
lib/stattr.rb

Overview

Representing a stat in a game.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Stat

Returns a new instance of Stat.



128
129
130
131
# File 'lib/stattr.rb', line 128

def initialize(value)
  @val= value
  @mod= modstat(value)
end

Instance Attribute Details

#modObject

The Calculated modifier of the stat



126
# File 'lib/stattr.rb', line 126

attr_accessor :val, :mod

#valObject

The value of the stat



126
127
128
# File 'lib/stattr.rb', line 126

def val
  @val
end

Instance Method Details

#modstat(r) ⇒ Integer

Creates stat/mod array.

Returns:

  • (Integer)

    modlist. Returns the modifier.



136
137
138
# File 'lib/stattr.rb', line 136

def modstat(r)
  modr = ((r-10)/2).to_int
end