class Mineswiper::Tile

Attributes

adj_bombs[RW]
bomb[R]
flag[RW]
hidden[RW]
number[RW]
pos[R]
state[RW]

Public Class Methods

new(pos, bomb=false) click to toggle source
# File lib/mineswiper/tile.rb, line 7
def initialize(pos, bomb=false)
  @pos, @bomb = pos, bomb
  @hidden = true
  @flag = false
  @adj_bombs = 0
end

Public Instance Methods

bomb?() click to toggle source
# File lib/mineswiper/tile.rb, line 18
def bomb?
  @bomb == true
end
flag_it() click to toggle source
# File lib/mineswiper/tile.rb, line 26
def flag_it
  @flag = true
end
flagged?() click to toggle source
# File lib/mineswiper/tile.rb, line 22
def flagged?
  @flag
end
reveal() click to toggle source
# File lib/mineswiper/tile.rb, line 14
def reveal
  @hidden = false
end
tilerender() click to toggle source
# File lib/mineswiper/tile.rb, line 34
def tilerender
  if flagged?
    return "\u2691".encode('utf-8')
  elsif @hidden
    return "\u25A0".encode('utf-8')
  elsif bomb?
    return "\u2622".encode('utf-8')
  else
    return self.adj_bombs.to_s
  end
end
unflag() click to toggle source
# File lib/mineswiper/tile.rb, line 30
def unflag
  flag = false
end