F494DC6A18C8BAB900AE97E4 /* HMPowerUpSupportViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F494DC6818C8BAB900AE97E4 /* HMPowerUpSupportViewController.xib */; };
F494DC6D18CC054800AE97E4 /* HMNyukyoDockStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = F494DC6C18CC054800AE97E4 /* HMNyukyoDockStatus.m */; };
F49828FC1902A226000D6BBE /* HMStrokeTextFieldCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F49828FB1902A226000D6BBE /* HMStrokeTextFieldCell.m */; };
+ F4AA05FB192B92C800844688 /* Temporary.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = F4AA05F9192B92C700844688 /* Temporary.xcdatamodeld */; };
+ F4AA05FE192B932E00844688 /* HMTemporaryDataStore.m in Sources */ = {isa = PBXBuildFile; fileRef = F4AA05FD192B932E00844688 /* HMTemporaryDataStore.m */; };
+ F4AA0601192E1FE900844688 /* HMBattleCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4AA0600192E1FE900844688 /* HMBattleCommand.m */; };
+ F4AA0604192E20F500844688 /* HMCalculateDamageCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4AA0603192E20F500844688 /* HMCalculateDamageCommand.m */; };
+ F4AA0607192E3B6200844688 /* HMMapStartCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4AA0606192E3B6200844688 /* HMMapStartCommand.m */; };
+ F4AA060D1930E69200844688 /* HMMidnightBattleCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4AA060C1930E69200844688 /* HMMidnightBattleCommand.m */; };
+ F4AA06101931869E00844688 /* HMBattleResultCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4AA060F1931869E00844688 /* HMBattleResultCommand.m */; };
F4B2D02B18F83A2F00542742 /* HMScreenshotWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4B2D02D18F83A2F00542742 /* HMScreenshotWindowController.xib */; };
F4B2D03118F83CBB00542742 /* HMDeckViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F4B2D02F18F83CBB00542742 /* HMDeckViewController.m */; };
F4B2D03318F83CC800542742 /* HMDeckViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4B2D03518F83CC800542742 /* HMDeckViewController.xib */; };
F494DC6C18CC054800AE97E4 /* HMNyukyoDockStatus.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMNyukyoDockStatus.m; sourceTree = "<group>"; };
F49828FA1902A226000D6BBE /* HMStrokeTextFieldCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMStrokeTextFieldCell.h; sourceTree = "<group>"; };
F49828FB1902A226000D6BBE /* HMStrokeTextFieldCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMStrokeTextFieldCell.m; sourceTree = "<group>"; };
+ F4AA05FA192B92C800844688 /* Temporary.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Temporary.xcdatamodel; sourceTree = "<group>"; };
+ F4AA05FC192B932E00844688 /* HMTemporaryDataStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMTemporaryDataStore.h; sourceTree = "<group>"; };
+ F4AA05FD192B932E00844688 /* HMTemporaryDataStore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMTemporaryDataStore.m; sourceTree = "<group>"; };
+ F4AA05FF192E1FE900844688 /* HMBattleCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMBattleCommand.h; sourceTree = "<group>"; };
+ F4AA0600192E1FE900844688 /* HMBattleCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMBattleCommand.m; sourceTree = "<group>"; };
+ F4AA0602192E20F500844688 /* HMCalculateDamageCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMCalculateDamageCommand.h; sourceTree = "<group>"; };
+ F4AA0603192E20F500844688 /* HMCalculateDamageCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMCalculateDamageCommand.m; sourceTree = "<group>"; };
+ F4AA0605192E3B6200844688 /* HMMapStartCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMMapStartCommand.h; sourceTree = "<group>"; };
+ F4AA0606192E3B6200844688 /* HMMapStartCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMMapStartCommand.m; sourceTree = "<group>"; };
+ F4AA060B1930E69200844688 /* HMMidnightBattleCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMMidnightBattleCommand.h; sourceTree = "<group>"; };
+ F4AA060C1930E69200844688 /* HMMidnightBattleCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMMidnightBattleCommand.m; sourceTree = "<group>"; };
+ F4AA060E1931869E00844688 /* HMBattleResultCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMBattleResultCommand.h; sourceTree = "<group>"; };
+ F4AA060F1931869E00844688 /* HMBattleResultCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMBattleResultCommand.m; sourceTree = "<group>"; };
F4B2D02C18F83A2F00542742 /* ja */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = ja; path = ja.lproj/HMScreenshotWindowController.xib; sourceTree = "<group>"; };
F4B2D02E18F83CBB00542742 /* HMDeckViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMDeckViewController.h; sourceTree = "<group>"; };
F4B2D02F18F83CBB00542742 /* HMDeckViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMDeckViewController.m; sourceTree = "<group>"; };
F4B3DC1D18DEB8C70011B4FC /* HMKenzoHistory.m */,
F4B3DC1918DEAB5E0011B4FC /* HMKaihatuHistory.h */,
F4B3DC1A18DEAB5E0011B4FC /* HMKaihatuHistory.m */,
+ F4AA05F9192B92C700844688 /* Temporary.xcdatamodeld */,
+ F4AA05FC192B932E00844688 /* HMTemporaryDataStore.h */,
+ F4AA05FD192B932E00844688 /* HMTemporaryDataStore.m */,
);
name = CoreData;
sourceTree = "<group>";
F4131ED7190FA08D004F7F9A /* HMDestroyItem2Command.m */,
F48F7B001907D7B800E78AE1 /* HMPortCommand.h */,
F48F7B011907D7B800E78AE1 /* HMPortCommand.m */,
+ F4AA0605192E3B6200844688 /* HMMapStartCommand.h */,
+ F4AA0606192E3B6200844688 /* HMMapStartCommand.m */,
+ F4AA05FF192E1FE900844688 /* HMBattleCommand.h */,
+ F4AA0600192E1FE900844688 /* HMBattleCommand.m */,
+ F4AA060B1930E69200844688 /* HMMidnightBattleCommand.h */,
+ F4AA060C1930E69200844688 /* HMMidnightBattleCommand.m */,
+ F4AA060E1931869E00844688 /* HMBattleResultCommand.h */,
+ F4AA060F1931869E00844688 /* HMBattleResultCommand.m */,
+ F4AA0602192E20F500844688 /* HMCalculateDamageCommand.h */,
+ F4AA0603192E20F500844688 /* HMCalculateDamageCommand.m */,
);
name = Command;
sourceTree = "<group>";
buildActionMask = 2147483647;
files = (
F4513EE818B77A5300073552 /* HMMemberKDockCommand.m in Sources */,
+ F4AA06101931869E00844688 /* HMBattleResultCommand.m in Sources */,
F4B3DC4418E70B370011B4FC /* HMServerDataStore.m in Sources */,
+ F4AA0607192E3B6200844688 /* HMMapStartCommand.m in Sources */,
+ F4AA0604192E20F500844688 /* HMCalculateDamageCommand.m in Sources */,
F4D2CBC518AE2AE2000EBC59 /* HMCompositCommand.m in Sources */,
F4C1190218A6FFC2005D5B25 /* HMQueue.m in Sources */,
F4513EEB18B7900A00073552 /* HMMemberDeckCommand.m in Sources */,
F4E7802E18DC3AF00011BC4C /* LocalData.xcdatamodeld in Sources */,
F4131ED5190F63D8004F7F9A /* HMUpdateSlotItemCommand.m in Sources */,
F4C1190518A71AEA005D5B25 /* HMJSONReciever.m in Sources */,
+ F4AA05FE192B932E00844688 /* HMTemporaryDataStore.m in Sources */,
F4B414F818B1D35800468DAF /* HMMasterMissionCommand.m in Sources */,
F4E33B5818BF5F67005B8C07 /* HMMemberSlotItemCommand.m in Sources */,
F4C1190B18A74DF0005D5B25 /* HMJSONCommand.m in Sources */,
F4B414F518B1888800468DAF /* HMMasterFurnitureCommand.m in Sources */,
+ F4AA0601192E1FE900844688 /* HMBattleCommand.m in Sources */,
F4513EEE18B8E2F600073552 /* HMMemberMaterialCommand.m in Sources */,
F4FCFD44191F4C1D000640A1 /* HMKenzoMarkCommand.m in Sources */,
F4BDEB53187252F30069D0CE /* main.m in Sources */,
F46F104118A9B85E0063E503 /* HMJSONNode.m in Sources */,
F4131ECF190F5C08004F7F9A /* HMStoreCreateSlotItemHistoryCommand.m in Sources */,
F4513EFE18BB6B0C00073552 /* HMKCShipObject.m in Sources */,
+ F4AA05FB192B92C800844688 /* Temporary.xcdatamodeld in Sources */,
F4E7802818DBD2A00011BC4C /* HMGetShipCommand.m in Sources */,
F4513EF618B9F29800073552 /* HMMemberShipCommand.m in Sources */,
F4C1190818A746EB005D5B25 /* HMJSONTracker.m in Sources */,
F4B414E918B09A4B00468DAF /* HMMasterMapAreaCommand.m in Sources */,
F4C3957418CDDFE500A1E918 /* HMKenzoDockStatus.m in Sources */,
F4C118FB18A67B1C005D5B25 /* CanonicalRequest.m in Sources */,
+ F4AA060D1930E69200844688 /* HMMidnightBattleCommand.m in Sources */,
F4131EE91911445F004F7F9A /* HMSlotItemEquipTypeTransformer.m in Sources */,
F4BDEB5A187252F30069D0CE /* HMAppDelegate.m in Sources */,
F4E7802B18DC3A820011BC4C /* HMLocalDataStore.m in Sources */,
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
};
+ F4AA05F9192B92C700844688 /* Temporary.xcdatamodeld */ = {
+ isa = XCVersionGroup;
+ children = (
+ F4AA05FA192B92C800844688 /* Temporary.xcdatamodel */,
+ );
+ currentVersion = F4AA05FA192B92C800844688 /* Temporary.xcdatamodel */;
+ path = Temporary.xcdatamodeld;
+ sourceTree = "<group>";
+ versionGroupType = wrapper.xcdatamodel;
+ };
F4E7802C18DC3AF00011BC4C /* LocalData.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
--- /dev/null
+//
+// HMBattleCommand.h
+// KCD
+//
+// Created by Hori,Masaki on 2014/05/22.
+// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMCompositCommand.h"
+
+@interface HMBattleCommand : HMCompositCommand
+
+@end
--- /dev/null
+//
+// HMBattleCommand.m
+// KCD
+//
+// Created by Hori,Masaki on 2014/05/22.
+// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMBattleCommand.h"
+
+#import "HMCalculateDamageCommand.h"
+
+@implementation HMBattleCommand
++ (void)load
+{
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ [HMJSONCommand registerClass:self];
+ });
+}
+
++ (BOOL)canExcuteAPI:(NSString *)api
+{
+ return [api isEqualToString:@"/kcsapi/api_req_sortie/battle"];
+}
+
+- (id)init
+{
+ self = [super initWithCommands:
+ [HMCalculateDamageCommand new],
+ nil];
+ return self;
+}
+@end
--- /dev/null
+//
+// HMBattleResultCommand.h
+// KCD
+//
+// Created by Hori,Masaki on 2014/05/25.
+// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMCompositCommand.h"
+
+@interface HMBattleResultCommand : HMCompositCommand
+
+@end
--- /dev/null
+//
+// HMBattleResultCommand.m
+// KCD
+//
+// Created by Hori,Masaki on 2014/05/25.
+// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMBattleResultCommand.h"
+
+#import "HMCalculateDamageCommand.h"
+
+@implementation HMBattleResultCommand
++ (void)load
+{
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ [HMJSONCommand registerClass:self];
+ });
+}
+
++ (BOOL)canExcuteAPI:(NSString *)api
+{
+ return [api isEqualToString:@"/kcsapi/api_req_sortie/battleresult"];
+}
+
+- (id)init
+{
+ self = [super initWithCommands:
+ [HMCalculateDamageCommand new],
+ nil];
+ return self;
+}
+@end
--- /dev/null
+//
+// HMCalculateDamageCommand.h
+// KCD
+//
+// Created by Hori,Masaki on 2014/05/22.
+// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMJSONCommand.h"
+
+@interface HMCalculateDamageCommand : HMJSONCommand
+
+@end
--- /dev/null
+//
+// HMCalculateDamageCommand.m
+// KCD
+//
+// Created by Hori,Masaki on 2014/05/22.
+// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMCalculateDamageCommand.h"
+
+#import "HMTemporaryDataStore.h"
+#import "HMServerDataStore.h"
+
+@implementation HMCalculateDamageCommand
+
+- (void)resetDamage
+{
+ HMTemporaryDataStore *store = [HMTemporaryDataStore oneTimeEditor];
+ NSManagedObjectContext *moc = store.managedObjectContext;
+
+ NSArray *array = [store objectsWithEntityName:@"Battle"
+ predicate:nil
+ error:NULL];
+ for(id object in array) {
+ [moc deleteObject:object];
+ }
+
+ array = [store objectsWithEntityName:@"Damage"
+ predicate:nil
+ error:NULL];
+ for(id object in array) {
+ [moc deleteObject:object];
+ }
+
+ [store saveAction:nil];
+}
+
+- (void)startBattle
+{
+ HMTemporaryDataStore *store = [HMTemporaryDataStore oneTimeEditor];
+ NSManagedObjectContext *moc = store.managedObjectContext;
+
+ // Battleエンティティ作成
+ id battle = [NSEntityDescription insertNewObjectForEntityForName:@"Battle"
+ inManagedObjectContext:moc];
+
+ [battle setValue:@([[self.arguments valueForKey:@"api_deck_id"] integerValue]) forKeyPath:@"deckId"];
+ [battle setValue:@([[self.arguments valueForKey:@"api_maparea_id"] integerValue]) forKeyPath:@"mapArea"];
+ [battle setValue:@([[self.arguments valueForKey:@"api_mapinfo_no"] integerValue]) forKeyPath:@"mapInfo"];
+
+ [store saveAction:nil];
+}
+
+- (void)calculateBattle
+{
+ HMTemporaryDataStore *store = [HMTemporaryDataStore oneTimeEditor];
+ NSManagedObjectContext *moc = store.managedObjectContext;
+
+ // 艦隊のチェック
+
+ // Battleエンティティ取得
+ NSArray *battles = [store objectsWithEntityName:@"Battle"
+ predicate:nil
+ error:NULL];
+ if(battles.count == 0) {
+ NSLog(@"Battle is invalid.");
+ return;
+ }
+ id battle = battles[0];
+
+ // Damage エンティティ作成6個
+ NSMutableArray *damages = [NSMutableArray new];
+ for(NSInteger i = 0; i < 6; i++) {
+ id damage = [NSEntityDescription insertNewObjectForEntityForName:@"Damage"
+ inManagedObjectContext:moc];
+ [damage setValue:battle forKeyPath:@"battle"];
+ [damage setValue:@(i) forKeyPath:@"id"];
+ [damages addObject:damage];
+ }
+
+ // koukuu
+ do {
+ id koukuDamage = [self.json valueForKeyPath:@"api_data.api_kouku.api_stage3.api_fdam"];
+ if(!koukuDamage || [koukuDamage isEqual:[NSNull null]]) break;
+ for(NSInteger i = 1; i <= 6; i++) {
+ NSInteger damage = [[koukuDamage objectAtIndex:i] integerValue];
+ id damageObject = [damages objectAtIndex:i];
+ [damageObject setValue:@(damage) forKeyPath:@"damage"];
+ }
+ } while(NO);
+
+ // opening attack
+ do {
+ id openigDamage = [self.json valueForKeyPath:@"api_data.api_opening_atack.api_fdam"];
+ if(!openigDamage || [openigDamage isEqual:[NSNull null]]) break;
+ for(NSInteger i = 0; i < 6; i++) {
+ NSInteger damage = [[openigDamage objectAtIndex:i] integerValue];
+ id damageObject = [damages objectAtIndex:i];
+ damage += [[damageObject valueForKey:@"damage"] integerValue];
+ [damageObject setValue:@(damage) forKeyPath:@"damage"];
+ }
+ } while(NO);
+
+
+ // hougeki1
+ {
+ id targetShips = [self.json valueForKeyPath:@"api_data.api_hougeki1.api_df_list"];
+ id hougeki1Damages = [self.json valueForKeyPath:@"api_data.api_hougeki1.api_damage"];
+ NSInteger i = 0;
+ for(NSArray *array in targetShips) {
+ if(![array isKindOfClass:[NSArray class]]) {
+ i++;
+ continue;
+ }
+
+ NSInteger j = 0;
+ for(id ship in array) {
+ NSInteger target = [ship integerValue];
+ if(target < 0 || target > 6) {
+ j++;
+ continue;
+ }
+
+ id damageObject = [damages objectAtIndex:target];
+ NSInteger damage = [[[hougeki1Damages objectAtIndex:i] objectAtIndex:j] integerValue];
+ damage += [[damageObject valueForKey:@"damage"] integerValue];
+ [damageObject setValue:@(damage) forKeyPath:@"damage"];
+
+ j++;
+ }
+ i++;
+ }
+ }
+
+ // hougeki2
+ do {
+ id hasHougeki2 = [self.json valueForKeyPath:@"api_data.api_hougeki2"];
+ if(!hasHougeki2 || [hasHougeki2 isEqual:[NSNull null]]) break;
+
+ id targetShips = [self.json valueForKeyPath:@"api_data.api_hougeki2.api_df_list"];
+ id hougeki1Damages = [self.json valueForKeyPath:@"api_data.api_hougeki2.api_damage"];
+ NSInteger i = 0;
+ for(NSArray *array in targetShips) {
+ if(![array isKindOfClass:[NSArray class]]) {
+ i++;
+ continue;
+ }
+
+ NSInteger j = 0;
+ for(id ship in array) {
+ NSInteger target = [ship integerValue];
+ if(target < 0 || target > 6) {
+ j++;
+ continue;
+ }
+
+ id damageObject = [damages objectAtIndex:target];
+ NSInteger damage = [[[hougeki1Damages objectAtIndex:i] objectAtIndex:j] integerValue];
+ damage += [[damageObject valueForKey:@"damage"] integerValue];
+ [damageObject setValue:@(damage) forKeyPath:@"damage"];
+
+ j++;
+ }
+ i++;
+ }
+ } while(NO);
+
+
+ // raigeki
+ do {
+ id raigekiDamage = [self.json valueForKeyPath:@"api_data.api_raigeki.api_fdam"];
+ if(!raigekiDamage || [raigekiDamage isEqual:[NSNull null]]) break;
+ for(NSInteger i = 1; i <= 6; i++) {
+ NSInteger damage = [[raigekiDamage objectAtIndex:i] integerValue];
+ id damageObject = [damages objectAtIndex:i - 1];
+ damage += [[damageObject valueForKey:@"damage"] integerValue];
+ [damageObject setValue:@(damage) forKeyPath:@"damage"];
+ }
+ } while(NO);
+
+ [store saveAction:nil];
+}
+
+- (void)calculateMidnightBattle
+{
+ HMTemporaryDataStore *store = [HMTemporaryDataStore oneTimeEditor];
+ NSManagedObjectContext *moc = store.managedObjectContext;
+
+ // Damage 取得
+ NSArray *damages = nil;
+
+ NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Damage"];
+ NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"id" ascending:NO];
+ [request setSortDescriptors:@[sortDescriptor]];
+ damages = [moc executeFetchRequest:request error:NULL];
+ if(damages.count != 6) {
+ NSLog(@"Damage is invalid.");
+ return;
+ }
+
+ // hougeki1
+ {
+ id targetShips = [self.json valueForKeyPath:@"api_data.api_hougeki1.api_df_list"];
+ id hougeki1Damages = [self.json valueForKeyPath:@"api_data.api_hougeki1.api_damage"];
+ NSInteger i = 0;
+ NSInteger j = 0;
+ for(NSArray *array in targetShips) {
+ for(id ship in array) {
+ NSInteger target = [ship integerValue];
+ if(target > 6) {
+ j++;
+ continue;
+ }
+
+ id damageObject = [damages objectAtIndex:target];
+ NSInteger damage = [[[hougeki1Damages objectAtIndex:i] objectAtIndex:j] integerValue];
+ damage += [[damageObject valueForKey:@"damage"] integerValue];
+ [damageObject setValue:@(damage) forKeyPath:@"damage"];
+
+ j++;
+ }
+ i++;
+ }
+ }
+
+ [store saveAction:nil];
+}
+
+- (void)applyDamage
+{
+ HMTemporaryDataStore *store = [HMTemporaryDataStore oneTimeEditor];
+ NSManagedObjectContext *moc = store.managedObjectContext;
+
+ // Damage 取得
+ NSArray *damages = nil;
+
+ NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Damage"];
+ NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"id" ascending:NO];
+ [request setSortDescriptors:@[sortDescriptor]];
+ damages = [moc executeFetchRequest:request error:NULL];
+ if(damages.count != 6) {
+ NSLog(@"Damage is invalid.");
+ return;
+ }
+
+ HMServerDataStore *serverStore = [HMServerDataStore oneTimeEditor];
+
+ // TODO:
+ NSLog(@"MUST IMPLEMENT!!");
+
+ [serverStore saveAction:nil];
+}
+
+- (void)execute
+{
+ if([self.api isEqualToString:@"/kcsapi/api_req_map/start"]) {
+ [self resetDamage];
+ [self startBattle];
+ return;
+ }
+ if([self.api isEqualToString:@"/kcsapi/api_req_sortie/battle"]) {
+ [self calculateBattle];
+ return;
+ }
+ if([self.api isEqualToString:@"/kcsapi/api_req_battle_midnight/battle"]) {
+ [self calculateMidnightBattle];
+ return;
+ }
+ if([self.api isEqualToString:@"/kcsapi/api_req_sortie/battleresult"]) {
+ [self applyDamage];
+ [self resetDamage];
+ return;
+ }
+
+ NSLog(@"undefined battle type");
+}
+
+@end
--- /dev/null
+//
+// HMMapStartCommand.h
+// KCD
+//
+// Created by Hori,Masaki on 2014/05/22.
+// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMCompositCommand.h"
+
+@interface HMMapStartCommand : HMCompositCommand
+
+@end
--- /dev/null
+//
+// HMMapStartCommand.m
+// KCD
+//
+// Created by Hori,Masaki on 2014/05/22.
+// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMMapStartCommand.h"
+
+#import "HMCalculateDamageCommand.h"
+
+@implementation HMMapStartCommand
++ (void)load
+{
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ [HMJSONCommand registerClass:self];
+ });
+}
+
++ (BOOL)canExcuteAPI:(NSString *)api
+{
+ return [api isEqualToString:@"/kcsapi/api_req_map/start"];
+}
+
+- (id)init
+{
+ self = [super initWithCommands:
+ [HMCalculateDamageCommand new],
+ nil];
+ return self;
+}
+@end
--- /dev/null
+//
+// HMMidnightBattleCommand.h
+// KCD
+//
+// Created by Hori,Masaki on 2014/05/24.
+// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMCompositCommand.h"
+
+@interface HMMidnightBattleCommand : HMCompositCommand
+
+@end
--- /dev/null
+//
+// HMMidnightBattleCommand.m
+// KCD
+//
+// Created by Hori,Masaki on 2014/05/24.
+// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMMidnightBattleCommand.h"
+
+#import "HMCalculateDamageCommand.h"
+
+@implementation HMMidnightBattleCommand
++ (void)load
+{
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ [HMJSONCommand registerClass:self];
+ });
+}
+
++ (BOOL)canExcuteAPI:(NSString *)api
+{
+ return [api isEqualToString:@"/kcsapi/api_req_battle_midnight/battle"];
+}
+
+- (id)init
+{
+ self = [super initWithCommands:
+ [HMCalculateDamageCommand new],
+ nil];
+ return self;
+}
+@end
--- /dev/null
+//
+// HMTemporaryDataStore.h
+// KCD
+//
+// Created by Hori,Masaki on 2014/05/20.
+// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMCoreDataManager.h"
+
+@interface HMTemporaryDataStore : HMCoreDataManager
+
+@end
--- /dev/null
+//
+// HMTemporaryDataStore.m
+// KCD
+//
+// Created by Hori,Masaki on 2014/05/20.
+// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMTemporaryDataStore.h"
+
+@implementation HMTemporaryDataStore
++ (void)load
+{
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ [self defaultManager];
+ });
+}
+
+- (NSString *)modelName
+{
+ return @"Temporary";
+}
+- (NSString *)storeFileName
+{
+ return @":memory:";
+}
+- (NSString *)storeType
+{
+ return NSInMemoryStoreType;
+}
+- (NSDictionary *)storeOptions
+{
+// NSDictionary *options = @{
+//#if COREDATA_STORE_TYPE == 0
+// NSSQLitePragmasOption : @{@"journal_mode" : @"MEMORY"},
+//#endif
+// NSMigratePersistentStoresAutomaticallyOption : @YES,
+// NSInferMappingModelAutomaticallyOption : @YES
+// };
+// return options;
+ return nil;
+}
+- (BOOL)deleteAndRetry
+{
+ return YES;
+}
+@end
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="5064" systemVersion="13C1021" minimumToolsVersion="Xcode 4.3" macOSVersion="Automatic" iOSVersion="Automatic">
+ <entity name="Battle" syncable="YES">
+ <attribute name="deckId" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+ <attribute name="mapArea" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+ <attribute name="mapInfo" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+ <relationship name="damages" optional="YES" toMany="YES" maxCount="6" deletionRule="Cascade" ordered="YES" destinationEntity="Damage" inverseName="battle" inverseEntity="Damage" syncable="YES"/>
+ </entity>
+ <entity name="Damage" syncable="YES">
+ <attribute name="damage" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+ <attribute name="id" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+ <relationship name="battle" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Battle" inverseName="damages" inverseEntity="Battle" syncable="YES"/>
+ </entity>
+ <elements>
+ <element name="Battle" positionX="-63" positionY="-18" width="128" height="103"/>
+ <element name="Damage" positionX="-54" positionY="18" width="128" height="88"/>
+ </elements>
+</model>
\ No newline at end of file