Class: Codenjoy::Client::Games::Minesweeper::Board

Inherits:
BaseBoard
  • Object
show all
Defined in:
lib/codenjoy/games/minesweeper/board.rb

Constant Summary collapse

ELEMENTS =
{
  BANG: 'Ѡ',
  HERE_IS_BOMB: '',
  DETECTOR: '',
  FLAG: '',
  HIDDEN: '*',

  ONE_MINE: '1',
  TWO_MINES: '2',
  THREE_MINES: '3',
  FOUR_MINES: '4',
  FIVE_MINES: '5',
  SIX_MINES: '6',
  SEVEN_MINES: '7',
  EIGHT_MINES: '8',

  BORDER: '',
  NONE:' ',
  DESTROYED_BOMB: 'x'
}

Instance Method Summary collapse

Methods inherited from BaseBoard

#any_of_at?, #at?, #board_to_s, #count_near, #find_all, #find_by_list, #get_at, #near?, #size, #xyl

Instance Method Details

#flag_cell(direction) ⇒ Object



49
50
51
# File 'lib/codenjoy/games/minesweeper/board.rb', line 49

def flag_cell(direction)
  "FLAG, #{direction}"
end

#get_boardersObject



45
46
47
# File 'lib/codenjoy/games/minesweeper/board.rb', line 45

def get_boarders
  find_by_list([:BORDER].map{ |e| ELEMENTS[e] })
end

#get_meObject



41
42
43
# File 'lib/codenjoy/games/minesweeper/board.rb', line 41

def get_me
  find_by_list([:DETECTOR].map{ |e| ELEMENTS[e] })
end

#process(str) ⇒ Object



35
36
37
38
39
# File 'lib/codenjoy/games/minesweeper/board.rb', line 35

def process(str)
  puts "-------------------------------------------------------------------------------------------"
  puts str
  @raw = str
end

#to_sObject



53
54
55
56
57
58
# File 'lib/codenjoy/games/minesweeper/board.rb', line 53

def  to_s
  [
    "Board:",
    board_to_s
  ].join("\n")
end