Class: GamesAndRpgParadise::Mud::Weapons
- Inherits:
-
Object
- Object
- GamesAndRpgParadise::Mud::Weapons
- Defined in:
- lib/games_and_rpg_paradise/mud/weapons/weapons.rb
Overview
RpgParadise::Mud::Weapons
Class Method Summary collapse
-
.available_weapons? ⇒ Boolean
# === GamesAndRpgParadise::Mud::Weapons.available_weapons?.
-
.create_weapon(name) ⇒ Object
# === GamesAndRpgParadise::Mud::Weapons.create_weapon ========================================================================= #.
-
.random_weapon ⇒ Object
# === GamesAndRpgParadise::Mud::Weapons.random_weapon.
Class Method Details
.available_weapons? ⇒ Boolean
#
GamesAndRpgParadise::Mud::Weapons.available_weapons?
Show which weapons are available.
This method will retun an Array that will look like this:
# => ["axe", "broadsword", "club", "dagger", "hammer", "pike", "sabre", "spear", "sword"]
#
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/games_and_rpg_paradise/mud/weapons/weapons.rb', line 47 def self.available_weapons? target_directory = GamesAndRpgParadise.project_base_directory?+'mud/weapons/' all_weapons = Dir[target_directory+'*.rb'].map {|entry| File.basename(entry, '.rb') }.sort all_weapons.reject! {|entry| entry.start_with?('weapon') or entry.start_with?('load') } return all_weapons end |
.create_weapon(name) ⇒ Object
#
GamesAndRpgParadise::Mud::Weapons.create_weapon
#
31 32 33 34 35 |
# File 'lib/games_and_rpg_paradise/mud/weapons/weapons.rb', line 31 def self.create_weapon(name) constant = ::GamesAndRpgParadise::Mud.const_get(name.to_s.capitalize) object = constant.new return object end |
.random_weapon ⇒ Object
#
GamesAndRpgParadise::Mud::Weapons.random_weapon
This method will yield to us a random weapon.
#
64 65 66 |
# File 'lib/games_and_rpg_paradise/mud/weapons/weapons.rb', line 64 def self.random_weapon GamesAndRpgParadise::Mud::Weapons.available_weapons?.sample end |