class Codebreaker::Player
Attributes
attempts_total[RW]
attempts_used[RW]
date[RW]
difficulty[RW]
hints_total[RW]
hints_used[RW]
name[RW]
rating[RW]
Public Class Methods
new(name, difficulty)
click to toggle source
# File lib/codebraker_ov/entities/player.rb, line 14 def initialize(name, difficulty) @name = name @difficulty = difficulty @attempts_total = Game::DIFFICULTIES[difficulty][:attempts] @attempts_used = nil @hints_total = Game::DIFFICULTIES[difficulty][:hints] @hints_used = nil @rating = nil @date = nil end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/codebraker_ov/entities/player.rb, line 25 def <=>(other) [ -@attempts_total, @attempts_used, @hints_used ] <=> [ -other.attempts_total, other.attempts_used, other.hints_used ] end
save_score(attempts:, hints:)
click to toggle source
# File lib/codebraker_ov/entities/player.rb, line 37 def save_score(attempts:, hints:) @attempts_used = @attempts_total - attempts @hints_used = hints end