admiral_stats_parser 0.1.7 → 0.1.8

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
  SHA1:
3
- metadata.gz: 21c3548c1043a396927fd0e6893258b699303d6c
4
- data.tar.gz: 9306cca5e82f639df4286f0d477b2c74643ebc58
3
+ metadata.gz: aef0c8b05ae9d0b5927985b4adddac004e9d8cd7
4
+ data.tar.gz: 2caebc70574e70a7d2d0bc5316aa3a1aa18c7a98
5
5
  SHA512:
6
- metadata.gz: a246e7a4560863fb3dfebdf0f337791deb08bcdc5d711bdd6b36a035077d5bfaaaba647743f1508aa44d73f08c66effc72b3d8d3c3dd2e609f725b0c5fc0e4b7
7
- data.tar.gz: 470107dac29c48e72f892e5b85664a53a9c91951d134d80e34d369b50d24dc576cd7b6befd07d6c053bec59e2c16cfd18e09afd1235a7a0a0bc8ca43f5b388aa
6
+ metadata.gz: 8a494052c90c15bb4fb249e6ce6e2f83d727a01b02a660c16378baeb95c89424d436a12251347e14cee59d0b3c9ffc09e1c9016b31d65ae85fc787acacef69e4
7
+ data.tar.gz: cf820f157bedac27f066eaef137724f978b1a6ad7c4bab3a71bad66b33c207ff2eb1f7fa560e4b9984309611644d4271234be4d9de99963cac5dfa4ab96f7d13
@@ -136,8 +136,7 @@ class EventInfoParser
136
136
  list = event_info_list.select{|info| info.level == level }
137
137
 
138
138
  # その周回をクリア済みかどうか
139
- # 最初の海域が 'NOOPEN' でなく、かつ 'NOTCLEAR' の海域が存在しない場合はクリア済み
140
- cleared = ( list.first.area_clear_state != 'NOOPEN' and list.select{|i| i.area_clear_state == 'NOTCLEAR' }.size == 0 )
139
+ cleared = EventInfoParser.all_cleared?(event_info_list, level)
141
140
 
142
141
  # 現在の周回数
143
142
  loop_count = list.map{|i| i.loop_count }.max
@@ -149,12 +148,12 @@ class EventInfoParser
149
148
  # 丙 E-1 クリア済みの場合も、乙 E-1 クリア済みの場合も 1 を返します。
150
149
  # E-1 未クリアの場合は 0 を返します。
151
150
  def self.cleared_stage_no(event_info_list, level)
151
+ # その難易度が未開放の場合は、0 を返す
152
+ return 0 unless EventInfoParser.opened?(event_info_list, level)
153
+
152
154
  # 指定されたレベルの情報を、サブ海域番号の小さい順に取り出し
153
155
  list = event_info_list.select{|info| info.level == level}.sort_by {|info| info.area_sub_id }
154
156
 
155
- # 最初の海域が NOOPEN の場合は、難易度自体が開放されていないため、0 を返す
156
- return 0 if list.first.area_clear_state == 'NOOPEN'
157
-
158
157
  list.each_with_index do |info, prev_stage_no|
159
158
  return prev_stage_no if info.area_clear_state == 'NOTCLEAR'
160
159
  end
@@ -166,10 +165,13 @@ class EventInfoParser
166
165
  # 与えられたリストから、攻略中のステージの海域ゲージの現在値を返します。
167
166
  # 全ステージクリア後、および掃討戦の場合は 0 を返します。
168
167
  def self.current_military_gauge_left(event_info_list, level)
168
+ # 全ステージクリア後は 0 を返す
169
+ return 0 if EventInfoParser.all_cleared?(event_info_list, level)
170
+
169
171
  # 指定されたレベルの情報を、サブ海域番号の小さい順に取り出し
170
172
  list = event_info_list.select{|info| info.level == level}.sort_by {|info| info.area_sub_id }
171
173
 
172
- list.each_with_index do |info, prev_stage_no|
174
+ list.each do |info|
173
175
  if info.area_clear_state == 'NOTCLEAR' or info.area_clear_state == 'NOOPEN'
174
176
  return info.military_gauge_left
175
177
  end
@@ -178,4 +180,28 @@ class EventInfoParser
178
180
  # NOTCLEAR のエリアがなければ 0 を返す
179
181
  0
180
182
  end
183
+
184
+ # 与えられた難易度が解放済みの場合に true を返します。
185
+ def self.opened?(event_info_list, level)
186
+ # 指定されたレベルの情報を、サブ海域番号の小さい順に取り出し
187
+ list = event_info_list.select{|info| info.level == level}.sort_by {|info| info.area_sub_id }
188
+
189
+ # その難易度のデータがなければ、未開放と見なす(通常は発生しない)
190
+ return false if list.size == 0
191
+
192
+ # 最初の海域の状態が NOOPEN の場合は未開放
193
+ return false if list.first.area_clear_state == 'NOOPEN'
194
+
195
+ true
196
+ end
197
+
198
+ # 与えられた難易度の全海域をクリア済みの場合に true を返します。
199
+ # その難易度が解放済みで、かつ 'NOTCLEAR' の海域が存在しない場合はクリア済みとみなします。
200
+ def self.all_cleared?(event_info_list, level)
201
+ return false unless EventInfoParser.opened?(event_info_list, level)
202
+
203
+ # 指定されたレベルの情報を、サブ海域番号の小さい順に取り出し
204
+ list = event_info_list.select{|info| info.level == level}.sort_by {|info| info.area_sub_id }
205
+ list.select{|i| i.area_clear_state == 'NOTCLEAR' }.size == 0
206
+ end
181
207
  end
@@ -1,3 +1,3 @@
1
1
  module AdmiralStatsParser
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: admiral_stats_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Yoshizawa