|
1 // |
|
2 // CommodityFunctions.m |
|
3 // HedgewarsMobile |
|
4 // |
|
5 // Created by Vittorio on 08/04/10. |
|
6 // Copyright 2010 __MyCompanyName__. All rights reserved. |
|
7 // |
|
8 |
|
9 #import "CommodityFunctions.h" |
|
10 |
|
11 |
|
12 void createTeamNamed (NSString *nameWithoutExt) { |
|
13 NSString *teamsDirectory = TEAMS_DIRECTORY(); |
|
14 |
|
15 if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) { |
|
16 [[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory |
|
17 withIntermediateDirectories:NO |
|
18 attributes:nil |
|
19 error:NULL]; |
|
20 } |
|
21 |
|
22 NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity: MAX_HOGS]; |
|
23 |
|
24 for (int i = 0; i < MAX_HOGS; i++) { |
|
25 NSString *hogName = [[NSString alloc] initWithFormat:@"hedgehog %d",i]; |
|
26 NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys:@"100",@"health", @"0",@"level", |
|
27 hogName,@"hogname", @"NoHat",@"hat", nil]; |
|
28 [hogName release]; |
|
29 [hedgehogs addObject:hog]; |
|
30 [hog release]; |
|
31 } |
|
32 |
|
33 NSDictionary *theTeam = [[NSDictionary alloc] initWithObjectsAndKeys:@"0",@"hash", nameWithoutExt,@"teamname", |
|
34 @"Statue",@"grave", @"Plane",@"fort", @"Default",@"voicepack", |
|
35 @"hedgewars",@"flag", hedgehogs,@"hedgehogs", nil]; |
|
36 [hedgehogs release]; |
|
37 |
|
38 NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", teamsDirectory, nameWithoutExt]; |
|
39 NSLog(@"%@",teamFile); |
|
40 [theTeam writeToFile:teamFile atomically:YES]; |
|
41 [teamFile release]; |
|
42 [theTeam release]; |
|
43 } |