lib/mastermind/game.rb in mastermind-game-0.0.1 vs lib/mastermind/game.rb in mastermind-game-0.0.2
- old
+ new
@@ -1,11 +1,11 @@
module Mastermind
class Game
attr_reader :turns, :codemaker, :codebreaker, :max_attempts
def initialize(secret: nil, codemaker: nil, codebreaker: nil)
- @secret = (secret && Code.from(secret)) || Code.random
+ @secret = secret || Code.random
@turns = []
@codemaker = codemaker || Player.new(name: "AbstractCodemaker")
@codebreaker = codebreaker || Player.new(name: "AbstractCodebreaker")
@max_attempts = 12
end
@@ -16,11 +16,10 @@
def secret_length
@secret.length
end
- def guess(guess_sequence)
- code = Code.from(guess_sequence)
+ def guess(code)
@turns << Turn.new(
guess: code, number: attempts + 1,
exact: @secret.exact_matches_with(code),
partial: @secret.partial_matches_with(code)
)