OSDN Git Service

HMDestroyShipCommandをSwiftに変換した
authormasakih <masakih@users.sourceforge.jp>
Mon, 9 Jan 2017 15:00:15 +0000 (00:00 +0900)
committermasakih <masakih@users.sourceforge.jp>
Mon, 9 Jan 2017 15:00:15 +0000 (00:00 +0900)
HMRealDestroyShipCommandをSwiftに変換した

KCD.xcodeproj/project.pbxproj
KCD/HMDestroyShipCommand.h [deleted file]
KCD/HMDestroyShipCommand.m [deleted file]
KCD/HMDestroyShipCommand.swift [new file with mode: 0644]
KCD/HMRealDestroyShipCommand.h [deleted file]
KCD/HMRealDestroyShipCommand.m [deleted file]
KCD/HMRealDestroyShipCommand.swift [new file with mode: 0644]
KCD/KCD-Bridging-Header.h

index d632025..bd93f19 100644 (file)
@@ -29,8 +29,6 @@
                F431E9761DF3AC1C00FB56AE /* HMSetActionCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F431E9751DF3AC1C00FB56AE /* HMSetActionCommand.m */; };
                F43769DE1AE1248800DE6204 /* HMAirBattleCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F43769DD1AE1248800DE6204 /* HMAirBattleCommand.m */; };
                F43769E71AE7D22700DE6204 /* HMKCQuest.m in Sources */ = {isa = PBXBuildFile; fileRef = F43769E61AE7D22700DE6204 /* HMKCQuest.m */; };
-               F43BA4A1197BE22200CFF788 /* HMDestroyShipCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F43BA4A0197BE22200CFF788 /* HMDestroyShipCommand.m */; };
-               F43BA4A4197BE6C200CFF788 /* HMRealDestroyShipCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F43BA4A3197BE6C200CFF788 /* HMRealDestroyShipCommand.m */; };
                F43E67B718BE02A10087E5B6 /* STypeShortName.plist in Resources */ = {isa = PBXBuildFile; fileRef = F43E67B618BE02A10087E5B6 /* STypeShortName.plist */; };
                F43E67B918BE060E0087E5B6 /* LevelUpExp.plist in Resources */ = {isa = PBXBuildFile; fileRef = F43E67B818BE060E0087E5B6 /* LevelUpExp.plist */; };
                F43F3D461A33F7D400D6DAF7 /* HMResetSortieCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F43F3D451A33F7D400D6DAF7 /* HMResetSortieCommand.m */; };
@@ -69,6 +67,8 @@
                F44BC6F11E23A10C004644E3 /* HMRemodelSlotItemCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44BC6F01E23A10C004644E3 /* HMRemodelSlotItemCommand.swift */; };
                F44BC6F31E23D32B004644E3 /* HMRealPowerUpCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44BC6F21E23D32B004644E3 /* HMRealPowerUpCommand.swift */; };
                F44BC6F51E23D593004644E3 /* HMPowerUpCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44BC6F41E23D593004644E3 /* HMPowerUpCommand.swift */; };
+               F44BC6F71E23DA4A004644E3 /* HMDestroyShipCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44BC6F61E23DA4A004644E3 /* HMDestroyShipCommand.swift */; };
+               F44BC6F91E23DAC5004644E3 /* HMRealDestroyShipCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44BC6F81E23DAC5004644E3 /* HMRealDestroyShipCommand.swift */; };
                F4513EDD18B619B600073552 /* HMCoreDataManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F4513EDC18B619B600073552 /* HMCoreDataManager.m */; };
                F4513EE818B77A5300073552 /* HMMemberKDockCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4513EE718B77A5300073552 /* HMMemberKDockCommand.m */; };
                F4513EEB18B7900A00073552 /* HMMemberDeckCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4513EEA18B7900A00073552 /* HMMemberDeckCommand.m */; };
                F43769DD1AE1248800DE6204 /* HMAirBattleCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMAirBattleCommand.m; sourceTree = "<group>"; };
                F43769E51AE7D22700DE6204 /* HMKCQuest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMKCQuest.h; sourceTree = "<group>"; };
                F43769E61AE7D22700DE6204 /* HMKCQuest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMKCQuest.m; sourceTree = "<group>"; };
-               F43BA49F197BE22200CFF788 /* HMDestroyShipCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMDestroyShipCommand.h; sourceTree = "<group>"; };
-               F43BA4A0197BE22200CFF788 /* HMDestroyShipCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMDestroyShipCommand.m; sourceTree = "<group>"; };
-               F43BA4A2197BE6C200CFF788 /* HMRealDestroyShipCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMRealDestroyShipCommand.h; sourceTree = "<group>"; };
-               F43BA4A3197BE6C200CFF788 /* HMRealDestroyShipCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMRealDestroyShipCommand.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>"; };
                F43F3D441A33F7D400D6DAF7 /* HMResetSortieCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMResetSortieCommand.h; sourceTree = "<group>"; };
                F44BC6F01E23A10C004644E3 /* HMRemodelSlotItemCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMRemodelSlotItemCommand.swift; sourceTree = "<group>"; };
                F44BC6F21E23D32B004644E3 /* HMRealPowerUpCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMRealPowerUpCommand.swift; sourceTree = "<group>"; };
                F44BC6F41E23D593004644E3 /* HMPowerUpCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMPowerUpCommand.swift; sourceTree = "<group>"; };
+               F44BC6F61E23DA4A004644E3 /* HMDestroyShipCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMDestroyShipCommand.swift; sourceTree = "<group>"; };
+               F44BC6F81E23DAC5004644E3 /* HMRealDestroyShipCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMRealDestroyShipCommand.swift; sourceTree = "<group>"; };
                F4513EDB18B619B600073552 /* HMCoreDataManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMCoreDataManager.h; sourceTree = "<group>"; };
                F4513EDC18B619B600073552 /* HMCoreDataManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMCoreDataManager.m; sourceTree = "<group>"; };
                F4513EE618B77A5300073552 /* HMMemberKDockCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMMemberKDockCommand.h; sourceTree = "<group>"; };
                                F4131ED4190F63D8004F7F9A /* HMUpdateSlotItemCommand.m */,
                                F4131ED6190FA08D004F7F9A /* HMDestroyItem2Command.h */,
                                F4131ED7190FA08D004F7F9A /* HMDestroyItem2Command.m */,
-                               F43BA4A2197BE6C200CFF788 /* HMRealDestroyShipCommand.h */,
-                               F43BA4A3197BE6C200CFF788 /* HMRealDestroyShipCommand.m */,
+                               F44BC6F81E23DAC5004644E3 /* HMRealDestroyShipCommand.swift */,
+                               F44BC6F61E23DA4A004644E3 /* HMDestroyShipCommand.swift */,
                        );
                        name = "Create&DestoryCommand";
                        sourceTree = "<group>";
                                F4B3DBC918DDB9170011B4FC /* HMCreateSlotItemCommand.m */,
                                F4E7802618DBD2A00011BC4C /* HMGetShipCommand.h */,
                                F4E7802718DBD2A00011BC4C /* HMGetShipCommand.m */,
-                               F43BA49F197BE22200CFF788 /* HMDestroyShipCommand.h */,
-                               F43BA4A0197BE22200CFF788 /* HMDestroyShipCommand.m */,
                                F44BC6F41E23D593004644E3 /* HMPowerUpCommand.swift */,
                                F44BC6F21E23D32B004644E3 /* HMRealPowerUpCommand.swift */,
                                F44BC6F01E23A10C004644E3 /* HMRemodelSlotItemCommand.swift */,
                                F4E5FF041E1518200026868C /* HMScreenshotDetailViewController.swift in Sources */,
                                F472159E1E1E6EE70083D3BC /* HMShipMasterDetailWindowController.swift in Sources */,
                                F44BC6D71E226CB1004644E3 /* HMHokyuChargeCommand.swift in Sources */,
+                               F44BC6F91E23DAC5004644E3 /* HMRealDestroyShipCommand.swift in Sources */,
                                F44BC6D31E22581D004644E3 /* HMApplySuppliesCommand.swift in Sources */,
                                F4D05BDB1E0F76A800688D66 /* HMResourceViewController.swift in Sources */,
                                F4A3AD82199F529700FDBF80 /* HMCombinedBattleCommand.m in Sources */,
                                F4AA0601192E1FE900844688 /* HMBattleCommand.m in Sources */,
                                F495462B1B14CBA600E0D8D0 /* HMBookmarkManager.m in Sources */,
                                F43F3D521A39CC7500D6DAF7 /* HMKCMasterSlotItemObject.m in Sources */,
+                               F44BC6F71E23DA4A004644E3 /* HMDestroyShipCommand.swift in Sources */,
                                F4AA59141E1C951F001667AF /* HMTimerCountFormatter.swift in Sources */,
                                F448F9921B6FBF80004901AD /* HMResourceHistoryManager.m in Sources */,
                                F44BC6D91E2272F6004644E3 /* HMNyukyoStartCommand.swift in Sources */,
                                F4D05BCC1E0D274100688D66 /* HMBookmarkEditorViewController.swift in Sources */,
                                F494DC6D18CC054800AE97E4 /* HMNyukyoDockStatus.m in Sources */,
                                F4666C641B25CA3E001840DB /* HMKCQuest+Extensions.m in Sources */,
-                               F43BA4A1197BE22200CFF788 /* HMDestroyShipCommand.m in Sources */,
                                F4B414EF18B0BF1A00468DAF /* HMMasterMapInfoCommand.m in Sources */,
                                F4B3DC1B18DEAB5E0011B4FC /* HMKaihatuHistory.m in Sources */,
                                F49097871E1A85F70085A45D /* HMImageView.swift in Sources */,
                                F4D2CBC218AD0E1A000EBC59 /* HMMasterSTypeCommand.m in Sources */,
                                F4AA59361E1D36C5001667AF /* HMQuestProgressTransformer.swift in Sources */,
                                F4F9F8891C6B642B00D0EE76 /* HMKCMasterMapArea+CoreDataProperties.m in Sources */,
-                               F43BA4A4197BE6C200CFF788 /* HMRealDestroyShipCommand.m in Sources */,
                                F4F9F8711C6A306A00D0EE76 /* HMKCBattle+CoreDataProperties.m in Sources */,
                                F4B414EC18B0A7D600468DAF /* HMMasterUseItemCommand.m in Sources */,
                                F45FBB731E116F53000E72B9 /* HMMainTabVIewItemViewController.swift in Sources */,
diff --git a/KCD/HMDestroyShipCommand.h b/KCD/HMDestroyShipCommand.h
deleted file mode 100644 (file)
index d54702f..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-//
-//  HMDestroyShipCommand.h
-//  KCD
-//
-//  Created by Hori,Masaki on 2014/07/20.
-//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
-//
-
-#import "HMCompositCommand.h"
-
-@interface HMDestroyShipCommand : HMCompositCommand
-
-@end
diff --git a/KCD/HMDestroyShipCommand.m b/KCD/HMDestroyShipCommand.m
deleted file mode 100644 (file)
index 9382610..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-//  HMDestroyShipCommand.m
-//  KCD
-//
-//  Created by Hori,Masaki on 2014/07/20.
-//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
-//
-
-#import "HMDestroyShipCommand.h"
-
-#import "HMRealDestroyShipCommand.h"
-#import "HMMemberMaterialCommand.h"
-
-
-@implementation HMDestroyShipCommand
-//+ (void)load
-//{
-//     static dispatch_once_t onceToken;
-//     dispatch_once(&onceToken, ^{
-//             [HMJSONCommand registerClass:self];
-//     });
-//}
-
-+ (BOOL)canExcuteAPI:(NSString *)api
-{
-       if([api isEqualToString:@"/kcsapi/api_req_kousyou/destroyship"]) return YES;
-       
-       return NO;
-}
-- (instancetype)initWithAPIResponse:(HMAPIResponse *)apiResponse
-{
-    self = [super initWithAPIResponse:apiResponse
-                          commandList:
-            @[
-              [HMMemberMaterialCommand commandWithAPIResponse:apiResponse],
-              [HMRealDestroyShipCommand commandWithAPIResponse:apiResponse],
-              ]];
-    return self;
-}
-@end
diff --git a/KCD/HMDestroyShipCommand.swift b/KCD/HMDestroyShipCommand.swift
new file mode 100644 (file)
index 0000000..6a2365b
--- /dev/null
@@ -0,0 +1,24 @@
+//
+//  HMDestroyShipCommand.swift
+//  KCD
+//
+//  Created by Hori,Masaki on 2017/01/09.
+//  Copyright © 2017年 Hori,Masaki. All rights reserved.
+//
+
+import Cocoa
+
+class HMDestroyShipCommand: HMCompositCommand {
+    override init(apiResponse: HMAPIResponse) {
+        super.init(apiResponse: apiResponse, commandList:
+            [
+                HMMemberMaterialCommand(apiResponse: apiResponse),
+                HMRealDestroyShipCommand(apiResponse: apiResponse),
+                ]
+        )
+    }
+    override class func canExcuteAPI(_ api: String) -> Bool {
+        if api == "/kcsapi/api_req_kousyou/destroyship" { return true }
+        return false
+    }
+}
diff --git a/KCD/HMRealDestroyShipCommand.h b/KCD/HMRealDestroyShipCommand.h
deleted file mode 100644 (file)
index 0e45979..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-//
-//  HMRealDestroyShipCommand.h
-//  KCD
-//
-//  Created by Hori,Masaki on 2014/07/20.
-//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
-//
-
-#import "HMJSONCommand.h"
-
-@interface HMRealDestroyShipCommand : HMJSONCommand
-
-@end
diff --git a/KCD/HMRealDestroyShipCommand.m b/KCD/HMRealDestroyShipCommand.m
deleted file mode 100644 (file)
index 6309753..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-//
-//  HMRealDestroyShipCommand.m
-//  KCD
-//
-//  Created by Hori,Masaki on 2014/07/20.
-//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
-//
-
-#import "HMRealDestroyShipCommand.h"
-
-#import "KCD-Swift.h"
-
-@implementation HMRealDestroyShipCommand
-- (void)execute
-{
-       HMServerDataStore *store = [HMServerDataStore oneTimeEditor];
-       
-       NSString *destroyedShipId = [self.arguments objectForKey:@"api_ship_id"];
-       
-       NSError *error = nil;
-       NSArray<NSManagedObject *> *ships = [store objectsWithEntityName:@"Ship"
-                                                                                                                          error:&error
-                                                                                                        predicateFormat:@"id = %@", @([destroyedShipId integerValue])];
-       if(ships.count == 0) {
-               return;
-       }
-       [store deleteObject:ships[0]];
-}
-@end
diff --git a/KCD/HMRealDestroyShipCommand.swift b/KCD/HMRealDestroyShipCommand.swift
new file mode 100644 (file)
index 0000000..c5f4305
--- /dev/null
@@ -0,0 +1,23 @@
+//
+//  HMRealDestroyShipCommand.swift
+//  KCD
+//
+//  Created by Hori,Masaki on 2017/01/09.
+//  Copyright © 2017年 Hori,Masaki. All rights reserved.
+//
+
+import Cocoa
+
+class HMRealDestroyShipCommand: HMJSONCommand {
+    override func execute() {
+        guard let d = arguments["api_ship_id"] as? String
+            else { return print("api_ship_id is wrong") }
+        let store = HMServerDataStore.oneTimeEditor()
+        let p = NSPredicate(format: "id = %@", d)
+        guard let s = try? store?.objects(withEntityName: "Ship", predicate: p),
+            let ships = s as? [HMKCShipObject],
+            let ship = ships.first
+            else { return print("Ship not found") }
+        store?.delete(ship)
+    }
+}
index c6610b5..325f2bd 100644 (file)
 #import "HMSetActionCommand.h"
 #import "HMCreateSlotItemCommand.h"
 #import "HMGetShipCommand.h"
-#import "HMDestroyShipCommand.h"
 #import "HMResetSortieCommand.h"
 #import "HMDropShipHistoryCommand.h"
 #import "HMDummyShipCommand.h"
 
+
 // Core Data
 #import "HMBookmarkManager.h"