OSDN Git Service

ColorSetを変更
[kcd/KCD.git] / KCD / SetActionCommand.swift
1 //
2 //  SetActionCommand.swift
3 //  KCD
4 //
5 //  Created by Hori,Masaki on 2017/01/14.
6 //  Copyright © 2017年 Hori,Masaki. All rights reserved.
7 //
8
9 import Cocoa
10
11 final class SetActionCommand: JSONCommand {
12     
13     override class func canExecuteAPI(_ api: API) -> Bool {
14         
15         return api.endpoint == .setAction
16     }
17     
18     override func execute() {
19         
20         guard let areaId = parameter["api_area_id"].int else {
21             
22             Logger.shared.log("api_area_id is wrong.")
23             
24             return
25         }
26         
27         let rIds = parameter["api_base_id"].integerArray
28         let actions = parameter["api_action_kind"].integerArray
29         if rIds.count != actions.count {
30             
31             Logger.shared.log("missmatch count")
32         }
33         
34         let store = ServerDataStore.oneTimeEditor()
35         store.sync {
36             
37             zip(rIds, actions).forEach { rId, action in
38                 
39                 store.airBase(area: areaId, base: rId)?.action_kind = action
40             }
41         }
42     }
43 }