OSDN Git Service

ApplicationDirecroriesの中のアプリケーションに依存する部分を分離した
[kcd/KCD.git] / KCD / NyukyoStartCommand.swift
1 //
2 //  NyukyoStartCommand.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 NyukyoStartCommand: JSONCommand {
12     
13     override class func canExecuteAPI(_ api: API) -> Bool {
14         
15         return api.endpoint == .startNyukyo
16     }
17     
18     override func execute() {
19         
20         guard let hi = parameter["api_highspeed"].int, hi != 0 else {
21             
22             return
23         }
24         
25         let store = ServerDataStore.oneTimeEditor()
26         store.sync {
27             
28             self.parameter["api_ship_id"]
29                 .int
30                 .flatMap(store.ship(by:))
31                 .map { $0.nowhp = $0.maxhp }
32             
33             store.material()
34                 .map { $0.kousokushuhuku = $0.kousokushuhuku - 1 }
35         }
36     }
37 }