aromancer 0.0.5 → 0.0.6

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: e0cceb1c6a55e9d5753254eb63ee964d5607a6d1cf2726bb84cce84992cdc5c8
4
+ data.tar.gz: 8c9b7c1dc2d9d5366f1aa32aa0b40c60d77f31a8779f3a818da897f1e20fc73e
5
5
  SHA512:
6
- metadata.gz: d0d2618429769e3253eaeb474ae51fd5a7cbfa704eef19bbbb730fa1dacc25f0439eeafe6d8268028d0596a9f4efb3a16392ce4e1f0253d5f193642612d6d8f4
7
- data.tar.gz: 6a53306414b2c2921f57e3e2f497ff25901af7f126740a003b572f7d4b2723a1a132be4bf702c3582041eb2965a5adde5d7909c1b0fa7c7531b30f8d1a5a9dde
6
+ metadata.gz: 8d003f5fe55523266a5c68e7960e3e55eeaf8e2b687c5cd4d2bbeb1ea33e78d85d2c878e2309a5154c51eb84d053a1e593ddd9d7a92d9db5c031b223ef735257
7
+ data.tar.gz: de814ec7a6c83262ff9d6b9b699bfb01943080ffe01a0436d570fc14a49991baea16138b9ba4741e7f654769cc2fe3a1efd2c8c71b13f11c84e0b74a1661919d
data/README.md CHANGED
@@ -1,6 +1 @@
1
1
  ## aromancer gem
2
-
3
- # todos:
4
- - settings
5
- - server url
6
- - force ssl
@@ -0,0 +1 @@
1
+ 67c2e2ec251ed1f69ccd21bd1501d8a0ade0f56392d893217a5e528b40418a2f573ef3f3749d6a034b7a40c2fbf1d6e2486c2adfe488983d2e5a8d5149528109
data/lib/aromancer/api.rb CHANGED
@@ -28,19 +28,21 @@ module Aromancer
28
28
 
29
29
  signed_out = false
30
30
  signed_out = response.status == 401
31
- error_body = nil
32
- begin
33
- error_body = JSON.parse(response.body)
34
- rescue StandardError => e
35
- end
31
+ # error_body = nil
32
+ # begin
33
+ # error_body = JSON.parse(response.body)
34
+ # rescue StandardError => e
35
+ # end
36
36
 
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"
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"
41
41
 
42
- Aromancer::Storage.instance.clear_cache! if signed_out
43
- Aromancer::Storage.set_signed_out_flag(signed_out)
42
+ if signed_out
43
+ Aromancer::Storage.instance.clear_cache!
44
+ Aromancer::Storage.set_signed_out_flag(signed_out)
45
+ end
44
46
  end
45
47
 
46
48
  def self.sign_in
@@ -93,9 +95,15 @@ module Aromancer
93
95
  def self.sign_out
94
96
  result = Aromancer::Server.sign_out
95
97
  # clear storage
98
+ Aromancer::Storage.instance.clear_cache!
99
+ Aromancer::Storage.set_signed_out_flag(true)
96
100
  Aromancer::Storage.set_player(nil)
101
+ Aromancer::Storage.set_legends(nil)
102
+ Aromancer::Storage.set_arena(nil)
103
+ Aromancer::Storage.set_stream(nil)
97
104
  Aromancer::Storage.set_last_error(nil)
98
- FileUtils.rm_rf(Aromancer::Storage.storage_filepath)
105
+
106
+ Aromancer::Websocket.instance.disconnect
99
107
 
100
108
  register_error(result) if result.status != 200
101
109
  end
@@ -110,6 +118,9 @@ module Aromancer
110
118
  result = Aromancer::Server.create_legend({legend: params})
111
119
  if result.status == 201
112
120
  response = JSON.parse(result.body)
121
+ if Aromancer::Storage.get_preference(:debug)
122
+ Aromancer::Prompt.say(JSON.pretty_generate(response))
123
+ end
113
124
  set_active_legend_id(response["id"])
114
125
  else
115
126
  register_error(result)
@@ -122,12 +133,13 @@ module Aromancer
122
133
  response = JSON.parse(result.body)
123
134
  Aromancer::Storage.set_legends(response)
124
135
  else
125
- Aromancer::Storage.set_legends([])
136
+ Aromancer::Storage.set_legends(nil)
126
137
  register_error(result)
127
138
  end
128
139
  end
129
140
 
130
141
  def self.set_active_legend_id(active_legend_id)
142
+ Aromancer::Storage.set_arena(nil)
131
143
  result = Aromancer::Server.update_player({player: {
132
144
  active_legend_id: active_legend_id,
133
145
  status: active_legend_id.nil? ? :lobby : :playing
@@ -178,7 +190,6 @@ module Aromancer
178
190
  result = Aromancer::Server.create_turn({arena: arena_params})
179
191
  if result.status == 201
180
192
  response = JSON.parse(result.body)
181
- load_arena
182
193
  else
183
194
  register_error(result)
184
195
  end
@@ -188,7 +199,6 @@ module Aromancer
188
199
  result = Aromancer::Server.update_turn({arena: arena_params})
189
200
  if result.status == 200
190
201
  response = JSON.parse(result.body)
191
- load_arena
192
202
  else
193
203
  register_error(result)
194
204
  end