Sha256: 79305be2bba675a8161017775bbca426f62a2e22a9155483131cecb96957d3ba
Contents?: true
Size: 571 Bytes
Versions: 1
Compression:
Stored size: 571 Bytes
Contents
# A single tile on the map/board. class BoardGame::Tile attr_accessor :content, :x, :y, :map def initialize(x: nil , y: nil, map: nil, content: []) @content, @x, @y, @map = content, x, y, map end def move_to(x, y, map = @map) if map.within? x, y @x, @y, @map = x, y, map else raise 'invalid move' end self end def inspect content.empty? ? "□" : content.last.inspect end def <<(piece) piece.tile = self @content << piece end def remove(piece) piece.tile = nil @content.delete piece end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
boardgame-0.0.2 | lib/boardgame/tile.rb |