Sha256: 2e3aa4cbf68a1b067d389966ef7764d59edff28d9f897c119c054934b81a2bb7
Contents?: true
Size: 684 Bytes
Versions: 1
Compression:
Stored size: 684 Bytes
Contents
# frozen_string_literal: true module Codebreaker class Player def initialize(name, tries_left, hints_left) self.name = name @tries_left = tries_left @hints_left = hints_left end def formatted format('%10s %6i', @name, points) end def as_json { name: @name, points: points } end def to_json(*options) as_json.to_json(*options) end def points 100 * (@tries_left + 1) + 75 * @hints_left end private def name=(value) msg = 'The name must be between 1 and 10 characters long' raise(ArgumentError, msg) unless (1..10).cover?(value.length) @name = value end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ep-codebreaker-0.4.0 | lib/ep-codebreaker/player.rb |