play_hangman 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/play_hangman.rb +18 -5
  3. metadata +5 -5
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjQ5NTg2YWQxYTJhZTlhZGMwODRlMDdkZDA0YjRlY2Y5ODQ1MTlhNQ==
4
+ YWZkY2E1ZTA4OWRjMzIxYjMxMzdlM2E4MDdkMWUwZTliZWIzNzVhOA==
5
5
  data.tar.gz: !binary |-
6
- NWNmODdkNjA5ZmEzZmJhMGM4MTcyODhlNTY0NGM0NzM3ZDA4OGU3Zg==
6
+ ZDgxYWM1MDRlZDQ5MjdmN2E0OTRmOGI2ZWVkMzU3MDQ2MGIzNDQwZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTJkN2ZjMmRiMDUyNjlkZDJkNDBkZTM0NDYzY2U4NDljNjhhOTkwYTMzZmQ5
10
- MmM5MzUyNmMwOWVmMjc2NmJjYmU2MGJjNzJhM2Y3YTVkYTIzZDVmOTZlMGZj
11
- YTdkMjEyZTgxZmQ4NWYwZjY0YzA1NDVlMGFmMDYwZjUyZjAzMDE=
9
+ YTFmNDRiYTQxNDBjY2JkY2UxMmFiZWEzZmU4ODZhZTk2N2NmNTUzOTYyOTZm
10
+ MDUwYzRmYzA4NWQ0NDc0ODcwMTQ2NmY5NzQyYTY4YjVmMTA3OTA0NzEwZGQ3
11
+ MWE4ZjI2NDIxOTcxY2M5MDI4ZmJmYjQxNjA3YjYyN2EyZmVmN2E=
12
12
  data.tar.gz: !binary |-
13
- NWRjZWQzNmQ0MzY4ZWUyZjQzYTc3M2M2ODcxNjlmZWUyYjU5MjljYWJhOTk2
14
- NGU5Nzc2N2M5NWVhZTZjNTE4ZmRjZjRmMzYwM2FmZTIzZDJhNmY4M2E3MDIz
15
- YjAwMjZjZTUyYTg0MTM5NmJjYjNjNWU4NjVjZGM2NmQwYmI5ZmU=
13
+ YTc2MDY5ZDRjOGQyN2Q3N2ViM2YxMmMyY2RmNWMwMzRmM2NlYmJmOGEyZjA3
14
+ M2I1Y2QwNDY4ZjU5YjllOGQ1ZTM2MDg4ZmYyNWI4OTkwMzQyZTllMGY5MDdl
15
+ NTE5MjNmMDU3ZTQyNGQ3Nzk1ZjY2ZGVlMWVkNjI0N2Y4MDZhOTc=
@@ -4,19 +4,31 @@
4
4
  # Ready to play console version of HANGMAN built using 'hangman_engine' gem
5
5
  #
6
6
  # --------------------------------------------------------------------------
7
+
8
+ # General requires
7
9
  require 'rbconfig'
8
- require 'win32console' if (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
9
10
  require 'hangman_engine'
10
11
  require 'console_view_helper'
11
12
  include ConsoleViewHelper
12
13
 
14
+ # Windows requires
15
+ if (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
16
+ begin
17
+ require 'win32console'
18
+ rescue LoadError
19
+ error_msg = nl + banner('ERROR', subtitle: "win32console gem is missing") + nl
20
+ error_msg << "To solve this error install win32console gem. Just run: 'gem install win32console'."
21
+ abort error_msg
22
+ end
23
+ end
24
+
13
25
  # --- Helper Methods
14
26
  def display_notice(notice)
15
27
  putsi(colorize(notice[:msg], notice[:status]) + nl(2)) if notice[:msg]
16
28
  end
17
29
 
18
30
  def display_game_banner(base_width, base_idt)
19
- puts nl(2) + banner('HANGMAN GAME', subtitle: 'by Alfonso Mancilla', width: base_width, indent: base_idt) + nl(2)
31
+ puts nl + banner('HANGMAN GAME', subtitle: 'by Alfonso Mancilla', width: base_width, indent: base_idt) + nl
20
32
  end
21
33
 
22
34
  def display_game_board(hangman_game, base_width, base_idt, notice = {})
@@ -102,11 +114,12 @@ while keep_playing == 'y'
102
114
  puts nl
103
115
  else
104
116
  display_lost(base_width)
105
- puts nl(3)
106
- putsi align("Sol.: #{hangman_game.word}", base_width, :center) + nl(2)
117
+ puts nl(2)
118
+ putsi align("Answer: #{hangman_game.word}", base_width, :center) + nl(2)
107
119
  end
108
120
  putsi underscore * base_width + nl(3)
109
121
 
110
122
  # Play again?
111
123
  keep_playing = input('New game? (y/n):', 1)[0].downcase
112
- end
124
+ end
125
+ cls
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: play_hangman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alfonso Mancilla
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-12 00:00:00.000000000 Z
11
+ date: 2015-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: console_view_helper
@@ -38,11 +38,11 @@ dependencies:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.0.1
41
- description: ! 'Play HANGMAN on your console! Install, run the command ''play_hangman''
41
+ description: ! 'Play Hangman on your console! Install, run the command ''play_hangman''
42
42
  and enjoy.
43
43
 
44
44
  This game was built using the ''hangman_engine'' gem. Check it out to build your
45
- own HANGMAN version.'
45
+ own Hangman game.'
46
46
  email:
47
47
  - almancill@gmail.com
48
48
  executables:
@@ -75,6 +75,6 @@ rubyforge_project:
75
75
  rubygems_version: 2.4.5
76
76
  signing_key:
77
77
  specification_version: 4
78
- summary: Play HANGMAN on your console! Install, run the command 'play_hangman' and
78
+ summary: Play Hangman on your console! Install, run the command 'play_hangman' and
79
79
  enjoy.
80
80
  test_files: []