OSDN Git Service

a6576e5c6c5e4d9533437fccd41fb49f991e3094
[kcd/KCD.git] / KCD / KaisouLockCommand.swift
1 //
2 //  KaisouLockCommand.swift
3 //  KCD
4 //
5 //  Created by Hori,Masaki on 2017/01/09.
6 //  Copyright © 2017年 Hori,Masaki. All rights reserved.
7 //
8
9 import Cocoa
10
11 final class KaisouLockCommand: JSONCommand {
12     
13     override class func canExecuteAPI(_ api: String) -> Bool {
14         
15         if api == "/kcsapi/api_req_kaisou/lock" { return true }
16         
17         return false
18     }
19     
20     override func execute() {
21         
22         guard let slotId = parameter["api_slotitem_id"].int else {
23             
24             return Logger.shared.log("api_slotitem_id is wrong")
25         }
26         guard let locked = data["api_locked"].int else {
27             
28             return Logger.shared.log("api_locked is wrong")
29         }
30         
31         let store = ServerDataStore.oneTimeEditor()
32         
33         store.slotItem(by: slotId)?.locked = (locked != 0)
34     }
35 }