import Cocoa
-class NyukyoStartCommand: JSONCommand {
- override class func canExecuteAPI(_ api: String) -> Bool {
- if api == "/kcsapi/api_req_nyukyo/start" { return true }
- return false
+final class NyukyoStartCommand: JSONCommand {
+
+ override class func canExecuteAPI(_ api: API) -> Bool {
+
+ return api.endpoint == .startNyukyo
}
+
override func execute() {
- guard let hi = parameter["api_highspeed"].int,
- hi != 0
- else { return }
- let store = ServerDataStore.oneTimeEditor()
- parameter["api_ship_id"]
- .int
- .flatMap { store.ship(by: $0) }
- .map { $0.nowhp = $0.maxhp }
+ guard let hi = parameter["api_highspeed"].int, hi != 0 else {
+
+ return
+ }
- store.material()
- .map { $0.kousokushuhuku = $0.kousokushuhuku - 1 }
+ let store = ServerDataStore.oneTimeEditor()
+ store.sync {
+
+ self.parameter["api_ship_id"]
+ .int
+ .flatMap(store.ship(by:))
+ .map { $0.nowhp = $0.maxhp }
+
+ store.material()
+ .map { $0.kousokushuhuku = $0.kousokushuhuku - 1 }
+ }
}
}