blob: 87500275c9579c4789e6e7492f02d9256f5664cd (
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
32
33
34
|
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
|