2 // KenzoMarkCommand.swift
5 // Created by Hori,Masaki on 2017/01/12.
6 // Copyright © 2017年 Hori,Masaki. All rights reserved.
11 final class KenzoMarkCommand: JSONCommand {
13 override func execute() {
15 guard let kdockId = parameter["api_kdock_id"].int
16 else { return print("api_kdock_id is wrong") }
18 let store = ServerDataStore.default
20 guard let kenzoDock = store.kenzoDock(by: kdockId)
21 else { return print("KenzoDock is not fount") }
23 let fuel = kenzoDock.item1
24 let bull = kenzoDock.item2
25 let steel = kenzoDock.item3
26 let bauxite = kenzoDock.item4
27 let kaihatu = kenzoDock.item5
28 let shipId = kenzoDock.created_ship_id
30 guard let flagShip = store.masterShip(by: shipId)
31 else { return print("MasterShip is not found") }
33 let localStore = LocalDataStore.oneTimeEditor()
34 guard let new = localStore.createKenzoHistory()
35 else { return print("Can not create KenzoHistory") }
37 new.name = flagShip.name
38 new.sTypeId = flagShip.stype.id
43 new.kaihatusizai = kaihatu
45 (new.flagShipLv, new.flagShipName, new.commanderLv) =
46 markedValues(fuel: fuel,
55 // swiftlint:disable function_parameter_count
56 private func markedValues(fuel: Int,
62 shipId: Int) -> (Int, String, Int) {
64 let store = LocalDataStore.default
66 if let kenzoMark = store.kenzoMark(fuel: fuel,
70 kaihatusizai: kaihatu,
74 return (kenzoMark.flagShipLv, kenzoMark.flagShipName, kenzoMark.commanderLv)