project_files/HedgewarsMobile/Classes/GameSetup.m
changeset 4488 e83216eba1db
parent 4478 05029b4d8490
child 4510 ce9b8206e681
equal deleted inserted replaced
4486:2c8e4d859d37 4488:e83216eba1db
   163     NSString *schemePath = [[NSString alloc] initWithFormat:@"%@/%@",SCHEMES_DIRECTORY(),schemeName];
   163     NSString *schemePath = [[NSString alloc] initWithFormat:@"%@/%@",SCHEMES_DIRECTORY(),schemeName];
   164     NSDictionary *schemeDictionary = [[NSDictionary alloc] initWithContentsOfFile:schemePath];
   164     NSDictionary *schemeDictionary = [[NSDictionary alloc] initWithContentsOfFile:schemePath];
   165     [schemePath release];
   165     [schemePath release];
   166     NSArray *basicArray = [schemeDictionary objectForKey:@"basic"];
   166     NSArray *basicArray = [schemeDictionary objectForKey:@"basic"];
   167     NSArray *gamemodArray = [schemeDictionary objectForKey:@"gamemod"];
   167     NSArray *gamemodArray = [schemeDictionary objectForKey:@"gamemod"];
   168     int i = 0;
       
   169     int result = 0;
   168     int result = 0;
   170     int mask = 0x00000004;
   169     int mask = 0x00000004;
   171 
   170 
   172     // pack the gameflags in a single var and send it
   171     // pack the gameflags in a single var and send it
   173     for (NSNumber *value in gamemodArray) {
   172     for (NSNumber *value in gamemodArray) {
   182     /* basic game flags */
   181     /* basic game flags */
   183     NSString *path = [[NSString alloc] initWithFormat:@"%@/basicFlags_en.plist",IFRONTEND_DIRECTORY()];
   182     NSString *path = [[NSString alloc] initWithFormat:@"%@/basicFlags_en.plist",IFRONTEND_DIRECTORY()];
   184     NSArray *mods = [[NSArray alloc] initWithContentsOfFile:path];
   183     NSArray *mods = [[NSArray alloc] initWithContentsOfFile:path];
   185     [path release];
   184     [path release];
   186 
   185 
       
   186     int i = 0;
   187     // initial health
   187     // initial health
   188     result = [[basicArray objectAtIndex:0] intValue];
   188     result = [[basicArray objectAtIndex:i++] intValue];
   189 
   189 
   190     // turn time
   190     // turn time
   191     NSInteger tentativeTurntime = [[basicArray objectAtIndex:1] intValue];
   191     NSInteger tentativeTurntime = [[basicArray objectAtIndex:i++] intValue];
   192     if (tentativeTurntime >= 100)
   192     if (tentativeTurntime >= 100)
   193         tentativeTurntime = 9999;
   193         tentativeTurntime = 9999;
   194     NSString *turnTime = [[NSString alloc] initWithFormat:@"e$turntime %d",tentativeTurntime * 1000];
   194     NSString *turnTime = [[NSString alloc] initWithFormat:@"e$turntime %d",tentativeTurntime * 1000];
   195     [self sendToEngine:turnTime];
   195     [self sendToEngine:turnTime];
   196     [turnTime release];
   196     [turnTime release];
   197 
   197 
   198     NSString *minesTime = [[NSString alloc] initWithFormat:@"e$turntime %d",[[basicArray objectAtIndex:2] intValue] * 1000];
   198     NSString *minesTime = [[NSString alloc] initWithFormat:@"e$turntime %d",[[basicArray objectAtIndex:i++] intValue] * 1000];
   199     [self sendToEngine:minesTime];
   199     [self sendToEngine:minesTime];
   200     [minesTime release];
   200     [minesTime release];
   201 
   201 
   202     for (i = 2; i < [basicArray count]; i++) {
   202     for (; i < [basicArray count]; i++) {
   203         NSDictionary *basicDict = [mods objectAtIndex:i];
   203         NSDictionary *basicDict = [mods objectAtIndex:i];
   204         NSString *command = [basicDict objectForKey:@"command"];
   204         NSString *command = [basicDict objectForKey:@"command"];
   205         NSInteger value = [[basicArray objectAtIndex:i] intValue];
   205         NSInteger value = [[basicArray objectAtIndex:i] intValue];
   206         if ([basicDict objectForKey:@"checkOverMax"] && value >= [[basicDict objectForKey:@"max"] intValue])
   206         if ([basicDict objectForKey:@"checkOverMax"] && value >= [[basicDict objectForKey:@"max"] intValue])
   207             value = 9999;
   207             value = 9999;