Module: GamesAndRpgParadise::Mud::Hitpoints

Included in:
Living
Defined in:
lib/games_and_rpg_paradise/mud/hitpoints/hitpoints.rb

Overview

RpgParadise::Mud::Hitpoints

Instance Method Summary collapse

Instance Method Details

#deduct_hp(i = 30) ⇒ Object

#

deduct_hp

Presently we can not have hp below 0.

#


46
47
48
49
50
# File 'lib/games_and_rpg_paradise/mud/hitpoints/hitpoints.rb', line 46

def deduct_hp(i = 30)
  i = i.to_i
  @hp -= i
  @hp  = 0 if @hp < 0 # Ensure that 0 is the minimum value.
end

#hp?Boolean Also known as: hp

#

hp?

#

Returns:

  • (Boolean)


19
20
21
# File 'lib/games_and_rpg_paradise/mud/hitpoints/hitpoints.rb', line 19

def hp?
  @hp
end

#max_hp?Boolean Also known as: max_hp

#

max_hp?

Counts our max hp. @hp may never exceed @max_hp.

#

Returns:

  • (Boolean)


28
29
30
# File 'lib/games_and_rpg_paradise/mud/hitpoints/hitpoints.rb', line 28

def max_hp?
  @max_hp
end

#modify_health(value = -10)) ⇒ Object

#

modify_health

Alter health whenever you get injured or cured. Default is to subtract from our @hp

Usage Examples (is done in percent):

modify_health('-50')
modify_health('+50')
#


64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/games_and_rpg_paradise/mud/hitpoints/hitpoints.rb', line 64

def modify_health(value = -10)
  value = value.to_s
  if    value.start_with? '+'
    value[0,1] = ''
    @hp += value.to_i
  elsif value.start_with? '-'
    value[0,1] = ''
    deduct_hp(value)
  else # default is to subtract from our @hp
    deduct_hp(value)
  end
end

#resetObject

#

reset

#


80
81
82
# File 'lib/games_and_rpg_paradise/mud/hitpoints/hitpoints.rb', line 80

def reset
  @hp = 0
end

#sync_hpObject

#

sync_hp

This will sync the @max_hp with the current hp.

#


37
38
39
# File 'lib/games_and_rpg_paradise/mud/hitpoints/hitpoints.rb', line 37

def sync_hp
  @max_hp = @hp
end