Method: MISSIONGAME::NewOrleans#get_map

Defined in:
lib/neworleans.rb

#get_map(args) ⇒ Object

Return map data in a display format



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/neworleans.rb', line 53

def get_map(args)
  player = args[:player]
  buffer = []
  x = 1
  y = 1
  @the_map.each do |row|
    tmp_row = []
    x = 1
    row.each do |col|
      placed = 0

      # Place WITCH
      if x == MAP_WITCH_X && y == MAP_WITCH_Y
        tmp_row << MAP_KEY_WITCH.colorize(color: :white, background: :red)
        placed = 1
      end

      # If player is here, display them
      if x == player.x && y == player.y
        tmp_row << MAP_KEY_PLAYER.colorize(color: :red, background: :white)
        placed = 1
      end

      # If we haven't already placed the Player, run through the rest of the options
      if placed == 0
        case col
        when MAP_KEY_TREE
          tmp_row << col.colorize(color: :light_green, background: :green)
        when MAP_KEY_GRASS
          tmp_row << col.colorize(color: :green, background: :green)
        when MAP_KEY_WATER
          tmp_row << col.colorize(color: :white, background: :blue)
        when MAP_KEY_MOUNTAIN
          tmp_row << col.colorize(color: :yellow, background: :green)
        when MAP_KEY_ENEMY
          tmp_row << col.colorize(color: :red, background: :green)
        end
      end
      x += 1
    end
    buffer << tmp_row
    y += 1
  end

  buffer
end