F44BC7031E252C4F004644E3 /* HMUpdateSlotItemCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44BC7021E252C4F004644E3 /* HMUpdateSlotItemCommand.swift */; };
F44BC7051E2660E4004644E3 /* HMStoreCreateSlotItemHistoryCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44BC7041E2660E4004644E3 /* HMStoreCreateSlotItemHistoryCommand.swift */; };
F44BC7071E2670BB004644E3 /* HMCreateShipCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44BC7061E2670BB004644E3 /* HMCreateShipCommand.swift */; };
+ F44BC7091E279C41004644E3 /* HMKenzoMarkCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44BC7081E279C41004644E3 /* HMKenzoMarkCommand.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 */; };
F4F9F89B1C6CB7D400D0EE76 /* HMFleet.m in Sources */ = {isa = PBXBuildFile; fileRef = F4F9F89A1C6CB7D400D0EE76 /* HMFleet.m */; };
F4F9F8A31C70AFB600D0EE76 /* HMFleetManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F4F9F8A21C70AFB600D0EE76 /* HMFleetManager.m */; };
F4F9F8A61C78596900D0EE76 /* HMAnchorageRepairManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F4F9F8A51C78596900D0EE76 /* HMAnchorageRepairManager.m */; };
- F4FCFD44191F4C1D000640A1 /* HMKenzoMarkCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4FCFD43191F4C1D000640A1 /* HMKenzoMarkCommand.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
F44BC7021E252C4F004644E3 /* HMUpdateSlotItemCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMUpdateSlotItemCommand.swift; sourceTree = "<group>"; };
F44BC7041E2660E4004644E3 /* HMStoreCreateSlotItemHistoryCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMStoreCreateSlotItemHistoryCommand.swift; sourceTree = "<group>"; };
F44BC7061E2670BB004644E3 /* HMCreateShipCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMCreateShipCommand.swift; sourceTree = "<group>"; };
+ F44BC7081E279C41004644E3 /* HMKenzoMarkCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMKenzoMarkCommand.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>"; };
F4F9F8A21C70AFB600D0EE76 /* HMFleetManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMFleetManager.m; sourceTree = "<group>"; };
F4F9F8A41C78596900D0EE76 /* HMAnchorageRepairManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMAnchorageRepairManager.h; sourceTree = "<group>"; };
F4F9F8A51C78596900D0EE76 /* HMAnchorageRepairManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMAnchorageRepairManager.m; sourceTree = "<group>"; };
- F4FCFD42191F4C1D000640A1 /* HMKenzoMarkCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMKenzoMarkCommand.h; sourceTree = "<group>"; };
- F4FCFD43191F4C1D000640A1 /* HMKenzoMarkCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMKenzoMarkCommand.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
F4649FC21DBBB3820097AEBF /* Create&DestoryCommand */ = {
isa = PBXGroup;
children = (
- F4FCFD42191F4C1D000640A1 /* HMKenzoMarkCommand.h */,
- F4FCFD43191F4C1D000640A1 /* HMKenzoMarkCommand.m */,
+ F44BC7081E279C41004644E3 /* HMKenzoMarkCommand.swift */,
F44BC7061E2670BB004644E3 /* HMCreateShipCommand.swift */,
F44BC7041E2660E4004644E3 /* HMStoreCreateSlotItemHistoryCommand.swift */,
F44BC7021E252C4F004644E3 /* HMUpdateSlotItemCommand.swift */,
F49097831E19F7760085A45D /* HMStrengthenListItemCellView.swift in Sources */,
F495462E1B1894DD00E0D8D0 /* Bookmark.xcdatamodeld in Sources */,
F4B414FB18B1FB6C00468DAF /* HMMasterMapCellCommand.m in Sources */,
+ F44BC7091E279C41004644E3 /* HMKenzoMarkCommand.swift in Sources */,
F4B3DC2118DECF570011B4FC /* HMTSVSupport.m in Sources */,
F4048AA11E1951BB008ACFD6 /* HMSuppliesCell.swift in Sources */,
F4A3AD8E19BB220000FDBF80 /* HMMaskInfomation.m in Sources */,
F448F9921B6FBF80004901AD /* HMResourceHistoryManager.m in Sources */,
F44BC6D91E2272F6004644E3 /* HMNyukyoStartCommand.swift in Sources */,
F4513EEE18B8E2F600073552 /* HMMemberMaterialCommand.m in Sources */,
- F4FCFD44191F4C1D000640A1 /* HMKenzoMarkCommand.m in Sources */,
F4ED5D2D1B7C677E00D1BDEF /* HMGuardShelterCommand.m in Sources */,
F4F9F86E1C6A306A00D0EE76 /* HMKCDamage.m in Sources */,
F4D05BD21E0F3C4E00688D66 /* HMCombileViewController.swift in Sources */,
+++ /dev/null
-//
-// HMKenzoMarkCommand.h
-// KCD
-//
-// Created by Hori,Masaki on 2014/05/11.
-// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
-//
-
-#import "HMJSONCommand.h"
-
-@interface HMKenzoMarkCommand : HMJSONCommand
-
-@end
+++ /dev/null
-//
-// HMKenzoMarkCommand.m
-// KCD
-//
-// Created by Hori,Masaki on 2014/05/11.
-// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
-//
-
-#import "HMKenzoMarkCommand.h"
-
-#import "KCD-Swift.h"
-
-#import "HMKenzoHistory.h"
-#import "HMKenzoMark.h"
-#import "HMKCKenzoDock.h"
-#import "HMKCMasterShipObject.h"
-#import "HMKCMasterSType.h"
-
-
-/**
- * 建造履歴を残す
- */
-@implementation HMKenzoMarkCommand
-- (void)execute
-{
- HMServerDataStore *serverDataStore = [HMServerDataStore oneTimeEditor];
- NSArray<HMKCKenzoDock *> *kenzoDocks = [serverDataStore objectsWithEntityName:@"KenzoDock"
- error:NULL
- predicateFormat:@"id = %@", @([[self.arguments valueForKey:@"api_kdock_id"] integerValue])];
- if([kenzoDocks count] == 0) {
- NSLog(@"KenzoDock data is invalid.");
- return;
- }
- NSNumber *item1 = kenzoDocks[0].item1;
-
- //
- NSArray<HMKCMasterShipObject *> *ships = [serverDataStore objectsWithEntityName:@"MasterShip"
- error:NULL
- predicateFormat:@"id = %@", kenzoDocks[0].created_ship_id];
- if([ships count] == 0) {
- NSLog(@"MasterShip data is invalid or ship_id is invalid.");
- return;
- }
-
- //
- NSNumber *flagShipLv = nil;
- NSString *flafShipName = nil;
- NSNumber *commanderLv = nil;
- HMLocalDataStore *localDataStore = [HMLocalDataStore oneTimeEditor];
- NSArray<HMKenzoMark *> *kenzoMarks = [localDataStore objectsWithEntityName:@"KenzoMark"
- error:NULL
- predicateFormat:
- @"fuel = %@ AND bull = %@ AND steel = %@ AND bauxite = %@ AND kaihatusizai = %@ AND kDockId = %@ AND created_ship_id = %@",
- item1, kenzoDocks[0].item2, kenzoDocks[0].item3, kenzoDocks[0].item4, kenzoDocks[0].item5,
- @([[self.arguments valueForKey:@"api_kdock_id"] integerValue]), kenzoDocks[0].created_ship_id
- ];
- if([kenzoMarks count] != 0) {
- flagShipLv = kenzoMarks[0].flagShipLv;
- flafShipName = kenzoMarks[0].flagShipName;
- commanderLv = kenzoMarks[0].commanderLv;
- }
-
- HMLocalDataStore *lds = [HMLocalDataStore oneTimeEditor];
- HMKenzoHistory *newObejct = [lds insertNewObjectForEntityForName:@"KenzoHistory"];
- newObejct.name = ships[0].name;
- newObejct.sTypeId = ships[0].stype.id;
- newObejct.fuel = item1;
- newObejct.bull = kenzoDocks[0].item2;
- newObejct.steel = kenzoDocks[0].item3;
- newObejct.bauxite = kenzoDocks[0].item4;
- newObejct.kaihatusizai = kenzoDocks[0].item5;
- newObejct.flagShipLv = flagShipLv;
- newObejct.flagShipName = flafShipName;
- newObejct.commanderLv = commanderLv;
- newObejct.date = [NSDate dateWithTimeIntervalSinceNow:0];
-
- [lds saveAction:nil];
-}
-@end
--- /dev/null
+//
+// HMKenzoMarkCommand.swift
+// KCD
+//
+// Created by Hori,Masaki on 2017/01/12.
+// Copyright © 2017年 Hori,Masaki. All rights reserved.
+//
+
+import Cocoa
+
+class HMKenzoMarkCommand: HMJSONCommand {
+ override func execute() {
+ guard let kd = arguments["api_kdock_id"] as? String,
+ let kdockId = Int(kd)
+ else { return print("api_kdock_id is wrong") }
+
+ let store = HMServerDataStore.default()
+ let p = NSPredicate(format: "id = %ld", kdockId)
+ guard let k = try? store?.objects(withEntityName: "KenzoDock", predicate: p),
+ let kenzoDocks = k as? [HMKCKenzoDock],
+ let kenzoDock = kenzoDocks.first,
+ let fuel = kenzoDock.item1,
+ let bull = kenzoDock.item2,
+ let steel = kenzoDock.item3,
+ let bauxite = kenzoDock.item4,
+ let kaihatu = kenzoDock.item5,
+ let shipId = kenzoDock.created_ship_id
+ else { return print("KenzoDock is not fount") }
+
+ let pp = NSPredicate(format: "id = %@", shipId)
+ guard let s = try? store?.objects(withEntityName: "MasterShip", predicate: pp),
+ let ships = s as? [HMKCMasterShipObject],
+ let flagShip = ships.first
+ else { return print("MasterShip is not found") }
+
+ let localStore = HMLocalDataStore.oneTimeEditor()
+ let predicate = NSPredicate(format: "fuel = %@ AND bull = %@ AND steel = %@ AND bauxite = %@ AND kaihatusizai = %@ AND kDockId = %ld AND created_ship_id = %@"
+ , fuel, bull, steel, bauxite, kaihatu, kdockId, shipId)
+
+ var flagShipLv: NSNumber? = nil
+ var flagShipName: String? = nil
+ var commanderLv: NSNumber? = nil
+
+ if let km = try? localStore?.objects(withEntityName: "KenzoMark", predicate: predicate),
+ let kenzoMarks = km as? [HMKenzoMark],
+ let kenzoMark = kenzoMarks.first
+ {
+ flagShipLv = kenzoMark.flagShipLv
+ flagShipName = kenzoMark.flagShipName
+ commanderLv = kenzoMark.commanderLv
+ }
+
+ guard let new = localStore?.insertNewObjectForEntity(forName: "KenzoHistory"),
+ let newHistory = new as? HMKenzoHistory
+ else { return print("Can not create KenzoHistory") }
+
+ newHistory.name = flagShip.name
+ newHistory.sTypeId = flagShip.stype?.id
+ newHistory.fuel = fuel
+ newHistory.bull = bull
+ newHistory.steel = steel
+ newHistory.bauxite = bauxite
+ newHistory.kaihatusizai = kaihatu
+ newHistory.flagShipLv = flagShipLv
+ newHistory.flagShipName = flagShipName
+ newHistory.commanderLv = commanderLv
+ newHistory.date = Date()
+ }
+}
#import "HMResetSortieCommand.h"
#import "HMDropShipHistoryCommand.h"
#import "HMDummyShipCommand.h"
-#import "HMKenzoMarkCommand.h"
// Core Data
#import "HMBookmarkManager.h"
#import "HMKaihatuHistory.h"
#import "HMKCKenzoDock.h"
#import "HMKenzoMark.h"
+#import "HMKCMasterSType.h"
#import "HMKaihatuHistory.h"