F4E7802818DBD2A00011BC4C /* HMGetShipCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E7802718DBD2A00011BC4C /* HMGetShipCommand.m */; };
F4E7802B18DC3A820011BC4C /* HMLocalDataStore.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E7802A18DC3A820011BC4C /* HMLocalDataStore.m */; };
F4E7802E18DC3AF00011BC4C /* LocalData.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = F4E7802C18DC3AF00011BC4C /* LocalData.xcdatamodeld */; };
+ F4FCFD44191F4C1D000640A1 /* HMKenzoMarkCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4FCFD43191F4C1D000640A1 /* HMKenzoMarkCommand.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
F4E7802918DC3A820011BC4C /* HMLocalDataStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMLocalDataStore.h; sourceTree = "<group>"; };
F4E7802A18DC3A820011BC4C /* HMLocalDataStore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMLocalDataStore.m; sourceTree = "<group>"; };
F4E7802D18DC3AF00011BC4C /* LocalData.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = LocalData.xcdatamodel; sourceTree = "<group>"; };
+ F4FCFD42191F4C1D000640A1 /* HMKenzoMarkCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMKenzoMarkCommand.h; sourceTree = "<group>"; };
+ F4FCFD43191F4C1D000640A1 /* HMKenzoMarkCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMKenzoMarkCommand.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
F4E33B5718BF5F67005B8C07 /* HMMemberSlotItemCommand.m */,
F4E7802618DBD2A00011BC4C /* HMGetShipCommand.h */,
F4E7802718DBD2A00011BC4C /* HMGetShipCommand.m */,
+ F4FCFD42191F4C1D000640A1 /* HMKenzoMarkCommand.h */,
+ F4FCFD43191F4C1D000640A1 /* HMKenzoMarkCommand.m */,
F4B3DC2818DF31400011B4FC /* HMCreateShipCommand.h */,
F4B3DC2918DF31400011B4FC /* HMCreateShipCommand.m */,
F4B3DBC818DDB9170011B4FC /* HMCreateSlotItemCommand.h */,
F4C1190B18A74DF0005D5B25 /* HMJSONCommand.m in Sources */,
F4B414F518B1888800468DAF /* HMMasterFurnitureCommand.m in Sources */,
F4513EEE18B8E2F600073552 /* HMMemberMaterialCommand.m in Sources */,
+ F4FCFD44191F4C1D000640A1 /* HMKenzoMarkCommand.m in Sources */,
F4BDEB53187252F30069D0CE /* main.m in Sources */,
F48F7B021907D7B800E78AE1 /* HMPortCommand.m in Sources */,
F494DC5F18C30AE100AE97E4 /* HMMissionStatus.m in Sources */,
// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
//
-#import "HMJSONCommand.h"
+#import "HMCompositCommand.h"
-@interface HMGetShipCommand : HMJSONCommand
+@interface HMGetShipCommand : HMCompositCommand
@end
#import "HMGetShipCommand.h"
-#import "HMServerDataStore.h"
-#import "HMLocalDataStore.h"
-#import "HMKenzoHistory.h"
+#import "HMMemberKDockCommand.h"
+#import "HMKenzoMarkCommand.h"
-/**
- * 建造履歴を残す
- */
@implementation HMGetShipCommand
+ (void)load
{
+ (BOOL)canExcuteAPI:(NSString *)api
{
- if([api isEqualToString:@"/kcsapi/api_req_kousyou/getship"]) return YES;
-
- return NO;
+ return [api isEqualToString:@"/kcsapi/api_req_kousyou/getship"];
}
-- (void)execute
+
+- (id)init
{
- HMServerDataStore *serverDataStore = [HMServerDataStore defaultManager];
- NSArray *array = [serverDataStore objectsWithEntityName:@"KenzoDock" error:NULL predicateFormat:@"id = %@", [self.arguments valueForKey:@"api_kdock_id"]];
- if([array count] == 0) {
- NSLog(@"KenzoDock data is invalid.");
- return;
- }
-
- id kdock = array[0];
- NSNumber *item1 = [kdock valueForKey:@"item1"];
-
- //
- array = [serverDataStore objectsWithEntityName:@"MasterShip" error:NULL predicateFormat:@"id = %@", [kdock valueForKey:@"created_ship_id"]];
- if([array count] == 0) {
- NSLog(@"MasterShip data is invalid or ship_id is invalid.");
- return;
- }
- id ship = array[0];
-
- //
- NSNumber *flagShipLv = nil;
- NSString *flafShipName = nil;
- NSNumber *commanderLv = nil;
- HMLocalDataStore *localDataStore = [HMLocalDataStore defaultManager];
- array = [localDataStore objectsWithEntityName:@"KenzoMark"
- error:NULL
- predicateFormat:@"fuel = %@ AND bull = %@ AND steel = %@ AND bauxite = %@ AND kaihatusizai = %@ AND kDockId = %@ AND created_ship_id = %@",
- item1, [kdock valueForKey:@"item2"], [kdock valueForKey:@"item3"], [kdock valueForKey:@"item4"], [kdock valueForKey:@"item5"],
- @([[self.arguments valueForKey:@"api_kdock_id"] integerValue]), [kdock valueForKey:@"created_ship_id"]
- ];
- if([array count] != 0) {
- flagShipLv = [array[0] valueForKey:@"flagShipLv"];
- flafShipName = [array[0] valueForKey:@"flagShipName"];
- commanderLv = [array[0] valueForKey:@"commanderLv"];
- }
-
- HMLocalDataStore *lds = [HMLocalDataStore oneTimeEditor];
- NSManagedObjectContext *localStoreContext = [lds managedObjectContext];
- HMKenzoHistory *newObejct = [NSEntityDescription insertNewObjectForEntityForName:@"KenzoHistory"
- inManagedObjectContext:localStoreContext];
- newObejct.name = [ship valueForKey:@"name"];
- newObejct.sTypeId = [ship valueForKeyPath:@"stype.id"];
- newObejct.fuel = item1;
- newObejct.bull = [kdock valueForKey:@"item2"];
- newObejct.steel = [kdock valueForKey:@"item3"];
- newObejct.bauxite = [kdock valueForKey:@"item4"];
- newObejct.kaihatusizai = [kdock valueForKey:@"item5"];
- newObejct.flagShipLv = flagShipLv;
- newObejct.flagShipName = flafShipName;
- newObejct.commanderLv = commanderLv;
- newObejct.date = [NSDate dateWithTimeIntervalSinceNow:0];
+ self = [super init];
+ self = [[super class] compositCommandWithCommands:
+ [HMMemberKDockCommand new], [HMKenzoMarkCommand new],
+ nil];
+ return self;
}
-
@end
--- /dev/null
+//
+// HMKenzoMarkCommand.h
+// KCD
+//
+// Created by Hori,Masaki on 2014/05/11.
+// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMJSONCommand.h"
+
+@interface HMKenzoMarkCommand : HMJSONCommand
+
+@end
--- /dev/null
+//
+// HMKenzoMarkCommand.m
+// KCD
+//
+// Created by Hori,Masaki on 2014/05/11.
+// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMKenzoMarkCommand.h"
+
+#import "HMServerDataStore.h"
+#import "HMLocalDataStore.h"
+#import "HMKenzoHistory.h"
+
+/**
+ * 建造履歴を残す
+ */
+@implementation HMKenzoMarkCommand
++ (void)load
+{
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ [HMJSONCommand registerClass:self];
+ });
+}
+
++ (BOOL)canExcuteAPI:(NSString *)api
+{
+ if([api isEqualToString:@"/kcsapi/api_req_kousyou/getship"]) return YES;
+
+ return NO;
+}
+- (void)execute
+{
+ HMServerDataStore *serverDataStore = [HMServerDataStore defaultManager];
+ NSArray *array = [serverDataStore objectsWithEntityName:@"KenzoDock" error:NULL predicateFormat:@"id = %@", [self.arguments valueForKey:@"api_kdock_id"]];
+ if([array count] == 0) {
+ NSLog(@"KenzoDock data is invalid.");
+ return;
+ }
+
+ id kdock = array[0];
+ NSNumber *item1 = [kdock valueForKey:@"item1"];
+
+ //
+ array = [serverDataStore objectsWithEntityName:@"MasterShip" error:NULL predicateFormat:@"id = %@", [kdock valueForKey:@"created_ship_id"]];
+ if([array count] == 0) {
+ NSLog(@"MasterShip data is invalid or ship_id is invalid.");
+ return;
+ }
+ id ship = array[0];
+
+ //
+ NSNumber *flagShipLv = nil;
+ NSString *flafShipName = nil;
+ NSNumber *commanderLv = nil;
+ HMLocalDataStore *localDataStore = [HMLocalDataStore defaultManager];
+ array = [localDataStore objectsWithEntityName:@"KenzoMark"
+ error:NULL
+ predicateFormat:@"fuel = %@ AND bull = %@ AND steel = %@ AND bauxite = %@ AND kaihatusizai = %@ AND kDockId = %@ AND created_ship_id = %@",
+ item1, [kdock valueForKey:@"item2"], [kdock valueForKey:@"item3"], [kdock valueForKey:@"item4"], [kdock valueForKey:@"item5"],
+ @([[self.arguments valueForKey:@"api_kdock_id"] integerValue]), [kdock valueForKey:@"created_ship_id"]
+ ];
+ if([array count] != 0) {
+ flagShipLv = [array[0] valueForKey:@"flagShipLv"];
+ flafShipName = [array[0] valueForKey:@"flagShipName"];
+ commanderLv = [array[0] valueForKey:@"commanderLv"];
+ }
+
+ HMLocalDataStore *lds = [HMLocalDataStore oneTimeEditor];
+ NSManagedObjectContext *localStoreContext = [lds managedObjectContext];
+ HMKenzoHistory *newObejct = [NSEntityDescription insertNewObjectForEntityForName:@"KenzoHistory"
+ inManagedObjectContext:localStoreContext];
+ newObejct.name = [ship valueForKey:@"name"];
+ newObejct.sTypeId = [ship valueForKeyPath:@"stype.id"];
+ newObejct.fuel = item1;
+ newObejct.bull = [kdock valueForKey:@"item2"];
+ newObejct.steel = [kdock valueForKey:@"item3"];
+ newObejct.bauxite = [kdock valueForKey:@"item4"];
+ newObejct.kaihatusizai = [kdock valueForKey:@"item5"];
+ newObejct.flagShipLv = flagShipLv;
+ newObejct.flagShipName = flafShipName;
+ newObejct.commanderLv = commanderLv;
+ newObejct.date = [NSDate dateWithTimeIntervalSinceNow:0];
+}
+@end
+ (BOOL)canExcuteAPI:(NSString *)api
{
if([api isEqualToString:@"/kcsapi/api_get_member/kdock"]) return YES;
- if([api isEqualToString:@"/kcsapi/api_req_kousyou/getship"]) return YES;
return NO;
}
- (NSString *)dataKey