-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhigh_card.rb
42 lines (30 loc) · 904 Bytes
/
high_card.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
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "lib")
require "game_engine"
#
# A simple game where each player is dealt 1 card and who-ever has the highest card wins
#
HAND_SIZE = 1
SIZE_OF_DECK = 52
# Get the number of players, then their names
puts "Welcome to the High Card Game"
puts "Enter number of players"
player_count = gets
player_count = player_count.to_i
if player_count > 0 and player_count < (SIZE_OF_DECK / HAND_SIZE)
# Load up some players
players = []
(0...player_count).each do |index|
print "Enter name for player ##{index + 1}: "
name = gets
name = name.chomp
players << name
end
# Initialize a new game
game_engine = GameEngine.new(players, HAND_SIZE)
# Let's see the setup game
game_engine.show
# Let's play and see who wins
game_engine.play
else
puts "Player count should be between 1 and #{(SIZE_OF_DECK / HAND_SIZE)}"
end