mastermind-scott 1.0.3 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/game.rb +30 -15
- data/lib/game_prompts.rb +15 -13
- data/lib/table.rb +1 -1
- data/mastermind-scott.gemspec +2 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97de0bdd2f5f54df55087874472037230ccd7b3c
|
4
|
+
data.tar.gz: f9511f74f739dc58abd105af0fa380d089964cfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b41c25e72b070b83a456311a91af85ed645aaa0df171dd62492108f6047303dc1a5f51258460434c64e268485c64b5a3bbf7ec42272f4c27ba34fe87ea90a8b2
|
7
|
+
data.tar.gz: 2b7592f0ce1e1e1acbc4440fedc3d77d8d773648ddff383f1d6534e6e6a28a8782f67b859abca0fd1209e93add428b24efb1926b83d013598c8f3b51272f5420
|
data/lib/game.rb
CHANGED
@@ -44,23 +44,39 @@ class Game
|
|
44
44
|
private
|
45
45
|
|
46
46
|
def turn_evaluation
|
47
|
+
turn_visuals
|
48
|
+
case
|
49
|
+
when quit? then abort(messages.quit)
|
50
|
+
when win? then you_win
|
51
|
+
when !valid_size? || !valid_letters? then invalid
|
52
|
+
when lose? then you_lose
|
53
|
+
else turn_validate
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def invalid
|
58
|
+
output.puts messages.guess_again
|
59
|
+
@guess_count -= 1
|
60
|
+
end
|
61
|
+
|
62
|
+
def you_lose
|
63
|
+
output.puts messages.lose
|
64
|
+
end
|
65
|
+
|
66
|
+
def turn_validate
|
67
|
+
validator
|
68
|
+
output.puts messages.after_guess(command, number_correct, position_right)
|
69
|
+
output.puts messages.guess_count(guess_count)
|
70
|
+
end
|
71
|
+
|
72
|
+
def you_win
|
73
|
+
output.puts messages.winner(answer, guess_count, minutes, seconds)
|
74
|
+
end
|
75
|
+
|
76
|
+
def turn_visuals
|
47
77
|
output.puts messages.mastermind_logo
|
48
78
|
table_update
|
49
79
|
output.puts table.show
|
50
|
-
case
|
51
|
-
when quit?
|
52
|
-
abort(messages.quit)
|
53
|
-
when win?
|
54
|
-
output.puts messages.winner(answer, guess_count, minutes, seconds)
|
55
|
-
when !valid_size? || !valid_letters?
|
56
|
-
output.puts messages.guess_again
|
57
|
-
@guess_count -= 1
|
58
|
-
when lose?
|
59
|
-
output.puts messages.lose
|
60
|
-
else validator
|
61
|
-
output.puts messages.after_guess(command, number_correct, position_right)
|
62
|
-
output.puts messages.guess_count(guess_count)
|
63
|
-
end
|
64
80
|
end
|
65
81
|
|
66
82
|
def guess_counter
|
@@ -79,7 +95,6 @@ private
|
|
79
95
|
total_time / 60
|
80
96
|
end
|
81
97
|
|
82
|
-
|
83
98
|
def total_time
|
84
99
|
(end_time - @start_time).to_i
|
85
100
|
end
|
data/lib/game_prompts.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
|
1
3
|
class GamePrompts
|
2
4
|
attr_reader :intro_message # => nil
|
3
5
|
|
4
6
|
def intro_message
|
5
7
|
%x( say "so check me out")
|
6
|
-
"Welcome to MASTERMIND\n"+
|
7
|
-
"Would you like to (p)lay, read the (i)nstructions, or (q)uit?"
|
8
|
+
"Welcome to MASTERMIND\n".green +
|
9
|
+
"Would you like to (p)lay, read the (i)nstructions, or (q)uit?".light_blue
|
8
10
|
end
|
9
11
|
|
10
12
|
def lose
|
11
|
-
"Nice try you
|
13
|
+
"Nice try you " + "DUMMY. ".blue.bold + play_again
|
12
14
|
end
|
13
15
|
|
14
16
|
def winner(answer, guess_count, minutes, seconds)
|
@@ -16,7 +18,7 @@ class GamePrompts
|
|
16
18
|
end
|
17
19
|
|
18
20
|
def game_start
|
19
|
-
"I have generated a beginner sequence with four elements made up of
|
21
|
+
"I have generated a beginner sequence with four elements made up of:\n" + "(r)".red + "ed, " + "(g)".green + "reen, " + "(b)".light_blue + "lue, " + "and " +"(y)".yellow + "ellow.\n Use (q)uit at any time to end the game."
|
20
22
|
end
|
21
23
|
|
22
24
|
def mastermind_logo
|
@@ -28,7 +30,7 @@ class GamePrompts
|
|
28
30
|
| '_ ` _ \ / _` / __| __/ _ \ '__| '_ ` _ \| | '_ \ / _` |
|
29
31
|
| | | | | | (_| \__ \ || __/ | | | | | | | | | | | (_| |
|
30
32
|
|_| |_| |_|\__,_|___/\__\___|_| |_| |_| |_|_|_| |_|\__,_|
|
31
|
-
}
|
33
|
+
}.cyan
|
32
34
|
|
33
35
|
end
|
34
36
|
|
@@ -37,7 +39,7 @@ class GamePrompts
|
|
37
39
|
end
|
38
40
|
|
39
41
|
def player_input
|
40
|
-
"Enter Choice: "
|
42
|
+
"Enter Choice: ".yellow
|
41
43
|
end
|
42
44
|
|
43
45
|
def instructions
|
@@ -45,31 +47,31 @@ class GamePrompts
|
|
45
47
|
end
|
46
48
|
|
47
49
|
def quit
|
48
|
-
"Your father was right about you, you are a quitter."
|
50
|
+
"Your father was right about you, you are a quitter.".red
|
49
51
|
end
|
50
52
|
|
51
53
|
def invalid
|
52
|
-
"Your argument is invalid. Try again."
|
54
|
+
"Your argument is invalid. Try again.".red
|
53
55
|
end
|
54
56
|
|
55
57
|
def guess_prompt
|
56
|
-
"Take your guess: "
|
58
|
+
"Take your guess: ".yellow
|
57
59
|
end
|
58
60
|
|
59
61
|
def guess_again
|
60
|
-
"The guess must only be 4 colors and either r, g, b, or y."
|
62
|
+
"The guess must only be 4 colors and either" +" r, ".red + "g, ".green + "b, ".light_blue + "or y.".yellow
|
61
63
|
end
|
62
64
|
|
63
65
|
def guess_count(guess_count)
|
64
66
|
if guess_count == 1
|
65
|
-
"You have taken #{guess_count} guess."
|
67
|
+
"You have taken" + " #{guess_count}".red + " guess."
|
66
68
|
else
|
67
|
-
"You have taken #{guess_count} guesses."
|
69
|
+
"You have taken " + " #{guess_count}".red + " guesses."
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|
71
73
|
def after_guess(guess,number_correct, position_right)
|
72
|
-
"Your guess '#{guess.upcase}' has #{number_correct} correct colors with #{position_right} in the correct position."
|
74
|
+
"Your guess " + "'#{guess.upcase}'".magenta + " has " + "#{number_correct}".magenta + " correct colors with " + "#{position_right}".magenta + " in the correct position."
|
73
75
|
end
|
74
76
|
|
75
77
|
def play_again
|
data/lib/table.rb
CHANGED
data/mastermind-scott.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'mastermind-scott'
|
3
|
-
s.version = '
|
3
|
+
s.version = '2.0.3'
|
4
4
|
s.date = '2014-11-12'
|
5
5
|
s.summary = "Try to guess the secret code."
|
6
6
|
s.description = "The Mastermind Game"
|
@@ -19,4 +19,5 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables << 'mastermind-scott'
|
20
20
|
|
21
21
|
s.add_runtime_dependency 'terminal-table', '~> 1.4.5', '>= 1.4.5'
|
22
|
+
s.add_runtime_dependency 'colorize', '>= 0.7.3'
|
22
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mastermind-scott
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Crawford
|
@@ -30,6 +30,20 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 1.4.5
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: colorize
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.7.3
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.7.3
|
33
47
|
description: The Mastermind Game
|
34
48
|
email: scottcrawford03@gmail.com
|
35
49
|
executables:
|