need_for_type 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 +5 -5
- data/lib/need_for_type/states/game.rb +9 -7
- data/lib/need_for_type/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 57d73179c5ea1d16a242cd2115bee5426dd9c9cf92ab8831d597c62ce6a0fdc7
|
4
|
+
data.tar.gz: d644ecb4c00b11e57a611f12b7ebc06873d6f041937692f4c2e5cd0ee20953bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ef3f90f9d5188a6982dd24435654497e4532cd8eb0f3e008222a818a8c40eaeddb3a88cacd35b15c4c32e5cb0978f3d434c5a1095abc995f661767acef19857
|
7
|
+
data.tar.gz: 74bf370dcdff5487eb331d968c58d80a754eea5c658228459c42a8db1fd0c8f89ba72c645c0861e201d9d02bd895a7a406e0624443470e47ee905ac31953c2b0
|
@@ -5,7 +5,6 @@ require 'need_for_type/file_manager'
|
|
5
5
|
|
6
6
|
module NeedForType::States
|
7
7
|
class Game < State
|
8
|
-
|
9
8
|
def initialize(display_window, difficulty)
|
10
9
|
super(display_window)
|
11
10
|
|
@@ -15,6 +14,7 @@ module NeedForType::States
|
|
15
14
|
@word = ''
|
16
15
|
|
17
16
|
@chars_completed = 0
|
17
|
+
@words_completed = 0
|
18
18
|
@total_taps = 0
|
19
19
|
@correct_taps = 0
|
20
20
|
|
@@ -53,7 +53,7 @@ module NeedForType::States
|
|
53
53
|
|
54
54
|
@state = :in_game_get_input
|
55
55
|
|
56
|
-
|
56
|
+
self
|
57
57
|
end
|
58
58
|
|
59
59
|
# Gets input from user and compares it
|
@@ -69,7 +69,7 @@ module NeedForType::States
|
|
69
69
|
|
70
70
|
calculate_stats
|
71
71
|
|
72
|
-
|
72
|
+
self
|
73
73
|
end
|
74
74
|
|
75
75
|
# User input is correct
|
@@ -78,11 +78,13 @@ module NeedForType::States
|
|
78
78
|
@correct_taps += 1
|
79
79
|
|
80
80
|
if @chars_completed == @text.size
|
81
|
+
@words_completed += 1
|
81
82
|
@state = :end_game
|
82
83
|
return self
|
83
84
|
end
|
84
85
|
|
85
86
|
if @text[@chars_completed] == ' '
|
87
|
+
@words_completed += 1
|
86
88
|
@word = ''
|
87
89
|
else
|
88
90
|
@word += @text[@chars_completed]
|
@@ -92,7 +94,7 @@ module NeedForType::States
|
|
92
94
|
|
93
95
|
@state = :in_game_get_input
|
94
96
|
|
95
|
-
|
97
|
+
self
|
96
98
|
end
|
97
99
|
|
98
100
|
# User input is wrong
|
@@ -103,20 +105,20 @@ module NeedForType::States
|
|
103
105
|
|
104
106
|
@state = :in_game_get_input
|
105
107
|
|
106
|
-
|
108
|
+
self
|
107
109
|
end
|
108
110
|
|
109
111
|
def handle_end_game
|
110
112
|
calculate_stats
|
111
113
|
|
112
|
-
|
114
|
+
NeedForType::States::End.new(@display_window, @stats, @difficulty, @text_id)
|
113
115
|
end
|
114
116
|
|
115
117
|
def calculate_stats
|
116
118
|
current_time = Time.now
|
117
119
|
|
118
120
|
@stats[:total_time] = current_time - @start_time
|
119
|
-
@stats[:wpm] = (@
|
121
|
+
@stats[:wpm] = (@words_completed * 60) / @stats[:total_time]
|
120
122
|
@stats[:accuracy] = (@correct_taps.to_f / @total_taps.to_f) * 100
|
121
123
|
end
|
122
124
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: need_for_type
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tiagonbotelho
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-02-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -834,7 +834,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
834
834
|
version: '0'
|
835
835
|
requirements: []
|
836
836
|
rubyforge_project:
|
837
|
-
rubygems_version: 2.
|
837
|
+
rubygems_version: 2.7.4
|
838
838
|
signing_key:
|
839
839
|
specification_version: 4
|
840
840
|
summary: A terminal typeracer
|