OSDN Git Service

素早く7隻の艦隊を含む艦隊を切り替えると表示がおかしくなる問題を修正
[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: String) -> Bool {
14         
15         if api == "/kcsapi/api_req_nyukyo/start" { return true }
16         
17         return false
18     }
19     
20     override func execute() {
21         
22         guard let hi = parameter["api_highspeed"].int, hi != 0 else { return }
23         
24         let store = ServerDataStore.oneTimeEditor()
25         
26         parameter["api_ship_id"]
27             .int
28             .flatMap(store.ship(by:))
29             .map { $0.nowhp = $0.maxhp }
30         
31         store.material()
32             .map { $0.kousokushuhuku = $0.kousokushuhuku - 1 }
33     }
34 }