• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Révisionc0eaf176994ac78e0f2cd8a9a137ccf93e2129b8 (tree)
l'heure2019-07-06 18:14:05
AuteurKazuhiro Fujieda <fujieda@user...>
CommiterKazuhiro Fujieda

Message de Log

QuestCounterの見通しをよくする

Change Summary

Modification

--- a/KancolleSniffer/KancolleSniffer.csproj
+++ b/KancolleSniffer/KancolleSniffer.csproj
@@ -57,6 +57,7 @@
5757 <Compile Include="Model\AirBaseParams.cs" />
5858 <Compile Include="Model\QuestCounter.cs" />
5959 <Compile Include="Model\QuestCountList.cs" />
60+ <Compile Include="Model\QuestSpec.cs" />
6061 <Compile Include="Privacy.cs" />
6162 <Compile Include="Log\LogProcessor.cs" />
6263 <Compile Include="Model\Achievement.cs" />
--- a/KancolleSniffer/Model/QuestCounter.cs
+++ b/KancolleSniffer/Model/QuestCounter.cs
@@ -160,6 +160,26 @@ namespace KancolleSniffer.Model
160160 private int _cell;
161161 private bool _boss;
162162
163+ private class ResultShipSpecs
164+ {
165+ public ResultShipSpecs(BattleInfo battleInfo)
166+ {
167+ Specs = battleInfo.Result?.Friend.Main.Where(s => s.NowHp > 0).Select(ship => ship.Spec).ToArray() ?? new ShipSpec[0];
168+ Ids = Specs.Select(spec => spec.Id).ToArray();
169+ Types = Specs.Select(spec => spec.ShipType).ToArray();
170+ Classes = Specs.Select(spec => spec.ShipClass).ToArray();
171+ Flagship = Specs.FirstOrDefault();
172+ FlagshipType = Types.FirstOrDefault();
173+ }
174+
175+ public ShipSpec[] Specs { get; }
176+ public int[] Ids { get; }
177+ public int[] Types { get; }
178+ public int[] Classes { get; }
179+ public ShipSpec Flagship { get; }
180+ public int FlagshipType { get; }
181+ }
182+
163183 public QuestCounter(QuestInfo questInfo, ItemInfo itemInfo, BattleInfo battleInfo)
164184 {
165185 _questInfo = questInfo;
@@ -186,272 +206,253 @@ namespace KancolleSniffer.Model
186206 _cell = json.api_no() ? (int)json.api_no : 0;
187207 _boss = (int)json.api_event_id == 5;
188208
189- if (_quests.TryGetValue(861, out var q861))
209+ if (_quests.TryGetValue(861, out var q861) && _map == 16 && (int)json.api_event_id == 8)
190210 {
191- if (_map == 16 && (int)json.api_event_id == 8)
192- {
193- var fleet = _battleInfo.Result.Friend.Main.Where(s => s.NowHp > 0).Select(s => s.Spec.ShipType)
194- .ToArray();
195- if (fleet.Count(s => s == 10 || s == 22) == 2)
196- Increment(q861.Count);
197- }
211+ if (new ResultShipSpecs(_battleInfo).Types.Count(s => s == 10 || s == 22) == 2)
212+ Increment(q861.Count);
198213 }
199214 }
200215
216+ private class Rank
217+ {
218+ private readonly string _rank;
219+
220+ public Rank(string rank)
221+ {
222+ _rank = rank;
223+ }
224+
225+ public bool S => QuestSortie.CompareRank(_rank, "S") == 0;
226+ public bool A => QuestSortie.CompareRank(_rank, "A") <= 0;
227+ public bool B => QuestSortie.CompareRank(_rank, "B") <= 0;
228+ }
229+
201230 public void InspectBattleResult(dynamic json)
202231 {
203- var rank = json.api_win_rank;
232+ var rawRak = json.api_win_rank;
233+ var rank = new Rank(rawRak);
234+ var specs = new ResultShipSpecs(_battleInfo);
204235 foreach (var quest in _quests.Values)
205236 {
206237 var count = quest.Count;
207238 switch (count.Spec)
208239 {
209240 case QuestSortie sortie:
210- if (count.Id == 216 && !_boss || sortie.Check(rank, _map, _boss))
241+ if (count.Id == 216 && !_boss || sortie.Check(rawRak, _map, _boss))
211242 Increment(count);
212- break;
243+ continue;
213244 case QuestEnemyType enemyType:
214245 var num = enemyType.CountResult(
215246 _battleInfo.Result.Enemy.Main.Concat(_battleInfo.Result.Enemy.Guard));
216247 if (num > 0)
217248 Add(count, num);
218- break;
219- }
220- }
221- if (_quests.TryGetValue(214, out var ago))
222- {
223- var count = ago.Count;
224- if (_boss)
225- {
226- IncrementNth(count, 2);
227- if (QuestSortie.CompareRank(rank, "B") <= 0)
228- IncrementNth(count, 3);
229- }
230- if (rank == "S")
231- IncrementNth(count, 1);
232- }
233- if (_quests.TryGetValue(249, out var q249))
234- {
235- if (_map == 25 && _boss && QuestSortie.CompareRank(rank, "S") == 0)
236- {
237- var fleet = _battleInfo.Result.Friend.Main.Where(s => s.NowHp > 0).Select(s => s.Spec.Id)
238- .ToArray();
239- if (fleet.Intersect(new[] {62, 63, 64, 265, 266, 268, 319, 192, 194}).Count() == 3)
240- Increment(q249.Count);
241- }
242- }
243- if (_quests.TryGetValue(257, out var q257))
244- {
245- if (_map == 14 && _boss && QuestSortie.CompareRank(rank, "S") == 0)
246- {
247- var fleet = _battleInfo.Result.Friend.Main.Where(s => s.NowHp > 0).Select(s => s.Spec.ShipType)
248- .ToArray();
249- if (fleet[0] == 3 && fleet.Count(s => s == 3) <= 3 && fleet.All(s => s == 2 || s == 3))
250- Increment(q257.Count);
251- }
252- }
253- if (_quests.TryGetValue(259, out var q259))
254- {
255- if (_map == 51 && _boss && QuestSortie.CompareRank(rank, "S") == 0)
256- {
257- var fleet = _battleInfo.Result.Friend.Main.Where(s => s.NowHp > 0).Select(s => s.Spec).ToArray();
258- // ReSharper disable once IdentifierTypo
259- var ctype = new[]
260- {
261- 2, // 伊勢型
262- 19, // 長門型
263- 26, // 扶桑型
264- 37 // 大和型
265- };
266- if (fleet.Select(s => s.ShipClass).Count(c => ctype.Contains(c)) == 3 &&
267- fleet.Count(s => s.ShipType == 3) > 0)
268- {
269- Increment(q259.Count);
270- }
271- }
272- }
273- if (_quests.TryGetValue(264, out var q264))
274- {
275- if (_map == 42 && _boss && QuestSortie.CompareRank(rank, "S") == 0)
276- {
277- var fleet = _battleInfo.Result.Friend.Main.Where(s => s.NowHp > 0).Select(s => s.Spec)
278- .ToArray();
279- if (fleet.Count(spec => spec.ShipType == 2) >= 2 &&
280- fleet.Count(spec => spec.IsAircraftCarrier) >= 2)
281- Increment(q264.Count);
282- }
283- }
284- if (_quests.TryGetValue(266, out var q266))
285- {
286- if (_map == 25 && _boss && QuestSortie.CompareRank(rank, "S") == 0)
287- {
288- var fleet = _battleInfo.Result.Friend.Main.Where(s => s.NowHp > 0).Select(s => s.Spec.ShipType)
289- .ToArray();
290- if (fleet[0] == 2 && fleet.OrderBy(x => x).SequenceEqual(new[] {2, 2, 2, 2, 3, 5}))
291- Increment(q266.Count);
249+ continue;
292250 }
293- }
294- if (_quests.TryGetValue(280, out var q280))
295- {
296- if (!(_boss && QuestSortie.CompareRank(rank, "S") == 0))
297- return;
298- var shipTypes = _battleInfo.Result.Friend.Main.Where(s => s.NowHp > 0).Select(s => s.Spec.ShipType)
299- .ToArray();
300- if (!(shipTypes.Count(type => type == 1 || type == 2) >= 3 &&
301- shipTypes.Any(type => new[] {3, 4, 7, 21}.Contains(type))))
302- return;
303- var count = q280.Count;
304- switch (_map)
251+ switch (quest.Id)
305252 {
306- case 12:
307- IncrementNth(count, 0);
308- break;
309- case 13:
310- IncrementNth(count, 1);
311- break;
312- case 14:
313- IncrementNth(count, 2);
314- break;
315- case 21:
316- IncrementNth(count, 3);
317- break;
318- }
319- }
320- if (_quests.TryGetValue(854, out var opz) && _boss)
321- {
322- var count = opz.Count;
323- switch (_map)
324- {
325- case 24 when QuestSortie.CompareRank(rank, "A") <= 0:
326- IncrementNth(count, 0);
327- break;
328- case 61 when QuestSortie.CompareRank(rank, "A") <= 0:
329- IncrementNth(count, 1);
253+ case 214:
254+ if (rank.S)
255+ IncrementNth(count, 1);
256+ if (_boss)
257+ {
258+ IncrementNth(count, 2);
259+ if (rank.B)
260+ IncrementNth(count, 3);
261+ }
330262 break;
331- case 63 when QuestSortie.CompareRank(rank, "A") <= 0:
332- IncrementNth(count, 2);
263+ case 249:
264+ if (_map == 25 && _boss && rank.S &&
265+ specs.Ids.Intersect(new[] {62, 63, 64, 265, 266, 268, 319, 192, 194}).Count() == 3)
266+ {
267+ Increment(count);
268+ }
333269 break;
334- case 64 when QuestSortie.CompareRank(rank, "S") <= 0:
335- IncrementNth(count, 3);
270+ case 257:
271+ if (_map == 14 && _boss && rank.S &&
272+ specs.FlagshipType == 3 &&
273+ specs.Types.Count(s => s == 3) <= 3 &&
274+ specs.Types.All(s => s == 2 || s == 3))
275+ {
276+ Increment(count);
277+ }
336278 break;
337- }
338- }
339- if (_quests.TryGetValue(862, out var q862))
340- {
341- if (_map == 63 && _boss && QuestSortie.CompareRank(rank, "A") <= 0)
342- {
343- var fleet = _battleInfo.Result.Friend.Main.Where(s => s.NowHp > 0).Select(s => s.Spec.ShipType)
344- .ToArray();
345- if (fleet.Count(s => s == 3) >= 2 && fleet.Count(s => s == 16) >= 1)
346- Increment(q862.Count);
347- }
348- }
349- if (_quests.TryGetValue(873, out var q873))
350- {
351- if (_battleInfo.Result.Friend.Main.Count(s => s.NowHp > 0 && s.Spec.ShipType == 3) >= 1 &&
352- _boss && QuestSortie.CompareRank(rank, "A") <= 0)
353- {
354- var count = q873.Count;
355- switch (_map)
356- {
357- case 31:
358- IncrementNth(count, 0);
359- break;
360- case 32:
361- IncrementNth(count, 1);
362- break;
363- case 33:
364- IncrementNth(count, 2);
365- break;
366- }
367- }
368- }
369- if (_quests.TryGetValue(875, out var q875))
370- {
371- if (_map == 54 && _boss && QuestSortie.CompareRank(rank, "S") == 0)
372- {
373- var fleet = _battleInfo.Result.Friend.Main.Where(s => s.NowHp > 0).Select(s => s.Spec.Id).ToArray();
374- if (fleet.Contains(543) && fleet.Intersect(new[] {344, 345, 359}).Any())
375- Increment(q875.Count);
376- }
377- }
378- if (_quests.TryGetValue(888, out var q888))
379- {
380- if (!_boss || QuestSortie.CompareRank(rank, "S") != 0)
381- return;
382- var fleet = from ship in _battleInfo.Result.Friend.Main where ship.NowHp > 0 select ship.Spec.Id;
383- var member = new[]
384- {
385- 69, 272, 427, // 鳥海
386- 61, 264, // 青葉
387- 123, 295, 142, // 衣笠
388- 59, 262, 416, // 古鷹
389- 60, 263, 417, // 加古
390- 51, 213, 477, // 天龍
391- 115, 293 // 夕張
392- };
393- if (fleet.Intersect(member).Count() < 4)
394- return;
395- var count = q888.Count;
396- switch (_map)
397- {
398- case 51:
399- IncrementNth(count, 0);
279+ case 259:
280+ if (_map == 51 && _boss && rank.S &&
281+ specs.Types.Count(type => type == 3) > 0 &&
282+ specs.Classes.Count(c => new[]
283+ {
284+ 2, // 伊勢型
285+ 19, // 長門型
286+ 26, // 扶桑型
287+ 37 // 大和型
288+ }.Contains(c)) == 3)
289+ {
290+ Increment(count);
291+ }
400292 break;
401- case 53:
402- IncrementNth(count, 1);
293+ case 264:
294+ if (_map == 42 && _boss && rank.S &&
295+ specs.Types.Count(type => type == 2) >= 2 &&
296+ specs.Specs.Count(spec => spec.IsAircraftCarrier) >= 2)
297+ {
298+ Increment(count);
299+ }
403300 break;
404- case 54:
405- IncrementNth(count, 2);
301+ case 266:
302+ if (_map == 25 && _boss && rank.S &&
303+ specs.FlagshipType == 2 &&
304+ specs.Types.OrderBy(x => x).SequenceEqual(new[] {2, 2, 2, 2, 3, 5}))
305+ {
306+ Increment(count);
307+ }
406308 break;
407- }
408- }
409- if (_quests.TryGetValue(893, out var q893))
410- {
411- if (!_boss || QuestSortie.CompareRank(rank, "S") != 0)
412- return;
413- var count = q893.Count;
414- switch (_map)
415- {
416- case 15:
417- IncrementNth(count, 0);
309+ case 280:
310+ if (!(_boss && rank.S))
311+ return;
312+ if (!(specs.Types.Count(type => type == 1 || type == 2) >= 3 &&
313+ specs.Types.Any(type => new[] {3, 4, 7, 21}.Contains(type))))
314+ return;
315+ switch (_map)
316+ {
317+ case 12:
318+ IncrementNth(count, 0);
319+ break;
320+ case 13:
321+ IncrementNth(count, 1);
322+ break;
323+ case 14:
324+ IncrementNth(count, 2);
325+ break;
326+ case 21:
327+ IncrementNth(count, 3);
328+ break;
329+ }
418330 break;
419- case 71:
420- IncrementNth(count, 1);
331+ case 854:
332+ if (_boss)
333+ {
334+ switch (_map)
335+ {
336+ case 24 when rank.A:
337+ IncrementNth(count, 0);
338+ break;
339+ case 61 when rank.A:
340+ IncrementNth(count, 1);
341+ break;
342+ case 63 when rank.A:
343+ IncrementNth(count, 2);
344+ break;
345+ case 64 when rank.S:
346+ IncrementNth(count, 3);
347+ break;
348+ }
349+ }
421350 break;
422- case 72:
423- if (_cell == 7)
351+ case 862:
352+ if (_map == 63 && _boss && rank.A &&
353+ specs.Types.Count(s => s == 3) >= 2 &&
354+ specs.Types.Count(s => s == 16) >= 1)
424355 {
425- IncrementNth(count, 2);
426- break;
356+ Increment(count);
427357 }
428- IncrementNth(count, 3);
429358 break;
430- }
431- }
432- if (_quests.TryGetValue(894, out var q894))
433- {
434- if (!_boss ||
435- QuestSortie.CompareRank(rank, "S") != 0 ||
436- !_battleInfo.Result.Friend.Main.Any(s => s.Spec.IsAircraftCarrier && s.NowHp > 0))
437- return;
438- var count = q894.Count;
439- switch (_map)
440- {
441- case 13:
442- IncrementNth(count, 0);
359+ case 873:
360+ if (_boss && rank.A &&
361+ specs.Types.Count(type => type == 3) >= 1)
362+ {
363+ switch (_map)
364+ {
365+ case 31:
366+ IncrementNth(count, 0);
367+ break;
368+ case 32:
369+ IncrementNth(count, 1);
370+ break;
371+ case 33:
372+ IncrementNth(count, 2);
373+ break;
374+ }
375+ }
443376 break;
444- case 14:
445- IncrementNth(count, 1);
377+ case 875:
378+ if (_map == 54 && _boss && rank.S &&
379+ specs.Ids.Contains(543) &&
380+ specs.Ids.Intersect(new[] {344, 345, 359}).Any())
381+ {
382+ Increment(count);
383+ }
446384 break;
447- case 21:
448- IncrementNth(count, 2);
385+ case 888:
386+ if (!_boss || !rank.S)
387+ return;
388+ var member = new[]
389+ {
390+ 69, 272, 427, // 鳥海
391+ 61, 264, // 青葉
392+ 123, 295, 142, // 衣笠
393+ 59, 262, 416, // 古鷹
394+ 60, 263, 417, // 加古
395+ 51, 213, 477, // 天龍
396+ 115, 293 // 夕張
397+ };
398+ if (specs.Ids.Intersect(member).Count() < 4)
399+ return;
400+ switch (_map)
401+ {
402+ case 51:
403+ IncrementNth(count, 0);
404+ break;
405+ case 53:
406+ IncrementNth(count, 1);
407+ break;
408+ case 54:
409+ IncrementNth(count, 2);
410+ break;
411+ }
449412 break;
450- case 22:
451- IncrementNth(count, 3);
413+ case 893:
414+ if (!_boss || !rank.S)
415+ return;
416+ switch (_map)
417+ {
418+ case 15:
419+ IncrementNth(count, 0);
420+ break;
421+ case 71:
422+ IncrementNth(count, 1);
423+ break;
424+ case 72:
425+ if (_cell == 7)
426+ {
427+ IncrementNth(count, 2);
428+ break;
429+ }
430+ IncrementNth(count, 3);
431+ break;
432+ }
452433 break;
453- case 23:
454- IncrementNth(count, 4);
434+ case 894:
435+ if (!_boss || !rank.S ||
436+ !specs.Specs.Any(spec => spec.IsAircraftCarrier))
437+ return;
438+ switch (_map)
439+ {
440+ case 13:
441+ IncrementNth(count, 0);
442+ break;
443+ case 14:
444+ IncrementNth(count, 1);
445+ break;
446+ case 21:
447+ IncrementNth(count, 2);
448+ break;
449+ case 22:
450+ IncrementNth(count, 3);
451+ break;
452+ case 23:
453+ IncrementNth(count, 4);
454+ break;
455+ }
455456 break;
456457 }
457458 }
@@ -467,31 +468,35 @@ namespace KancolleSniffer.Model
467468
468469 public void InspectPracticeResult(dynamic json)
469470 {
471+ var rank = new Rank(json.api_win_rank);
472+ var specs = new ResultShipSpecs(_battleInfo);
470473 foreach (var quest in _quests.Values)
471474 {
472475 var count = quest.Count;
473- if (!(count.Spec is QuestPractice practice))
474- continue;
475- if (practice.Check(json.api_win_rank))
476- Increment(count);
477- }
478- if (_quests.TryGetValue(318, out var q318))
479- {
480- if (_questFleet == 0 && QuestSortie.CompareRank(json.api_win_rank, "B") <= 0 &&
481- _battleInfo.Result.Friend.Main.Count(s => s.Spec.ShipType == 3) >= 2)
476+ if (count.Spec is QuestPractice practice)
482477 {
483- Increment(q318.Count);
478+ if (practice.Check(json.api_win_rank))
479+ Increment(count);
480+ continue;
484481 }
485- }
486- if (_quests.TryGetValue(330, out var q330))
487- {
488- var fleet = _battleInfo.Result.Friend.Main;
489- if (QuestSortie.CompareRank(json.api_win_rank, "B") <= 0 &&
490- fleet.Count(s => s.Spec.IsAircraftCarrier) >= 2 &&
491- fleet.Count(s => s.Spec.ShipType == 2) >= 2 &&
492- fleet[0].Spec.IsAircraftCarrier)
482+ switch (quest.Id)
493483 {
494- Increment(q330.Count);
484+ case 318:
485+ if (_questFleet == 0 && rank.B &&
486+ specs.Types.Count(type => type == 3) >= 2)
487+ {
488+ Increment(count);
489+ }
490+ break;
491+ case 330:
492+ if (rank.B &&
493+ specs.Flagship.IsAircraftCarrier &&
494+ specs.Specs.Count(spec => spec.IsAircraftCarrier) >= 2 &&
495+ specs.Types.Count(type => type == 2) >= 2)
496+ {
497+ Increment(count);
498+ }
499+ break;
495500 }
496501 }
497502 }
@@ -514,43 +519,44 @@ namespace KancolleSniffer.Model
514519 foreach (var quest in _quests.Values)
515520 {
516521 var count = quest.Count;
517- if (!(count.Spec is QuestMission mission))
518- continue;
519- if (mission.Check(mid))
520- Increment(count);
521- }
522- if (_quests.TryGetValue(426, out var q426))
523- {
524- var count = q426.Count;
525- switch (mid)
522+ if (count.Spec is QuestMission mission)
526523 {
527- case 3:
528- IncrementNth(count, 0);
529- break;
530- case 4:
531- IncrementNth(count, 1);
532- break;
533- case 5:
534- IncrementNth(count, 2);
535- break;
536- case 10:
537- IncrementNth(count, 3);
538- break;
524+ if (mission.Check(mid))
525+ Increment(count);
526+ continue;
539527 }
540- }
541- if (_quests.TryGetValue(428, out var q428))
542- {
543- var count = q428.Count;
544- switch (mid)
528+ switch (quest.Id)
545529 {
546- case 4:
547- IncrementNth(count, 0);
548- break;
549- case 101:
550- IncrementNth(count, 1);
530+ case 426:
531+ switch (mid)
532+ {
533+ case 3:
534+ IncrementNth(count, 0);
535+ break;
536+ case 4:
537+ IncrementNth(count, 1);
538+ break;
539+ case 5:
540+ IncrementNth(count, 2);
541+ break;
542+ case 10:
543+ IncrementNth(count, 3);
544+ break;
545+ }
551546 break;
552- case 102:
553- IncrementNth(count, 2);
547+ case 428:
548+ switch (mid)
549+ {
550+ case 4:
551+ IncrementNth(count, 0);
552+ break;
553+ case 101:
554+ IncrementNth(count, 1);
555+ break;
556+ case 102:
557+ IncrementNth(count, 2);
558+ break;
559+ }
554560 break;
555561 }
556562 }
@@ -588,16 +594,18 @@ namespace KancolleSniffer.Model
588594 foreach (var quest in _quests.Values)
589595 {
590596 var count = quest.Count;
591- if (!(count.Spec is QuestDestroyItem destroy))
597+ if (count.Spec is QuestDestroyItem destroy)
598+ {
599+ if (destroy.Count(count, items))
600+ NeedSave = true;
592601 continue;
593- if (destroy.Count(count, items))
602+ }
603+ if (quest.Id == 680)
604+ {
605+ count.NowArray[0] += items.Count(spec => spec.Type == 21);
606+ count.NowArray[1] += items.Count(spec => spec.Type == 12 || spec.Type == 13);
594607 NeedSave = true;
595- }
596- if (_quests.TryGetValue(680, out var q680))
597- {
598- q680.Count.NowArray[0] += items.Count(spec => spec.Type == 21);
599- q680.Count.NowArray[1] += items.Count(spec => spec.Type == 12 || spec.Type == 13);
600- NeedSave = true;
608+ }
601609 }
602610 }
603611
--- a/KancolleSniffer/Model/QuestInfo.cs
+++ b/KancolleSniffer/Model/QuestInfo.cs
@@ -65,86 +65,6 @@ namespace KancolleSniffer.Model
6565 Quarterly
6666 }
6767
68- public class QuestSpec
69- {
70- public QuestInterval Interval { get; set; }
71- public int Max { get; set; }
72- public int[] MaxArray { get; set; }
73- public bool AdjustCount { get; set; } = true;
74- public int Shift { get; set; }
75- public int[] Material { get; set; }
76- }
77-
78- public class QuestSortie : QuestSpec
79- {
80- public string Rank { get; set; }
81- public int[] Maps { get; set; }
82-
83- public static int CompareRank(string a, string b)
84- {
85- const string ranks = "SABCDE";
86- return ranks.IndexOf(a, StringComparison.Ordinal) -
87- ranks.IndexOf(b, StringComparison.Ordinal);
88- }
89-
90- public bool Check(string rank, int map, bool boss)
91- {
92- return (Rank == null || CompareRank(rank, Rank) <= 0) &&
93- (Maps == null || Maps.Contains(map) && boss);
94- }
95- }
96-
97- public class QuestEnemyType : QuestSpec
98- {
99- public int[] EnemyType { get; set; } = new int[0];
100-
101- public int CountResult(IEnumerable<ShipStatus> enemyResult) =>
102- enemyResult.Count(ship => ship.NowHp == 0 && EnemyType.Contains(ship.Spec.ShipType));
103- }
104-
105- public class QuestPractice : QuestSpec
106- {
107- public bool Win { get; set; }
108- public bool Check(string rank) => !Win || QuestSortie.CompareRank(rank, "B") <= 0;
109- }
110-
111- public class QuestMission : QuestSpec
112- {
113- public int[] Ids { get; set; }
114- public bool Check(int id) => Ids == null || Ids.Contains(id);
115- }
116-
117- public class QuestDestroyItem : QuestSpec
118- {
119- public int[] Types { get; set; }
120- public int[] Ids { get; set; }
121-
122- public bool Count(QuestCount count, ItemSpec[] specs)
123- {
124- if (count.NowArray == null)
125- {
126- var num = specs.Count(spec => Types?.Contains(spec.Type) ?? (Ids?.Contains(spec.Id) ?? true));
127- count.Now += num;
128- return num > 0;
129- }
130- if (Types == null && Ids == null)
131- return false;
132- var result = false;
133- for (var i = 0; i < count.NowArray.Length; i++)
134- {
135- var num = specs.Count(spec => Types != null ? Types[i] == spec.Type : Ids[i] == spec.Id);
136- count.NowArray[i] += num;
137- if (num > 0)
138- result = true;
139- }
140- return result;
141- }
142- }
143-
144- public class QuestPowerUp : QuestSpec
145- {
146- }
147-
14868 public class QuestInfo : IHaveState
14969 {
15070 private readonly SortedDictionary<int, QuestStatus> _quests = new SortedDictionary<int, QuestStatus>();
--- /dev/null
+++ b/KancolleSniffer/Model/QuestSpec.cs
@@ -0,0 +1,100 @@
1+// Copyright (C) 2019 Kazuhiro Fujieda <fujieda@users.osdn.me>
2+//
3+// Licensed under the Apache License, Version 2.0 (the "License");
4+// you may not use this file except in compliance with the License.
5+// You may obtain a copy of the License at
6+//
7+// http://www.apache.org/licenses/LICENSE-2.0
8+//
9+// Unless required by applicable law or agreed to in writing, software
10+// distributed under the License is distributed on an "AS IS" BASIS,
11+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+// See the License for the specific language governing permissions and
13+// limitations under the License.
14+
15+using System;
16+using System.Collections.Generic;
17+using System.Linq;
18+
19+namespace KancolleSniffer.Model
20+{
21+ public class QuestSpec
22+ {
23+ public QuestInterval Interval { get; set; }
24+ public int Max { get; set; }
25+ public int[] MaxArray { get; set; }
26+ public bool AdjustCount { get; set; } = true;
27+ public int Shift { get; set; }
28+ public int[] Material { get; set; }
29+ }
30+
31+ public class QuestSortie : QuestSpec
32+ {
33+ public string Rank { get; set; }
34+ public int[] Maps { get; set; }
35+
36+ public static int CompareRank(string a, string b)
37+ {
38+ const string ranks = "SABCDE";
39+ return ranks.IndexOf(a, StringComparison.Ordinal) -
40+ ranks.IndexOf(b, StringComparison.Ordinal);
41+ }
42+
43+ public bool Check(string rank, int map, bool boss)
44+ {
45+ return (Rank == null || CompareRank(rank, Rank) <= 0) &&
46+ (Maps == null || Maps.Contains(map) && boss);
47+ }
48+ }
49+
50+ public class QuestEnemyType : QuestSpec
51+ {
52+ public int[] EnemyType { get; set; } = new int[0];
53+
54+ public int CountResult(IEnumerable<ShipStatus> enemyResult) =>
55+ enemyResult.Count(ship => ship.NowHp == 0 && EnemyType.Contains(ship.Spec.ShipType));
56+ }
57+
58+ public class QuestPractice : QuestSpec
59+ {
60+ public bool Win { get; set; }
61+ public bool Check(string rank) => !Win || QuestSortie.CompareRank(rank, "B") <= 0;
62+ }
63+
64+ public class QuestMission : QuestSpec
65+ {
66+ public int[] Ids { get; set; }
67+ public bool Check(int id) => Ids == null || Ids.Contains(id);
68+ }
69+
70+ public class QuestDestroyItem : QuestSpec
71+ {
72+ public int[] Types { get; set; }
73+ public int[] Ids { get; set; }
74+
75+ public bool Count(QuestCount count, ItemSpec[] specs)
76+ {
77+ if (count.NowArray == null)
78+ {
79+ var num = specs.Count(spec => Types?.Contains(spec.Type) ?? (Ids?.Contains(spec.Id) ?? true));
80+ count.Now += num;
81+ return num > 0;
82+ }
83+ if (Types == null && Ids == null)
84+ return false;
85+ var result = false;
86+ for (var i = 0; i < count.NowArray.Length; i++)
87+ {
88+ var num = specs.Count(spec => Types != null ? Types[i] == spec.Type : Ids[i] == spec.Id);
89+ count.NowArray[i] += num;
90+ if (num > 0)
91+ result = true;
92+ }
93+ return result;
94+ }
95+ }
96+
97+ public class QuestPowerUp : QuestSpec
98+ {
99+ }
100+}
\ No newline at end of file