Class: RubyArena::Level

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

Constant Summary collapse

LEVELS =
{
  0 => {
    robots: [
      { ai: Level0Ai, x: 600, y: 300, heading: 90 }
    ],
    user_robot_options: { x: 200, y: 300, heading: 90 }
  },
  1 => {
    robots: [
      { ai: Level1Ai, x: 600, y: 300, heading: 90 }
    ],
    user_robot_options: { x: 200, y: 300, heading: -90 }
  },
  2 => {
    robots: [
      { ai: Level2Ai, x: 600, y: 300, heading: -90, energy: 200 }
    ],
    user_robot_options: { x: 200, y: 300, heading: 90 }
  },
  3 => {
    robots: [
      { ai: Level3Ai, 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.



32
33
34
35
# File 'lib/ruby_arena/level.rb', line 32

def initialize(level)
  @level = level
  exit_if_level_is_not_defined
end

Instance Attribute Details

#levelObject (readonly)

Returns the value of attribute level.



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

def level
  @level
end

Instance Method Details

#options_for_cpu_robotsObject



37
38
39
# File 'lib/ruby_arena/level.rb', line 37

def options_for_cpu_robots
  LEVELS[level][:robots]
end

#options_for_user_robotObject



41
42
43
# File 'lib/ruby_arena/level.rb', line 41

def options_for_user_robot
  LEVELS[level][:user_robot_options]
end