From bcca54466513ab115da066586cc97e8913b9cf15 Mon Sep 17 00:00:00 2001 From: masakih Date: Tue, 10 Jan 2017 00:00:15 +0900 Subject: [PATCH] =?utf8?q?HMDestroyShipCommand=E3=82=92Swift=E3=81=AB?= =?utf8?q?=E5=A4=89=E6=8F=9B=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit HMRealDestroyShipCommandをSwiftに変換した --- KCD.xcodeproj/project.pbxproj | 20 ++++++++----------- KCD/HMDestroyShipCommand.h | 13 ------------- KCD/HMDestroyShipCommand.m | 40 -------------------------------------- KCD/HMDestroyShipCommand.swift | 24 +++++++++++++++++++++++ KCD/HMRealDestroyShipCommand.h | 13 ------------- KCD/HMRealDestroyShipCommand.m | 29 --------------------------- KCD/HMRealDestroyShipCommand.swift | 23 ++++++++++++++++++++++ KCD/KCD-Bridging-Header.h | 2 +- 8 files changed, 56 insertions(+), 108 deletions(-) delete mode 100644 KCD/HMDestroyShipCommand.h delete mode 100644 KCD/HMDestroyShipCommand.m create mode 100644 KCD/HMDestroyShipCommand.swift delete mode 100644 KCD/HMRealDestroyShipCommand.h delete mode 100644 KCD/HMRealDestroyShipCommand.m create mode 100644 KCD/HMRealDestroyShipCommand.swift diff --git a/KCD.xcodeproj/project.pbxproj b/KCD.xcodeproj/project.pbxproj index d632025b..bd93f190 100644 --- a/KCD.xcodeproj/project.pbxproj +++ b/KCD.xcodeproj/project.pbxproj @@ -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 */; }; @@ -358,10 +358,6 @@ F43769DD1AE1248800DE6204 /* HMAirBattleCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMAirBattleCommand.m; sourceTree = ""; }; F43769E51AE7D22700DE6204 /* HMKCQuest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMKCQuest.h; sourceTree = ""; }; F43769E61AE7D22700DE6204 /* HMKCQuest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMKCQuest.m; sourceTree = ""; }; - F43BA49F197BE22200CFF788 /* HMDestroyShipCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMDestroyShipCommand.h; sourceTree = ""; }; - F43BA4A0197BE22200CFF788 /* HMDestroyShipCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMDestroyShipCommand.m; sourceTree = ""; }; - F43BA4A2197BE6C200CFF788 /* HMRealDestroyShipCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMRealDestroyShipCommand.h; sourceTree = ""; }; - F43BA4A3197BE6C200CFF788 /* HMRealDestroyShipCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMRealDestroyShipCommand.m; sourceTree = ""; }; F43E67B618BE02A10087E5B6 /* STypeShortName.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = STypeShortName.plist; sourceTree = ""; }; F43E67B818BE060E0087E5B6 /* LevelUpExp.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = LevelUpExp.plist; sourceTree = ""; }; F43F3D441A33F7D400D6DAF7 /* HMResetSortieCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMResetSortieCommand.h; sourceTree = ""; }; @@ -411,6 +407,8 @@ F44BC6F01E23A10C004644E3 /* HMRemodelSlotItemCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMRemodelSlotItemCommand.swift; sourceTree = ""; }; F44BC6F21E23D32B004644E3 /* HMRealPowerUpCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMRealPowerUpCommand.swift; sourceTree = ""; }; F44BC6F41E23D593004644E3 /* HMPowerUpCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMPowerUpCommand.swift; sourceTree = ""; }; + F44BC6F61E23DA4A004644E3 /* HMDestroyShipCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMDestroyShipCommand.swift; sourceTree = ""; }; + F44BC6F81E23DAC5004644E3 /* HMRealDestroyShipCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMRealDestroyShipCommand.swift; sourceTree = ""; }; F4513EDB18B619B600073552 /* HMCoreDataManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMCoreDataManager.h; sourceTree = ""; }; F4513EDC18B619B600073552 /* HMCoreDataManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMCoreDataManager.m; sourceTree = ""; }; F4513EE618B77A5300073552 /* HMMemberKDockCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMMemberKDockCommand.h; sourceTree = ""; }; @@ -886,8 +884,8 @@ 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 = ""; @@ -936,8 +934,6 @@ F4B3DBC918DDB9170011B4FC /* HMCreateSlotItemCommand.m */, F4E7802618DBD2A00011BC4C /* HMGetShipCommand.h */, F4E7802718DBD2A00011BC4C /* HMGetShipCommand.m */, - F43BA49F197BE22200CFF788 /* HMDestroyShipCommand.h */, - F43BA4A0197BE22200CFF788 /* HMDestroyShipCommand.m */, F44BC6F41E23D593004644E3 /* HMPowerUpCommand.swift */, F44BC6F21E23D32B004644E3 /* HMRealPowerUpCommand.swift */, F44BC6F01E23A10C004644E3 /* HMRemodelSlotItemCommand.swift */, @@ -1724,6 +1720,7 @@ 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 */, @@ -1748,6 +1745,7 @@ 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 */, @@ -1767,7 +1765,6 @@ 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 */, @@ -1855,7 +1852,6 @@ 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 index d54702f0..00000000 --- a/KCD/HMDestroyShipCommand.h +++ /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 index 93826108..00000000 --- a/KCD/HMDestroyShipCommand.m +++ /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 index 00000000..6a2365b0 --- /dev/null +++ b/KCD/HMDestroyShipCommand.swift @@ -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 index 0e459799..00000000 --- a/KCD/HMRealDestroyShipCommand.h +++ /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 index 63097532..00000000 --- a/KCD/HMRealDestroyShipCommand.m +++ /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 *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 index 00000000..c5f43056 --- /dev/null +++ b/KCD/HMRealDestroyShipCommand.swift @@ -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) + } +} diff --git a/KCD/KCD-Bridging-Header.h b/KCD/KCD-Bridging-Header.h index c6610b55..325f2bd4 100644 --- a/KCD/KCD-Bridging-Header.h +++ b/KCD/KCD-Bridging-Header.h @@ -52,11 +52,11 @@ #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" -- 2.11.0