-
Notifications
You must be signed in to change notification settings - Fork 0
/
player_test.rb
38 lines (31 loc) · 1004 Bytes
/
player_test.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
require './lib/die'
require './lib/player.rb'
require './lib/turn.rb'
require './lib/game.rb'
puts "Welcome to Pig!\n\n"
players = [Player.new("Gulec 1"), Player.new("Gulec 2"), Player.new("Gulec 3"), Player.new("Gulec 4")]
die=Die.new
game = Game.new (players)
until game.over?
players.each do |player|
puts "#{player.name}, your turn.\n\n"
turn= Turn.new(player)
until turn.over?
turn.roll(die)
puts "You rolled a #{die.roll}."
unless turn.over?
puts "So far this turn, you have #{turn.points} points."
puts "Press 'h' to hold or any other key to roll again.\n\n"
player_choice = gets.chomp
turn.hold if player_choice == 'h'
end
end
player.add_points(turn.points)
puts "You got #{turn.points} points this turn."
puts "You have #{player.points} points total.\n\n\n"
puts "fafadsfdsgfdsfs"
puts "fafadsfdsgfdsfs"
puts "fafadsfdsgfdsfs"
end
end
puts "Congratulations, #{game.winner.name}. You win!"