tobi-mastermind 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,137 +1,137 @@
1
- --- !ruby/object:Player
2
- name: tobiloba
3
- sequence:
4
- - b
5
- - g
6
- - r
7
- - y
8
- time: 5
9
- guesses: 1
10
- --- !ruby/object:Player
11
- name: tben
12
- sequence:
13
- - r
14
- - r
15
- - y
16
- - y
17
- - g
18
- time: 13
19
- guesses: 1
20
- --- !ruby/object:Player
21
- name: tobi2
22
- sequence:
23
- - y
24
- - b
25
- - r
26
- - g
27
- - y
28
- time: 7
29
- guesses: 1
30
- --- !ruby/object:Player
31
- name: tobi3
32
- sequence:
33
- - y
34
- - g
35
- - g
36
- - y
37
- time: 3
38
- guesses: 1
39
- --- !ruby/object:Player
40
- name: tobi4
41
- sequence:
42
- - r
43
- - y
44
- - y
45
- - y
46
- time: 5
47
- guesses: 1
48
- --- !ruby/object:Player
49
- name: tbaba
50
- sequence:
51
- - r
52
- - r
53
- - g
54
- - y
55
- time: 3
56
- guesses: 1
57
- --- !ruby/object:Player
58
- name: tboss
59
- sequence:
60
- - b
61
- - y
62
- - g
63
- - b
64
- time: 15
65
- guesses: 1
66
- --- !ruby/object:Player
67
- name: madara
68
- sequence:
69
- - r
70
- - r
71
- - b
72
- - y
73
- time: 27
74
- guesses: 1
75
- --- !ruby/object:Player
76
- name: 7jsdf
77
- sequence:
78
- - b
79
- - g
80
- - b
81
- - r
82
- time: 3
83
- guesses: 1
84
- --- !ruby/object:Player
85
- name: asdf
86
- sequence:
87
- - y
88
- - r
89
- - b
90
- - b
91
- time: 4
92
- guesses: 1
93
- --- !ruby/object:Player
94
- name: babatee
95
- sequence:
96
- - g
97
- - g
98
- - b
99
- - r
100
- time: 2
101
- guesses: 1
102
- --- !ruby/object:Player
103
- name: Tbff
104
- sequence:
105
- - r
106
- - g
107
- - y
108
- - b
109
- time: 74
110
- guesses: 2
111
- --- !ruby/object:Player
112
- name: Toisdaf
113
- sequence:
114
- - r
115
- - g
116
- - y
117
- - b
118
- time: 8
119
- guesses: 2
120
- --- !ruby/object:Player
121
- name: Yuo
122
- sequence:
123
- - r
124
- - g
125
- - y
126
- - b
127
- time: 9
128
- guesses: 2
129
- --- !ruby/object:Player
130
- name: Ttiosd
131
- sequence:
132
- - r
133
- - g
134
- - y
135
- - b
136
- time: 24
137
- guesses: 2
1
+ --- !ruby/object:Player
2
+ name: tobiloba
3
+ sequence:
4
+ - b
5
+ - g
6
+ - r
7
+ - y
8
+ time: 5
9
+ guesses: 1
10
+ --- !ruby/object:Player
11
+ name: tben
12
+ sequence:
13
+ - r
14
+ - r
15
+ - y
16
+ - y
17
+ - g
18
+ time: 13
19
+ guesses: 1
20
+ --- !ruby/object:Player
21
+ name: tobi2
22
+ sequence:
23
+ - y
24
+ - b
25
+ - r
26
+ - g
27
+ - y
28
+ time: 7
29
+ guesses: 1
30
+ --- !ruby/object:Player
31
+ name: tobi3
32
+ sequence:
33
+ - y
34
+ - g
35
+ - g
36
+ - y
37
+ time: 3
38
+ guesses: 1
39
+ --- !ruby/object:Player
40
+ name: tobi4
41
+ sequence:
42
+ - r
43
+ - y
44
+ - y
45
+ - y
46
+ time: 5
47
+ guesses: 1
48
+ --- !ruby/object:Player
49
+ name: tbaba
50
+ sequence:
51
+ - r
52
+ - r
53
+ - g
54
+ - y
55
+ time: 3
56
+ guesses: 1
57
+ --- !ruby/object:Player
58
+ name: tboss
59
+ sequence:
60
+ - b
61
+ - y
62
+ - g
63
+ - b
64
+ time: 15
65
+ guesses: 1
66
+ --- !ruby/object:Player
67
+ name: madara
68
+ sequence:
69
+ - r
70
+ - r
71
+ - b
72
+ - y
73
+ time: 27
74
+ guesses: 1
75
+ --- !ruby/object:Player
76
+ name: 7jsdf
77
+ sequence:
78
+ - b
79
+ - g
80
+ - b
81
+ - r
82
+ time: 3
83
+ guesses: 1
84
+ --- !ruby/object:Player
85
+ name: asdf
86
+ sequence:
87
+ - y
88
+ - r
89
+ - b
90
+ - b
91
+ time: 4
92
+ guesses: 1
93
+ --- !ruby/object:Player
94
+ name: babatee
95
+ sequence:
96
+ - g
97
+ - g
98
+ - b
99
+ - r
100
+ time: 2
101
+ guesses: 1
102
+ --- !ruby/object:Player
103
+ name: Tbff
104
+ sequence:
105
+ - r
106
+ - g
107
+ - y
108
+ - b
109
+ time: 74
110
+ guesses: 2
111
+ --- !ruby/object:Player
112
+ name: Toisdaf
113
+ sequence:
114
+ - r
115
+ - g
116
+ - y
117
+ - b
118
+ time: 8
119
+ guesses: 2
120
+ --- !ruby/object:Player
121
+ name: Yuo
122
+ sequence:
123
+ - r
124
+ - g
125
+ - y
126
+ - b
127
+ time: 9
128
+ guesses: 2
129
+ --- !ruby/object:Player
130
+ name: Ttiosd
131
+ sequence:
132
+ - r
133
+ - g
134
+ - y
135
+ - b
136
+ time: 24
137
+ guesses: 2
@@ -1,31 +1,39 @@
1
- module MasterMind
2
- module Tobi
3
- module TimeHelper
4
- def time_convert(time_int)
5
- hours = time_int / 3600
6
- minutes = (time_int % 3600) / 60
7
- seconds = (time_int % 3600) % 60
8
- time_string = construct_string(hours, minutes, seconds)
9
- end
10
-
11
- def construct_string(hours, minutes, seconds)
12
- time_string = ''
13
- if hours >= 1
14
- time_string << (hours.to_s + (time == 1 ? ' hour' :' hours'))
15
- time_string << ', ' if minutes > 0
16
- end
17
-
18
- if minutes >= 1
19
- time_string << (minutes.to_s + (minutes == 1 ? ' minute' : ' minutes'))
20
- time_string << ', ' if seconds > 0
21
- end
22
-
23
- if seconds >= 1
24
- time_string << (seconds.to_s + (seconds == 1 ? ' second' : ' seconds'))
25
- elsif seconds == 0 && time_string == ''
26
- time_string << '0 seconds'
27
- end
28
- end
29
- end
30
- end
1
+ module MasterMind
2
+ module Tobi
3
+ module TimeHelper
4
+ SINGULAR = [' hour', ' minute', ' second']
5
+ PLURAL = [' hours', ' minutes', ' seconds']
6
+ def time_convert(time_int)
7
+ hours = time_int / 3600
8
+ minutes = (time_int % 3600) / 60
9
+ seconds = (time_int % 3600) % 60
10
+ time_string = construct_string(hours, minutes, seconds)
11
+ end
12
+
13
+ def construct_string(hours, minutes, seconds)
14
+ time_string = ''
15
+ time_string = hour_minute_helper(hours, minutes, time_string, 0)
16
+ time_string = hour_minute_helper(minutes, seconds, time_string, 1)
17
+ time_string = second_helper(seconds, time_string)
18
+ time_string
19
+ end
20
+
21
+ def hour_minute_helper(greater, lesser, time_string, position)
22
+ if greater >= 1
23
+ time_string << (greater.to_s + (greater == 1 ? SINGULAR[position] : PLURAL[position]))
24
+ time_string << ', ' if lesser > 0
25
+ end
26
+ time_string
27
+ end
28
+
29
+ def second_helper(seconds, time_string)
30
+ if seconds >= 1
31
+ time_string << (seconds.to_s + (seconds == 1 ? ' second' : ' seconds'))
32
+ elsif seconds == 0 && time_string == ''
33
+ time_string << '0 seconds'
34
+ end
35
+ time_string
36
+ end
37
+ end
38
+ end
31
39
  end
@@ -1,71 +1,71 @@
1
- module MasterMind
2
- module Tobi
3
- module UI
4
-
5
- GUESS_MAX = 12
6
-
7
- WELCOME_MESSAGE = "\nWelcome to the Classy MasterMind game by Tobi\n"
8
-
9
- INPUT_PROMPT = "\n>> "
10
-
11
- OPTIONS_MESSAGE = "\nWould you like to (p)lay, (r)ead the instructions or (quit) ?"
12
-
13
- HELP_MESSAGE = "\nOnce game starts, a random code is generated and you're asked to guess what the code is.
14
- Every code is a four/five/six digit word made up by the letters [r, g, b, y]/[r, g, b, y, o]/[r, g, b, y, o, v]
15
- depending on difficulty levels beginner/intermediate/advanced levels. You have twelve guesses per game.
16
- On every guess, you are presented with a message identifying the number of elements you got correctly, and in what positions.
17
- To view entry history, enter h or history at any time
18
- To view sequence generated, enter c or cheat at any time
19
- To quit the game at any point enter q or quit\n\n"
20
-
21
- BEGINNER_COLOR = "(r)ed, (g)reen, (b)lue and (y)ellow"
22
-
23
- INTERMEDIATE_COLOR = "(r)ed, (g)reen, (b)lue, (y)ellow, and (o)range"
24
-
25
- ADVANCED_COLOR = "(r)ed, (g)reen, (b)lue, (y)ellow, (o)range and (v)iolet"
26
-
27
- COLOR_STRINGS = [BEGINNER_COLOR, INTERMEDIATE_COLOR, ADVANCED_COLOR]
28
-
29
- GENERATE_MESSAGE = "\nI have generated %s sequence with %s elements made \
30
- up of: %s\nUse (q)uit at any time to end the game. \nWhat's your guess?"
31
-
32
- INVALID_MESSAGE = "\nEntry invalid! Please try again" + INPUT_PROMPT
33
-
34
- INPUT_SHORT_MESSAGE = "Input too short. Please enter guess correctly" + INPUT_PROMPT
35
-
36
- INPUT_LONG_MESSAGE = "Input too long. Please enter guess correctly." + INPUT_PROMPT
37
-
38
- SEQUENCE_MESSAGE = "The sequence is %s" + INPUT_PROMPT
39
-
40
- CONGRATS_MESSAGE = "\n%s, You guessed the sequence '%s' in %s %s over %s"
41
-
42
- INFO_MESSAGE = "'%s' has %s of the correct elements with %s in the correct positions."
43
-
44
- END_MESSAGE = "Do you want to (p)lay again or (q)uit?"
45
-
46
- GUESSES_MESSAGE = "You've taken %s %s"
47
-
48
- LEVEL_MESSAGE = "\nDifficulty level: (b)eginner, (i)ntermediate or (a)dvanced? " + INPUT_PROMPT
49
-
50
- NAME_MESSAGE = "\nCongratulations! You've guessed the sequence! What's your name?" + INPUT_PROMPT
51
-
52
- DB_STORE = 'store.yaml'
53
-
54
- TOP_TEN = '=== TOP TEN ==='
55
-
56
- OVERWRITE_MESSAGE = 'Data file already exists. Do you want to add your score to top scores? (y)es or (n)o..'
57
-
58
- MODE_SELECT = "\nPlease choose mode >>> (s)ingle or (m)ulti player mode?" + INPUT_PROMPT
59
-
60
- MULTI_START_MESSAGE = "Welcome to the MultiPlayer Challenge. How many users will be playing today?" + INPUT_PROMPT
61
-
62
- PLAYER_MESSAGE = "********Player %s's turn" + INPUT_PROMPT
63
-
64
- SORRY_SINGLE_MESSAGE = "Sorry, You lost. The sequence is %s"
65
-
66
- SORRY_MULTI_MESSAGE = "Sorry, You all lost. The sequence is %s"
67
-
68
- PASSWORD_MESSAGE = "\nWould you like to hide each player's guesses? (y)es or (n)o ?" + INPUT_PROMPT
69
- end
70
- end
1
+ module MasterMind
2
+ module Tobi
3
+ module UI
4
+
5
+ GUESS_MAX = 12
6
+
7
+ WELCOME_MESSAGE = "\nWelcome to the Classy MasterMind game by Tobi\n"
8
+
9
+ INPUT_PROMPT = "\n>> "
10
+
11
+ OPTIONS_MESSAGE = "\nWould you like to (p)lay, (r)ead the instructions or (quit) ?"
12
+
13
+ HELP_MESSAGE = "\nOnce game starts, a random code is generated and you're asked to guess what the code is.
14
+ Every code is a four/five/six digit word made up by the letters [r, g, b, y]/[r, g, b, y, o]/[r, g, b, y, o, v]
15
+ depending on difficulty levels beginner/intermediate/advanced levels. You have twelve guesses per game.
16
+ On every guess, you are presented with a message identifying the number of elements you got correctly, and in what positions.
17
+ To view entry history, enter h or history at any time
18
+ To view sequence generated, enter c or cheat at any time
19
+ To quit the game at any point enter q or quit\n\n"
20
+
21
+ BEGINNER_COLOR = "(r)ed, (g)reen, (b)lue and (y)ellow"
22
+
23
+ INTERMEDIATE_COLOR = "(r)ed, (g)reen, (b)lue, (y)ellow, and (o)range"
24
+
25
+ ADVANCED_COLOR = "(r)ed, (g)reen, (b)lue, (y)ellow, (o)range and (v)iolet"
26
+
27
+ COLOR_STRINGS = [BEGINNER_COLOR, INTERMEDIATE_COLOR, ADVANCED_COLOR]
28
+
29
+ GENERATE_MESSAGE = "\nI have generated %s sequence with %s elements made \
30
+ up of: %s\nUse (q)uit at any time to end the game. \nWhat's your guess?"
31
+
32
+ INVALID_MESSAGE = "\nEntry invalid! Please try again" + INPUT_PROMPT
33
+
34
+ INPUT_SHORT_MESSAGE = "Input too short. Please enter guess correctly" + INPUT_PROMPT
35
+
36
+ INPUT_LONG_MESSAGE = "Input too long. Please enter guess correctly." + INPUT_PROMPT
37
+
38
+ SEQUENCE_MESSAGE = "The sequence is %s" + INPUT_PROMPT
39
+
40
+ CONGRATS_MESSAGE = "\n%s, You guessed the sequence '%s' in %s %s over %s"
41
+
42
+ INFO_MESSAGE = "'%s' has %s of the correct elements with %s in the correct positions."
43
+
44
+ END_MESSAGE = "Do you want to (p)lay again or (q)uit?"
45
+
46
+ GUESSES_MESSAGE = "You've taken %s %s"
47
+
48
+ LEVEL_MESSAGE = "\nDifficulty level: (b)eginner, (i)ntermediate or (a)dvanced? " + INPUT_PROMPT
49
+
50
+ NAME_MESSAGE = "\nCongratulations! You've guessed the sequence! What's your name?" + INPUT_PROMPT
51
+
52
+ DB_STORE = 'store.yaml'
53
+
54
+ TOP_TEN = '=== TOP TEN ==='
55
+
56
+ OVERWRITE_MESSAGE = 'Data file already exists. Do you want to add your score to top scores? (y)es or (n)o..'
57
+
58
+ MODE_SELECT = "\nPlease choose mode >>> (s)ingle or (m)ulti player mode?" + INPUT_PROMPT
59
+
60
+ MULTI_START_MESSAGE = "Welcome to the MultiPlayer Challenge. How many users will be playing today?" + INPUT_PROMPT
61
+
62
+ PLAYER_MESSAGE = "********Player %s's turn" + INPUT_PROMPT
63
+
64
+ SORRY_SINGLE_MESSAGE = "Sorry, You lost. The sequence is %s"
65
+
66
+ SORRY_MULTI_MESSAGE = "Sorry, You all lost. The sequence is %s"
67
+
68
+ PASSWORD_MESSAGE = "\nWould you like to hide each player's guesses? (y)es or (n)o ?" + INPUT_PROMPT
69
+ end
70
+ end
71
71
  end