class Stats
Attributes
changed_at[R]
deaths[R]
kills[R]
name[R]
shots[R]
Public Class Methods
new(name)
click to toggle source
# File lib/misc/stats.rb, line 3 def initialize(name) @name = name @kills = @deaths = @shots = @damage = @damage_dealt = 0 changed end
Public Instance Methods
add_damage(amount)
click to toggle source
# File lib/misc/stats.rb, line 24 def add_damage(amount) @damage += amount changed end
add_damage_dealt(amount)
click to toggle source
# File lib/misc/stats.rb, line 33 def add_damage_dealt(amount) @damage_dealt += amount changed end
add_death()
click to toggle source
# File lib/misc/stats.rb, line 14 def add_death @deaths += 1 changed end
add_kill(amount = 1)
click to toggle source
# File lib/misc/stats.rb, line 9 def add_kill(amount = 1) @kills += amount changed end
add_shot()
click to toggle source
# File lib/misc/stats.rb, line 19 def add_shot @shots += 1 changed end
damage()
click to toggle source
# File lib/misc/stats.rb, line 29 def damage @damage.round end
damage_dealt()
click to toggle source
# File lib/misc/stats.rb, line 38 def damage_dealt @damage_dealt.round end
to_s()
click to toggle source
# File lib/misc/stats.rb, line 42 def to_s "[kills: #{@kills}, " \ "deaths: #{@deaths}, " \ "shots: #{@shots}, " \ "damage: #{damage}, " \ "damage_dealt: #{damage_dealt}]" end
Private Instance Methods
changed()
click to toggle source
# File lib/misc/stats.rb, line 52 def changed @changed_at = Gosu.milliseconds end