aromancer 0.0.7 → 0.0.9
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 +4 -4
- data/.DS_Store +0 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/Gemfile.lock +2 -2
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/checksums/aromancer-0.0.8.gem.sha512 +1 -0
- data/checksums/aromancer-0.0.9.gem.sha512 +1 -0
- data/lib/aromancer/api.rb +10 -27
- data/lib/aromancer/cli.rb +153 -0
- data/lib/aromancer/routes.rb +117 -134
- data/lib/aromancer/serve.rb +35 -0
- data/lib/aromancer/server.rb +6 -6
- data/lib/aromancer/storage.rb +214 -93
- data/lib/aromancer/unix_dom.rb +13 -0
- data/lib/aromancer/version.rb +1 -1
- data/lib/aromancer/websocket.rb +29 -8
- data/lib/aromancer.rb +48 -127
- data/lib/reiquire.rb +2 -0
- data/listen.rb +0 -4
- data/locale/en.yml +3 -2
- data/tasks/make.rake +2 -2
- metadata +7 -3
- data/LICENSE.txt +0 -21
- data/gem_graph.png +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 635ad1d6e0100e8311e7d9a2ed2d810e939684c02dc3572fbb6150cda376a90a
|
|
4
|
+
data.tar.gz: f3c3c71736c9c1ea4bf339ad6b3b804b302526f8b063de19d64138cdfa539792
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1284816493145370d4f997a9e5e0ffd74791faa5c7ddd8ca9d131ed0e1ebd7189026d238cc7f3999714cf2235f198be2a1c64e9f2aae9f812a9463ff1672cb7e
|
|
7
|
+
data.tar.gz: 19d0046c8683d31847cd51b59b0228eff1cca91a15eb4af6160cbc526294c032ed3fcc21ad8c60d7de9154137af35260106b9c83a6e1af6f7adf0b254d89e1d2
|
data/.DS_Store
ADDED
|
Binary file
|
data/CODE_OF_CONDUCT.md
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* When interpreting the words and actions of others, participants should always assume good intentions.
|
|
8
8
|
* Behaviour which can be reasonably considered harassment will not be tolerated.
|
|
9
9
|
|
|
10
|
-
If you have any concerns about
|
|
10
|
+
If you have any concerns about behavior within this project, please contact us at ["i2097i@hotmail.com"](mailto:"i2097i@hotmail.com").
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
aromancer (0.0.
|
|
4
|
+
aromancer (0.0.9)
|
|
5
5
|
activesupport (~> 8.1.4)
|
|
6
6
|
faraday (~> 2.14.4)
|
|
7
7
|
fileutils (~> 1.8.0)
|
|
@@ -171,7 +171,7 @@ DEPENDENCIES
|
|
|
171
171
|
|
|
172
172
|
CHECKSUMS
|
|
173
173
|
activesupport (8.1.4) sha256=891dd3fe43c4fc8391934b237b1189bb1f661c932a84a840043db9d46a4e80df
|
|
174
|
-
aromancer (0.0.
|
|
174
|
+
aromancer (0.0.9)
|
|
175
175
|
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
|
|
176
176
|
bigdecimal (4.1.3) sha256=61ebe1e5e559bdc3cc6f2c0ee7f427321fc838f59611c294356eb04d6e21cf66
|
|
177
177
|
bundler (4.0.22) sha256=d8d5ec84c8555e0af71db63ed7aee4d1a8fb839ec46d84212d61979242a5d75a
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ea42cb760ae909d4de2b750f3ca7f125d58b9e9147886927e8f5b7dd81a80913152d6052c1c517a99a0733e7d3b15de86d3083d1f82d5341e4c8f1e3364222a2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
c113cc095e8e8621b438078a7708295b681cbe4887e0c2fa537c90c777c8f1bf548becf77efb1ae3ec0abfacc1c9fa43ff730ed82ffb4acd0dc62377ad9925cc
|
data/lib/aromancer/api.rb
CHANGED
|
@@ -24,23 +24,14 @@ module Aromancer
|
|
|
24
24
|
body: response.body.to_s
|
|
25
25
|
}
|
|
26
26
|
Aromancer::Storage.set_last_error(le)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
# signed_out = signed_out &&
|
|
37
|
-
# !error_body.nil? &&
|
|
38
|
-
# error_body.keys.include?(:error_message.to_s) &&
|
|
39
|
-
# error_body["error_message"] == "not signed in"
|
|
40
|
-
|
|
41
|
-
if signed_out
|
|
42
|
-
Aromancer::Storage.instance.clear_cache!
|
|
43
|
-
Aromancer::Storage.set_signed_out_flag(signed_out)
|
|
27
|
+
|
|
28
|
+
if response.status == 401
|
|
29
|
+
Aromancer::Storage.set_signed_out_flag(true)
|
|
30
|
+
player = Aromancer::Storage.get_player
|
|
31
|
+
unless player.nil?
|
|
32
|
+
player["api_key"] = nil
|
|
33
|
+
Aromancer::Storage.set_player(player)
|
|
34
|
+
end
|
|
44
35
|
end
|
|
45
36
|
end
|
|
46
37
|
|
|
@@ -93,17 +84,9 @@ module Aromancer
|
|
|
93
84
|
|
|
94
85
|
def self.sign_out
|
|
95
86
|
result = Aromancer::Server.sign_out
|
|
96
|
-
# clear storage
|
|
97
|
-
Aromancer::Storage.instance.clear_cache!
|
|
98
|
-
Aromancer::Storage.set_signed_out_flag(false)
|
|
99
87
|
Aromancer::Storage.set_player(nil)
|
|
100
|
-
Aromancer::Storage.set_legends(nil)
|
|
101
|
-
Aromancer::Storage.set_arena(nil)
|
|
102
|
-
Aromancer::Storage.set_stream(nil)
|
|
103
|
-
Aromancer::Storage.set_last_error(nil)
|
|
104
|
-
|
|
105
88
|
Aromancer::Websocket.instance.disconnect
|
|
106
|
-
|
|
89
|
+
Aromancer::Storage.recreate!
|
|
107
90
|
register_error(result) if result.status != 200
|
|
108
91
|
end
|
|
109
92
|
|
|
@@ -149,7 +132,7 @@ module Aromancer
|
|
|
149
132
|
player["active_legend_id"] = active_legend_id
|
|
150
133
|
Aromancer::Storage.set_player(player)
|
|
151
134
|
end
|
|
152
|
-
Aromancer::
|
|
135
|
+
Aromancer::Cli.instance.should_clear_cache = true
|
|
153
136
|
result = Aromancer::Server.update_player({player: {
|
|
154
137
|
active_legend_id: active_legend_id,
|
|
155
138
|
status: active_legend_id.nil? ? :lobby : :playing
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
=begin
|
|
4
|
+
|
|
5
|
+
cli.rb
|
|
6
|
+
|
|
7
|
+
aromancer cli
|
|
8
|
+
|
|
9
|
+
by i2097i
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
module Aromancer
|
|
14
|
+
# instance runs on main thread
|
|
15
|
+
class Cli
|
|
16
|
+
include Singleton
|
|
17
|
+
|
|
18
|
+
attr_accessor :error_timeout, :last_render, :should_clear_cache, :storage_mutex, :ui_busy, :ui_thread, :ws_busy, :ws_thread
|
|
19
|
+
|
|
20
|
+
RENDER_DELAY = 0.1
|
|
21
|
+
|
|
22
|
+
def initialize
|
|
23
|
+
self.storage_mutex = Mutex.new
|
|
24
|
+
self.should_clear_cache = false
|
|
25
|
+
self.last_render = 0
|
|
26
|
+
self.error_timeout = Time.now.to_i
|
|
27
|
+
|
|
28
|
+
Thread.main[:route] = :authentication
|
|
29
|
+
Thread.main[:menu_runners] = {}
|
|
30
|
+
Thread.main[:menu_options] = {}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# user entry point
|
|
34
|
+
def self.run
|
|
35
|
+
Aromancer::Websocket.instance
|
|
36
|
+
Aromancer::Storage.instance.ensure_default_preferences_exist
|
|
37
|
+
|
|
38
|
+
# load player on-start
|
|
39
|
+
Aromancer::Api.set_active_legend_id(
|
|
40
|
+
({} || Aromancer::Storage.get_player)[:active_legend_id.to_s]
|
|
41
|
+
) unless Aromancer::Storage.get_player.nil?
|
|
42
|
+
|
|
43
|
+
Aromancer::Prompt.say(I18n.t("shared.welcome", version: Aromancer::VERSION))
|
|
44
|
+
|
|
45
|
+
self.instance.start_ui_thread
|
|
46
|
+
self.instance.start_ws_thread
|
|
47
|
+
loop do
|
|
48
|
+
begin
|
|
49
|
+
|
|
50
|
+
if self.instance.should_clear_cache
|
|
51
|
+
Aromancer::Storage.instance.clear_cache!
|
|
52
|
+
self.instance.should_clear_cache = false
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
self.instance.ui_thread.join
|
|
56
|
+
|
|
57
|
+
rescue NoMethodError => e
|
|
58
|
+
Aromancer::Storage.set_last_error({
|
|
59
|
+
status: -1,
|
|
60
|
+
headers: e.to_s,
|
|
61
|
+
body: e.inspect.to_s
|
|
62
|
+
})
|
|
63
|
+
if Aromancer::Storage.get_preference(:debug)
|
|
64
|
+
Aromancer::Prompt.say(I18n.t("shared.last_error"))
|
|
65
|
+
Aromancer::Prompt.say("sleeping 1 on main thread...")
|
|
66
|
+
sleep(1)
|
|
67
|
+
end
|
|
68
|
+
Aromancer::Storage.instance.clear_cache!
|
|
69
|
+
self.instance.start_ui_thread
|
|
70
|
+
self.instance.start_ws_thread
|
|
71
|
+
sleep(1)
|
|
72
|
+
rescue Interrupt => e
|
|
73
|
+
Aromancer::Prompt.say("interrupt on main thread...exiting immediately.")
|
|
74
|
+
exit
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def start_ui_thread(force = false)
|
|
80
|
+
return if (@ui_busy || Time.now - @last_render < 2.0) && !force
|
|
81
|
+
|
|
82
|
+
@ui_busy = true
|
|
83
|
+
self.ui_thread&.exit
|
|
84
|
+
self.ui_thread&.kill
|
|
85
|
+
Thread.main[:menu_runners] = {}
|
|
86
|
+
Thread.main[:menu_options] = {}
|
|
87
|
+
Aromancer::Prompt.instance.reload!
|
|
88
|
+
self.ui_thread = Thread.new do
|
|
89
|
+
loop do
|
|
90
|
+
menu_options = Thread.main[:menu_options][Thread.main[:route]]
|
|
91
|
+
menu_runners = Thread.main[:menu_runners][Thread.main[:route]]
|
|
92
|
+
unless menu_options.nil? ||
|
|
93
|
+
menu_runners.nil? ||
|
|
94
|
+
menu_options.empty? ||
|
|
95
|
+
menu_runners.empty?
|
|
96
|
+
|
|
97
|
+
Aromancer::Routes.resume
|
|
98
|
+
sleep(Aromancer::Cli::RENDER_DELAY)
|
|
99
|
+
Aromancer.print_hud
|
|
100
|
+
|
|
101
|
+
v = Aromancer::Prompt.p.select("", menu_options, show_help: :always, cycle: true, per_page: 11)
|
|
102
|
+
runners = menu_runners.select{|r| r[:value] == v}
|
|
103
|
+
runners = menu_runners.select{|r| r[:value].nil?} if runners.empty?
|
|
104
|
+
|
|
105
|
+
if runners.any?
|
|
106
|
+
r = runners.first
|
|
107
|
+
r[:proc].call(v)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
else
|
|
111
|
+
sleep(Aromancer::Cli::RENDER_DELAY)
|
|
112
|
+
Aromancer::Routes.resume
|
|
113
|
+
Aromancer.print_hud
|
|
114
|
+
end
|
|
115
|
+
Aromancer::Cli.instance.ui_busy = false
|
|
116
|
+
Aromancer::Cli.instance.last_render = Time.now
|
|
117
|
+
sleep(Aromancer::Cli::RENDER_DELAY)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def start_ws_thread
|
|
123
|
+
return if @ws_busy
|
|
124
|
+
@ws_busy = true
|
|
125
|
+
self.ws_thread&.exit
|
|
126
|
+
self.ws_thread&.kill
|
|
127
|
+
self.ws_thread = Thread.new do
|
|
128
|
+
Aromancer::Websocket.instance.disconnect
|
|
129
|
+
loop do
|
|
130
|
+
player = Aromancer::Storage.get_player
|
|
131
|
+
if player.nil? ||
|
|
132
|
+
player["active_legend_id"].nil?
|
|
133
|
+
@ws_busy = true
|
|
134
|
+
Aromancer::Websocket.instance.disconnect
|
|
135
|
+
elsif !player["api_key"].nil? &&
|
|
136
|
+
!player["active_legend_id"].nil? &&
|
|
137
|
+
(Aromancer::Websocket.instance.socket.nil? || Aromancer::Websocket.instance.socket.closed?)
|
|
138
|
+
# attempt websocket connection
|
|
139
|
+
@ws_busy = true
|
|
140
|
+
Aromancer::Websocket.instance.connect
|
|
141
|
+
if Aromancer::Storage.get_arena.nil?
|
|
142
|
+
Aromancer::Api.load_arena
|
|
143
|
+
sleep(Aromancer::Cli::RENDER_DELAY)
|
|
144
|
+
Aromancer::Cli.instance.start_ui_thread(true)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
@ws_busy = false
|
|
148
|
+
sleep(Aromancer::Cli::RENDER_DELAY)
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|