-
Notifications
You must be signed in to change notification settings - Fork 0
/
secret_santa_ryan.rb
86 lines (71 loc) · 2.26 KB
/
secret_santa_ryan.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Create a Secret Santa app
## Parts
## - Participants
## - Givers
## - Receivers
## They're the same people but they have to be
## - matched up
## - you can't be matched with yourself
## - List of gifts to be given
## - Matched to the giver (hash)
# Variables
all_participants = []
givers = []
receivers = []
givers_and_their_gifts = {}
givers_and_receivers = {}
system('clear')
puts "**************************************"
puts "**************************************"
puts "** Welcome to **"
puts "** Secret Santa **"
puts "**************************************"
puts "**************************************\n\n"
sleep 1
puts "It's time to make a list of all the people participating."
puts "Please list everyone who wants to play."
puts "\nYou can type in everyone all at once,\njust put a comma inbetween names."
puts "(ie. name, name, name)"
print "> "
# Gets the name list and splits it.
# Saves it into the array "all_participants"
initial_names_list = gets.chomp
all_participants = initial_names_list.split(", ")
# Populates the list "givers" with all the participants
all_participants.each { |participant| givers << participant }
# puts "givers - #{givers.to_s}"
# Populates the list "receivers" with all the participants
all_participants.each { |participant| receivers << participant}
# puts "receivers - #{receivers.to_s}"
# Match up the givers and receivers
# Create a hash called "givers_and_recievers" with an each loop
givers.each do |gifter, giftee|
giftee = receivers.pop
givers_and_receivers[gifter] = giftee
end
system('clear')
# puts givers_and_receivers
givers_and_receivers.each do |santa, kid|
puts "\nHey #{santa}, what are you going to get for #{kid}?"
print " > "
gift = gets.chomp
givers_and_their_gifts[santa] = gift
system('clear')
end
# puts givers_and_their_gifts
# Give out the gifts
system('clear')
sleep 2
puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
puts " It's about that time!! "
puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n"
givers_and_receivers.each do |santa, kid, gift|
kid = givers_and_receivers[santa]
gift = givers_and_their_gifts[santa]
puts "\nHey #{kid}!"
puts "Guess what?!?!?"
sleep 1
puts "Your Secret Santa got you #{gift}!!!"
sleep 2
end
4.times { puts"" }