OSDN Git Service

補給時に即座に情報を更新するようにした
authormasakih <masakih@users.sourceforge.jp>
Tue, 23 Sep 2014 16:06:11 +0000 (01:06 +0900)
committermasakih <masakih@users.sourceforge.jp>
Tue, 23 Sep 2014 16:06:11 +0000 (01:06 +0900)
KCD.xcodeproj/project.pbxproj
KCD/HMApplySuppliesCommand.h [new file with mode: 0644]
KCD/HMApplySuppliesCommand.m [new file with mode: 0644]
KCD/HMHokyuChargeCommand.h [new file with mode: 0644]
KCD/HMHokyuChargeCommand.m [new file with mode: 0644]
KCD/HMMemberMaterialCommand.m

index 882a62e..dd72773 100644 (file)
@@ -64,6 +64,8 @@
                F4AA06101931869E00844688 /* HMBattleResultCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4AA060F1931869E00844688 /* HMBattleResultCommand.m */; };
                F4B1E30819C73B6A00805879 /* HMSuppliesCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F4B1E30419C73B6A00805879 /* HMSuppliesCell.m */; };
                F4B1E30919C73B6A00805879 /* HMSuppliesView.m in Sources */ = {isa = PBXBuildFile; fileRef = F4B1E30619C73B6A00805879 /* HMSuppliesView.m */; };
+               F4B1E30C19D1C06900805879 /* HMHokyuChargeCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4B1E30B19D1C06900805879 /* HMHokyuChargeCommand.m */; };
+               F4B1E30F19D1C9C400805879 /* HMApplySuppliesCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4B1E30E19D1C9C400805879 /* HMApplySuppliesCommand.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 */; };
                F4B1E30419C73B6A00805879 /* HMSuppliesCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMSuppliesCell.m; sourceTree = "<group>"; };
                F4B1E30519C73B6A00805879 /* HMSuppliesView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMSuppliesView.h; sourceTree = "<group>"; };
                F4B1E30619C73B6A00805879 /* HMSuppliesView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMSuppliesView.m; sourceTree = "<group>"; };
+               F4B1E30A19D1C06900805879 /* HMHokyuChargeCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMHokyuChargeCommand.h; sourceTree = "<group>"; };
+               F4B1E30B19D1C06900805879 /* HMHokyuChargeCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMHokyuChargeCommand.m; sourceTree = "<group>"; };
+               F4B1E30D19D1C9C400805879 /* HMApplySuppliesCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMApplySuppliesCommand.h; sourceTree = "<group>"; };
+               F4B1E30E19D1C9C400805879 /* HMApplySuppliesCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMApplySuppliesCommand.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>"; };
                                F43BA4A6197CD59400CFF788 /* HMNyukyoSpeedChangeCommand.m */,
                                F4A3AD8619B6149D00FDBF80 /* HMNyukyoStartCommand.h */,
                                F4A3AD8719B6149D00FDBF80 /* HMNyukyoStartCommand.m */,
+                               F4B1E30A19D1C06900805879 /* HMHokyuChargeCommand.h */,
+                               F4B1E30B19D1C06900805879 /* HMHokyuChargeCommand.m */,
+                               F4B1E30D19D1C9C400805879 /* HMApplySuppliesCommand.h */,
+                               F4B1E30E19D1C9C400805879 /* HMApplySuppliesCommand.m */,
                        );
                        name = Command;
                        sourceTree = "<group>";
                                F4513EEE18B8E2F600073552 /* HMMemberMaterialCommand.m in Sources */,
                                F4FCFD44191F4C1D000640A1 /* HMKenzoMarkCommand.m in Sources */,
                                F4BDEB53187252F30069D0CE /* main.m in Sources */,
+                               F4B1E30F19D1C9C400805879 /* HMApplySuppliesCommand.m in Sources */,
                                F48F7B021907D7B800E78AE1 /* HMPortCommand.m in Sources */,
                                F494DC5F18C30AE100AE97E4 /* HMMissionStatus.m in Sources */,
                                F4268031194D1B1A00B2C27F /* HMChangeHenseiCommand.m in Sources */,
                                F494DC6718C8BA6400AE97E4 /* HMPowerUpSupportViewController.m in Sources */,
                                F43BA4A7197CD59400CFF788 /* HMNyukyoSpeedChangeCommand.m in Sources */,
                                F4A3AD8819B6149D00FDBF80 /* HMNyukyoStartCommand.m in Sources */,
+                               F4B1E30C19D1C06900805879 /* HMHokyuChargeCommand.m in Sources */,
                                F494DC6318C608C100AE97E4 /* HMShipViewController.m in Sources */,
                                F46F104918ABAC910063E503 /* KCD.xcdatamodeld in Sources */,
                                F4B414FE18B3A66200468DAF /* HMMemberNDockCommand.m in Sources */,
diff --git a/KCD/HMApplySuppliesCommand.h b/KCD/HMApplySuppliesCommand.h
new file mode 100644 (file)
index 0000000..06f3331
--- /dev/null
@@ -0,0 +1,13 @@
+//
+//  HMApplySuppliesCommand.h
+//  KCD
+//
+//  Created by Hori,Masaki on 2014/09/24.
+//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMJSONCommand.h"
+
+@interface HMApplySuppliesCommand : HMJSONCommand
+
+@end
diff --git a/KCD/HMApplySuppliesCommand.m b/KCD/HMApplySuppliesCommand.m
new file mode 100644 (file)
index 0000000..3d90e8e
--- /dev/null
@@ -0,0 +1,39 @@
+//
+//  HMApplySuppliesCommand.m
+//  KCD
+//
+//  Created by Hori,Masaki on 2014/09/24.
+//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMApplySuppliesCommand.h"
+
+#import "HMServerDataStore.h"
+
+
+@implementation HMApplySuppliesCommand
+- (void)execute
+{
+       HMServerDataStore *store = [HMServerDataStore oneTimeEditor];
+       
+       NSDictionary *data = self.json[@"api_data"];
+       NSArray *shipInfos = data[@"api_ship"];
+       
+       for(NSDictionary *updataInfo in shipInfos) {
+               NSError *error = nil;
+               NSArray *array = [store objectsWithEntityName:@"Ship"
+                                                                                               error:&error
+                                                                         predicateFormat:@"id = %@", @([updataInfo[@"api_id"] integerValue])];
+               if(array.count == 0) {
+                       if(error) {
+                               NSLog(@"Error: at %@ : %@", NSStringFromClass([self class]), error);
+                       }
+                       continue;
+               }
+               
+               id ship = array[0];
+               [ship setValue:updataInfo[@"api_bull"] forKey:@"bull"];
+               [ship setValue:updataInfo[@"api_fuel"] forKey:@"fuel"];
+       }
+}
+@end
diff --git a/KCD/HMHokyuChargeCommand.h b/KCD/HMHokyuChargeCommand.h
new file mode 100644 (file)
index 0000000..2d020be
--- /dev/null
@@ -0,0 +1,13 @@
+//
+//  HMHokyuChargeCommand.h
+//  KCD
+//
+//  Created by Hori,Masaki on 2014/09/23.
+//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMCompositCommand.h"
+
+@interface HMHokyuChargeCommand : HMCompositCommand
+
+@end
diff --git a/KCD/HMHokyuChargeCommand.m b/KCD/HMHokyuChargeCommand.m
new file mode 100644 (file)
index 0000000..c8c17fb
--- /dev/null
@@ -0,0 +1,37 @@
+//
+//  HMHokyuChargeCommand.m
+//  KCD
+//
+//  Created by Hori,Masaki on 2014/09/23.
+//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMHokyuChargeCommand.h"
+
+#import "HMMemberMaterialCommand.h"
+#import "HMApplySuppliesCommand.h"
+
+
+@implementation HMHokyuChargeCommand
++ (void)load
+{
+       static dispatch_once_t onceToken;
+       dispatch_once(&onceToken, ^{
+               [HMJSONCommand registerClass:self];
+       });
+}
+
++ (BOOL)canExcuteAPI:(NSString *)api
+{
+       return [api isEqualToString:@"/kcsapi/api_req_hokyu/charge"];
+}
+
+- (id)init
+{
+       self = [super initWithCommands:
+                       [HMMemberMaterialCommand new],
+                       [HMApplySuppliesCommand new],
+                       nil];
+       return self;
+}
+@end
index e29c8a3..37c9c29 100644 (file)
@@ -22,7 +22,7 @@
 + (BOOL)canExcuteAPI:(NSString *)api
 {
        if([api isEqualToString:@"/kcsapi/api_get_member/material"]) return YES;
-       if([api isEqualToString:@"/kcsapi/api_req_hokyu/charge"]) return YES;
+//     if([api isEqualToString:@"/kcsapi/api_req_hokyu/charge"]) return YES;
        return NO;
 }
 - (NSString *)dataKey