Module: GreedGame

Defined in:
lib/greed_game.rb,
lib/greed_game/version.rb

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.nameObject



7
8
9
# File 'lib/greed_game.rb', line 7

def self.name
  "Greed Game"
end

Instance Method Details

#finishedObject



31
32
33
34
# File 'lib/greed_game.rb', line 31

def finished
  return "#{@winner[0].name} is winner" if @winner.count == 1
  "Winner is absent"
end

#in_progressObject



21
22
23
24
25
26
27
28
29
# File 'lib/greed_game.rb', line 21

def in_progress
  while  next_round?
    calculate_max_score
    @players.each do |player|
      player.roll(@dices)
    end
  end
  winner
end

#initialize(*names) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/greed_game.rb', line 11

def initialize(*names)
  raise "It should be 2 or more players in the game" if names.size < 2
  @dices = 5
  @max_score = 0
  @players = Array.new
  names.each do |name|
    @players << Player.new(name)
  end
end