typeking 0.1.0 → 0.1.1

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: 7d70c8a418e4287f6080862bfa045ddc7d29f9c382972b63a6caa932d148da1d
4
- data.tar.gz: 84820a050ee309c49b453635ab39ebbd6ad0e778c8f3b2b28442c8f07d7b6593
3
+ metadata.gz: fb37c928cbf328adbb5dff7f054a35df51ea603f2db5ccbba2beea1294d26d04
4
+ data.tar.gz: 866a6988b093c121aea0dc84c20741ed23d4bcdbf7aae034609df59239879bd9
5
5
  SHA512:
6
- metadata.gz: e992ae851ff5c997eb5128d9eb39a3d7f6df9e9c29128fdf7146bb696b3d98173740df34bda32e0ddf181a1ad610f1465d548ade8f1e8f34942c3defa8039925
7
- data.tar.gz: 251f47eb13b01665f1ce81980c43cea454239f236dee44b751b5c0f7e00e6d9e86aee92ae9d41674a086f19692db7665dbbd79ec909d933e84a2b965172fd6f8
6
+ metadata.gz: b51ed0c2557667ad206d6b86649863b9ec7cd99c616a6f07ae019b43c15cbe517da58af2eb3e0fe1f3c543474d9d3d4d06b9a54bcaa847a3a164894cb3719ab6
7
+ data.tar.gz: 813d8e46d63ab1f0dc20df7756119ad26d2d9f5052ffaa4743b97f890e2ab9867e48d95d5761b1537a7323dea082adf6d1002321d16a3608cf89cdd662173104
data/README.md CHANGED
@@ -19,9 +19,22 @@ Or install it yourself as:
19
19
  ## Usage
20
20
 
21
21
  ```ruby
22
- Typeking::GameController.new()
22
+ Typeking::GameController.new() #starts the application
23
23
  ```
24
24
 
25
+ 1. Install the gem
26
+ 2. Open IRB by typing 'irb' in the terminal
27
+ 3. Type 'require 'typeking'' and press enter
28
+ 4. Type Typeking::GameController.new() and press enter
29
+ 5. Use the keyboard to navigation to 'Register' and press enter
30
+ 6. Login using the registered name (case-sensitive)
31
+ 7. Press enter on the 'Play' option
32
+ 8. Enter how many words you want to type (enter a number from 5-500)
33
+ 9. Type the words that appear in the terminal
34
+ 10. See results when typing is finished
35
+ 11. Play again or log out to check if you have made the leaderboards!
36
+
37
+
25
38
 
26
39
  ## Development
27
40
 
@@ -14,7 +14,6 @@ module Typeking
14
14
  @userHashes = {} #stores indexes for all users
15
15
  @currentUserData = {} #stores current stats
16
16
  @currentUid = 0 #current user id
17
- @leaderboardArr = []
18
17
  setup_application
19
18
  end
20
19
 
@@ -91,31 +90,31 @@ module Typeking
91
90
  end
92
91
 
93
92
  def attempt_login(username)
94
- if @userHashes[username] #check if user exists
93
+ begin
95
94
  @currentUid = @userHashes[username] #update current user id to the username from the userhashes directory
96
95
  @currentUserData = @userData[currentUid] #user data hash becomes hash from database
97
96
  return "Hello #{@currentUserData[:name]}!" #user_login will puts this to terminal
98
- else
97
+ rescue
99
98
  return "You have not registered yet, please register first." #user_login will puts this to terminal
100
99
  end
101
100
  end
102
101
 
103
102
 
104
- def display_leaders(leaderCount)
103
+ def display_leaders(leaderCount,leaderboardArr)
105
104
  leaders = 0 #current number of users displayed on leaderboard
106
105
  while leaders < leaderCount #loop while displayed leaders is less than actual users
107
- leaderHash = @leaderboardArr[leaders] #creates new hash using leaders as the index as the highest score would start from index 0
106
+ leaderHash = leaderboardArr[leaders] #creates new hash using leaders as the index as the highest score would start from index 0
108
107
  puts "#{leaders+1}. #{leaderHash[:name]} - WPM: #{leaderHash[:high_score]}, Accuracy: #{leaderHash[:accuracy]}%, Worst Character: #{leaderHash[:worst_character]}" #uses hash to output leaderboards
109
108
  leaders += 1 #increment leaders
110
109
  end
111
110
  end
112
111
 
113
112
  def show_leaderboards
114
- @leaderboardArr = @userData.dup #creates a new duplicate array of all user data
115
- puts "No entries yet!" unless @leaderboardArr.count > 0 #output when no users in data
116
- @leaderboardArr.sort_by!{|w| w[:high_score]} #sort by ascending order
117
- @leaderboardArr = @leaderboardArr.reverse #reverse order to descending
118
- leaderCount = @leaderboardArr.count #checks how many users are in the array
113
+ leaderboardArr = @userData.dup #creates a new duplicate array of all user data
114
+ puts "No entries yet!" unless leaderboardArr.count > 0 #output when no users in data
115
+ leaderboardArr.sort_by!{|w| w[:high_score]} #sort by ascending order
116
+ leaderboardArr = leaderboardArr.reverse #reverse order to descending
117
+ leaderCount = leaderboardArr.count #checks how many users are in the array
119
118
  display_leaders(leaderCount) #calls method based on number of users
120
119
  start_screen #return to starting screen
121
120
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Typeking
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typeking
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AnthonyALu