OSDN Git Service

portコマンドから連合艦隊の状態を反映するようにした
[kcd/KCD.git] / KCD / HMCombinedCommand.m
1 //
2 //  HMCombinedCommand.m
3 //  KCD
4 //
5 //  Created by Hori,Masaki on 2015/11/26.
6 //  Copyright (c) 2015年 Hori,Masaki. All rights reserved.
7 //
8
9 #import "HMCombinedCommand.h"
10
11
12 NSString *HMCombinedCommandCombinedDidCangeNotification = @"HMCombinedCommandCombinedDidCangeNotification";
13 NSString                *HMCombinedType = @"HMCombinedType";
14
15 @implementation HMCombinedCommand
16 + (void)load
17 {
18         static dispatch_once_t onceToken;
19         dispatch_once(&onceToken, ^{
20                 [HMJSONCommand registerClass:self];
21         });
22 }
23 + (BOOL)canExcuteAPI:(NSString *)api
24 {
25         if([api isEqualToString:@"/kcsapi/api_req_hensei/combined"]) return YES;
26         return NO;
27 }
28 - (void)execute
29 {
30         id type = nil;
31         if([self.api isEqualToString:@"/kcsapi/api_port/port"]) {
32                 NSDictionary *data = self.json[@"api_data"];
33                 type = data[@"api_combined_flag"];
34         }
35         if([self.api isEqualToString:@"/kcsapi/api_req_hensei/combined"]) {
36                 type = self.arguments[@"api_combined_type"];
37         }
38         if(!type) return;
39         
40         NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
41         [nc postNotificationName:HMCombinedCommandCombinedDidCangeNotification
42                                           object:self
43                                         userInfo:@{
44                                                            HMCombinedType : type
45                                                            }];
46 }
47 @end