-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodejam.rb
63 lines (53 loc) · 1.43 KB
/
codejam.rb
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class SongFighter
def homer_simpson
results = {}
system("xmms2 stop")
system("xmms2 clear")
list = Dir.glob("*.mp3")
list.each do |l|
results[l.to_sym] = 0
end
first = list[0]
second = list[1]
count = 2
system("clear")
while(true) do
time = "3"
puts "--------- PICK YOUR SONG ------------"
puts "\n\n lıllı ((((|̲̅̅●̲̅̅|̲̅̅=̲̅̅|̲̅̅●̲̅̅|)))) ıllı \n\n"
puts '#1: ' + first
puts '#2: ' + second
puts "Choose 1 or 2 (or 3 to finish the voting)"
song = first.gsub(" ", "\\ ")
system("xmms2 stop")
system("xmms2 clear")
system("xmms2 add " + song)
system("xmms2 play")
system("sleep " + time)
system("xmms2 stop")
system("xmms2 clear")
song = second.gsub(" ", "\\ ")
system("xmms2 add " + song)
system("xmms2 play")
system("sleep " + time)
system("xmms2 stop")
choice = gets.chomp
if choice == '1'
results[first.to_sym] = results[first.to_sym]+1
second = list[count]
elsif choice == '2'
results[second.to_sym] = results[second.to_sym]+1
first = list[count]
else
break
end
count = count + 1
system("clear")
end
puts "The results are: "
results.keys.each do |k|
puts "#{results[k.to_sym]} - #{k}"
end
end
end
SongFighter.new.homer_simpson