OSDN Git Service

/kcsapi/api_get_member/basicに対応
authormasakih <masakih@users.sourceforge.jp>
Sun, 23 Feb 2014 02:49:48 +0000 (11:49 +0900)
committermasakih <masakih@users.sourceforge.jp>
Sun, 23 Feb 2014 02:49:48 +0000 (11:49 +0900)
KCD.xcodeproj/project.pbxproj
KCD/HMKCManagedObject.m
KCD/HMMemberBasicCommand.h [new file with mode: 0644]
KCD/HMMemberBasicCommand.m [new file with mode: 0644]
KCD/KCD.xcdatamodeld/KCD.xcdatamodel/contents

index 88882fe..570be7a 100644 (file)
@@ -14,6 +14,7 @@
                F4513EEB18B7900A00073552 /* HMMemberDeckCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4513EEA18B7900A00073552 /* HMMemberDeckCommand.m */; };
                F4513EEE18B8E2F600073552 /* HMMemberMaterialCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4513EED18B8E2F600073552 /* HMMemberMaterialCommand.m */; };
                F4513EF018B96C6C00073552 /* Links.rtf in Resources */ = {isa = PBXBuildFile; fileRef = F4513EEF18B96C6C00073552 /* Links.rtf */; };
+               F4513EF318B991F800073552 /* HMMemberBasicCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4513EF218B991F800073552 /* HMMemberBasicCommand.m */; };
                F46F103618A7CE310063E503 /* HMJSONViewCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F46F103518A7CE310063E503 /* HMJSONViewCommand.m */; };
                F46F104118A9B85E0063E503 /* HMJSONNode.m in Sources */ = {isa = PBXBuildFile; fileRef = F46F104018A9B85E0063E503 /* HMJSONNode.m */; };
                F46F104518AA50730063E503 /* HMBroserWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = F46F104318AA50730063E503 /* HMBroserWindowController.m */; };
@@ -78,6 +79,8 @@
                F4513EEC18B8E2F600073552 /* HMMemberMaterialCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMMemberMaterialCommand.h; sourceTree = "<group>"; };
                F4513EED18B8E2F600073552 /* HMMemberMaterialCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMMemberMaterialCommand.m; sourceTree = "<group>"; };
                F4513EEF18B96C6C00073552 /* Links.rtf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.rtf; path = Links.rtf; sourceTree = "<group>"; };
+               F4513EF118B991F800073552 /* HMMemberBasicCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMMemberBasicCommand.h; sourceTree = "<group>"; };
+               F4513EF218B991F800073552 /* HMMemberBasicCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMMemberBasicCommand.m; sourceTree = "<group>"; };
                F46F103418A7CE310063E503 /* HMJSONViewCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMJSONViewCommand.h; sourceTree = "<group>"; };
                F46F103518A7CE310063E503 /* HMJSONViewCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMJSONViewCommand.m; sourceTree = "<group>"; };
                F46F103F18A9B85E0063E503 /* HMJSONNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMJSONNode.h; sourceTree = "<group>"; };
                                F4513EEA18B7900A00073552 /* HMMemberDeckCommand.m */,
                                F4513EEC18B8E2F600073552 /* HMMemberMaterialCommand.h */,
                                F4513EED18B8E2F600073552 /* HMMemberMaterialCommand.m */,
+                               F4513EF118B991F800073552 /* HMMemberBasicCommand.h */,
+                               F4513EF218B991F800073552 /* HMMemberBasicCommand.m */,
                        );
                        name = Command;
                        sourceTree = "<group>";
                                F4D2CBC218AD0E1A000EBC59 /* HMMasterSTypeCommand.m in Sources */,
                                F46F104518AA50730063E503 /* HMBroserWindowController.m in Sources */,
                                F4B414EC18B0A7D600468DAF /* HMMasterUseItemCommand.m in Sources */,
+                               F4513EF318B991F800073552 /* HMMemberBasicCommand.m in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index ffad016..51e8d58 100644 (file)
@@ -23,7 +23,8 @@
                                   @"api_req_shiptype_0", @"api_req_shiptype_1", @"api_req_shiptype_2", @"api_req_shiptype_3", @"api_req_shiptype_4", @"api_req_shiptype_5",
                                   @"api_next_rate_req_0", @"api_next_rate_req_1", @"api_next_rate_req_2",
                                   @"api_link_no_0", @"api_link_no_1",
-                                  @"api_flagship", @"api_name_id"];
+                                  @"api_flagship", @"api_name_id",
+                                  @"api_comment_id", @"api_nickname_id", @"api_member_id"];
        if([t containsObject:inKey]) {
                if(![*ioValue isKindOfClass:[NSNumber class]]) {
                        id newValue = @([*ioValue integerValue]);
diff --git a/KCD/HMMemberBasicCommand.h b/KCD/HMMemberBasicCommand.h
new file mode 100644 (file)
index 0000000..7aaf9de
--- /dev/null
@@ -0,0 +1,13 @@
+//
+//  HMMemberBasicCommand.h
+//  KCD
+//
+//  Created by Hori,Masaki on 2014/02/23.
+//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMJSONCommand.h"
+
+@interface HMMemberBasicCommand : HMJSONCommand
+
+@end
diff --git a/KCD/HMMemberBasicCommand.m b/KCD/HMMemberBasicCommand.m
new file mode 100644 (file)
index 0000000..c7920d1
--- /dev/null
@@ -0,0 +1,84 @@
+//
+//  HMMemberBasicCommand.m
+//  KCD
+//
+//  Created by Hori,Masaki on 2014/02/23.
+//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMMemberBasicCommand.h"
+
+#import "HMCoreDataManager.h"
+
+
+@implementation HMMemberBasicCommand
++ (void)load
+{
+       static dispatch_once_t onceToken;
+       dispatch_once(&onceToken, ^{
+               [HMJSONCommand registerClass:self];
+       });
+}
+
++ (BOOL)canExcuteAPI:(NSString *)api
+{
+       return [api isEqualToString:@"/kcsapi/api_get_member/basic"];
+}
+- (void)execute
+{
+       NSDictionary *api_data = [self.json objectForKey:@"api_data"];
+       if(![api_data isKindOfClass:[NSDictionary class]]) {
+               [self log:@"api_data is NOT NSDictionary."];
+               return;
+       }
+       
+       HMCoreDataManager *dm = [HMCoreDataManager oneTimeEditor];
+       NSManagedObjectContext *managedObjectContext = [dm managedObjectContext];
+       
+       NSFetchRequest *req = [NSFetchRequest fetchRequestWithEntityName:@"Basic"];
+       NSError *error = nil;
+       id result = [managedObjectContext executeFetchRequest:req
+                                                                                                       error:&error];
+       if(error) {
+               [self log:@"Fetch error: %@", error];
+               return;
+       }
+       NSManagedObject *object = nil;
+       if(!result || [result count] == 0) {
+               object = [NSEntityDescription insertNewObjectForEntityForName:@"Basic"
+                                                                                          inManagedObjectContext:managedObjectContext];
+       } else {
+               object = result[0];
+       }
+       
+       for(NSString *key in api_data) {
+               id value = api_data[key];
+               if([self handleExtraValue:value forKey:key toObject:object]) {
+                       continue;
+               }
+               if([value isKindOfClass:[NSArray class]]) {
+                       NSUInteger i = 0;
+                       for(id element in value) {
+                               id hoge = element;
+                               NSString *newKey = [NSString stringWithFormat:@"%@_%ld", key, i];
+                               if([object validateValue:&hoge forKey:newKey error:NULL]) {
+                                       [object setValue:hoge forKey:newKey];
+                               }
+                               i++;
+                       }
+               } else if([value isKindOfClass:[NSDictionary class]]) {
+                       for(id subKey in value) {
+                               id subValue = value[subKey];
+                               NSString *newKey = [NSString stringWithFormat:@"%@_D_%@", key, keyByDeletingPrefix(subKey)];
+                               if([object validateValue:&subValue forKey:newKey error:NULL]) {
+                                       [object setValue:subValue forKey:newKey];
+                               }
+                       }
+               } else {
+                       if([object validateValue:&value forKey:key error:NULL]) {
+                               [object setValue:value forKey:key];
+                       }
+               }
+       }
+}
+@end
index 40ed235..dca3c68 100644 (file)
@@ -1,5 +1,45 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="3401" systemVersion="13B42" minimumToolsVersion="Xcode 4.3" macOSVersion="Automatic" iOSVersion="Automatic">
+    <entity name="Basic" representedClassName="HMKCManagedObject" syncable="YES">
+        <attribute name="active_flag" optional="YES" attributeType="Boolean" syncable="YES"/>
+        <attribute name="comment" optional="YES" attributeType="String" syncable="YES"/>
+        <attribute name="comment_id" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="count_deck" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="count_kdock" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="count_ndock" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="experience" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="fcoin" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="firstflag" optional="YES" attributeType="Boolean" syncable="YES"/>
+        <attribute name="fleetname" optional="YES" attributeType="String" syncable="YES"/>
+        <attribute name="furniture_0" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="furniture_1" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="furniture_2" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="furniture_3" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="furniture_4" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="furniture_5" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="level" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="max_chara" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="max_kagu" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="max_slotitem" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="member_id" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="ms_count" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="ms_success" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="nickname" optional="YES" attributeType="String" syncable="YES"/>
+        <attribute name="nickname_id" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="playtime" optional="YES" attributeType="Integer 64" defaultValueString="0" syncable="YES"/>
+        <attribute name="pt_challenged" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="pt_challenged_win" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="pt_lose" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="pt_win" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="pvp_0" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="pvp_1" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="rank" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="st_lose" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="st_win" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+        <attribute name="starttime" optional="YES" attributeType="Integer 64" defaultValueString="0" syncable="YES"/>
+        <attribute name="tutorial" optional="YES" attributeType="Boolean" syncable="YES"/>
+        <attribute name="tutorial_progress" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+    </entity>
     <entity name="Deck" representedClassName="HMKCManagedObject" syncable="YES">
         <attribute name="flagship" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
         <attribute name="id" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
         <element name="MasterUseItem" positionX="0" positionY="0" width="0" height="0"/>
         <element name="Material" positionX="0" positionY="0" width="0" height="0"/>
         <element name="NyukyoDock" positionX="0" positionY="0" width="0" height="0"/>
+        <element name="Basic" positionX="0" positionY="0" width="0" height="0"/>
     </elements>
 </model>
\ No newline at end of file