OSDN Git Service

HMCompositCommandをSwiftに変換した
authormasakih <masakih@users.sourceforge.jp>
Wed, 18 Jan 2017 15:12:39 +0000 (00:12 +0900)
committermasakih <masakih@users.sourceforge.jp>
Wed, 18 Jan 2017 15:12:39 +0000 (00:12 +0900)
27 files changed:
KCD.xcodeproj/project.pbxproj
KCD/HMAirBattleCommand.swift
KCD/HMBattleCommand.swift
KCD/HMBattleResultCommand.swift
KCD/HMClearItemGetComand.swift
KCD/HMCombinedBattleCommand.swift
KCD/HMCompositCommand.h [deleted file]
KCD/HMCompositCommand.m [deleted file]
KCD/HMCompositCommand.swift [new file with mode: 0644]
KCD/HMCreateSlotItemCommand.swift
KCD/HMDestroyShipCommand.swift
KCD/HMGetShipCommand.swift
KCD/HMHokyuChargeCommand.swift
KCD/HMJSONCommand.m
KCD/HMMapInfoCommand.swift
KCD/HMMapStartCommand.swift
KCD/HMMemberRequireInfoCommand.swift
KCD/HMMemberShip2Command.swift
KCD/HMMemberShip3Command.swift
KCD/HMMidnightBattleCommand.swift
KCD/HMPortCommand.swift
KCD/HMPowerUpCommand.swift
KCD/HMRemodelSlotCommand.swift
KCD/HMShipDeckCommand.swift
KCD/HMSlotDepriveCommand.swift
KCD/HMStart2Command.swift
KCD/KCD-Bridging-Header.h

index eb9bd23..6f57fd9 100644 (file)
                F4A0D7111E2FA5AF00224DCE /* HMMidnightBattleCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A0D7101E2FA5AF00224DCE /* HMMidnightBattleCommand.swift */; };
                F4A0D7131E2FAEF800224DCE /* HMBattleCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A0D7121E2FAEF800224DCE /* HMBattleCommand.swift */; };
                F4A0D7151E2FB11F00224DCE /* HMMapStartCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A0D7141E2FB11F00224DCE /* HMMapStartCommand.swift */; };
+               F4A0D7171E2FB7E000224DCE /* HMCompositCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A0D7161E2FB7E000224DCE /* HMCompositCommand.swift */; };
                F4A2AF581A0930160024BD9E /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F4A2AF571A0930160024BD9E /* Quartz.framework */; };
                F4A2AF5B1A0F9B490024BD9E /* HMScreenshotInformation.m in Sources */ = {isa = PBXBuildFile; fileRef = F4A2AF5A1A0F9B490024BD9E /* HMScreenshotInformation.m */; };
                F4A3AD8B19B9BE7A00FDBF80 /* HMMaskSelectView.m in Sources */ = {isa = PBXBuildFile; fileRef = F4A3AD8A19B9BE7A00FDBF80 /* HMMaskSelectView.m */; };
                F4D05BDB1E0F76A800688D66 /* HMResourceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4D05BDA1E0F76A800688D66 /* HMResourceViewController.swift */; };
                F4D05BDF1E0F8B6900688D66 /* HMPowerUpSupportViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4D05BDE1E0F8B6900688D66 /* HMPowerUpSupportViewController.swift */; };
                F4D05BE11E0FAB8E00688D66 /* HMShipViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4D05BE01E0FAB8E00688D66 /* HMShipViewController.swift */; };
-               F4D2CBC518AE2AE2000EBC59 /* HMCompositCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D2CBC418AE2AE2000EBC59 /* HMCompositCommand.m */; };
                F4D2CBC818B0555A000EBC59 /* HMKCManagedObject.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D2CBC718B0555A000EBC59 /* HMKCManagedObject.m */; };
                F4D6BC551A93903E00742FEB /* HMDropShipHistory.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D6BC541A93903E00742FEB /* HMDropShipHistory.m */; };
                F4E5FF021E150A850026868C /* HMAncherageRepairTimerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4E5FF011E150A850026868C /* HMAncherageRepairTimerViewController.swift */; };
                F4A0D7101E2FA5AF00224DCE /* HMMidnightBattleCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMMidnightBattleCommand.swift; sourceTree = "<group>"; };
                F4A0D7121E2FAEF800224DCE /* HMBattleCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMBattleCommand.swift; sourceTree = "<group>"; };
                F4A0D7141E2FB11F00224DCE /* HMMapStartCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMMapStartCommand.swift; sourceTree = "<group>"; };
+               F4A0D7161E2FB7E000224DCE /* HMCompositCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMCompositCommand.swift; sourceTree = "<group>"; };
                F4A2AF571A0930160024BD9E /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = System/Library/Frameworks/Quartz.framework; sourceTree = SDKROOT; };
                F4A2AF591A0F9B490024BD9E /* HMScreenshotInformation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMScreenshotInformation.h; sourceTree = "<group>"; };
                F4A2AF5A1A0F9B490024BD9E /* HMScreenshotInformation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMScreenshotInformation.m; sourceTree = "<group>"; };
                F4D05BDA1E0F76A800688D66 /* HMResourceViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMResourceViewController.swift; sourceTree = "<group>"; };
                F4D05BDE1E0F8B6900688D66 /* HMPowerUpSupportViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMPowerUpSupportViewController.swift; sourceTree = "<group>"; };
                F4D05BE01E0FAB8E00688D66 /* HMShipViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMShipViewController.swift; sourceTree = "<group>"; };
-               F4D2CBC318AE2AE2000EBC59 /* HMCompositCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMCompositCommand.h; sourceTree = "<group>"; };
-               F4D2CBC418AE2AE2000EBC59 /* HMCompositCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMCompositCommand.m; sourceTree = "<group>"; };
                F4D2CBC618B0555A000EBC59 /* HMKCManagedObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMKCManagedObject.h; sourceTree = "<group>"; };
                F4D2CBC718B0555A000EBC59 /* HMKCManagedObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMKCManagedObject.m; sourceTree = "<group>"; };
                F4D6BC4C1A923C0B00742FEB /* LocalData 2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "LocalData 2.xcdatamodel"; sourceTree = "<group>"; };
                                F4B15CBC1E21BA870078CFFC /* CommandRegister.swift */,
                                F4C1190918A74DF0005D5B25 /* HMJSONCommand.h */,
                                F4C1190A18A74DF0005D5B25 /* HMJSONCommand.m */,
-                               F4D2CBC318AE2AE2000EBC59 /* HMCompositCommand.h */,
-                               F4D2CBC418AE2AE2000EBC59 /* HMCompositCommand.m */,
+                               F4A0D7161E2FB7E000224DCE /* HMCompositCommand.swift */,
                                F44BC6D01E224299004644E3 /* HMPortCommand.swift */,
                                F44BC6CA1E223208004644E3 /* HMIgnoreCommand.swift */,
                                F44BC6C81E22314B004644E3 /* HMUnknownComand.swift */,
                                F4AC136D1E0802C000851147 /* HMPreferencePanelController.swift in Sources */,
                                F44BC6E91E232B15004644E3 /* HMKaisouLockCommand.swift in Sources */,
                                F44BC6EF1E239FB1004644E3 /* HMRemodelSlotCommand.swift in Sources */,
-                               F4D2CBC518AE2AE2000EBC59 /* HMCompositCommand.m in Sources */,
                                F4F9F89B1C6CB7D400D0EE76 /* HMFleet.m in Sources */,
                                F48A705D1DE58A38005DFC0B /* HMKCAirBase+CoreDataProperties.m in Sources */,
                                F4AA59161E1C9C5D001667AF /* ValueTransformerRegister.swift in Sources */,
                                F44BC72F1E2A0B75004644E3 /* HMMaserShipCommand.swift in Sources */,
                                F44BC7271E29ED87004644E3 /* HMMasterUseItemCommand.swift in Sources */,
                                F4F9F8711C6A306A00D0EE76 /* HMKCBattle+CoreDataProperties.m in Sources */,
+                               F4A0D7171E2FB7E000224DCE /* HMCompositCommand.swift in Sources */,
                                F44BC7011E251408004644E3 /* HMDestroyItem2Command.swift in Sources */,
                                F45FBB731E116F53000E72B9 /* HMMainTabVIewItemViewController.swift in Sources */,
                                F4F9F8A61C78596900D0EE76 /* HMAnchorageRepairManager.m in Sources */,
index 15ad551..f893c90 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMAirBattleCommand: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMDropShipHistoryCommand(apiResponse: apiResponse),
index 0a3b2d0..52dcbbf 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMBattleCommand: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMCalculateDamageCommand(apiResponse: apiResponse),
index 39f3151..8130d17 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMBattleResultCommand: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMDropShipHistoryCommand(apiResponse: apiResponse),
index d1e73e8..8966a70 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMClearItemGetComand: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMUpdateQuestListCommand(apiResponse: apiResponse),
index 1cd5f4d..4a93616 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMCombinedBattleCommand: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMCalculateDamageCommand(apiResponse: apiResponse),
diff --git a/KCD/HMCompositCommand.h b/KCD/HMCompositCommand.h
deleted file mode 100644 (file)
index 02b2da1..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-//
-//  HMCompositCommand.h
-//  KCD
-//
-//  Created by Hori,Masaki on 2014/02/14.
-//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
-//
-
-#import "HMJSONCommand.h"
-
-@interface HMCompositCommand : HMJSONCommand
-
-+ (instancetype)compositCommandWithAPIResponse:(HMAPIResponse *)apiResponse commandList:(NSArray<HMJSONCommand *> *)commands;
-- (instancetype)initWithAPIResponse:(HMAPIResponse *)apiResponse commandList:(NSArray<HMJSONCommand *> *)commandList;
-@end
diff --git a/KCD/HMCompositCommand.m b/KCD/HMCompositCommand.m
deleted file mode 100644 (file)
index cc077ff..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-//
-//  HMCompositCommand.m
-//  KCD
-//
-//  Created by Hori,Masaki on 2014/02/14.
-//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
-//
-
-#import "HMCompositCommand.h"
-
-@interface HMCompositCommand ()
-@property (nonatomic, strong) NSMutableArray *commands;
-@end
-
-@implementation HMCompositCommand
-
-+ (instancetype)compositCommandWithAPIResponse:(HMAPIResponse *)apiResponse commandList:(NSArray<HMJSONCommand *> *)commands
-{
-    return [[self alloc] initWithAPIResponse:apiResponse commandList:commands];
-}
-- (instancetype)initWithAPIResponse:(HMAPIResponse *)apiResponse commandList:(NSArray<HMJSONCommand *> *)commandList
-{
-    self = [super initWithAPIResponse:apiResponse];
-    if(self) {
-        _commands = [commandList copy];
-    }
-    return self;
-}
-
-- (void)execute
-{
-       for(HMJSONCommand *command in self.commands) {
-               [command execute];
-       }
-}
-
-- (void)setApi:(NSString *)api
-{
-       for(id command in self.commands) {
-               [command setApi:api];
-       }
-}
-- (void)setRecieveDate:(NSDate *)recieveDate
-{
-       for(id command in self.commands) {
-               [command setRecieveDate:recieveDate];
-       }
-}
-
-- (void)setJson:(id)json
-{
-       for(id command in self.commands) {
-               [command setJson:json];
-       }
-}
-- (void)setArguments:(NSDictionary *)arguments
-{
-       for(id command in self.commands) {
-               [command setArguments:arguments];
-       }
-}
-
-
-@end
diff --git a/KCD/HMCompositCommand.swift b/KCD/HMCompositCommand.swift
new file mode 100644 (file)
index 0000000..f08c91e
--- /dev/null
@@ -0,0 +1,25 @@
+//
+//  HMCompositCommand.swift
+//  KCD
+//
+//  Created by Hori,Masaki on 2017/01/18.
+//  Copyright © 2017年 Hori,Masaki. All rights reserved.
+//
+
+import Cocoa
+
+class HMCompositCommand: HMJSONCommand {
+    
+    init(apiResponse: HMAPIResponse, commandList: [HMJSONCommand]) {
+        commands = commandList
+        super.init(apiResponse: apiResponse)
+    }
+    required override convenience init(apiResponse: HMAPIResponse) {
+        self.init(apiResponse: apiResponse, commandList: [])
+    }
+    private let commands: [HMJSONCommand]
+    
+    override func execute() {
+        commands.forEach { $0.execute() }
+    }
+}
index 60dcfc6..6852c45 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMCreateSlotItemCommand: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMMemberMaterialCommand(apiResponse: apiResponse),
index 6a2365b..e8661d4 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMDestroyShipCommand: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMMemberMaterialCommand(apiResponse: apiResponse),
index b3f3e1f..27f2ab0 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMGetShipCommand: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMMemberSlotItemCommand(apiResponse: apiResponse),
index 6c6b202..7934408 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMHokyuChargeCommand: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMMemberMaterialCommand(apiResponse: apiResponse),
index 2fe05cd..58ebb9b 100644 (file)
@@ -13,7 +13,6 @@
 #import "HMAppDelegate.h"
 
 #if ENABLE_JSON_LOG
-#import "HMCompositCommand.h"
 #import "HMJSONViewCommand.h"
 #endif
 
@@ -97,7 +96,7 @@ typedef NSManagedObject *(^HMObjectSearcher)(NSString *entityName, HMCoreDataMan
     }
     viewCommand.recieveDate = apiResult.date;
     
-    command = [HMCompositCommand compositCommandWithAPIResponse:apiResult
+    command = [[HMCompositCommand alloc] initWithApiResponse: apiResult
                                                     commandList: @[
                                                                    command,
                                                                    viewCommand,
index ec4ca4a..893eebb 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMMapInfoCommand: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMAirBaseCommand(apiResponse: apiResponse),
index ab3d1a9..2fc581e 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMMapStartCommand: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMCalculateDamageCommand(apiResponse: apiResponse),
index df21a10..c8d37a3 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMMemberRequireInfoCommand: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMMemberSlotItemCommand(apiResponse: apiResponse),
index 3ad361b..3c301db 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMMemberShip2Command: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMMemberShipCommand(apiResponse: apiResponse),
index c34b18d..00f2e33 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMMemberShip3Command: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMMemberShipCommand(apiResponse: apiResponse),
index 04ec7f3..e9a3ed3 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMMidnightBattleCommand: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMCalculateDamageCommand(apiResponse: apiResponse),
index 17e36f8..70bf7fc 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMPortCommand: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMMemberShipCommand(apiResponse: apiResponse),
index 4511b8e..0bffb22 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMPowerUpCommand: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMMemberShipCommand(apiResponse: apiResponse),
index 7b86b59..59c0448 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMRemodelSlotCommand: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMMemberMaterialCommand(apiResponse: apiResponse),
index f429439..5903b55 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMShipDeckCommand: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMMemberShipCommand(apiResponse: apiResponse),
index 7f8a120..a242f66 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMSlotDepriveCommand: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMMemberShipCommand(apiResponse: apiResponse),
index 91115e8..6a151f8 100644 (file)
@@ -9,7 +9,7 @@
 import Cocoa
 
 class HMStart2Command: HMCompositCommand {
-    override init(apiResponse: HMAPIResponse) {
+    required init(apiResponse: HMAPIResponse) {
         super.init(apiResponse: apiResponse, commandList:
             [
                 HMMasterMapAreaCommand(apiResponse: apiResponse),
index 14995ea..c752fb6 100644 (file)
@@ -26,7 +26,6 @@
 
 // Command
 #import "HMJSONCommand.h"
-#import "HMCompositCommand.h"
 
 
 // Core Data