F4513EE518B635EA00073552 /* HMDocksViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4513EE318B635EA00073552 /* HMDocksViewController.xib */; };
F4513EE818B77A5300073552 /* HMMemberKDockCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4513EE718B77A5300073552 /* HMMemberKDockCommand.m */; };
F4513EEB18B7900A00073552 /* HMMemberDeckCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4513EEA18B7900A00073552 /* HMMemberDeckCommand.m */; };
+ F4513EEE18B8E2F600073552 /* HMMemberMaterialCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4513EED18B8E2F600073552 /* HMMemberMaterialCommand.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 */; };
F4513EE718B77A5300073552 /* HMMemberKDockCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMMemberKDockCommand.m; sourceTree = "<group>"; };
F4513EE918B7900A00073552 /* HMMemberDeckCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMMemberDeckCommand.h; sourceTree = "<group>"; };
F4513EEA18B7900A00073552 /* HMMemberDeckCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMMemberDeckCommand.m; sourceTree = "<group>"; };
+ 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>"; };
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>"; };
F4513EE718B77A5300073552 /* HMMemberKDockCommand.m */,
F4513EE918B7900A00073552 /* HMMemberDeckCommand.h */,
F4513EEA18B7900A00073552 /* HMMemberDeckCommand.m */,
+ F4513EEC18B8E2F600073552 /* HMMemberMaterialCommand.h */,
+ F4513EED18B8E2F600073552 /* HMMemberMaterialCommand.m */,
);
name = Command;
sourceTree = "<group>";
F4B414F818B1D35800468DAF /* HMMasterMissionCommand.m in Sources */,
F4C1190B18A74DF0005D5B25 /* HMJSONCommand.m in Sources */,
F4B414F518B1888800468DAF /* HMMasterFurnitureCommand.m in Sources */,
+ F4513EEE18B8E2F600073552 /* HMMemberMaterialCommand.m in Sources */,
F4BDEB53187252F30069D0CE /* main.m in Sources */,
F4513EE418B635EA00073552 /* HMDocksViewController.m in Sources */,
F47B78B218A7B42B0011386E /* HMJSONViewWindowController.m in Sources */,
--- /dev/null
+//
+// HMMemberMaterialCommand.h
+// KCD
+//
+// Created by Hori,Masaki on 2014/02/22.
+// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMJSONCommand.h"
+
+@interface HMMemberMaterialCommand : HMJSONCommand
+
+@end
--- /dev/null
+//
+// HMMemberMaterialCommand.m
+// KCD
+//
+// Created by Hori,Masaki on 2014/02/22.
+// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMMemberMaterialCommand.h"
+
+#import "HMCoreDataManager.h"
+
+@implementation HMMemberMaterialCommand
++ (void)load
+{
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ [HMJSONCommand registerClass:self];
+ });
+}
+
++ (BOOL)canExcuteAPI:(NSString *)api
+{
+ return [api isEqualToString:@"/kcsapi/api_get_member/material"];
+}
+- (void)execute
+{
+ NSArray *api_data = [self.json objectForKey:@"api_data"];
+ if(![api_data isKindOfClass:[NSArray class]]) {
+ [self log:@"api_data is NOT NSArray."];
+ return;
+ }
+
+ HMCoreDataManager *dm = [HMCoreDataManager oneTimeEditor];
+ NSManagedObjectContext *managedObjectContext = [dm managedObjectContext];
+
+ NSFetchRequest *req = [NSFetchRequest fetchRequestWithEntityName:@"Material"];
+ 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:@"Material"
+ inManagedObjectContext:managedObjectContext];
+ } else {
+ object = result[0];
+ }
+
+ NSArray *keys = @[@"fuel", @"bull", @"steel", @"bauxite", @"kousokukenzo", @"kousokushuhuku", @"kaihatusizai"];
+
+ for(NSDictionary *dict in api_data) {
+ NSNumber *idValue = [dict valueForKey:@"api_id"];
+ NSString *key = keys[[idValue integerValue] - 1];
+ [object setValue:[dict valueForKey:@"api_value"] forKey:key];
+ }
+}
+@end
<attribute name="price" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
<attribute name="usetype" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
</entity>
+ <entity name="Material" representedClassName="HMKCManagedObject" syncable="YES">
+ <attribute name="bauxite" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+ <attribute name="bull" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+ <attribute name="fuel" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+ <attribute name="kaihatusizai" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+ <attribute name="kousokukenzo" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+ <attribute name="kousokushuhuku" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+ <attribute name="steel" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
+ </entity>
<entity name="NyukyoDock" representedClassName="HMKCManagedObject" syncable="YES">
<attribute name="complete_time" optional="YES" attributeType="Integer 64" defaultValueString="0" syncable="YES"/>
<attribute name="complete_time_str" optional="YES" attributeType="String" syncable="YES"/>
<element name="NyukyoDock" positionX="0" positionY="0" width="0" height="0"/>
<element name="KenzoDock" positionX="0" positionY="0" width="0" height="0"/>
<element name="Deck" positionX="0" positionY="0" width="0" height="0"/>
+ <element name="Material" positionX="0" positionY="0" width="0" height="0"/>
</elements>
</model>
\ No newline at end of file