games_bfox 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff3dcb410111396a3ce03ef859fb52d70a5b5d5d
4
- data.tar.gz: 269d8193da9129cf52efd370764abc318d376de6
3
+ metadata.gz: eea4457891bd6031147b650c010445ea236d8e74
4
+ data.tar.gz: d37e19b5a8627b9d6b4c7cd5f2214c1c726f8d85
5
5
  SHA512:
6
- metadata.gz: cabca83cb240420badc2e59c271f6ef5de2c9ac9b2825fedbf65ef2f20d14b14f3ac9a9593e709381bdb55a2f38c86217b65134aa3d7eb36856e566b046f0f73
7
- data.tar.gz: 648ab711ef30fc5ba0f7b9bc3fdb082bfbc761e4e03c9cf67f90c9ef5504533042bf3774d121d93592402cbd348ff6984fdea9851d996d2dbc84346a23ca1d74
6
+ metadata.gz: 9a19f97734b8a705a775424c3d18d52aa7174c379bf89061fd83e92cc2311a355b7650257712fa33f2b96c9751053e79e86b96ce5c52cd506a07921a5b520777
7
+ data.tar.gz: 97764dfed555860fae880c91bfe2cf73ff2ca6448bf86e85018097329f2cefc9003cacae4a04be1da8104d4f758d1dfa6686d71bbf6fe1f1accb96ca8919ea34
@@ -1,4 +1,5 @@
1
1
  require_relative '../shared/game'
2
+ require 'logger'
2
3
 
3
4
  module MM
4
5
  class Game < Shared::Game
@@ -7,8 +8,9 @@ module MM
7
8
  def local_setup
8
9
  self.code_setter = config.code_setter
9
10
  self.secret_code = config.secret_code
10
- print secret_code
11
- print "\n"
11
+ logger = Logger.new(STDOUT)
12
+ logger.level = Logger::DEBUG
13
+ logger.debug("The secret code is #{secret_code.join(",")}.")
12
14
  self.guess_evaluator = MM::GuessEvaluator.new
13
15
  self.current_guess = []
14
16
  self.current_result = []
@@ -31,6 +31,15 @@ module MM
31
31
  io.present_with_new_line("No such luck! Please try again.")
32
32
  end
33
33
 
34
+ def initial_instructions
35
+ io.present_with_new_line("MASTERMIND")
36
+ io.present_with_new_line("__________")
37
+ io.present_with_new_line("Game Instructions: Try to guess a 4 digit code that contains a collection of numbers 1-6 (\"6241\", for example).")
38
+ io.present_with_new_line("After each guess, the \"Result\" section will generate an \"X\" for each digit in the guess that is perfect(correct number and correct spot) and an \"O\" for each digit that is the correct number but in the wrong spot.")
39
+ io.present_with_new_line("Type \"Exit\" to quit the game.")
40
+ io.present_with_new_line("___________")
41
+ end
42
+
34
43
  def winning_prompt(current_player_name)
35
44
  io.present_with_new_line("#{current_player_name} wins!")
36
45
  end
@@ -39,6 +48,10 @@ module MM
39
48
  io.present_with_new_line("Game over!")
40
49
  end
41
50
 
51
+ def custom_final_message(game)
52
+ io.present_with_new_line("The secret code was #{game.secret_code.join(",")}")
53
+ end
54
+
42
55
  def get_number_of_rows
43
56
  get_user_input("Please choose how many rows of pegs you would like, from 4 to 12.", "Please choose a number between 4 and 12.") do |input|
44
57
  input.to_i >=4 && input.to_i <=12
@@ -34,6 +34,7 @@ module Shared
34
34
  end
35
35
 
36
36
  def every_time_setup
37
+ #setup gets necessary info from user and stores it in config object
37
38
  config.every_time_setup
38
39
  self.players = players_factory.generate_players(config)
39
40
  self.board = board_builder.generate_empty_board(config)
@@ -51,6 +52,7 @@ module Shared
51
52
  end
52
53
 
53
54
  def play
55
+ initial_instructions
54
56
  one_time_setup
55
57
  while true
56
58
  every_time_setup
@@ -67,6 +69,7 @@ module Shared
67
69
  winning_prompt
68
70
  elsif over_with_no_winner?
69
71
  no_winner_prompt
72
+ custom_final_message(self)
70
73
  end
71
74
 
72
75
  game_resetter.reset_game(self)
@@ -128,6 +131,10 @@ module Shared
128
131
  raise 'Called abstract method: won?'
129
132
  end
130
133
 
134
+ def custom_final_message(game)
135
+ input_helper.custom_final_message(game)
136
+ end
137
+
131
138
  def print_board
132
139
  board_presenter.present_board(board)
133
140
  end
@@ -140,8 +147,12 @@ module Shared
140
147
  (number_of_turns_taken % number_of_players)
141
148
  end
142
149
 
150
+ def initial_instructions
151
+ input_helper.initial_instructions
152
+ end
153
+
143
154
  def winning_prompt
144
- input_helper.winning_prompt(current_player.name)
155
+ input_helper.winning_prompt(current_player_name)
145
156
  end
146
157
 
147
158
  def no_winner_prompt
@@ -70,5 +70,9 @@ module Shared
70
70
  sleep(0.1)
71
71
  io.present(".")
72
72
  end
73
+
74
+ def custom_final_message(game)
75
+
76
+ end
73
77
  end
74
78
  end
@@ -65,6 +65,13 @@ module TTT
65
65
  end
66
66
  end
67
67
 
68
+ def initial_instructions
69
+ io.present_with_new_line("TIC TAC TOE")
70
+ io.present_with_new_line("___________")
71
+ io.present_with_new_line("Type \"Exit\" to quit the game.")
72
+ io.present_with_new_line("___________")
73
+ end
74
+
68
75
  def draw_prompt
69
76
  io.present_with_new_line("Draw! Please try again.")
70
77
  end
data/lib/games/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Games
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: games_bfox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Fox
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-16 00:00:00.000000000 Z
11
+ date: 2017-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler