177 } |
178 } |
178 NSString *flags = [[NSString alloc] initWithFormat:@"e$gmflags %d",result]; |
179 NSString *flags = [[NSString alloc] initWithFormat:@"e$gmflags %d",result]; |
179 [self sendToEngine:flags]; |
180 [self sendToEngine:flags]; |
180 [flags release]; |
181 [flags release]; |
181 |
182 |
182 /* basic game flags */ |
183 NSString *dmgMod = [[NSString alloc] initWithFormat:@"e$damagepct %d",[[basicArray objectAtIndex:i] intValue]]; |
183 NSString *path = [[NSString alloc] initWithFormat:@"%@/basicFlags_en.plist",IFRONTEND_DIRECTORY()]; |
184 [self sendToEngine:dmgMod]; |
184 NSArray *mods = [[NSArray alloc] initWithContentsOfFile:path]; |
185 [dmgMod release]; |
185 [path release]; |
186 if (i < basicArraySize) i++; |
186 |
187 |
187 // initial health |
188 // support for endless games |
188 result = [[basicArray objectAtIndex:0] intValue]; |
189 NSInteger tentativeTurntime = [[basicArray objectAtIndex:i] intValue]; |
189 |
190 if (tentativeTurntime >= 100) |
190 for (i = 1; i < [basicArray count]; i++) { |
191 tentativeTurntime = 9999; |
191 NSDictionary *basicDict = [mods objectAtIndex:i]; |
192 NSString *turnTime = [[NSString alloc] initWithFormat:@"e$turntime %d",tentativeTurntime * 1000]; |
192 NSString *command = [basicDict objectForKey:@"command"]; |
193 [self sendToEngine:turnTime]; |
193 NSInteger value = [[basicArray objectAtIndex:i] intValue]; |
194 [turnTime release]; |
194 if ([basicDict objectForKey:@"checkOverMax"] && value >= [[basicDict objectForKey:@"max"] intValue]) |
195 if (i < basicArraySize) i++; |
195 value = 9999; |
196 |
196 NSString *strToSend = [[NSString alloc] initWithFormat:@"%@ %d",command,value]; |
197 result = [[basicArray objectAtIndex:i] intValue]; // initial health |
197 [self sendToEngine:strToSend]; |
198 if (i < basicArraySize) i++; |
198 [strToSend release]; |
199 |
199 } |
200 NSString *sdTime = [[NSString alloc] initWithFormat:@"e$sd_turns %d",[[basicArray objectAtIndex:i] intValue]]; |
200 [mods release]; |
201 [self sendToEngine:sdTime]; |
201 |
202 [sdTime release]; |
|
203 if (i < basicArraySize) i++; |
|
204 |
|
205 NSString *crateDrops = [[NSString alloc] initWithFormat:@"e$casefreq %d",[[basicArray objectAtIndex:i] intValue]]; |
|
206 [self sendToEngine:crateDrops]; |
|
207 [crateDrops release]; |
|
208 if (i < basicArraySize) i++; |
|
209 |
|
210 NSString *healthProb = [[NSString alloc] initWithFormat:@"e$healthprob %d",[[basicArray objectAtIndex:i] intValue]]; |
|
211 [self sendToEngine:healthProb]; |
|
212 [healthProb release]; |
|
213 if (i < basicArraySize) i++; |
|
214 |
|
215 NSString *healthAmount = [[NSString alloc] initWithFormat:@"e$hcaseamount %d",[[basicArray objectAtIndex:i] intValue]]; |
|
216 [self sendToEngine:healthAmount]; |
|
217 [healthAmount release]; |
|
218 if (i < basicArraySize) i++; |
|
219 |
|
220 NSString *minesTime = [[NSString alloc] initWithFormat:@"e$minestime %d",[[basicArray objectAtIndex:i] intValue] * 1000]; |
|
221 [self sendToEngine:minesTime]; |
|
222 [minesTime release]; |
|
223 if (i < basicArraySize) i++; |
|
224 |
|
225 NSString *minesNumber = [[NSString alloc] initWithFormat:@"e$minesnum %d",[[basicArray objectAtIndex:i] intValue]]; |
|
226 [self sendToEngine:minesNumber]; |
|
227 [minesNumber release]; |
|
228 if (i < basicArraySize) i++; |
|
229 |
|
230 NSString *dudMines = [[NSString alloc] initWithFormat:@"e$minedudpct %d",[[basicArray objectAtIndex:i] intValue]]; |
|
231 [self sendToEngine:dudMines]; |
|
232 [dudMines release]; |
|
233 if (i < basicArraySize) i++; |
|
234 |
|
235 NSString *explosives = [[NSString alloc] initWithFormat:@"e$explosives %d",[[basicArray objectAtIndex:i] intValue]]; |
|
236 [self sendToEngine:explosives]; |
|
237 [explosives release]; |
|
238 if (i < basicArraySize) i++; |
|
239 |
|
240 DLog(@"Sent %d flags and %d modes", [gamemodArray count], i); |
202 [schemeDictionary release]; |
241 [schemeDictionary release]; |
203 return result; |
242 return result; |
204 } |
243 } |
205 |
244 |
206 #pragma mark - |
245 #pragma mark - |