Class Edge
In: lib/core/board.rb
Parent: Object

an edge is just a collection of 2 nodes that belongs to a hex

Methods

Attributes

coords  [RW] 
hexes  [RW] 
nodes  [RW] 
road  [RW] 
road_lengths  [RW] 

Public Class methods

[Source]

# File lib/core/board.rb, line 221
  def initialize
    @nodes = []
    @road_lengths = []
  end

Public Instance methods

[Source]

# File lib/core/board.rb, line 226
  def get_adjecent_edges
    result = []
    for n in @nodes
      result += n.edges
    end
    result.delete(self)
    result.uniq
  end

An iterator to visit every connected road with the same color yields the edge containing the road

[Source]

# File lib/core/board.rb, line 237
  def visit_road(visitedEdges=[])
    if @road
      visitedEdges << self
      yield self
      for e in get_adjecent_edges
        if not visitedEdges.include?(e) 
          if e.road and e.road.color == @road.color
            e.visit_road(visitedEdges){|edge| yield edge}
          end
        end
      end
    end
  end

[Validate]