aromancer 0.0.5 → 0.0.7

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: 117a4ac8211f275343a236d489c481e073604599325d5df3d8f7032fe5c83256
4
- data.tar.gz: 7fce17acc9a26840d6005d9ce16b91bac8a2c6f0cc0356827b3495b1ab6a6db4
3
+ metadata.gz: 5ebbde2a81b320eab73f2035b03d5166c5bcec1c01eaef7e51e4a010a8ab8251
4
+ data.tar.gz: 044c185f6741090deb4e179c8716e35d23e1b6a775c42db683ee079db8cb1419
5
5
  SHA512:
6
- metadata.gz: d0d2618429769e3253eaeb474ae51fd5a7cbfa704eef19bbbb730fa1dacc25f0439eeafe6d8268028d0596a9f4efb3a16392ce4e1f0253d5f193642612d6d8f4
7
- data.tar.gz: 6a53306414b2c2921f57e3e2f497ff25901af7f126740a003b572f7d4b2723a1a132be4bf702c3582041eb2965a5adde5d7909c1b0fa7c7531b30f8d1a5a9dde
6
+ metadata.gz: d992314e5e012369313167b145991a687ec0cfaa2a4e6b8ef445f147333e64e287eb70e9208215fac91b6ef20b04e0b3f740ee20ffd7f3c1b60197ad536dd4ad
7
+ data.tar.gz: 9210fd3030350a65b7f56ee68be13296a2707514f9cb1cf378e792b95868ad08c0009ec7c6c7409d6060919ee28911b557b4b4e673b933f47790b50ea2a46b4f
data/README.md CHANGED
@@ -1,6 +1,27 @@
1
- ## aromancer gem
1
+ # [aromancer](https://rubygems.org/gems/aromancer)
2
+ ## word
3
+ ### sentence
4
+ #### scroll
5
+ #### chapter
6
+ ##### dictionary
7
+ ##### story
8
+ ###### legend
9
+ ###### [aromancer_serve](https://github.com/arowmancy/aromancer_serve)
2
10
 
3
- # todos:
4
- - settings
5
- - server url
6
- - force ssl
11
+ `tl;dr`
12
+
13
+ ```bash
14
+ gem install aromancer && aromancer serve
15
+ ```
16
+ > then, from different terminal run
17
+ ```bash
18
+ aromancer
19
+ ```
20
+ #### `in-game`
21
+ > go to `configure` and verify settings
22
+
23
+ [rubygems](https://rubygems.org/gems/aromancer)
24
+ [license](http://opensource.org/licenses/MIT)
25
+ [issues](https://github.com/i2097i/aromancer/issues)
26
+
27
+ #### aromancer by i2097i is copyright (2026)
data/aromancer.gemspec CHANGED
@@ -13,7 +13,7 @@
13
13
  require_relative "lib/aromancer/version"
14
14
 
15
15
  Gem::Specification.new do |spec|
16
- spec.name = "aromancer"
16
+ spec.name = Aromancer.to_s.downcase
17
17
  spec.version = Aromancer::VERSION
18
18
  spec.authors = ["i2097i"]
19
19
  spec.email = ["i2097i@hotmail.com"]
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.license = "MIT"
25
25
  spec.files = `git ls-files`.split("\n").reject{|p| p.match?(/^(spec|.release|.*.gem$)/)}
26
26
  spec.bindir = "bin"
27
- spec.executables = ["aromancer"]
27
+ spec.executables = [Aromancer.to_s.downcase]
28
28
  spec.require_paths = ["lib", "db"]
29
29
  spec.required_ruby_version = ">= 4.0.7"
30
30
 
data/bin/aromancer CHANGED
@@ -12,4 +12,8 @@
12
12
 
13
13
  require :aromancer.to_s
14
14
 
15
- Aromancer::Cli.run
15
+ if ARGV[0] == :serve.to_s
16
+ Aromancer::Serve.run
17
+ else
18
+ Aromancer::Cli.run
19
+ end
@@ -0,0 +1 @@
1
+ 67c2e2ec251ed1f69ccd21bd1501d8a0ade0f56392d893217a5e528b40418a2f573ef3f3749d6a034b7a40c2fbf1d6e2486c2adfe488983d2e5a8d5149528109
@@ -0,0 +1 @@
1
+ 2183e762fd2705e60f043abdb5db94f220945cad83e3dc6813bb0c03f5bd000cd3cf3b4628a470335b075ef8a6180644d9d6e18695f17bc202fe9d8cb3126068
data/lib/aromancer/api.rb CHANGED
@@ -13,34 +13,35 @@
13
13
  module Aromancer
14
14
  class Api
15
15
 
16
- DATE_FORMAT = "%A %d %b %Y %I:%M:%S %p"
17
-
18
16
  def self.storage_headers(result)
19
17
  result.kind_of?(Aromancer::Server::InternalError) ? nil : result.headers
20
18
  end
21
19
 
22
20
  def self.register_error(response)
23
- Aromancer::Storage.set_last_error({
21
+ le = {
24
22
  status: response.status,
25
23
  headers: storage_headers(response),
26
- body: response.body.to_s[0..444]
27
- })
28
-
24
+ body: response.body.to_s
25
+ }
26
+ Aromancer::Storage.set_last_error(le)
27
+ Aromancer.print_last_error
29
28
  signed_out = false
30
29
  signed_out = response.status == 401
31
- error_body = nil
32
- begin
33
- error_body = JSON.parse(response.body)
34
- rescue StandardError => e
35
- end
30
+ # error_body = nil
31
+ # begin
32
+ # error_body = JSON.parse(response.body)
33
+ # rescue StandardError => e
34
+ # end
36
35
 
37
- signed_out = signed_out &&
38
- !error_body.nil? &&
39
- error_body.keys.include?(:error_message.to_s) &&
40
- error_body["error_message"] == "not signed in"
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"
41
40
 
42
- Aromancer::Storage.instance.clear_cache! if signed_out
43
- Aromancer::Storage.set_signed_out_flag(signed_out)
41
+ if signed_out
42
+ Aromancer::Storage.instance.clear_cache!
43
+ Aromancer::Storage.set_signed_out_flag(signed_out)
44
+ end
44
45
  end
45
46
 
46
47
  def self.sign_in
@@ -93,9 +94,15 @@ module Aromancer
93
94
  def self.sign_out
94
95
  result = Aromancer::Server.sign_out
95
96
  # clear storage
97
+ Aromancer::Storage.instance.clear_cache!
98
+ Aromancer::Storage.set_signed_out_flag(false)
96
99
  Aromancer::Storage.set_player(nil)
100
+ Aromancer::Storage.set_legends(nil)
101
+ Aromancer::Storage.set_arena(nil)
102
+ Aromancer::Storage.set_stream(nil)
97
103
  Aromancer::Storage.set_last_error(nil)
98
- FileUtils.rm_rf(Aromancer::Storage.storage_filepath)
104
+
105
+ Aromancer::Websocket.instance.disconnect
99
106
 
100
107
  register_error(result) if result.status != 200
101
108
  end
@@ -110,6 +117,9 @@ module Aromancer
110
117
  result = Aromancer::Server.create_legend({legend: params})
111
118
  if result.status == 201
112
119
  response = JSON.parse(result.body)
120
+ if Aromancer::Storage.get_preference(:debug)
121
+ Aromancer::Prompt.say(JSON.pretty_generate(response))
122
+ end
113
123
  set_active_legend_id(response["id"])
114
124
  else
115
125
  register_error(result)
@@ -122,12 +132,24 @@ module Aromancer
122
132
  response = JSON.parse(result.body)
123
133
  Aromancer::Storage.set_legends(response)
124
134
  else
125
- Aromancer::Storage.set_legends([])
135
+ Aromancer::Storage.set_legends(nil)
126
136
  register_error(result)
127
137
  end
128
138
  end
129
139
 
130
140
  def self.set_active_legend_id(active_legend_id)
141
+
142
+ previous_arena = Aromancer::Storage.get_arena
143
+ Aromancer::Storage.set_arena(nil)
144
+
145
+ # update local storage first
146
+ player = Aromancer::Storage.get_player
147
+ unless player.nil?
148
+ previous_active_legend_id = player["active_legend_id"]
149
+ player["active_legend_id"] = active_legend_id
150
+ Aromancer::Storage.set_player(player)
151
+ end
152
+ Aromancer::Storage.instance.clear_cache!
131
153
  result = Aromancer::Server.update_player({player: {
132
154
  active_legend_id: active_legend_id,
133
155
  status: active_legend_id.nil? ? :lobby : :playing
@@ -137,6 +159,14 @@ module Aromancer
137
159
  response = JSON.parse(result.body)
138
160
  Aromancer::Storage.set_player(response)
139
161
  else
162
+ # revert local storage
163
+ player = Aromancer::Storage.get_player
164
+ unless player.nil?
165
+ player["active_legend_id"] = previous_active_legend_id
166
+ Aromancer::Storage.set_player(player)
167
+ end
168
+ Aromancer::Storage.set_arena(previous_arena)
169
+
140
170
  register_error(result)
141
171
  end
142
172
  end
@@ -152,8 +182,8 @@ module Aromancer
152
182
  end
153
183
  end
154
184
 
155
- def self.load_stream
156
- result = Aromancer::Server.get_stream
185
+ def self.load_stream(count = nil)
186
+ result = Aromancer::Server.get_stream(count)
157
187
 
158
188
  if result.status == 200
159
189
  response = JSON.parse(result.body)
@@ -174,26 +204,24 @@ module Aromancer
174
204
  end
175
205
  end
176
206
 
177
- def self.create_turn(arena_params)
178
- result = Aromancer::Server.create_turn({arena: arena_params})
179
- if result.status == 201
207
+ def self.submit_turn(request_uuid, option = {})
208
+ result = Aromancer::Server.submit_turn(request_uuid, option)
209
+ if result.status == 200
180
210
  response = JSON.parse(result.body)
181
- load_arena
211
+ Aromancer::Storage.set_arena(response)
182
212
  else
183
213
  register_error(result)
184
214
  end
185
215
  end
186
216
 
187
- def self.update_turn(arena_params)
188
- result = Aromancer::Server.update_turn({arena: arena_params})
217
+ def self.load_rules
218
+ result = Aromancer::Server.load_rules
189
219
  if result.status == 200
190
- response = JSON.parse(result.body)
191
- load_arena
220
+ return JSON.parse(result.body)
192
221
  else
193
222
  register_error(result)
194
223
  end
195
224
  end
196
-
197
225
  end
198
226
 
199
227
  end
@@ -28,8 +28,24 @@ module Aromancer
28
28
  Aromancer::Prompt.instance.prompt
29
29
  end
30
30
 
31
- def self.say(message)
32
- (message.kind_of?(String) ? message.split("\n").each{|l| p.say(l.to_s.center(TTY::Screen.width))} : message)
31
+ def self.print_divider(text = nil)
32
+ puts "\n" if TTY::Screen.width > 99.9
33
+ self.p.say((text || "").center(TTY::Screen.width / 2.2, "-").center(TTY::Screen.width))
34
+ puts "\n" if TTY::Screen.width > 99.9
35
+ end
36
+
37
+ def self.say(message, ljust: false, rjust: false)
38
+ center = !ljust && !rjust
39
+ if message.kind_of?(String)
40
+ # puts "\n" if TTY::Screen.width > 99.9
41
+ message.split("\n").each{|l|
42
+ self.p.say(l.to_s.ljust(TTY::Screen.width)) if ljust
43
+ self.p.say(l.to_s.center(TTY::Screen.width)) if center
44
+ self.p.say(l.to_s.rjust(TTY::Screen.width)) if rjust
45
+ }
46
+ else
47
+ self.p.say(message)
48
+ end
33
49
  end
34
50
  end
35
51