OSDN Git Service

Doutakuを導入
[kcd/KCD.git] / KCD / CombinedCommand.swift
index 2acb14a..9330666 100644 (file)
@@ -14,6 +14,16 @@ enum CombineType: Int {
     case maneuver
     case water
     case transportation
+    
+    func displayName() -> String {
+        
+        switch self {
+        case .cancel: return LocalizedStrings.uncombined.string
+        case .maneuver: return LocalizedStrings.maneuver.string
+        case .water: return LocalizedStrings.water.string
+        case .transportation: return LocalizedStrings.transportation.string
+        }
+    }
 }
 
 extension Notification.Name {
@@ -34,15 +44,7 @@ final class CombinedCommand: JSONCommand {
         
         if api.endpoint == .port {
             
-            if let t = data["api_combined_flag"].int {
-                
-                CombineType(rawValue: t).map(postNotification(withType:))
-                
-            } else {
-                
-                postNotification(withType: .cancel)
-            }
-            
+            handlePort()
             return
         }
         
@@ -52,6 +54,18 @@ final class CombinedCommand: JSONCommand {
             .map(postNotification(withType:))
     }
     
+    private func handlePort() {
+        
+        if let t = data["api_combined_flag"].int {
+            
+            CombineType(rawValue: t).map(postNotification(withType:))
+            
+        } else {
+            
+            postNotification(withType: .cancel)
+        }
+    }
+    
     private func postNotification(withType type: CombineType) {
         
         let userInfo = [CombinedCommand.userInfoKey: type]