OSDN Git Service

開発成功時に装備の更新を行うようにした
authormasakih <masakih@users.sourceforge.jp>
Tue, 29 Apr 2014 04:51:16 +0000 (13:51 +0900)
committermasakih <masakih@users.sourceforge.jp>
Tue, 29 Apr 2014 04:51:16 +0000 (13:51 +0900)
KCD.xcodeproj/project.pbxproj
KCD/HMCreateSlotItemCommand.m
KCD/HMUpdateslotItemCommand.h [new file with mode: 0644]
KCD/HMUpdateslotItemCommand.m [new file with mode: 0644]

index 866fa26..a1c37f5 100644 (file)
@@ -8,6 +8,7 @@
 
 /* Begin PBXBuildFile section */
                F4131ECF190F5C08004F7F9A /* HMStoreCreateSlotItemHistoryCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4131ECE190F5C08004F7F9A /* HMStoreCreateSlotItemHistoryCommand.m */; };
+               F4131ED5190F63D8004F7F9A /* HMUpdateslotItemCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4131ED4190F63D8004F7F9A /* HMUpdateslotItemCommand.m */; };
                F43E67B718BE02A10087E5B6 /* STypeShortName.plist in Resources */ = {isa = PBXBuildFile; fileRef = F43E67B618BE02A10087E5B6 /* STypeShortName.plist */; };
                F43E67B918BE060E0087E5B6 /* LevelUpExp.plist in Resources */ = {isa = PBXBuildFile; fileRef = F43E67B818BE060E0087E5B6 /* LevelUpExp.plist */; };
                F4513EDD18B619B600073552 /* HMCoreDataManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F4513EDC18B619B600073552 /* HMCoreDataManager.m */; };
 /* Begin PBXFileReference section */
                F4131ECD190F5C08004F7F9A /* HMStoreCreateSlotItemHistoryCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMStoreCreateSlotItemHistoryCommand.h; sourceTree = "<group>"; };
                F4131ECE190F5C08004F7F9A /* HMStoreCreateSlotItemHistoryCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMStoreCreateSlotItemHistoryCommand.m; sourceTree = "<group>"; };
+               F4131ED3190F63D8004F7F9A /* HMUpdateslotItemCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMUpdateslotItemCommand.h; sourceTree = "<group>"; };
+               F4131ED4190F63D8004F7F9A /* HMUpdateslotItemCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMUpdateslotItemCommand.m; sourceTree = "<group>"; };
                F43E67B618BE02A10087E5B6 /* STypeShortName.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = STypeShortName.plist; sourceTree = "<group>"; };
                F43E67B818BE060E0087E5B6 /* LevelUpExp.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = LevelUpExp.plist; sourceTree = "<group>"; };
                F4513EDB18B619B600073552 /* HMCoreDataManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMCoreDataManager.h; sourceTree = "<group>"; };
                                F4B3DBC918DDB9170011B4FC /* HMCreateSlotItemCommand.m */,
                                F4131ECD190F5C08004F7F9A /* HMStoreCreateSlotItemHistoryCommand.h */,
                                F4131ECE190F5C08004F7F9A /* HMStoreCreateSlotItemHistoryCommand.m */,
+                               F4131ED3190F63D8004F7F9A /* HMUpdateslotItemCommand.h */,
+                               F4131ED4190F63D8004F7F9A /* HMUpdateslotItemCommand.m */,
                                F48F7B001907D7B800E78AE1 /* HMPortCommand.h */,
                                F48F7B011907D7B800E78AE1 /* HMPortCommand.m */,
                        );
                                F4C118FA18A67B1C005D5B25 /* CacheStoragePolicy.m in Sources */,
                                F4B3DC2118DECF570011B4FC /* HMTSVSupport.m in Sources */,
                                F4E7802E18DC3AF00011BC4C /* LocalData.xcdatamodeld in Sources */,
+                               F4131ED5190F63D8004F7F9A /* HMUpdateslotItemCommand.m in Sources */,
                                F4C1190518A71AEA005D5B25 /* HMJSONReciever.m in Sources */,
                                F4B414F818B1D35800468DAF /* HMMasterMissionCommand.m in Sources */,
                                F4E33B5818BF5F67005B8C07 /* HMMemberSlotItemCommand.m in Sources */,
index 843e9cb..e506ab3 100644 (file)
@@ -9,6 +9,7 @@
 #import "HMCreateSlotItemCommand.h"
 
 #import "HMMemberMaterialCommand.h"
+#import "HMUpdateslotItemCommand.h"
 #import "HMStoreCreateSlotItemHistoryCommand.h"
 
 
@@ -31,7 +32,9 @@
 {
        self = [super init];
        self = [[super class] compositCommandWithCommands:
-                       [HMStoreCreateSlotItemHistoryCommand new], [HMMemberMaterialCommand new],
+                       [HMMemberMaterialCommand new],
+                       [HMUpdateslotItemCommand new],
+                       [HMStoreCreateSlotItemHistoryCommand new],
                        nil];
        return self;
 }
diff --git a/KCD/HMUpdateslotItemCommand.h b/KCD/HMUpdateslotItemCommand.h
new file mode 100644 (file)
index 0000000..43db34f
--- /dev/null
@@ -0,0 +1,13 @@
+//
+//  HMUpdateslotItemCommand.h
+//  KCD
+//
+//  Created by Hori,Masaki on 2014/04/29.
+//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMJSONCommand.h"
+
+@interface HMUpdateslotItemCommand : HMJSONCommand
+
+@end
diff --git a/KCD/HMUpdateslotItemCommand.m b/KCD/HMUpdateslotItemCommand.m
new file mode 100644 (file)
index 0000000..ee76165
--- /dev/null
@@ -0,0 +1,43 @@
+//
+//  HMUpdateslotItemCommand.m
+//  KCD
+//
+//  Created by Hori,Masaki on 2014/04/29.
+//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMUpdateslotItemCommand.h"
+
+#import "HMServerDataStore.h"
+
+@implementation HMUpdateslotItemCommand
+- (NSString *)dataKey
+{
+       return @"api_data.api_slot_item";
+}
+- (void)execute
+{
+       NSDictionary *data = [self.json valueForKeyPath:self.dataKey];
+       if(!data || [data isKindOfClass:[NSNull class]]) return;
+       
+       HMServerDataStore *store = [HMServerDataStore oneTimeEditor];
+       NSManagedObjectContext *moc = store.managedObjectContext;
+       
+       NSError *error = nil;
+       
+       NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"MasterSlotItem"];
+       NSPredicate *predicate = [NSPredicate predicateWithFormat:@"id = %@", data[@"api_slotitem_id"]];
+       [request setPredicate:predicate];
+       NSArray *array = [moc executeFetchRequest:request error:&error];
+       if([array count] == 0) {
+               NSLog(@"MasterSlotItem is invalid");
+               return;
+       }
+       
+       id object = [NSEntityDescription insertNewObjectForEntityForName:@"SlotItem"
+                                                                                         inManagedObjectContext:moc];
+       [object setValue:data[@"api_id"] forKey:@"id"];
+       [object setValue:array[0] forKey:@"master_slotItem"];
+}
+
+@end