Class: GamesAndRpgParadise::Mechwars::Vehicle
- Inherits:
-
Object
- Object
- GamesAndRpgParadise::Mechwars::Vehicle
- Defined in:
- lib/games_and_rpg_paradise/games/mechwars/vehicle.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#array_weapons ⇒ Object
Returns the value of attribute array_weapons.
-
#average_speed ⇒ Object
Returns the value of attribute average_speed.
-
#has_pilot ⇒ Object
Returns the value of attribute has_pilot.
-
#height ⇒ Object
Returns the value of attribute height.
-
#length ⇒ Object
Returns the value of attribute length.
-
#maximum_speed ⇒ Object
Returns the value of attribute maximum_speed.
-
#plating ⇒ Object
Returns the value of attribute plating.
-
#type ⇒ Object
Returns the value of attribute type.
-
#weight ⇒ Object
in kg.
Instance Method Summary collapse
-
#debug ⇒ Object
# === debug =========================================================================== #.
-
#fetch_which_yaml_data(name) ⇒ Object
# === fetch_which_yaml_data =========================================================================== #.
-
#fetch_yaml_data(yaml_file_location = 'YAML/truck.yml') ⇒ Object
# === fetch_yaml_data =========================================================================== #.
-
#initialize ⇒ Vehicle
constructor
# === initialize.
-
#reset ⇒ Object
# === reset (reset tag) =========================================================================== #.
Constructor Details
#initialize ⇒ Vehicle
#
initialize
initialize is always done, but the data is sanitized afterwards if we read from a yaml file (for instance)
#
67 68 69 |
# File 'lib/games_and_rpg_paradise/games/mechwars/vehicle.rb', line 67 def initialize reset end |
Instance Attribute Details
#array_weapons ⇒ Object
Returns the value of attribute array_weapons.
52 53 54 |
# File 'lib/games_and_rpg_paradise/games/mechwars/vehicle.rb', line 52 def array_weapons @array_weapons end |
#average_speed ⇒ Object
Returns the value of attribute average_speed.
54 55 56 |
# File 'lib/games_and_rpg_paradise/games/mechwars/vehicle.rb', line 54 def average_speed @average_speed end |
#has_pilot ⇒ Object
Returns the value of attribute has_pilot.
51 52 53 |
# File 'lib/games_and_rpg_paradise/games/mechwars/vehicle.rb', line 51 def has_pilot @has_pilot end |
#height ⇒ Object
Returns the value of attribute height.
57 58 59 |
# File 'lib/games_and_rpg_paradise/games/mechwars/vehicle.rb', line 57 def height @height end |
#length ⇒ Object
Returns the value of attribute length.
58 59 60 |
# File 'lib/games_and_rpg_paradise/games/mechwars/vehicle.rb', line 58 def length @length end |
#maximum_speed ⇒ Object
Returns the value of attribute maximum_speed.
55 56 57 |
# File 'lib/games_and_rpg_paradise/games/mechwars/vehicle.rb', line 55 def maximum_speed @maximum_speed end |
#plating ⇒ Object
Returns the value of attribute plating.
53 54 55 |
# File 'lib/games_and_rpg_paradise/games/mechwars/vehicle.rb', line 53 def plating @plating end |
#type ⇒ Object
Returns the value of attribute type.
59 60 61 |
# File 'lib/games_and_rpg_paradise/games/mechwars/vehicle.rb', line 59 def type @type end |
#weight ⇒ Object
in kg
56 57 58 |
# File 'lib/games_and_rpg_paradise/games/mechwars/vehicle.rb', line 56 def weight @weight end |
Instance Method Details
#debug ⇒ Object
#
debug
#
138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/games_and_rpg_paradise/games/mechwars/vehicle.rb', line 138 def debug e '='*80 e 'Type: '+@type.to_s e 'Has pilot? '+verbose_truth(@has_pilot).to_s e 'Weapons: '+@array_weapons.to_s e 'plating: '+@plating.to_s e 'Maximum speed: '+@maximum_speed.to_s e 'Average speed: '+@average_speed.to_s e 'weight: '+@weight.to_s e 'height: '+@height.to_s e 'length: '+@length.to_s e '='*80 end |
#fetch_which_yaml_data(name) ⇒ Object
#
fetch_which_yaml_data
#
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/games_and_rpg_paradise/games/mechwars/vehicle.rb', line 93 def fetch_which_yaml_data(name) case name when :random r = rand(2) case r when 0 name = :truck when 1 name = :jeep end end case name when :truck then fetch_yaml_data('YAML/truck.yml') when :jeep then fetch_yaml_data('YAML/jeep.yml') else puts 'ERROR: not found '+:name.to_s end end |
#fetch_yaml_data(yaml_file_location = 'YAML/truck.yml') ⇒ Object
#
fetch_yaml_data
#
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/games_and_rpg_paradise/games/mechwars/vehicle.rb', line 115 def fetch_yaml_data( yaml_file_location = 'YAML/truck.yml' ) @yaml_hash = YAML.load_file(yaml_file_location) @type = @yaml_hash.keys.to_s @yaml_hash = @yaml_hash[@type] @yaml_hash = @yaml_hash.to_hash @weight = @yaml_hash['weight'].to_i if @type == 'truck' # truck kann schwer sein @weight += Array.new.random_by_step else @weight += Array.new.random_by_step(20,300) end @height = @yaml_hash['height'].to_i @length = @yaml_hash['length'].to_i @plating = @yaml_hash['plating'].to_i+rand(1) # bissi random @average_speed = @yaml_hash['average_speed'].to_i @maximum_speed = @yaml_hash['maximum_speed'].to_i end |
#reset ⇒ Object
#
reset (reset tag)
#
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/games_and_rpg_paradise/games/mechwars/vehicle.rb', line 74 def reset # ========================================================================= # # === @type # ========================================================================= # @type = 'tank' @has_pilot = true @array_weapons = [] @plating = 0 @integrity = 100 @maximum_speed = 10 @average_speed = 10 @weight = 100+rand(100) @length = 100+rand(100) @height = 100+rand(100) end |