Module: GamesAndRpgParadise::Mud::Living

Includes:
Gender, Hitpoints, Talk
Included in:
Animal, Humanoid, Person
Defined in:
lib/games_and_rpg_paradise/mud/living/living.rb

Overview

GamesAndRpgParadise::Mud::Living

Constant Summary collapse

DEFAULT_HP_FOR_HUMANS =
#

DEFAULT_HP_FOR_HUMANS

#
100

Constants included from Adverbs

Adverbs::ADVERBS_ABBREVIATED, Adverbs::ARRAY_ADVERBS

Instance Method Summary collapse

Methods included from Talk

included, #say, #set_how

Methods included from Adverbs

all?, file?, find_adverb_for, keys, n_adverbs?, original_adverbs

Methods included from Hitpoints

#deduct_hp, #hp?, #max_hp?, #modify_health, #sync_hp

Methods included from Gender

#female?, #gender?, #has_gender?, #male?, #neuter?, #set_female, #set_male, #set_neuter, #subjective_case?

Instance Method Details

#can_breathe?Boolean

#

can_breathe?

All living objects can breathe. Some conditions however may alter this boolean value, such as suffocation. Maybe this should reside in a module instead.

#

Returns:

  • (Boolean)


163
164
165
# File 'lib/games_and_rpg_paradise/mud/living/living.rb', line 163

def can_breathe?
  true
end

#can_talk?Boolean Also known as: can_speak?

#

can_talk?

This will be overruled if the Talk module is included.

#

Returns:

  • (Boolean)


222
223
224
# File 'lib/games_and_rpg_paradise/mud/living/living.rb', line 222

def can_talk?
  @can_talk
end

#do_dieObject

#

do_die

This lets a living being die.

If the instance variable @hp is used, then we check on whether it is set to 0 or less. If it is, then the object is consider to be dead.

#


136
137
138
139
140
# File 'lib/games_and_rpg_paradise/mud/living/living.rb', line 136

def do_die
  @hp = 0 if instance_variable_defined? '@hp'
  @is_alive = false
  Ghost.new(self)
end

#do_resurrectObject Also known as: resurrect

#

do_resurrect

#


120
121
122
123
124
125
126
# File 'lib/games_and_rpg_paradise/mud/living/living.rb', line 120

def do_resurrect
  if instance_variable_defined? '@hp'
    @hp = return_default_hp
    sync_hp
  end
  @is_alive = true
end

#initialize(run_already = true) ⇒ Object

#

initialize

#


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

def initialize(
    run_already = true
  )
  reset
  run if run_already
end

#is_alive?Boolean Also known as: is_living?, living?, alive

#

is_alive?

This method determines whether the object in question is still “alive” or whether it is not.

#

Returns:

  • (Boolean)


184
185
186
# File 'lib/games_and_rpg_paradise/mud/living/living.rb', line 184

def is_alive?
  @is_alive
end

#is_dead?Boolean

#

is_dead?

#

Returns:

  • (Boolean)


145
146
147
# File 'lib/games_and_rpg_paradise/mud/living/living.rb', line 145

def is_dead?
  return !@is_alive
end

#is_poisoned?Boolean Also known as: poisoned?, poisoned

#

is_poisoned?

Living beings can be poisoned. This query-method tells us whether we are poisoned or not.

#

Returns:

  • (Boolean)


173
174
175
# File 'lib/games_and_rpg_paradise/mud/living/living.rb', line 173

def is_poisoned?
  @is_poisoned
end

#my_race?Boolean

#

race?

This will return which race this living object is.

#

my_race?

Returns:

  • (Boolean)


101
102
103
# File 'lib/games_and_rpg_paradise/mud/living/living.rb', line 101

def race?
  @race
end

#race?Boolean Also known as: race

#

race?

#

Returns:

  • (Boolean)


97
98
99
# File 'lib/games_and_rpg_paradise/mud/living/living.rb', line 97

def race?
  @race
end

#report_raceObject

#

report_race

#


106
107
108
# File 'lib/games_and_rpg_paradise/mud/living/living.rb', line 106

def report_race
  e 'I am of race '+race?+'.'
end

#resetObject

#

reset

#


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/games_and_rpg_paradise/mud/living/living.rb', line 55

def reset
  super()
  # ======================================================================= #
  # === @skills
  # ======================================================================= #
  @skills = {} # A Hash storing all of our skills.
  # ======================================================================= #
  # === @is_alive
  # ======================================================================= #
  @is_alive = true
  # ======================================================================= #
  # === @is_poisoned
  #
  # Whether this living being is poisoned or whether it is not.
  # ======================================================================= #
  @is_poisoned = false
  # ======================================================================= #
  # === @race
  #
  # This should be stored as a Symbol.
  #
  # Can be :human, :dwarf, :elf, :troll, :orc, :ogre (or goblinoid)
  # ======================================================================= #
  @race = :human
  # ======================================================================= #
  # === @can_talk
  # ======================================================================= #
  @can_talk = false
end

#return_default_hpObject

#

return_default_hp

#


113
114
115
# File 'lib/games_and_rpg_paradise/mud/living/living.rb', line 113

def return_default_hp
  DEFAULT_HP_FOR_HUMANS
end

#return_raceBoolean

#

race?

This will return which race this living object is.

#

return_race

Returns:

  • (Boolean)


100
101
102
# File 'lib/games_and_rpg_paradise/mud/living/living.rb', line 100

def race?
  @race
end

#runObject

#

run

#


229
230
231
# File 'lib/games_and_rpg_paradise/mud/living/living.rb', line 229

def run
  determine_the_attributes
end

#set_stats_packages(for_this_race = @race) ⇒ Object

#

determine_the_attributes

The human attributes are set to a value of 100 each.

We assume a human with a weight of 100kg, of age 25, and of male gender.

#


198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/games_and_rpg_paradise/mud/living/living.rb', line 198

def set_stats_packages(
    for_this_race = @race
  )
  case for_this_race
  # ================================================================== #
  # === :human
  # ================================================================== #
  when :human 
    @strength     = HUMAN_STR_BASE # 100 base strength for humans.
    @agility      = HUMAN_AGI_BASE # 100 base agility for humans.
    @endurance    = HUMAN_END_BASE # 100 base endurance for humans.
    @constitution = HUMAN_CON_BASE # 100 base con for humans.
    @intelligence = HUMAN_INT_BASE # 100 base intelligence for humans.
    @speed_factor = 5   # factor 5 means: 5 meters / seconds at a max speed
  else
    e 'Unknown race: '+for_this_race.to_s
  end
end

#skills?Boolean Also known as: skills

#

skills?

#

Returns:

  • (Boolean)


88
89
90
# File 'lib/games_and_rpg_paradise/mud/living/living.rb', line 88

def skills?
  @skills
end