2 // DestroyItem2Command.swift
5 // Created by Hori,Masaki on 2017/01/10.
6 // Copyright © 2017年 Hori,Masaki. All rights reserved.
11 final class DestroyItem2Command: JSONCommand {
13 override class func canExecuteAPI(_ api: API) -> Bool {
15 return api.endpoint == .destroyItem2
18 override func execute() {
20 let store = ServerDataStore.oneTimeEditor()
22 store.sync { store.slotItems(in: self.parameter["api_slotitem_ids"].integerArray).forEach(store.delete) }
24 guard let material = store.sync(execute: { store.material() }) else {
26 Logger.shared.log("Material is not found")
30 guard let getMaterials = data["api_get_material"].arrayObject as? [Int],
31 getMaterials.count >= 4 else {
33 Logger.shared.log("api_get_material is wrong")
40 material.fuel += getMaterials[0]
41 material.bull += getMaterials[1]
42 material.steel += getMaterials[2]
43 material.bauxite += getMaterials[3]