2 // ApplySuppliesCommand.swift
5 // Created by Hori,Masaki on 2017/01/08.
6 // Copyright © 2017年 Hori,Masaki. All rights reserved.
11 final class ApplySuppliesCommand: JSONCommand {
13 override func execute() {
15 let store = ServerDataStore.oneTimeEditor()
18 .forEach { (_, json) in
20 guard let i = json["api_id"].int else { return }
21 guard let ship = store.sync(execute: { store.ship(by: i) }) else { return }
22 guard let bull = json["api_bull"].int else { return }
23 guard let fuel = json["api_fuel"].int else { return }
24 guard let slots = json["api_onslot"].arrayObject as? [Int] else { return }
25 guard slots.count > 4 else { return }
31 ship.onslot_0 = slots[0]
32 ship.onslot_1 = slots[1]
33 ship.onslot_2 = slots[2]
34 ship.onslot_3 = slots[3]
35 ship.onslot_4 = slots[4]