From 155154bb4b29afe0de08ac791a2f128e03818400 Mon Sep 17 00:00:00 2001 From: masakih Date: Sun, 8 Jan 2017 23:42:23 +0900 Subject: [PATCH] =?utf8?q?HMUpdateQuestListCommand=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 HMClearItemGetComandをSwiftに変換した --- KCD.xcodeproj/project.pbxproj | 20 ++++++++------------ KCD/HMClearItemGetComand.h | 13 ------------- KCD/HMClearItemGetComand.m | 37 ------------------------------------- KCD/HMClearItemGetComand.swift | 23 +++++++++++++++++++++++ KCD/HMUpdateQuestListCommand.h | 13 ------------- KCD/HMUpdateQuestListCommand.m | 38 -------------------------------------- KCD/HMUpdateQuestListCommand.swift | 25 +++++++++++++++++++++++++ KCD/KCD-Bridging-Header.h | 2 +- 8 files changed, 57 insertions(+), 114 deletions(-) delete mode 100644 KCD/HMClearItemGetComand.h delete mode 100644 KCD/HMClearItemGetComand.m create mode 100644 KCD/HMClearItemGetComand.swift delete mode 100644 KCD/HMUpdateQuestListCommand.h delete mode 100644 KCD/HMUpdateQuestListCommand.m create mode 100644 KCD/HMUpdateQuestListCommand.swift diff --git a/KCD.xcodeproj/project.pbxproj b/KCD.xcodeproj/project.pbxproj index 4e8d1e24..78aa9863 100644 --- a/KCD.xcodeproj/project.pbxproj +++ b/KCD.xcodeproj/project.pbxproj @@ -32,8 +32,6 @@ F431E9761DF3AC1C00FB56AE /* HMSetActionCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F431E9751DF3AC1C00FB56AE /* HMSetActionCommand.m */; }; F43769D61ADE86B200DE6204 /* HMQuestListCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F43769D51ADE86B200DE6204 /* HMQuestListCommand.m */; }; F43769DE1AE1248800DE6204 /* HMAirBattleCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F43769DD1AE1248800DE6204 /* HMAirBattleCommand.m */; }; - F43769E11AE7CFF800DE6204 /* HMClearItemGetComand.m in Sources */ = {isa = PBXBuildFile; fileRef = F43769E01AE7CFF800DE6204 /* HMClearItemGetComand.m */; }; - F43769E41AE7D01D00DE6204 /* HMUpdateQuestListCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F43769E31AE7D01D00DE6204 /* HMUpdateQuestListCommand.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 */; }; @@ -62,6 +60,8 @@ F44BC6D51E226308004644E3 /* HMNyukyoSpeedChangeCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44BC6D41E226308004644E3 /* HMNyukyoSpeedChangeCommand.swift */; }; F44BC6D71E226CB1004644E3 /* HMHokyuChargeCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44BC6D61E226CB1004644E3 /* HMHokyuChargeCommand.swift */; }; F44BC6D91E2272F6004644E3 /* HMNyukyoStartCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44BC6D81E2272F6004644E3 /* HMNyukyoStartCommand.swift */; }; + F44BC6DB1E2281A7004644E3 /* HMClearItemGetComand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44BC6DA1E2281A7004644E3 /* HMClearItemGetComand.swift */; }; + F44BC6DD1E228345004644E3 /* HMUpdateQuestListCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44BC6DC1E228345004644E3 /* HMUpdateQuestListCommand.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 */; }; @@ -365,10 +365,6 @@ F43769D51ADE86B200DE6204 /* HMQuestListCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMQuestListCommand.m; sourceTree = ""; }; F43769DC1AE1248800DE6204 /* HMAirBattleCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMAirBattleCommand.h; sourceTree = ""; }; F43769DD1AE1248800DE6204 /* HMAirBattleCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMAirBattleCommand.m; sourceTree = ""; }; - F43769DF1AE7CFF800DE6204 /* HMClearItemGetComand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMClearItemGetComand.h; sourceTree = ""; }; - F43769E01AE7CFF800DE6204 /* HMClearItemGetComand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMClearItemGetComand.m; sourceTree = ""; }; - F43769E21AE7D01D00DE6204 /* HMUpdateQuestListCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMUpdateQuestListCommand.h; sourceTree = ""; }; - F43769E31AE7D01D00DE6204 /* HMUpdateQuestListCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMUpdateQuestListCommand.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 = ""; }; @@ -412,6 +408,8 @@ F44BC6D41E226308004644E3 /* HMNyukyoSpeedChangeCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMNyukyoSpeedChangeCommand.swift; sourceTree = ""; }; F44BC6D61E226CB1004644E3 /* HMHokyuChargeCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMHokyuChargeCommand.swift; sourceTree = ""; }; F44BC6D81E2272F6004644E3 /* HMNyukyoStartCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMNyukyoStartCommand.swift; sourceTree = ""; }; + F44BC6DA1E2281A7004644E3 /* HMClearItemGetComand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMClearItemGetComand.swift; sourceTree = ""; }; + F44BC6DC1E228345004644E3 /* HMUpdateQuestListCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMUpdateQuestListCommand.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 = ""; }; @@ -993,10 +991,8 @@ children = ( F43769D41ADE86B200DE6204 /* HMQuestListCommand.h */, F43769D51ADE86B200DE6204 /* HMQuestListCommand.m */, - F43769E21AE7D01D00DE6204 /* HMUpdateQuestListCommand.h */, - F43769E31AE7D01D00DE6204 /* HMUpdateQuestListCommand.m */, - F43769DF1AE7CFF800DE6204 /* HMClearItemGetComand.h */, - F43769E01AE7CFF800DE6204 /* HMClearItemGetComand.m */, + F44BC6DC1E228345004644E3 /* HMUpdateQuestListCommand.swift */, + F44BC6DA1E2281A7004644E3 /* HMClearItemGetComand.swift */, ); name = QuestCommand; sourceTree = ""; @@ -1741,7 +1737,6 @@ F4A9E7FB1D045BC100F91746 /* HMScreenshotModel.m in Sources */, F47215AC1E1FA2460083D3BC /* HMTemporaryDataStore.swift in Sources */, F448F9981B75A128004901AD /* HMKCBasic.m in Sources */, - F43769E11AE7CFF800DE6204 /* HMClearItemGetComand.m in Sources */, F4131ED5190F63D8004F7F9A /* HMUpdateSlotItemCommand.m in Sources */, F4D05BC81E0C0DA100688D66 /* HMAirBaseWindowController.swift in Sources */, F4C1190518A71AEA005D5B25 /* HMJSONReciever.m in Sources */, @@ -1770,6 +1765,7 @@ F45771231E1BCC7C008A9215 /* HMPeriodicNotifier.swift in Sources */, F4B414F518B1888800468DAF /* HMMasterFurnitureCommand.m in Sources */, F44BC6C91E22314B004644E3 /* HMUnknownComand.swift in Sources */, + F44BC6DD1E228345004644E3 /* HMUpdateQuestListCommand.swift in Sources */, F4AA0601192E1FE900844688 /* HMBattleCommand.m in Sources */, F495462B1B14CBA600E0D8D0 /* HMBookmarkManager.m in Sources */, F43F3D521A39CC7500D6DAF7 /* HMKCMasterSlotItemObject.m in Sources */, @@ -1811,6 +1807,7 @@ F44BC6C71E222675004644E3 /* HMFailedCommand.swift in Sources */, F4BEEFDB1B0A219E004702B8 /* HMShipDeckCommand.m in Sources */, F47215A01E1E90C10083D3BC /* HMJSONNode.swift in Sources */, + F44BC6DB1E2281A7004644E3 /* HMClearItemGetComand.swift in Sources */, F43F3D461A33F7D400D6DAF7 /* HMResetSortieCommand.m in Sources */, F4131ECF190F5C08004F7F9A /* HMStoreCreateSlotItemHistoryCommand.m in Sources */, F4AA05FB192B92C800844688 /* Temporary.xcdatamodeld in Sources */, @@ -1825,7 +1822,6 @@ F43769E71AE7D22700DE6204 /* HMKCQuest.m in Sources */, F4D05BCE1E0D50D300688D66 /* HMBrowserContentAdjuster.swift in Sources */, F4D05BD01E0D667600688D66 /* HMBookmarkListViewController.swift in Sources */, - F43769E41AE7D01D00DE6204 /* HMUpdateQuestListCommand.m in Sources */, F4C1190818A746EB005D5B25 /* HMJSONTracker.m in Sources */, F44BC6C51E222279004644E3 /* HMPortNotifyCommand.swift in Sources */, F4B3DC4718EEEB920011B4FC /* HMStart2Command.m in Sources */, diff --git a/KCD/HMClearItemGetComand.h b/KCD/HMClearItemGetComand.h deleted file mode 100644 index 60da162c..00000000 --- a/KCD/HMClearItemGetComand.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// HMClearItemGetComand.h -// KCD -// -// Created by Hori,Masaki on 2015/04/22. -// Copyright (c) 2015年 Hori,Masaki. All rights reserved. -// - -#import "HMCompositCommand.h" - -@interface HMClearItemGetComand : HMCompositCommand - -@end diff --git a/KCD/HMClearItemGetComand.m b/KCD/HMClearItemGetComand.m deleted file mode 100644 index ebf8fb8a..00000000 --- a/KCD/HMClearItemGetComand.m +++ /dev/null @@ -1,37 +0,0 @@ -// -// HMClearItemGetComand.m -// KCD -// -// Created by Hori,Masaki on 2015/04/22. -// Copyright (c) 2015年 Hori,Masaki. All rights reserved. -// - -#import "HMClearItemGetComand.h" - -#import "HMUpdateQuestListCommand.h" - - -@implementation HMClearItemGetComand -//+ (void)load -//{ -// static dispatch_once_t onceToken; -// dispatch_once(&onceToken, ^{ -// [HMJSONCommand registerClass:self]; -// }); -//} - -+ (BOOL)canExcuteAPI:(NSString *)api -{ - return [api isEqualToString:@"/kcsapi/api_req_quest/clearitemget"]; -} - -- (instancetype)initWithAPIResponse:(HMAPIResponse *)apiResponse -{ - self = [super initWithAPIResponse:apiResponse - commandList: - @[ - [HMUpdateQuestListCommand commandWithAPIResponse:apiResponse], - ]]; - return self; -} -@end diff --git a/KCD/HMClearItemGetComand.swift b/KCD/HMClearItemGetComand.swift new file mode 100644 index 00000000..d1e73e81 --- /dev/null +++ b/KCD/HMClearItemGetComand.swift @@ -0,0 +1,23 @@ +// +// HMClearItemGetComand.swift +// KCD +// +// Created by Hori,Masaki on 2017/01/08. +// Copyright © 2017年 Hori,Masaki. All rights reserved. +// + +import Cocoa + +class HMClearItemGetComand: HMCompositCommand { + override init(apiResponse: HMAPIResponse) { + super.init(apiResponse: apiResponse, commandList: + [ + HMUpdateQuestListCommand(apiResponse: apiResponse), + ] + ) + } + override class func canExcuteAPI(_ api: String) -> Bool { + if api == "/kcsapi/api_req_quest/clearitemget" { return true } + return false + } +} diff --git a/KCD/HMUpdateQuestListCommand.h b/KCD/HMUpdateQuestListCommand.h deleted file mode 100644 index fc2e87a6..00000000 --- a/KCD/HMUpdateQuestListCommand.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// HMUpdateQuestListCommand.h -// KCD -// -// Created by Hori,Masaki on 2015/04/22. -// Copyright (c) 2015年 Hori,Masaki. All rights reserved. -// - -#import "HMJSONCommand.h" - -@interface HMUpdateQuestListCommand : HMJSONCommand - -@end diff --git a/KCD/HMUpdateQuestListCommand.m b/KCD/HMUpdateQuestListCommand.m deleted file mode 100644 index 5131b631..00000000 --- a/KCD/HMUpdateQuestListCommand.m +++ /dev/null @@ -1,38 +0,0 @@ -// -// HMUpdateQuestListCommand.m -// KCD -// -// Created by Hori,Masaki on 2015/04/22. -// Copyright (c) 2015年 Hori,Masaki. All rights reserved. -// - -#import "HMUpdateQuestListCommand.h" -#import "HMKCQuest.h" - -#import "KCD-Swift.h" - -@implementation HMUpdateQuestListCommand -- (void)execute -{ - NSString *questNo = self.arguments[@"api_quest_id"]; - if(!questNo || [questNo isKindOfClass:[NSNull class]]) return; - - HMServerDataStore *serverDataStore = [HMServerDataStore oneTimeEditor]; - NSError *error = nil; - NSArray *objects = [serverDataStore objectsWithEntityName:@"Quest" - error:&error - predicateFormat:@"%K = %@", @"no", @([questNo integerValue])]; - - if(error) { - [self log:@"Fetch error: %@", error]; - return; - } - if(objects.count == 0) { - [self log:@"Could not find QuestList no %@", questNo]; - return; - } - - objects[0].progress_flag = @NO; - objects[0].state = @1; -} -@end diff --git a/KCD/HMUpdateQuestListCommand.swift b/KCD/HMUpdateQuestListCommand.swift new file mode 100644 index 00000000..3692f2c9 --- /dev/null +++ b/KCD/HMUpdateQuestListCommand.swift @@ -0,0 +1,25 @@ +// +// HMUpdateQuestListCommand.swift +// KCD +// +// Created by Hori,Masaki on 2017/01/08. +// Copyright © 2017年 Hori,Masaki. All rights reserved. +// + +import Cocoa + +class HMUpdateQuestListCommand: HMJSONCommand { + override func execute() { + guard let q = arguments["api_quest_id"] as? String, + let qno = Int(q) + else { return print("api_quest_id is wrong") } + let store = HMServerDataStore.oneTimeEditor() + let p = NSPredicate(format: "%K = %@", "no", qno) + guard let qu = try? store?.objects(withEntityName: "Quest", predicate: p), + let que = qu as? [HMKCQuest], + let quest = que.first + else { return print("Not found Quest") } + quest.progress_flag = false as NSNumber + quest.state = 1 as NSNumber + } +} diff --git a/KCD/KCD-Bridging-Header.h b/KCD/KCD-Bridging-Header.h index bff50a42..aa556f6f 100644 --- a/KCD/KCD-Bridging-Header.h +++ b/KCD/KCD-Bridging-Header.h @@ -62,7 +62,6 @@ #import "HMCombinedCommand.h" #import "HMSlotDepriveCommand.h" #import "HMQuestListCommand.h" -#import "HMClearItemGetComand.h" #import "HMResetSortieCommand.h" #import "HMDropShipHistoryCommand.h" #import "HMDummyShipCommand.h" @@ -81,6 +80,7 @@ #import "HMKCDeck+Extension.h" #import "HMKCMaterial.h" #import "HMKCNyukyoDock.h" +#import "HMKCQuest.h" #import "HMKaihatuHistory.h" #import "HMKenzoHistory.h" -- 2.11.0