blob: 40f54bc6b1663725399fd98a4fb282da06c888a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
require './level'
require './frame'
class L1_Hub2 < Level
interfaces %w(1 2)
description <<~EOD
You are a two-port hub. Your job is to forward frames from one interface to the other.
EOD
def self.target(frame)
case frame.iface
when ?1
[frame.to(?2)]
when ?2
[frame.to(?1)]
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
|