admiral_stats_parser 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9e468bdbc7341d12bbac3eb19cba7995141628e
4
- data.tar.gz: 02dfb8ffd40b36220449e5688ab9b63ffdf6b6bf
3
+ metadata.gz: 9e5ff7fec872328d25fbe2d5cdd120ed2537e0ee
4
+ data.tar.gz: 88619cde06ff2d7fc43eff9b8706887729dfd981
5
5
  SHA512:
6
- metadata.gz: 1703ef0cce3ec85d6909f3f9cc63e230a4734aa76cd267765a55e7a89037ecba26081135d89778c9eaac37f01fb71c11ef6304675a1a83ebe1f564e713b37a39
7
- data.tar.gz: d221dd576e9216b5cc819e697e01d0219f485903d1d3f88722381cb6a8e8f996d6dc9aba5efe0cdc14c11de376c4ee49dde59522d6d5fa8e483ffad25c107b91
6
+ metadata.gz: 10e51e7510ede251bfda79bc2e2b6bce88c0e9483d412fa9943d67b7d4473c3b51517e15f56fc91e323b987c63d095b335721d2620a99ed1afcc664949e15506
7
+ data.tar.gz: 32093c6b47e575c71dd2976edce24504ec8c337e46fad1f817416aeec0cf95a40c58cd793ad8244db7b104428f895fcbb48d409a958cd4b5928beacf67652370
@@ -111,4 +111,21 @@ module AdmiralStatsParser
111
111
  raise 'unsupported API version'
112
112
  end
113
113
  end
114
+
115
+ # イベント海域情報のサマリを作成します。
116
+ def self.summarize_event_info(event_info_list, level, api_version)
117
+ case api_version
118
+ when 1..3
119
+ raise "API version #{api_version} does not support event info"
120
+ when 4
121
+ {
122
+ current_loop_counts: EventInfoParser.current_loop_counts(event_info_list, level),
123
+ cleared_loop_counts: EventInfoParser.cleared_loop_counts(event_info_list, level),
124
+ cleared_stage_no: EventInfoParser.cleared_stage_no(event_info_list, level),
125
+ current_military_gauge_left: EventInfoParser.current_military_gauge_left(event_info_list, level)
126
+ }
127
+ else
128
+ raise 'unsupported API version'
129
+ end
130
+ end
114
131
  end
@@ -77,7 +77,7 @@ class EventInfo
77
77
  # クリア状態を表す文字列
78
78
  # CLEAR: クリア済み
79
79
  # NOTCLEAR: 出撃可能だが未クリア
80
- # NOOPEN: 出撃不可
80
+ # NOOPEN: 出撃不可(掃討戦クリア後は CLEAR にならず NOOPEN に戻る)
81
81
  attr_accessor :area_clear_state
82
82
 
83
83
  # 海域ゲージの状態
@@ -125,41 +125,6 @@ class EventInfo
125
125
  end
126
126
  end
127
127
 
128
- # 与えられたリストから、現在の周回数を返します。
129
- def self.current_loop_counts(event_info_list, level)
130
- # 指定されたレベルの情報のみ取り出し
131
- list = event_info_list.select{|info| info.level == level }
132
-
133
- # 現在の周回数
134
- list.map{|i| i.loop_count }.max
135
- end
136
-
137
- # 与えられたリストから、クリア済みの周回数を返します。
138
- def self.cleared_loop_counts(event_info_list, level)
139
- # 指定されたレベルの情報のみ取り出し
140
- list = event_info_list.select{|info| info.level == level }
141
-
142
- # その周回をクリア済みかどうか
143
- cleared = (list.size == list.select{|i| i.area_clear_state == 'CLEAR' }.size)
144
-
145
- # 現在の周回数
146
- loop_count = EventInfo.current_loop_counts(event_info_list, level)
147
-
148
- cleared ? loop_count : loop_count - 1
149
- end
150
-
151
- # 与えられたリストから、突破済みのサブ海域番号の最大値を返します。
152
- # まだ突破している海域がない場合は 0 を返します。
153
- def self.cleared_area_sub_id(event_info_list, level)
154
- list = event_info_list.select{|info| info.level == level and info.area_clear_state == 'CLEAR' }
155
-
156
- if list.size == 0
157
- 0
158
- else
159
- list.map{|info| info.area_sub_id }.max
160
- end
161
- end
162
-
163
128
  # 海域撃破ボーナス
164
129
  class EventInfoReward
165
130
  # 初回攻略時か2回目以降かを表すフラグ
@@ -120,4 +120,58 @@ class EventInfoParser
120
120
 
121
121
  results
122
122
  end
123
+
124
+ # 与えられたリストから、現在の周回数を返します。
125
+ def self.current_loop_counts(event_info_list, level)
126
+ # 指定されたレベルの情報のみ取り出し
127
+ list = event_info_list.select{|info| info.level == level }
128
+
129
+ # 現在の周回数
130
+ list.map{|i| i.loop_count }.max
131
+ end
132
+
133
+ # 与えられたリストから、クリア済みの周回数を返します。
134
+ def self.cleared_loop_counts(event_info_list, level)
135
+ # 指定されたレベルの情報のみ取り出し
136
+ list = event_info_list.select{|info| info.level == level }
137
+
138
+ # その周回をクリア済みかどうか
139
+ cleared = ( list.select{|i| i.area_clear_state == 'NOTCLEAR' }.size == 0 )
140
+
141
+ # 現在の周回数
142
+ loop_count = list.map{|i| i.loop_count }.max
143
+
144
+ cleared ? loop_count : loop_count - 1
145
+ end
146
+
147
+ # 与えられたリストから、現在の周回でクリア済みのステージ No. を返します。
148
+ # 丙 E-1 クリア済みの場合も、乙 E-1 クリア済みの場合も 1 を返します。
149
+ # E-1 未クリアの場合は 0 を返します。
150
+ def self.cleared_stage_no(event_info_list, level)
151
+ # 指定されたレベルの情報を、サブ海域番号の小さい順に取り出し
152
+ list = event_info_list.select{|info| info.level == level}.sort_by {|info| info.area_sub_id }
153
+
154
+ list.each_with_index do |info, prev_stage_no|
155
+ return prev_stage_no if info.area_clear_state == 'NOTCLEAR'
156
+ end
157
+
158
+ # NOTCLEAR のエリアがなければ、最終海域の番号を返す
159
+ list.size
160
+ end
161
+
162
+ # 与えられたリストから、攻略中のステージの海域ゲージの現在値を返します。
163
+ # 全ステージクリア後、および掃討戦の場合は 0 を返します。
164
+ def self.current_military_gauge_left(event_info_list, level)
165
+ # 指定されたレベルの情報を、サブ海域番号の小さい順に取り出し
166
+ list = event_info_list.select{|info| info.level == level}.sort_by {|info| info.area_sub_id }
167
+
168
+ list.each_with_index do |info, prev_stage_no|
169
+ if info.area_clear_state == 'NOTCLEAR'
170
+ return info.military_gauge_left
171
+ end
172
+ end
173
+
174
+ # NOTCLEAR のエリアがなければ 0 を返す
175
+ 0
176
+ end
123
177
  end
@@ -1,3 +1,3 @@
1
1
  module AdmiralStatsParser
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: admiral_stats_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Yoshizawa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-30 00:00:00.000000000 Z
11
+ date: 2016-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler