mirror of
https://github.com/danbee/scoreboard
synced 2025-03-04 08:59:11 +00:00
33 lines
395 B
Ruby
33 lines
395 B
Ruby
class Player
|
|
attr_reader :score, :games
|
|
|
|
def initialize
|
|
@score = 0
|
|
@games = 0
|
|
end
|
|
|
|
def has_beaten(player)
|
|
@score > 10 && @score > player.score + 1
|
|
end
|
|
|
|
def add_point
|
|
@score += 1
|
|
end
|
|
|
|
def add_game
|
|
@games += 1
|
|
end
|
|
|
|
def undo_point
|
|
@score -= 1
|
|
end
|
|
|
|
def reset_score
|
|
@score = 0
|
|
end
|
|
|
|
def attributes
|
|
{ score: @score, games: @games }
|
|
end
|
|
end
|