OSDN Git Service

不要となっていたプロパティを削除
[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 final class ApplySuppliesCommand: JSONCommand {
12     
13     override func execute() {
14         
15         let store = ServerDataStore.oneTimeEditor()
16         
17         data["api_ship"]
18             .forEach { _, json in
19                 
20                 guard let i = json["api_id"].int else {
21                     
22                     return
23                 }
24                 guard let ship = store.sync(execute: { store.ship(by: i) }) else {
25                     
26                     return
27                 }
28                 guard let bull = json["api_bull"].int else {
29                     
30                     return
31                 }
32                 guard let fuel = json["api_fuel"].int else {
33                     
34                     return
35                 }
36                 guard let slots = json["api_onslot"].arrayObject as? [Int] else {
37                     
38                     return
39                 }
40                 guard slots.count > 4 else {
41                     
42                     return
43                 }
44                 
45                 store.sync {
46                     
47                     ship.bull = bull
48                     ship.fuel = fuel
49                     ship.onslot_0 = slots[0]
50                     ship.onslot_1 = slots[1]
51                     ship.onslot_2 = slots[2]
52                     ship.onslot_3 = slots[3]
53                     ship.onslot_4 = slots[4]
54                 }
55         }
56     }
57 }