OSDN Git Service

UAをVersion/10.0.3 Safari/602.4.8に変更
[kcd/KCD.git] / KCD / BattleCommand.swift
1 //
2 //  BattleCommand.swift
3 //  KCD
4 //
5 //  Created by Hori,Masaki on 2017/01/18.
6 //  Copyright © 2017年 Hori,Masaki. All rights reserved.
7 //
8
9 import Cocoa
10
11 enum BattleAPI: String {
12     case battle = "/kcsapi/api_req_sortie/battle"
13     
14     case combinedBattle = "/kcsapi/api_req_combined_battle/battle"
15     case combinedAirBattle = "/kcsapi/api_req_combined_battle/airbattle"
16     case combinedBattleWater = "/kcsapi/api_req_combined_battle/battle_water"
17     case combinedEcBattle = "/kcsapi/api_req_combined_battle/ec_battle"
18     case combinedEachBattle = "/kcsapi/api_req_combined_battle/each_battle"
19     case combinedEachBattleWater = "/kcsapi/api_req_combined_battle/each_battle_water"
20     
21     case airBattle = "/kcsapi/api_req_sortie/airbattle"
22     case ldAirBattle = "/kcsapi/api_req_sortie/ld_airbattle"
23     case combinedLdAirBattle = "/kcsapi/api_req_combined_battle/ld_airbattle"
24     
25     case midnightBattle = "/kcsapi/api_req_battle_midnight/battle"
26     case midnightSpMidnight = "/kcsapi/api_req_battle_midnight/sp_midnight"
27     case combinedEcMidnightBattle = "/kcsapi/api_req_combined_battle/ec_midnight_battle"
28     case combinedMidnightBattle = "/kcsapi/api_req_combined_battle/midnight_battle"
29     case combinedSpMidnight = "/kcsapi/api_req_combined_battle/sp_midnight"
30     
31     case battleResult = "/kcsapi/api_req_sortie/battleresult"
32     case combinedBattleResult = "/kcsapi/api_req_combined_battle/battleresult"
33 }
34
35 class BattleCommand: JSONCommand {
36     override class func canExecuteAPI(_ api: String) -> Bool {
37         return BattleAPI(rawValue: api) != nil
38     }
39     
40     override func execute() {
41         CalculateDamageCommand(apiResponse: apiResponse).execute()
42         
43         guard let battleApi = BattleAPI(rawValue: apiResponse.api)
44             else { return }
45         switch battleApi {
46         case .battleResult, .combinedBattleResult:
47             DropShipHistoryCommand(apiResponse: apiResponse).execute()
48             DummyShipCommand(apiResponse: apiResponse).execute()
49             GuardShelterCommand(apiResponse: apiResponse).execute()
50         default: break
51         }
52     }
53 }