102 // this message is compulsory otherwise the table won't be loaded at all |
102 // this message is compulsory otherwise the table won't be loaded at all |
103 [activeController viewWillAppear:NO]; |
103 [activeController viewWillAppear:NO]; |
104 [self.view addSubview:activeController.view]; |
104 [self.view addSubview:activeController.view]; |
105 } |
105 } |
106 |
106 |
107 -(void) startGame:(UIButton *)button { |
107 -(BOOL) isEverythingSet { |
108 button.enabled = YES; |
|
109 |
|
110 // don't start playing if the preview is in progress |
108 // don't start playing if the preview is in progress |
111 if ([mapConfigViewController busy]) { |
109 if ([mapConfigViewController busy]) { |
112 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Wait for the Preview",@"") |
110 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Wait for the Preview",@"") |
113 message:NSLocalizedString(@"Before playing the preview needs to be generated",@"") |
111 message:NSLocalizedString(@"Before playing the preview needs to be generated",@"") |
114 delegate:nil |
112 delegate:nil |
115 cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"") |
113 cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"") |
116 otherButtonTitles:nil]; |
114 otherButtonTitles:nil]; |
117 [alert show]; |
115 [alert show]; |
118 [alert release]; |
116 [alert release]; |
119 return; |
117 return NO; |
120 } |
118 } |
121 |
119 |
122 // play only if there is more than one team |
120 // play only if there is more than one team |
123 if ([teamConfigViewController.listOfSelectedTeams count] < 2) { |
121 if ([teamConfigViewController.listOfSelectedTeams count] < 2) { |
124 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too few teams playing",@"") |
122 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too few teams playing",@"") |
125 message:NSLocalizedString(@"Select at least two teams to play a game",@"") |
123 message:NSLocalizedString(@"Select at least two teams to play a game",@"") |
126 delegate:nil |
124 delegate:nil |
127 cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"") |
125 cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"") |
128 otherButtonTitles:nil]; |
126 otherButtonTitles:nil]; |
129 [alert show]; |
127 [alert show]; |
130 [alert release]; |
128 [alert release]; |
131 return; |
129 return NO; |
132 } |
130 } |
133 |
131 |
134 // play if there's room for enough hogs in the selected map |
132 // play if there's room for enough hogs in the selected map |
135 int hogs = 0; |
133 int hogs = 0; |
136 for (NSDictionary *teamData in teamConfigViewController.listOfSelectedTeams) |
134 for (NSDictionary *teamData in teamConfigViewController.listOfSelectedTeams) |
137 hogs += [[teamData objectForKey:@"number"] intValue]; |
135 hogs += [[teamData objectForKey:@"number"] intValue]; |
138 |
136 |
139 if (hogs > mapConfigViewController.maxHogs) { |
137 if (hogs > mapConfigViewController.maxHogs) { |
140 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too many hogs",@"") |
138 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too many hogs",@"") |
141 message:NSLocalizedString(@"The map is too small for that many hogs",@"") |
139 message:NSLocalizedString(@"The map is too small for that many hogs",@"") |
142 delegate:nil |
140 delegate:nil |
143 cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"") |
141 cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"") |
144 otherButtonTitles:nil]; |
142 otherButtonTitles:nil]; |
145 [alert show]; |
143 [alert show]; |
146 [alert release]; |
144 [alert release]; |
147 return; |
145 return NO; |
148 } |
146 } |
149 |
147 |
|
148 if ([teamConfigViewController.listOfSelectedTeams count] > 6) { |
|
149 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too many teams",@"") |
|
150 message:NSLocalizedString(@"Max six teams are allowed in the same game",@"") |
|
151 delegate:nil |
|
152 cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"") |
|
153 otherButtonTitles:nil]; |
|
154 [alert show]; |
|
155 [alert release]; |
|
156 return NO; |
|
157 } |
|
158 |
150 if ([schemeWeaponConfigViewController.selectedScheme length] == 0 || [schemeWeaponConfigViewController.selectedWeapon length] == 0 ) { |
159 if ([schemeWeaponConfigViewController.selectedScheme length] == 0 || [schemeWeaponConfigViewController.selectedWeapon length] == 0 ) { |
151 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Missing detail",@"") |
160 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Missing detail",@"") |
152 message:NSLocalizedString(@"Select one Scheme and one Weapon for this game",@"") |
161 message:NSLocalizedString(@"Select one Scheme and one Weapon for this game",@"") |
153 delegate:nil |
162 delegate:nil |
154 cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"") |
163 cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"") |
155 otherButtonTitles:nil]; |
164 otherButtonTitles:nil]; |
156 [alert show]; |
165 [alert show]; |
157 [alert release]; |
166 [alert release]; |
|
167 return NO; |
|
168 } |
|
169 |
|
170 return YES; |
|
171 } |
|
172 |
|
173 -(void) startGame:(UIButton *)button { |
|
174 button.enabled = YES; |
|
175 |
|
176 if ([self isEverythingSet] == NO) |
158 return; |
177 return; |
159 } |
|
160 |
178 |
161 // create the configuration file that is going to be sent to engine |
179 // create the configuration file that is going to be sent to engine |
162 NSDictionary *gameDictionary = [NSDictionary dictionaryWithObjectsAndKeys:mapConfigViewController.seedCommand,@"seed_command", |
180 NSDictionary *gameDictionary = [NSDictionary dictionaryWithObjectsAndKeys:mapConfigViewController.seedCommand,@"seed_command", |
163 mapConfigViewController.templateFilterCommand,@"templatefilter_command", |
181 mapConfigViewController.templateFilterCommand,@"templatefilter_command", |
164 mapConfigViewController.mapGenCommand,@"mapgen_command", |
182 mapConfigViewController.mapGenCommand,@"mapgen_command", |