class GamalielPelino::Game

Public Class Methods

new(playlist) click to toggle source
# File lib/GamalielPelino/Agam11_split2.rb, line 27
def initialize(playlist)
    @playlist = playlist
    @players = []
end

Public Instance Methods

add_player(player) click to toggle source
# File lib/GamalielPelino/Agam11_split2.rb, line 32
def add_player(player)
    @players << player
end
call_items() click to toggle source
# File lib/GamalielPelino/Agam11_split2.rb, line 104
def call_items
    items = Item::PIECE
    puts "\n There are #{items.size} treasure to be found:"
    
    items.each do |call|
        puts "A #{call.item} is worth #{call.points} points"
    end

end
load_players(default_player_file) click to toggle source
# File lib/GamalielPelino/Agam11_split2.rb, line 52
def load_players(default_player_file)
    File.readlines(default_player_file).each do |line|
        add_player(Player.from_csv(line))
    end
end
play(rounds) click to toggle source
# File lib/GamalielPelino/Agam11_split2.rb, line 36
def play(rounds)
    puts "There are #{@players.size} players in #{@playlist}:"
    
    @players.each do |player|
        puts player
    end
    1.upto(rounds) do |count|
        puts "\n rounds #{count}"
        @players.each do |player|
            GameTurn.take_turn(player)   
            puts player
        end
        
    end    
end
print_stats() click to toggle source

def save_high_scores(to_file=“Agam19_save.csv”)

File.open(to_file, "w") do |file|
  file.puts "#{@title} High Scores:"
  @players.sort.each do |player|
        file.puts player.to_csv
  end
end

end

title() click to toggle source
# File lib/GamalielPelino/Agam11_split2.rb, line 100
def title
    "==#{@playlist}=="
end