return [NSArray arrayWithArray:array];
}
-- (void)calculateHougeki:(NSArray<HMKCDamage *> *)damages targetsKeyPath:(NSString *)targetKeyPath damageKeyPath:(NSString *)damageKeyPath eFlagKeyPath:(NSString *)eFlagKeyPath
+- (void)calculateHougeki:(NSArray<HMKCDamage *> *)damages baseKeyPath:(NSString *)baseKeyPath
{
+ NSString *targetKeyPath = [baseKeyPath stringByAppendingString:@".api_df_list"];
+ NSString *damageKeyPath = [baseKeyPath stringByAppendingString:@".api_damage"];
+ NSString *eFlagKeyPath = [baseKeyPath stringByAppendingString:@".api_at_eflag"];
+
NSArray<NSArray<NSNumber *> *> *targetPositionArraysArray = [self.json valueForKeyPath:targetKeyPath];
if(!targetPositionArraysArray || ![targetPositionArraysArray isKindOfClass:[NSArray class]]) return;
#if DAMAGE_CHECK
- NSLog(@"Start Hougeki %@", targetKeyPath);
+ NSLog(@"Start Hougeki %@", baseKeyPath);
#endif
NSArray<NSArray *> *hougeki1Damages = [self.json valueForKeyPath:damageKeyPath];
[self.store saveAction:nil];
}
-- (void)calculateFDam:(NSArray<HMKCDamage *> *)damages fdamKeyPath:(NSString *)fdamKeyPath
+- (void)calculateFDam:(NSArray<HMKCDamage *> *)damages baseKeyPath:(NSString *)baseKeyPath
{
+ NSString *fdamKeyPath = [baseKeyPath stringByAppendingString:@".api_fdam"];
+
NSArray<NSNumber *> *koukuDamage = [self.json valueForKeyPath:fdamKeyPath];
if(!koukuDamage || ![koukuDamage isKindOfClass:[NSArray class]]) return;
- (void)calcKouku:(NSArray<HMKCDamage *> *)damages
{
[self calculateFDam:damages
- fdamKeyPath:@"api_data.api_kouku.api_stage3.api_fdam"];
+ baseKeyPath:@"api_data.api_kouku.api_stage3"];
[self calculateFDam:damages
- fdamKeyPath:@"api_data.api_kouku2.api_stage3.api_fdam"];
+ baseKeyPath:@"api_data.api_kouku2.api_stage3"];
// 艦隊 戦闘艦隊
// 連合vs通常(水上) 第2
if(self.isCombinedBattle) {
self.calcSecondFleet = YES;
[self calculateFDam:damages
- fdamKeyPath:@"api_data.api_kouku.api_stage3_combined.api_fdam"];
+ baseKeyPath:@"api_data.api_kouku.api_stage3_combined"];
[self calculateFDam:damages
- fdamKeyPath:@"api_data.api_kouku2.api_stage3_combined.api_fdam"];
+ baseKeyPath:@"api_data.api_kouku2.api_stage3_combined"];
self.calcSecondFleet = NO;
}
}
// 連合vs連合(機動) 第2 全体
self.calcSecondFleet = self.battleType == typeCombinedAir || self.battleType == typeCombinedWater;
[self calculateFDam:damages
- fdamKeyPath:@"api_data.api_opening_atack.api_fdam"];
+ baseKeyPath:@"api_data.api_opening_atack"];
self.calcSecondFleet = NO;
}
- (void)calcOpeningTaisen:(NSArray<HMKCDamage *> *)damages
{
self.calcSecondFleet = self.isCombinedBattle;
[self calculateHougeki:damages
- targetsKeyPath:@"api_data.api_opening_taisen.api_df_list"
- damageKeyPath:@"api_data.api_opening_taisen.api_damage"
- eFlagKeyPath:@"api_data.api_opening_taisen.api_at_eflag"];
+ baseKeyPath:@"api_data.api_opening_taisen"];
self.calcSecondFleet = NO;
}
- (void)calcHougeki1:(NSArray<HMKCDamage *> *)damages
// 連合vs連合(機動) 第1
self.calcSecondFleet = self.battleType == typeCombinedAir;
[self calculateHougeki:damages
- targetsKeyPath:@"api_data.api_hougeki1.api_df_list"
- damageKeyPath:@"api_data.api_hougeki1.api_damage"
- eFlagKeyPath:@"api_data.api_hougeki1.api_at_eflag"];
+ baseKeyPath:@"api_data.api_hougeki1"];
self.calcSecondFleet = NO;
}
- (void)calcHougeki2:(NSArray<HMKCDamage *> *)damages
// 連合vs連合(機動) 第1
self.calcEachFleet = self.battleType == typeEachCombinedWater;
[self calculateHougeki:damages
- targetsKeyPath:@"api_data.api_hougeki2.api_df_list"
- damageKeyPath:@"api_data.api_hougeki2.api_damage"
- eFlagKeyPath:@"api_data.api_hougeki2.api_at_eflag"];
+ baseKeyPath:@"api_data.api_hougeki2"];
self.calcEachFleet = NO;
}
- (void)calcHougeki3:(NSArray<HMKCDamage *> *)damages
self.calcSecondFleet = self.battleType == typeCombinedWater;
self.calcEachFleet = self.battleType == typeEachCombinedAir;
[self calculateHougeki:damages
- targetsKeyPath:@"api_data.api_hougeki3.api_df_list"
- damageKeyPath:@"api_data.api_hougeki3.api_damage"
- eFlagKeyPath:@"api_data.api_hougeki3.api_at_eflag"];
+ baseKeyPath:@"api_data.api_hougeki3"];
self.calcSecondFleet = NO;
self.calcEachFleet = NO;
}
self.calcSecondFleet = NO;
}
[self calculateFDam:damages
- fdamKeyPath:@"api_data.api_raigeki.api_fdam"];
+ baseKeyPath:@"api_data.api_raigeki"];
self.calcSecondFleet = NO;
}
- (void)calculateMidnightBattle
// 連合vs連合(機動) 第2
self.calcSecondFleet = self.isCombinedBattle;
[self calculateHougeki:damages
- targetsKeyPath:@"api_data.api_hougeki.api_df_list"
- damageKeyPath:@"api_data.api_hougeki.api_damage"
- eFlagKeyPath:@"api_data.api_hougeki.api_at_eflag"];
+ baseKeyPath:@"api_data.api_hougeki"];
self.calcSecondFleet = NO;
[self.store saveAction:nil];