OSDN Git Service

MappingConfigurationのプロパティを変更
[kcd/KCD.git] / KCD / ApplySuppliesCommand.swift
1 //
2 //  ApplySuppliesCommand.swift
3 //  KCD
4 //
5 //  Created by Hori,Masaki on 2017/01/08.
6 //  Copyright © 2017年 Hori,Masaki. All rights reserved.
7 //
8
9 import Cocoa
10
11 class ApplySuppliesCommand: JSONCommand {
12     override func execute() {
13         let store = ServerDataStore.oneTimeEditor()
14         data["api_ship"]
15             .forEach { (_, json) in
16                 guard let i = json["api_id"].int,
17                     let ship = store.ship(byId: i),
18                     let bull = json["api_bull"].int,
19                     let fuel = json["api_fuel"].int,
20                     let slots = json["api_onslot"].arrayObject as? [Int],
21                     slots.count > 4
22                     else { return }
23                 ship.bull = bull
24                 ship.fuel = fuel
25                 ship.onslot_0 = slots[0]
26                 ship.onslot_1 = slots[1]
27                 ship.onslot_2 = slots[2]
28                 ship.onslot_3 = slots[3]
29                 ship.onslot_4 = slots[4]
30         }
31     }
32 }