--- a/project_files/HedgewarsMobile/Classes/CreationChamber.m Sat Oct 08 21:17:24 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/CreationChamber.m Sat Oct 08 22:44:32 2011 +0200
@@ -52,7 +52,7 @@
[CreationChamber createTeamNamed:nameWithoutExt ofType:type controlledByAI:NO];
}
-+(void) createTeamNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type controlledByAI:(BOOL) flag {
++(void) createTeamNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type controlledByAI:(BOOL) shouldAITakeOver {
NSString *teamsDirectory = TEAMS_DIRECTORY();
if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) {
@@ -62,26 +62,68 @@
error:NULL];
}
- NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity: HW_getMaxNumberOfHogs()];
+ NSArray *customNames;
+ NSArray *customHats;
+ NSString *flag, *grave, *voicepack, *fort;
+ switch (type) {
+ default: // default
+ customNames = [[NSArray alloc] initWithObjects:@"No Name",@"Unnamed",@"Anonymous",@"Nameless",@"Incognito",@"Unidentified",
+ @"Uknown",@"Secret",nil];
+ customHats = [[NSArray alloc] initWithObjects:@"NoHat",@"NoHat",@"NoHat",@"NoHat",@"NoHat",@"NoHat",@"NoHat",@"NoHat",nil];
+ flag = @"hedgewars";
+ grave = @"Statue";
+ voicepack = @"Default";
+ fort = @"Plane";
+ break;
+ case 1: // ninjas
+ customNames = [[NSArray alloc] initWithObjects:@"Shinobi",@"Ukemi",@"Godai",@"Ninpo",@"Tatsujin",@"Arashi",@"Bushi",@"Itami",nil];
+ customHats = [[NSArray alloc] initWithObjects:@"NinjaFull",@"NinjaStraight",@"NinjaTriangle",@"NinjaFull",@"NinjaStraight",
+ @"NinjaTriangle",@"NinjaFull",@"NinjaTriangle",nil];
+ flag = @"japan";
+ grave = @"bp2";
+ voicepack = @"Singer";
+ fort = @"Wood";
+ break;
+ case 2: // pirates
+ customNames = [[NSArray alloc] initWithObjects:@"Toothless Wayne",@"Long-nose Kidd",@"Eye-patch Jim",@"Rackham Blood",@"One-eyed Ayee",
+ @"Dirty Ben",@"Morris",@"Cruise Seymour",nil];
+ customHats = [[NSArray alloc] initWithObjects:@"pirate_jack_bandana",@"pirate_jack",@"dwarf",@"pirate_jack_bandana",@"pirate_jack",
+ @"dwarf",@"pirate_jack_bandana",@"pirate_jack",nil];
+ flag = @"cm_pirate";
+ grave = @"chest";
+ voicepack = @"Pirate";
+ fort = @"Hydrant";
+ break;
+ case 3: // robots
+ customNames = [[NSArray alloc] initWithObjects:@"HAL",@"R2-D2",@"Wall-E",@"Robocop",@"Optimus Prime",@"Terminator",@"C-3PO",@"KITT",nil];
+ customHats = [[NSArray alloc] initWithObjects:@"cyborg1",@"cyborg2",@"cyborg1",@"cyborg2",@"cyborg1",@"cyborg2",@"cyborg1",
+ @"cyborg2",nil];
+ flag = @"cm_binary";
+ grave = @"Rip";
+ voicepack = @"Robot";
+ fort = @"UFO";
+ break;
+ }
+ NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity:HW_getMaxNumberOfHogs()];
for (int i = 0; i < HW_getMaxNumberOfHogs(); i++) {
- NSString *hogName = [[NSString alloc] initWithFormat:@"hedgehog %d",i];
NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys:
- [NSNumber numberWithInt:0],@"level",
- hogName,@"hogname",
- @"NoHat",@"hat",
+ [NSNumber numberWithInt:(shouldAITakeOver ? 4 : 0)],@"level",
+ [customNames objectAtIndex:i],@"hogname",
+ [customHats objectAtIndex:i],@"hat",
nil];
- [hogName release];
[hedgehogs addObject:hog];
[hog release];
}
+ [customHats release];
+ [customNames release];
NSDictionary *theTeam = [[NSDictionary alloc] initWithObjectsAndKeys:
@"0",@"hash",
- @"Statue",@"grave",
- @"Plane",@"fort",
- @"Default",@"voicepack",
- @"hedgewars",@"flag",
+ grave,@"grave",
+ fort,@"fort",
+ voicepack,@"voicepack",
+ flag,@"flag",
hedgehogs,@"hedgehogs",
nil];
[hedgehogs release];
@@ -117,37 +159,37 @@
delay = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_DELAY length:ammolineSize encoding:NSUTF8StringEncoding];
crate = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_CRATE length:ammolineSize encoding:NSUTF8StringEncoding];
break;
- case 1: //crazy
+ case 1: //crazy
qt = [[NSString alloc] initWithBytes:AMMOLINE_CRAZY_QT length:ammolineSize encoding:NSUTF8StringEncoding];
prob = [[NSString alloc] initWithBytes:AMMOLINE_CRAZY_PROB length:ammolineSize encoding:NSUTF8StringEncoding];
delay = [[NSString alloc] initWithBytes:AMMOLINE_CRAZY_DELAY length:ammolineSize encoding:NSUTF8StringEncoding];
crate = [[NSString alloc] initWithBytes:AMMOLINE_CRAZY_CRATE length:ammolineSize encoding:NSUTF8StringEncoding];
break;
- case 2: //pro mode
+ case 2: //pro mode
qt = [[NSString alloc] initWithBytes:AMMOLINE_PROMODE_QT length:ammolineSize encoding:NSUTF8StringEncoding];
prob = [[NSString alloc] initWithBytes:AMMOLINE_PROMODE_PROB length:ammolineSize encoding:NSUTF8StringEncoding];
delay = [[NSString alloc] initWithBytes:AMMOLINE_PROMODE_DELAY length:ammolineSize encoding:NSUTF8StringEncoding];
crate = [[NSString alloc] initWithBytes:AMMOLINE_PROMODE_CRATE length:ammolineSize encoding:NSUTF8StringEncoding];
break;
- case 3: //shoppa
+ case 3: //shoppa
qt = [[NSString alloc] initWithBytes:AMMOLINE_SHOPPA_QT length:ammolineSize encoding:NSUTF8StringEncoding];
prob = [[NSString alloc] initWithBytes:AMMOLINE_SHOPPA_PROB length:ammolineSize encoding:NSUTF8StringEncoding];
delay = [[NSString alloc] initWithBytes:AMMOLINE_SHOPPA_DELAY length:ammolineSize encoding:NSUTF8StringEncoding];
crate = [[NSString alloc] initWithBytes:AMMOLINE_SHOPPA_CRATE length:ammolineSize encoding:NSUTF8StringEncoding];
break;
- case 4: //clean slate
+ case 4: //clean slate
qt = [[NSString alloc] initWithBytes:AMMOLINE_CLEAN_QT length:ammolineSize encoding:NSUTF8StringEncoding];
prob = [[NSString alloc] initWithBytes:AMMOLINE_CLEAN_PROB length:ammolineSize encoding:NSUTF8StringEncoding];
delay = [[NSString alloc] initWithBytes:AMMOLINE_CLEAN_DELAY length:ammolineSize encoding:NSUTF8StringEncoding];
crate = [[NSString alloc] initWithBytes:AMMOLINE_CLEAN_CRATE length:ammolineSize encoding:NSUTF8StringEncoding];
break;
- case 5: //minefield
+ case 5: //minefield
qt = [[NSString alloc] initWithBytes:AMMOLINE_MINES_QT length:ammolineSize encoding:NSUTF8StringEncoding];
prob = [[NSString alloc] initWithBytes:AMMOLINE_MINES_PROB length:ammolineSize encoding:NSUTF8StringEncoding];
delay = [[NSString alloc] initWithBytes:AMMOLINE_MINES_DELAY length:ammolineSize encoding:NSUTF8StringEncoding];
crate = [[NSString alloc] initWithBytes:AMMOLINE_MINES_CRATE length:ammolineSize encoding:NSUTF8StringEncoding];
break;
- case 6: //thinking with portals
+ case 6: //thinking with portals
qt = [[NSString alloc] initWithBytes:AMMOLINE_PORTALS_QT length:ammolineSize encoding:NSUTF8StringEncoding];
prob = [[NSString alloc] initWithBytes:AMMOLINE_PORTALS_PROB length:ammolineSize encoding:NSUTF8StringEncoding];
delay = [[NSString alloc] initWithBytes:AMMOLINE_PORTALS_DELAY length:ammolineSize encoding:NSUTF8StringEncoding];
@@ -197,17 +239,17 @@
[mods release];
switch (type) {
- case 0: // default
+ default: // default
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]];
break;
- case 1: // pro mode
+ case 1: // pro mode
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:15]];
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:0]];
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:0]];
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]];
[gamemodArray replaceObjectAtIndex:14 withObject:[NSNumber numberWithBool:YES]];
break;
- case 2: // shoppa
+ case 2: // shoppa
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:30]];
[basicArray replaceObjectAtIndex:3 withObject:[NSNumber numberWithInt:50]];
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:1]];
@@ -222,13 +264,13 @@
[gamemodArray replaceObjectAtIndex:15 withObject:[NSNumber numberWithBool:YES]];
[gamemodArray replaceObjectAtIndex:19 withObject:[NSNumber numberWithBool:YES]];
break;
- case 3: // clean slate
+ case 3: // clean slate
[gamemodArray replaceObjectAtIndex:6 withObject:[NSNumber numberWithBool:YES]];
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]];
[gamemodArray replaceObjectAtIndex:18 withObject:[NSNumber numberWithBool:YES]];
[gamemodArray replaceObjectAtIndex:19 withObject:[NSNumber numberWithBool:YES]];
break;
- case 4: // minefield
+ case 4: // minefield
[basicArray replaceObjectAtIndex:0 withObject:[NSNumber numberWithInt:50]];
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:30]];
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:0]];
@@ -239,7 +281,7 @@
[gamemodArray replaceObjectAtIndex:14 withObject:[NSNumber numberWithBool:YES]];
[gamemodArray replaceObjectAtIndex:15 withObject:[NSNumber numberWithBool:YES]];
break;
- case 5: // barrel mayhem
+ case 5: // barrel mayhem
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:30]];
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:0]];
[basicArray replaceObjectAtIndex:10 withObject:[NSNumber numberWithInt:0]];
@@ -248,7 +290,7 @@
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]];
[gamemodArray replaceObjectAtIndex:14 withObject:[NSNumber numberWithBool:YES]];
break;
- case 6: // tunnel hogs
+ case 6: // tunnel hogs
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:30]];
[basicArray replaceObjectAtIndex:9 withObject:[NSNumber numberWithInt:3]];
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:10]];
@@ -260,7 +302,7 @@
[gamemodArray replaceObjectAtIndex:15 withObject:[NSNumber numberWithBool:YES]];
[gamemodArray replaceObjectAtIndex:16 withObject:[NSNumber numberWithBool:YES]];
break;
- case 7: // fort mode
+ case 7: // fort mode
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:0]];
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:0]];
[gamemodArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithBool:YES]];
@@ -268,7 +310,7 @@
[gamemodArray replaceObjectAtIndex:10 withObject:[NSNumber numberWithBool:YES]];
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]];
break;
- case 8: // timeless
+ case 8: // timeless
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:100]];
[basicArray replaceObjectAtIndex:4 withObject:[NSNumber numberWithInt:0]];
[basicArray replaceObjectAtIndex:5 withObject:[NSNumber numberWithInt:0]];
@@ -279,7 +321,7 @@
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]];
[gamemodArray replaceObjectAtIndex:20 withObject:[NSNumber numberWithBool:YES]];
break;
- case 9: // thinking with portals
+ case 9: // thinking with portals
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:2]];
[basicArray replaceObjectAtIndex:8 withObject:[NSNumber numberWithInt:25]];
[basicArray replaceObjectAtIndex:10 withObject:[NSNumber numberWithInt:4]];
@@ -288,13 +330,10 @@
[gamemodArray replaceObjectAtIndex:9 withObject:[NSNumber numberWithBool:YES]];
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]];
break;
- case 10:// king mode
+ case 10: // king mode
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]];
[gamemodArray replaceObjectAtIndex:12 withObject:[NSNumber numberWithBool:YES]];
break;
- default:
- DLog(@"Impossible");
- break;
}
NSMutableDictionary *theScheme = [[NSMutableDictionary alloc] initWithObjectsAndKeys: