2 // AirCorpsSupplyCommand.swift
5 // Created by Hori,Masaki on 2017/01/08.
6 // Copyright © 2017年 Hori,Masaki. All rights reserved.
11 final class AirCorpsSupplyCommand: JSONCommand {
13 override class func canExecuteAPI(_ api: API) -> Bool {
15 return api.endpoint == .airCorpsSupply
18 override func execute() {
20 let store = ServerDataStore.oneTimeEditor()
23 guard let areaId = self.parameter["api_area_id"].int else {
27 guard let rId = self.parameter["api_base_id"].int else {
31 guard let airBase = store.airBase(area: areaId, base: rId) else {
36 let planeInfos = self.data["api_plane_info"]
37 let planes = airBase.planeInfo
39 self.parameter["api_squadron_id"]
44 guard planes.count >= $0.element else {
48 guard planeInfos.count > $0.offset else {
52 guard let plane = planes[$0.element - 1] as? AirBasePlaneInfo else {
57 let planeInfo = planeInfos[$0.offset]
59 if let v = planeInfo["api_cond"].int {
63 if let v = planeInfo["api_slotid"].int {
67 if let v = planeInfo["api_state"].int {
71 if let v = planeInfo["api_count"].int {
75 if let v = planeInfo["api_max_count"].int {
81 if let v = self.data["api_distance"].int {
86 guard let material = store.material() else {
91 if let v = self.data["api_after_bauxite"].int {
95 if let v = self.data["api_after_fuel"].int {