Sha256: 9c36af377e12d3b79ab84611b8f55f6f8f589dbafd53d42722233c5c77ed94f5
Contents?: true
Size: 942 Bytes
Versions: 2
Compression:
Stored size: 942 Bytes
Contents
# frozen_string_literal: true module Wordle class Game def self.play new.play end def initialize @list = List.new @target_word = generate_word end # print letters that have already been used? # compare to real words def play winner = false attempts = 0 puts "Guess a 5 letter word: " while attempts < 6 && !winner guess = gets.chomp validator = GuessValidator.new(guess, @list) if validator.invalid? puts validator.error next end analyzer = GuessAnalyzer.new(@target_word, guess) puts analyzer.colors if analyzer.match? winner = true break end attempts += 1 end if winner puts "winner!" else puts "better luck next time!" end end private def generate_word @list.random end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wordle-0.1.1 | lib/wordle/game.rb |
wordle-0.1.0 | lib/wordle/game.rb |