require './level' require './frame' class Level interfaces %w(1 2 3) description <<~EOD You are now a three-port hub. Your job is to forward frames from one interface to all the others. EOD clicks 5 def self.target(frame) case frame.iface when ?1 [frame.to(?2), frame.to(?3)] when ?2 [frame.to(?1), frame.to(?3)] when ?3 [frame.to(?1), frame.to(?2)] else puts "ERR" [] end end def self.generate frames = {} @@interfaces.each do |iface| next if rand < 0.3 frames[@@count.to_s] = Frame.new(iface, "Frame #{@@count}") @@count += 1 end frames end end