jiraquest 0.0.2
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 +7 -0
- data/.gitignore +52 -0
- data/.rspec +3 -0
- data/.rubocop.yml +19 -0
- data/.rubocop_todo.yml +8 -0
- data/.rubosync.yml +2 -0
- data/.travis.yml +27 -0
- data/CODE_OF_CONDUCT.md +46 -0
- data/CONTRIBUTING.md +50 -0
- data/Gemfile +9 -0
- data/LICENSE +165 -0
- data/README.md +51 -0
- data/Rakefile +17 -0
- data/assets/fonts/big.flf +2204 -0
- data/bin/jiraquest +4 -0
- data/jiraquest.gemspec +35 -0
- data/lib/jiraquest.rb +12 -0
- data/lib/jiraquest/distractions/activities.rb +161 -0
- data/lib/jiraquest/distractions/distractions.rb +4 -0
- data/lib/jiraquest/distractions/notifications.rb +55 -0
- data/lib/jiraquest/quests/button.rb +38 -0
- data/lib/jiraquest/quests/quests.rb +33 -0
- data/lib/jiraquest/quests/setup.rb +28 -0
- data/lib/jiraquest/version.rb +5 -0
- data/lib/utils/assetloader.rb +7 -0
- data/lib/utils/date/date.rb +28 -0
- data/lib/utils/game/achievements.rb +37 -0
- data/lib/utils/game/game.rb +6 -0
- data/lib/utils/game/login.rb +86 -0
- data/lib/utils/game/morale.rb +35 -0
- data/lib/utils/game/score.rb +53 -0
- data/lib/utils/prompts/figlet.rb +30 -0
- data/lib/utils/prompts/prompts.rb +6 -0
- data/lib/utils/prompts/reporter.rb +37 -0
- data/lib/utils/prompts/system.rb +65 -0
- data/lib/utils/prompts/terminal.rb +70 -0
- data/lib/utils/user/user.rb +35 -0
- data/lib/utils/utils.rb +7 -0
- metadata +208 -0
data/bin/jiraquest
ADDED
data/jiraquest.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'jiraquest/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'jiraquest'
|
9
|
+
spec.version = Jiraquest::VERSION
|
10
|
+
spec.authors = ['tcob']
|
11
|
+
spec.email = ['briantcob@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = 'Immersive jiraquest Text-based adventure game.'
|
14
|
+
# spec.description = %q{TODO: Write a longer description or delete this line.}
|
15
|
+
|
16
|
+
spec.homepage = 'https://github.com/tcob/jiraquest'
|
17
|
+
spec.license = 'MIT'
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
|
+
f.match(%r{^(test|spec|features)/})
|
21
|
+
end
|
22
|
+
spec.bindir = 'bin'
|
23
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ['lib']
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler'
|
27
|
+
spec.add_development_dependency 'rake'
|
28
|
+
spec.add_development_dependency 'rubocop'
|
29
|
+
spec.add_development_dependency 'test-unit'
|
30
|
+
spec.add_dependency 'figlet'
|
31
|
+
spec.add_dependency 'pastel'
|
32
|
+
spec.add_dependency 'ruby-progressbar'
|
33
|
+
spec.add_dependency 'tty-prompt'
|
34
|
+
spec.add_dependency 'tty-spinner'
|
35
|
+
end
|
data/lib/jiraquest.rb
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml/store'
|
4
|
+
require_relative '../../utils/utils'
|
5
|
+
|
6
|
+
# Workspace setup miniquest
|
7
|
+
class Activity
|
8
|
+
def initialize
|
9
|
+
@store = DATA
|
10
|
+
@prompt = TTY::Prompt.new
|
11
|
+
@distractions_list = %w[water coffee walk text think complain chat tune]
|
12
|
+
end
|
13
|
+
|
14
|
+
def list
|
15
|
+
@distractions_list
|
16
|
+
end
|
17
|
+
|
18
|
+
def read_distractions_count
|
19
|
+
@store.transaction { @store['distractions'] }
|
20
|
+
end
|
21
|
+
|
22
|
+
def read_warnings_count
|
23
|
+
@store.transaction { @store['warnings'] }
|
24
|
+
end
|
25
|
+
|
26
|
+
def coffee
|
27
|
+
puts 'You made a coffee'
|
28
|
+
update_distraction('coffee')
|
29
|
+
end
|
30
|
+
|
31
|
+
def chat
|
32
|
+
puts 'You chatted with your colleagues'
|
33
|
+
update_distraction('chat')
|
34
|
+
end
|
35
|
+
|
36
|
+
def text
|
37
|
+
puts 'You sent a text to your significant other'
|
38
|
+
update_distraction('text')
|
39
|
+
end
|
40
|
+
|
41
|
+
def water
|
42
|
+
puts 'You drank some cucumber water'
|
43
|
+
update_distraction('water')
|
44
|
+
end
|
45
|
+
|
46
|
+
def complain
|
47
|
+
puts 'You complained loudly'
|
48
|
+
update_distraction('complain')
|
49
|
+
end
|
50
|
+
|
51
|
+
def walk
|
52
|
+
puts 'You take a walk outside'
|
53
|
+
update_distraction('walk')
|
54
|
+
end
|
55
|
+
|
56
|
+
def think
|
57
|
+
puts 'You thought about things'
|
58
|
+
update_distraction('think')
|
59
|
+
end
|
60
|
+
|
61
|
+
def tune
|
62
|
+
dc = read_distractions_count
|
63
|
+
music = dc.select { |k, _v| k == 'tune' }
|
64
|
+
played = music['tune']
|
65
|
+
if played.even?
|
66
|
+
play_tune('why', 'does your love', 'hurt so much')
|
67
|
+
else
|
68
|
+
play_tune('words', 'don\'t come easy', 'to me')
|
69
|
+
end
|
70
|
+
update_distraction('tune')
|
71
|
+
end
|
72
|
+
|
73
|
+
def play_tune(*lines)
|
74
|
+
lines.each do |line|
|
75
|
+
puts "š¶ #{line} š¶"
|
76
|
+
sleep(1)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# rubocop:disable Metrics/MethodLength
|
81
|
+
def activities
|
82
|
+
@mode = @prompt.select('Do something else') do |menu|
|
83
|
+
menu.default 1
|
84
|
+
menu.choice name: 'Make coffee', value: 1
|
85
|
+
menu.choice name: 'Have a chat', value: 2
|
86
|
+
menu.choice name: 'Send a text', value: 3
|
87
|
+
menu.choice name: 'Drink some water', value: 4
|
88
|
+
menu.choice name: 'Complain', value: 5
|
89
|
+
menu.choice name: 'Go for a walk', value: 6
|
90
|
+
menu.choice name: 'Think', value: 7
|
91
|
+
menu.choice name: 'Play some tunes', value: 8
|
92
|
+
end
|
93
|
+
@mode
|
94
|
+
end
|
95
|
+
|
96
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
97
|
+
def choose
|
98
|
+
@distraction = case activities
|
99
|
+
when 1 then coffee
|
100
|
+
when 2 then chat
|
101
|
+
when 3 then text
|
102
|
+
when 4 then water
|
103
|
+
when 5 then complain
|
104
|
+
when 6 then walk
|
105
|
+
when 7 then think
|
106
|
+
when 8 then tune
|
107
|
+
end
|
108
|
+
|
109
|
+
@distraction
|
110
|
+
end
|
111
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
112
|
+
# rubocop:enable Metrics/MethodLength
|
113
|
+
|
114
|
+
def update_distraction(distraction)
|
115
|
+
@store.transaction { @store['distractions'][distraction] += 1 }
|
116
|
+
end
|
117
|
+
|
118
|
+
def distract_count(distraction)
|
119
|
+
@store['distractions'][distraction]
|
120
|
+
end
|
121
|
+
|
122
|
+
def warning_count(distraction)
|
123
|
+
@store['warnings'][distraction]
|
124
|
+
end
|
125
|
+
|
126
|
+
def update_warning(distraction)
|
127
|
+
@store.transaction { @store['warnings'][distraction] += 1 }
|
128
|
+
end
|
129
|
+
|
130
|
+
def warning
|
131
|
+
if coffee_armageddon
|
132
|
+
complain
|
133
|
+
else
|
134
|
+
distract_warning('already, you may lose a jira!')
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def boot_warning
|
139
|
+
distract_warning('without even turning on your machine!')
|
140
|
+
end
|
141
|
+
|
142
|
+
def distract_warning(message)
|
143
|
+
dc = read_distractions_count
|
144
|
+
limits = dc.select { |_k, v| v > 4 }
|
145
|
+
limits.each do |distraction, count|
|
146
|
+
@prompt.error("Be careful, you have had #{count} #{distraction}s " + message)
|
147
|
+
update_warning(distraction)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def coffee_armageddon
|
152
|
+
dc = read_warnings_count
|
153
|
+
limits = dc.select { |_k, v| v > 1 }
|
154
|
+
limits.each do |distraction, _count|
|
155
|
+
@prompt.error('You were warned! You now lose TEN jiras!')
|
156
|
+
update_warning(distraction)
|
157
|
+
Score.new.update_points(-10)
|
158
|
+
end
|
159
|
+
true
|
160
|
+
end
|
161
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ruby-progressbar'
|
4
|
+
|
5
|
+
# Simple User Prompts
|
6
|
+
class Notifications
|
7
|
+
def initialize
|
8
|
+
@store = DATA
|
9
|
+
@prompt = TTY::Prompt.new
|
10
|
+
@notifications_list = %w[slack reddit text email]
|
11
|
+
end
|
12
|
+
|
13
|
+
def list
|
14
|
+
@notifications_list
|
15
|
+
end
|
16
|
+
|
17
|
+
def slack
|
18
|
+
@prompt.ok('Someone sent you a slack message')
|
19
|
+
end
|
20
|
+
|
21
|
+
def reddit
|
22
|
+
@prompt.ok('Someone replied to a Reddit post of yours')
|
23
|
+
end
|
24
|
+
|
25
|
+
def text
|
26
|
+
@prompt.ok('Someone sent you a WhatsApp message')
|
27
|
+
end
|
28
|
+
|
29
|
+
def email
|
30
|
+
@prompt.ok('Someone sent you an email')
|
31
|
+
end
|
32
|
+
|
33
|
+
def random
|
34
|
+
[slack, reddit, text, email].sample
|
35
|
+
end
|
36
|
+
|
37
|
+
def read_notifications_count
|
38
|
+
@store.transaction { @store['notifications'] }
|
39
|
+
end
|
40
|
+
|
41
|
+
def warning
|
42
|
+
dc = read_notifications_count
|
43
|
+
limits = dc.select { |_k, v| v > 2 }
|
44
|
+
limits.each do |distraction, _count|
|
45
|
+
@prompt.error("Be careful, you are spending a lot of time #{distraction}ing, "\
|
46
|
+
'you may lose jiras!')
|
47
|
+
update_warning(distraction)
|
48
|
+
end
|
49
|
+
false
|
50
|
+
end
|
51
|
+
|
52
|
+
def update_warning(notification)
|
53
|
+
@store.transaction { @store['warnings'][notification] += 1 }
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'tty-prompt'
|
4
|
+
require 'utils/utils'
|
5
|
+
|
6
|
+
# Workspace setup miniquest
|
7
|
+
class Button
|
8
|
+
def initialize
|
9
|
+
@store = DATA
|
10
|
+
@prompt = TTY::Prompt.new
|
11
|
+
@user = @store.transaction { @store[:user] }
|
12
|
+
end
|
13
|
+
|
14
|
+
def quest
|
15
|
+
@prompt.warn("\nQuest 2")
|
16
|
+
@prompt.ok("'Press The Button'")
|
17
|
+
if @user[/[K|k]ristian/]
|
18
|
+
button?
|
19
|
+
Reporter.new.success('Great!')
|
20
|
+
else
|
21
|
+
4.times { button? }
|
22
|
+
Morale.new.update_and_print(-2)
|
23
|
+
end
|
24
|
+
sleep 1
|
25
|
+
Score.new.update_and_print(1)
|
26
|
+
sleep 1
|
27
|
+
Reporter.new.quest_complete('Button')
|
28
|
+
end
|
29
|
+
|
30
|
+
def button?
|
31
|
+
if @prompt.yes?('Have you pressed the button?')
|
32
|
+
Reporter.new.timed_success('Connected!', 3)
|
33
|
+
true
|
34
|
+
else
|
35
|
+
Activity.new.choose
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'tty-prompt'
|
4
|
+
require_relative 'setup'
|
5
|
+
require_relative 'button'
|
6
|
+
|
7
|
+
# A class to manage quests
|
8
|
+
class Quests
|
9
|
+
def initialize
|
10
|
+
@prompt = TTY::Prompt.new
|
11
|
+
@quests_list = %w[Setup Button]
|
12
|
+
end
|
13
|
+
|
14
|
+
def list
|
15
|
+
@quests_list
|
16
|
+
end
|
17
|
+
|
18
|
+
def quest?
|
19
|
+
@mode = @prompt.select('What Quest would you like to start?') do |menu|
|
20
|
+
menu.choice name: 'Setup Mini-Quest', value: 1
|
21
|
+
menu.choice name: 'The Button Challenge', value: 2
|
22
|
+
end
|
23
|
+
@mode
|
24
|
+
end
|
25
|
+
|
26
|
+
def launch_quest
|
27
|
+
@quest = case quest?
|
28
|
+
when 1 then Setup.new.quest
|
29
|
+
when 2 then Button.new.quest
|
30
|
+
end
|
31
|
+
@quest
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml/store'
|
4
|
+
require_relative '../../utils/utils'
|
5
|
+
require_relative '../distractions/distractions'
|
6
|
+
|
7
|
+
# Workspace setup miniquest
|
8
|
+
class Setup
|
9
|
+
def initialize
|
10
|
+
@store = DATA
|
11
|
+
@user = @store.transaction { @store[:user] }
|
12
|
+
@prompt = TTY::Prompt.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def quest
|
16
|
+
@prompt.warn("\nQuest 1")
|
17
|
+
@prompt.ok("'Set up your Work Environment'")
|
18
|
+
puts 'Can you avoid distractions and get your system ready to start collecting jiras?'
|
19
|
+
@prompt.warn('Begin:')
|
20
|
+
System.new.vpn if System.new.boot
|
21
|
+
System.new.ide_update
|
22
|
+
@prompt.warn('You updated your IDE, but lost work on 1 jira.')
|
23
|
+
sleep 1
|
24
|
+
Score.new.update_and_print(-1)
|
25
|
+
sleep 1
|
26
|
+
Reporter.new.quest_complete('Setup')
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'tty-prompt'
|
4
|
+
require 'tty-spinner'
|
5
|
+
|
6
|
+
# Some basic utils for handling date / time
|
7
|
+
class Dateutil
|
8
|
+
def initialize
|
9
|
+
@prompt = TTY::Prompt.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def ask_date
|
13
|
+
Time.parse(@prompt.ask('Enter a date (Y/M/D):'))
|
14
|
+
end
|
15
|
+
|
16
|
+
def ask_start_date
|
17
|
+
Time.parse(@prompt.ask('Enter a start date (Y/M/D):'))
|
18
|
+
end
|
19
|
+
|
20
|
+
def ask_end_date
|
21
|
+
Time.parse(@prompt.ask('Enter an end date (Y/M/D):'))
|
22
|
+
end
|
23
|
+
|
24
|
+
def seconds_to_str(seconds)
|
25
|
+
["#{seconds / 3600}h", "#{seconds / 60 % 60}m", "#{seconds % 60}s"]
|
26
|
+
.select { |str| str =~ /[1-9]/ }.join(' ')
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml/store'
|
4
|
+
require_relative '../utils'
|
5
|
+
require_relative 'score'
|
6
|
+
|
7
|
+
# Keeps track of users achievements
|
8
|
+
class Achievement
|
9
|
+
def initialize
|
10
|
+
@pastel = Pastel.new
|
11
|
+
@store = DATA
|
12
|
+
@user = @store.transaction { @store[:user] }
|
13
|
+
@chieve_list = %w[employee_otm]
|
14
|
+
@spinner = TTY::Spinner.new('[:spinner] :title', success_mark: @pastel.green('+'))
|
15
|
+
end
|
16
|
+
|
17
|
+
def list
|
18
|
+
@chieve_list
|
19
|
+
end
|
20
|
+
|
21
|
+
def increment_chieve(chieve)
|
22
|
+
puts 'š Achievement Unlocked! š'
|
23
|
+
@store.transaction { @store['achievements'][chieve] += 1 }
|
24
|
+
end
|
25
|
+
|
26
|
+
def employee_otm
|
27
|
+
if @user[/[K|k]ristian/]
|
28
|
+
@spinner.auto_spin
|
29
|
+
@spinner.update(title: 'Evaluating Performance')
|
30
|
+
sleep 5
|
31
|
+
@spinner.update(title: 'Calculated Value Added to Company:')
|
32
|
+
@spinner.success(@pastel.green("\nšØš»āš¼ Kristian has earned: Employee Of The Month\n"))
|
33
|
+
increment_chieve('employee_otm')
|
34
|
+
sleep 5
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|