Class: GamesAndRpgParadise::Mud::Weapon
- Defined in:
- lib/games_and_rpg_paradise/mud/weapons/weapon.rb
Overview
GamesAndRpgParadise::Mud::Weapon
Constant Summary collapse
- HASH_OF_MUD_WEAPONS =
#
HASH_OF_MUD_WEAPONS
This is a copy of HASH_OF_DSA4_WEAPONS, for use in the MUD, but also with a 1D1 added to each [2] value right now:
#
{}
Constants inherited from MudObject
MudObject::DEFAULT_NAME, MudObject::NAMESPACE
Instance Method Summary collapse
-
#broken? ⇒ Boolean
(also: #broken)
# === broken?.
-
#damage?(pick_which = :mud) ⇒ Boolean
# === damage?.
-
#do_break ⇒ Object
# === do_break.
-
#do_repair ⇒ Object
# === do_repair.
-
#initialize(name = obtain_name_from_filename, optional_hash = {}) ⇒ Weapon
constructor
# === initialize.
-
#inspect ⇒ Object
# === inspect.
-
#is_weapon? ⇒ Boolean
# === is_weapon?.
-
#material_type? ⇒ Boolean
# === material_type?.
-
#process_hash(i) ⇒ Object
# === process_hash ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#set_weapon_name(i) ⇒ Object
# === set_weapon_name ========================================================================= #.
-
#status?(i = @quality) ⇒ Boolean
# === status?.
-
#weapon_name? ⇒ Boolean
(also: #weapon?, #name?, #weapon)
# === weapon_name? ========================================================================= #.
Methods inherited from MudObject
[], #add, #add_prop, #add_to_inventory, #alias_action, #can_speak?, #define_action, #describe_the_mud_object, #description?, disable_debug, #empty?, enable_debug, #enable_speak, #find, #has_inventory?, #height?, #id?, #internal_hash?, #inventory?, #is_armour?, #is_inventory?, #is_mud_object?, #is_wearable?, #length?, #method_missing, #name=, #obtain_name_from_filename, #random_inventory_element, #report_height, #report_weight, #run, #set_description, #set_height, #set_is_an_armour, #set_is_inventory, #set_is_wearable, #set_length, #set_name, #set_object_name, #set_value, #set_weight, shall_we_debug?, #show_inventory, #store, #store_where?, #value?, #wear, #wearables?, #weight?, #who_am_i?, #wields?
Constructor Details
#initialize(name = obtain_name_from_filename, optional_hash = {}) ⇒ Weapon
#
initialize
The initial name will be chosen from the filename.
#
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/games_and_rpg_paradise/mud/weapons/weapon.rb', line 43 def initialize( name = obtain_name_from_filename, optional_hash = {} ) super() reset set_weapon_name(name) # <- This method is defined in mud_object.rb set_description(weapon_name?) process_hash(optional_hash) unless optional_hash.empty? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class GamesAndRpgParadise::Mud::MudObject
Instance Method Details
#broken? ⇒ Boolean Also known as: broken
#
broken?
Query whether the weapon is broken or whether it is still intact.
#
149 150 151 |
# File 'lib/games_and_rpg_paradise/mud/weapons/weapon.rb', line 149 def broken? @broken end |
#damage?(pick_which = :mud) ⇒ Boolean
#
damage?
Returns our base damage range.
#
87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/games_and_rpg_paradise/mud/weapons/weapon.rb', line 87 def damage?( pick_which = :mud ) case pick_which # ======================================================================= # # === :mud # ======================================================================= # when :mud return HASH_OF_MUD_WEAPONS[@name][2] else # anything else will go back to DSA4 weapons. return HASH_OF_DSA4_WEAPONS[@name][2] end end |
#do_break ⇒ Object
#
do_break
This is the action-method that will break the object in question.
#
158 159 160 |
# File 'lib/games_and_rpg_paradise/mud/weapons/weapon.rb', line 158 def do_break @broken = true end |
#do_repair ⇒ Object
#
do_repair
And here we will repair the object again.
#
167 168 169 |
# File 'lib/games_and_rpg_paradise/mud/weapons/weapon.rb', line 167 def do_repair @broken = false end |
#inspect ⇒ Object
#
inspect
- We don’t need the leading Mud
-
prefix.
#
201 202 203 |
# File 'lib/games_and_rpg_paradise/mud/weapons/weapon.rb', line 201 def inspect super.sub('Mud::', '') end |
#is_weapon? ⇒ Boolean
#
is_weapon?
Whether this object is a weapon or whether it is not.
#
176 177 178 |
# File 'lib/games_and_rpg_paradise/mud/weapons/weapon.rb', line 176 def is_weapon? true end |
#material_type? ⇒ Boolean
#
material_type?
What material_type this weapon is made of. Currently this is hardcoded to iron.
#
140 141 142 |
# File 'lib/games_and_rpg_paradise/mud/weapons/weapon.rb', line 140 def material_type? 'iron' end |
#process_hash(i) ⇒ Object
#
process_hash
#
104 105 106 107 108 109 110 |
# File 'lib/games_and_rpg_paradise/mud/weapons/weapon.rb', line 104 def process_hash(i) if i.is_a? Hash if i.has_key? :weight set_weight i.delete(:weight) end end end |
#reset ⇒ Object
#
reset (reset tag)
#
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/games_and_rpg_paradise/mud/weapons/weapon.rb', line 57 def reset super() # ======================================================================= # # === @name # ======================================================================= # @name = @weapon_name # ======================================================================= # # === Set the weight of the weapon. This is determined in mud_object.rb # ======================================================================= # set_weight(0) # ======================================================================= # # === Set the height of the weapon. # # Default height for a weapon. This is a fake value of course. # ======================================================================= # set_height(1) @quality = 100 # Can range from 0 to 100. # ======================================================================= # # === @broken # # Keep track as to whether the weapon is broken or not. # ======================================================================= # @broken = false end |
#set_weapon_name(i) ⇒ Object
#
set_weapon_name
#
192 193 194 |
# File 'lib/games_and_rpg_paradise/mud/weapons/weapon.rb', line 192 def set_weapon_name(i) @weapon_name = i end |
#status?(i = @quality) ⇒ Boolean
#
status?
Determine the quality of the weapon at hand.
#
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/games_and_rpg_paradise/mud/weapons/weapon.rb', line 117 def status?(i = @quality) case i when 0..10 'It is about to fall apart.' when 11..25 'It is in a very bad condition.' when 26..49 'It is in a bad condition.' when 50..75 'It is in quite condition.' when 76..99 'it almost looks new.' when 100 'It is in top condition.' end end |
#weapon_name? ⇒ Boolean Also known as: weapon?, name?, weapon
#
weapon_name?
#
183 184 185 |
# File 'lib/games_and_rpg_paradise/mud/weapons/weapon.rb', line 183 def weapon_name? @weapon_name end |