Class: RubyArena::Level

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_arena/level.rb

Constant Summary collapse

LEVELS =
{
  0 => {
    robots: [
      { ai: Level0, x: 600, y: 300 }
    ],
    user_robot_options: { x: 200, y: 300 }
  },
  1 => {
    robots: [
      { ai: Level1, x: 600, y: 300 }
    ],
    user_robot_options: { x: 200, y: 300 }
  }
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(level) ⇒ Level

Returns a new instance of Level.



20
21
22
23
# File 'lib/ruby_arena/level.rb', line 20

def initialize(level)
  @level = level
  exit_if_level_is_not_defined
end

Instance Attribute Details

#levelObject (readonly)

Returns the value of attribute level.



18
19
20
# File 'lib/ruby_arena/level.rb', line 18

def level
  @level
end

Instance Method Details

#options_for_cpu_robotsObject



25
26
27
# File 'lib/ruby_arena/level.rb', line 25

def options_for_cpu_robots
  LEVELS[level][:robots]
end

#options_for_user_robotObject



29
30
31
# File 'lib/ruby_arena/level.rb', line 29

def options_for_user_robot
  LEVELS[level][:user_robot_options]
end