m0rse_c0de 0.3.3 → 0.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e31672b6070e62ff6794244d674916bf04059f632dcedf2aed9ed06b74219e7
4
- data.tar.gz: 0df60097fd9b77bdefcd771d84cf57eda02f21e8f6f9b5e8ef83861d91866b45
3
+ metadata.gz: 38e09f2a0a166f1402cc51456d679030145bd6422a8ec2b8fa3b08e6bfe6b682
4
+ data.tar.gz: 494b61d73f0ff7194a697f08985f42cece88605fcc4a0de312ce2bbfb2c8aba7
5
5
  SHA512:
6
- metadata.gz: 5828345b366f9cee511a53cb681203e76c693f3508e643e22044d2998d240337fb51da71b3f63823557836cb3a7473b1ac81ba1fcd5a70dbd6c6895f35bc1cf0
7
- data.tar.gz: b93e24cde7c618d41445b0263c18a6e4520b55edc8b86f09a2d8289d91bc9d9979a8d621b791d78f5d1863506a3c5a65f29c3620eff5954cd33a9ec2777dd1a1
6
+ metadata.gz: 3f1d986feedeeda5ee5db6408855d72b6b577c8a57be9bdcddef4e573e5f8f608b3f54b2bd9261c2e8fdcc30ee61b665c06ada1cc756b340ce3bb024b7b6ff40
7
+ data.tar.gz: 39e7f2e4e4a50b265fe998737352ee47615b6308358f825db01fc56b9e1aad32cf2c341834315a15ade6271e58658326c2953df424bf1fceec7e01414ddd2478
@@ -1,7 +1,10 @@
1
1
  require_relative './hashes/hashes.rb'
2
2
  require_relative './sound/sound.rb'
3
3
  require_relative './teacher/teacher.rb'
4
+ require_relative './teacher/hangman.rb'
4
5
 
6
+
7
+ include H4ngman
5
8
  include Translation
6
9
  include Te4cher
7
10
  include Beeper
@@ -0,0 +1,132 @@
1
+
2
+
3
+ module H4ngman
4
+
5
+ class Hangman
6
+ @hangman_sprite5 = '''
7
+ ---
8
+ |
9
+ ( )
10
+
11
+
12
+ '''
13
+ @hangman_sprite4 = '''
14
+ ---
15
+ |
16
+ ( )
17
+ I
18
+
19
+ '''
20
+
21
+ @hangman_sprite3 = '''
22
+ ---
23
+ |
24
+ ( )
25
+ -I
26
+
27
+ '''
28
+
29
+ @hangman_sprite2 = '''
30
+ ---
31
+ |
32
+ ( )
33
+ -I-
34
+
35
+ '''
36
+
37
+ @hangman_sprite1 = '''
38
+ ---
39
+ |
40
+ ( )
41
+ -I-
42
+ /
43
+
44
+ '''
45
+
46
+ @hangman_sprite0 = '''
47
+ ---
48
+ |
49
+ ( )
50
+ -I-
51
+ / \
52
+
53
+ '''
54
+
55
+ def self.finish
56
+ if @remaining_credits == 0
57
+ puts "GAME OVER, YOU LOSE :("
58
+ elsif
59
+ puts "YOU WON! CONGRATS"
60
+ end
61
+
62
+ puts "the word was #{Morse.text_to_morse(@keyword)}"
63
+
64
+ end
65
+
66
+ def self.choose_word(list_)
67
+ @keyword = list_.sample
68
+ puts "Your word has been selected!"
69
+ end
70
+
71
+ def self.generate_mystery_text
72
+ @mystery_text = ("?"*@keyword.length).split(//)
73
+ end
74
+
75
+ def self.handle_mystery_text
76
+ begin
77
+ @mystery_text = @mystery_text.split(//)
78
+ rescue
79
+ end
80
+ matching_indexes = @keyword.split(//).each_index.select { |i| @keyword[i] == @user_answer }
81
+ for index in matching_indexes
82
+ @mystery_text.delete_at index
83
+ @mystery_text.insert(index, @user_answer)
84
+ end
85
+ @mystery_text = @mystery_text.join()
86
+ end
87
+
88
+ def self.display
89
+ sprite_dict = {5 => @hangman_sprite5, 4 => @hangman_sprite4, 3 => @hangman_sprite3, 2 =>@hangman_sprite2, 1 =>@hangman_sprite1, 0 => @hangman_sprite0}
90
+ self.handle_mystery_text
91
+ puts @mystery_text
92
+ puts sprite_dict[@remaining_credits]
93
+ puts "You have #{@remaining_credits} tries left."
94
+ end
95
+
96
+ def self.main
97
+ self.generate_mystery_text
98
+ @correct_guesses = []
99
+ @remaining_credits = 6
100
+ while @remaining_credits != 0
101
+ print "Try to guess the word or a character that the word consists! (in morse) --> "
102
+ @user_answer = Morse.morse_to_text(gets.chomp.strip)
103
+ system('clear')
104
+ system('cls')
105
+
106
+ if @keyword.include?(@user_answer)
107
+ puts "#{Morse.text_to_morse(@user_answer)} is an accurate guess!"
108
+ if @user_answer == @keyword
109
+ break
110
+ else
111
+ @correct_guesses.append(@user_answer)
112
+ end
113
+
114
+ elsif not @keyword.include?(@user_answer) or @user_answer == ''
115
+ puts "#{Morse.text_to_morse(@user_answer)} isn't an accurate guess."
116
+ @remaining_credits = @remaining_credits - 1
117
+ end
118
+
119
+ self.display
120
+
121
+ end
122
+
123
+ self.finish
124
+
125
+ end
126
+
127
+ end
128
+
129
+ end
130
+
131
+
132
+
@@ -2,13 +2,13 @@
2
2
  module Te4cher
3
3
  class Teacher
4
4
 
5
- def self.start_practice
6
- @words = ['Ruby', 'Red', 'Awesome', 'Burzum', 'Help', 'Blood', 'Emergency', 'Death', 'Morse', 'SOS', 'SQL', 'Wreck', 'Ship', 'You', 'Us', 'America', 'Boat', 'Hello', 'Amazed', 'Python', 'Life', 'acme', 'antiseptically', 'boudoir', 'cesium', 'circumscribing', 'collegians', 'confessionals', 'erectly', 'finagler', 'hostelries', 'howdah', 'impetigo', 'lampposts', 'lisle', 'mestizos', 'overcooked', 'slippage', 'slouchiest', 'strumpet', 'terabyte', 'transfiguration', 'twill', 'undersold', 'unsheathed', 'whelps', 'adlumidine', 'alinasal', 'aramina', 'begreen', 'bembixes', 'boundly', 'cannibalean', 'chondrinous', 'colickiest', 'cullas', 'hartake', 'interchangings', 'marquito', 'miscegenationists', 'peremption', 'quesitive', 'ragnarok', 'reconciliated', 'sepsine', 'sickless', 'sigillaria', 'staphyledema', 'undelible', 'unruth', 'yaourti', 'avoid', 'bottle', 'briefly', 'bug', 'dedicated', 'establish', 'everything', 'goes', 'harm', 'inferior', 'killed', 'leader', 'noticed', 'quicker', 'recovered', 'reflects', 'retain', 'self', 'should', 'signal', 'simultaneously', 'stayed', 'tomorrow', 'virtue', 'weird', 'adlumidine', 'alinasal', 'aramina', 'begreen', 'bembixes', 'boundly', 'cannibalean', 'chondrinous', 'colickiest', 'cullas', 'hartake', 'interchangings', 'marquito', 'miscegenationists', 'peremption', 'quesitive', 'ragnarok', 'reconciliated', 'sepsine', 'sickless', 'sigillaria', 'staphyledema', 'undelible', 'unruth', 'yaourti'] #todo: complete
7
-
5
+ @word_list = ['Ruby', 'Red', 'Awesome', 'Burzum', 'Help', 'Blood', 'Emergency', 'Death', 'Morse', 'SOS', 'SQL', 'Wreck', 'Ship', 'You', 'Us', 'America', 'Boat', 'Hello', 'Amazed', 'Python', 'Life', 'acme', 'antiseptically', 'boudoir', 'cesium', 'circumscribing', 'collegians', 'confessionals', 'erectly', 'finagler', 'hostelries', 'howdah', 'impetigo', 'lampposts', 'lisle', 'mestizos', 'overcooked', 'slippage', 'slouchiest', 'strumpet', 'terabyte', 'transfiguration', 'twill', 'undersold', 'unsheathed', 'whelps', 'adlumidine', 'alinasal', 'aramina', 'begreen', 'bembixes', 'boundly', 'cannibalean', 'chondrinous', 'colickiest', 'cullas', 'hartake', 'interchangings', 'marquito', 'miscegenationists', 'peremption', 'quesitive', 'ragnarok', 'reconciliated', 'sepsine', 'sickless', 'sigillaria', 'staphyledema', 'undelible', 'unruth', 'yaourti', 'avoid', 'bottle', 'briefly', 'bug', 'dedicated', 'establish', 'everything', 'goes', 'harm', 'inferior', 'killed', 'leader', 'noticed', 'quicker', 'recovered', 'reflects', 'retain', 'self', 'should', 'signal', 'simultaneously', 'stayed', 'tomorrow', 'virtue', 'weird', 'adlumidine', 'alinasal', 'aramina', 'begreen', 'bembixes', 'boundly', 'cannibalean', 'chondrinous', 'colickiest', 'cullas', 'hartake', 'interchangings', 'marquito', 'miscegenationists', 'peremption', 'quesitive', 'ragnarok', 'reconciliated', 'sepsine', 'sickless', 'sigillaria', 'staphyledema', 'undelible', 'unruth', 'yaourti'] #todo: complete
6
+
7
+ def self.start_practice
8
8
  puts "PRACTICE MODE STARTED"
9
9
 
10
10
  while true
11
- random_word = @words.sample.upcase!
11
+ random_word = @word_list.sample.upcase!
12
12
  correct_answer = Morse.text_to_morse(random_word)
13
13
  puts "translate ---> #{random_word}"
14
14
  print 'Your answer: '
@@ -17,13 +17,19 @@ module Te4cher
17
17
  puts 'Correct! Moving to the next word...'
18
18
  sleep(2)
19
19
  else
20
- puts "Wrong! The correct answer was: #{correct_answer}, moving to the next word..."
20
+ puts "Wrong! The correct answer was: #{correct_answer} moving to the next word..."
21
21
  sleep(2)
22
22
  end
23
23
  end
24
24
  end
25
25
 
26
+ def self.start_hangman
27
+ Hangman.choose_word(@word_list)
28
+ Hangman.main
29
+ end
30
+
26
31
  def self.show_hashes
32
+ print @word_list
27
33
  for char, morse in @@asciitomorse
28
34
  print char, ' --> ', morse, ' '
29
35
  end; 'Morse Alphabet'
@@ -34,7 +40,8 @@ module Te4cher
34
40
  greeting = '''
35
41
 
36
42
  Welcome to teaching mode! If you want to practice: input PRACTICE,
37
- if you want to view the Morse alphabet input ALPHABET.
43
+ if you want to view the Morse alphabet input ALPHABET,
44
+ if you want to play hangman in Morse; input HANGMAN.
38
45
 
39
46
  '''
40
47
 
@@ -47,6 +54,8 @@ if you want to view the Morse alphabet input ALPHABET.
47
54
 
48
55
  elsif @choice == 'ALPHABET'
49
56
  self.show_hashes
57
+ elsif @choice == 'HANGMAN'
58
+ self.start_hangman
50
59
  end
51
60
  end
52
61
 
@@ -58,4 +67,4 @@ end
58
67
 
59
68
 
60
69
 
61
-
70
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: m0rse_c0de
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burzum
@@ -36,6 +36,7 @@ files:
36
36
  - lib/sound/beeps/dah.wav
37
37
  - lib/sound/beeps/dit.wav
38
38
  - lib/sound/sound.rb
39
+ - lib/teacher/hangman.rb
39
40
  - lib/teacher/teacher.rb
40
41
  homepage:
41
42
  licenses: []