author | koda |
Wed, 28 Mar 2012 01:56:42 +0200 | |
changeset 6832 | fae8fd118da9 |
parent 6822 | 206db098f8c5 |
child 6865 | fe19af8278e6 |
permissions | -rw-r--r-- |
4281 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
6700 | 3 |
* Copyright (c) 2009-2012 Vittorio Giovara <vittorio.giovara@gmail.com> |
4281 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
17 |
*/ |
|
18 |
||
19 |
||
20 |
#import "CreationChamber.h" |
|
6103 | 21 |
|
6832 | 22 |
|
6103 | 23 |
@implementation CreationChamber |
24 |
||
25 |
#pragma mark Settings |
|
26 |
+(void) createSettings { |
|
5206 | 27 |
NSUserDefaults *settings = [NSUserDefaults standardUserDefaults]; |
28 |
[settings setObject:[NSNumber numberWithBool:NO] forKey:@"alternate"]; |
|
29 |
[settings setObject:[NSNumber numberWithBool:YES] forKey:@"music"]; |
|
30 |
[settings setObject:[NSNumber numberWithBool:YES] forKey:@"sound"]; |
|
5451
e359a79e3d08
rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents:
5376
diff
changeset
|
31 |
[settings setObject:[NSNumber numberWithBool:YES] forKey:@"sync_ws"]; |
e359a79e3d08
rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents:
5376
diff
changeset
|
32 |
|
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
33 |
// don't overwrite these two strings when present |
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
34 |
if ([settings objectForKey:@"username"] == nil) |
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
35 |
[settings setObject:@"" forKey:@"username"]; |
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
36 |
if ([settings objectForKey:@"password"] == nil) |
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
37 |
[settings setObject:@"" forKey:@"password"]; |
5206 | 38 |
|
39 |
[settings synchronize]; |
|
40 |
} |
|
4281 | 41 |
|
6103 | 42 |
#pragma mark Teams |
43 |
+(void) createTeamNamed:(NSString *)nameWithoutExt { |
|
44 |
[CreationChamber createTeamNamed:nameWithoutExt ofType:0 controlledByAI:NO]; |
|
45 |
} |
|
46 |
||
47 |
+(void) createTeamNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type { |
|
48 |
[CreationChamber createTeamNamed:nameWithoutExt ofType:type controlledByAI:NO]; |
|
49 |
} |
|
50 |
||
6104 | 51 |
+(void) createTeamNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type controlledByAI:(BOOL) shouldAITakeOver { |
4281 | 52 |
NSString *teamsDirectory = TEAMS_DIRECTORY(); |
53 |
||
54 |
if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) { |
|
55 |
[[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory |
|
56 |
withIntermediateDirectories:NO |
|
57 |
attributes:nil |
|
58 |
error:NULL]; |
|
59 |
} |
|
60 |
||
6104 | 61 |
NSArray *customNames; |
62 |
NSArray *customHats; |
|
63 |
NSString *flag, *grave, *voicepack, *fort; |
|
64 |
switch (type) { |
|
65 |
default: // default |
|
66 |
customNames = [[NSArray alloc] initWithObjects:@"No Name",@"Unnamed",@"Anonymous",@"Nameless",@"Incognito",@"Unidentified", |
|
67 |
@"Uknown",@"Secret",nil]; |
|
68 |
customHats = [[NSArray alloc] initWithObjects:@"NoHat",@"NoHat",@"NoHat",@"NoHat",@"NoHat",@"NoHat",@"NoHat",@"NoHat",nil]; |
|
69 |
flag = @"hedgewars"; |
|
70 |
grave = @"Statue"; |
|
71 |
voicepack = @"Default"; |
|
72 |
fort = @"Plane"; |
|
73 |
break; |
|
74 |
case 1: // ninjas |
|
75 |
customNames = [[NSArray alloc] initWithObjects:@"Shinobi",@"Ukemi",@"Godai",@"Ninpo",@"Tatsujin",@"Arashi",@"Bushi",@"Itami",nil]; |
|
76 |
customHats = [[NSArray alloc] initWithObjects:@"NinjaFull",@"NinjaStraight",@"NinjaTriangle",@"NinjaFull",@"NinjaStraight", |
|
77 |
@"NinjaTriangle",@"NinjaFull",@"NinjaTriangle",nil]; |
|
78 |
flag = @"japan"; |
|
79 |
grave = @"bp2"; |
|
80 |
voicepack = @"Singer"; |
|
81 |
fort = @"Wood"; |
|
82 |
break; |
|
83 |
case 2: // pirates |
|
84 |
customNames = [[NSArray alloc] initWithObjects:@"Toothless Wayne",@"Long-nose Kidd",@"Eye-patch Jim",@"Rackham Blood",@"One-eyed Ayee", |
|
85 |
@"Dirty Ben",@"Morris",@"Cruise Seymour",nil]; |
|
86 |
customHats = [[NSArray alloc] initWithObjects:@"pirate_jack_bandana",@"pirate_jack",@"dwarf",@"pirate_jack_bandana",@"pirate_jack", |
|
87 |
@"dwarf",@"pirate_jack_bandana",@"pirate_jack",nil]; |
|
88 |
flag = @"cm_pirate"; |
|
89 |
grave = @"chest"; |
|
90 |
voicepack = @"Pirate"; |
|
91 |
fort = @"Hydrant"; |
|
92 |
break; |
|
93 |
case 3: // robots |
|
94 |
customNames = [[NSArray alloc] initWithObjects:@"HAL",@"R2-D2",@"Wall-E",@"Robocop",@"Optimus Prime",@"Terminator",@"C-3PO",@"KITT",nil]; |
|
95 |
customHats = [[NSArray alloc] initWithObjects:@"cyborg1",@"cyborg2",@"cyborg1",@"cyborg2",@"cyborg1",@"cyborg2",@"cyborg1", |
|
96 |
@"cyborg2",nil]; |
|
97 |
flag = @"cm_binary"; |
|
98 |
grave = @"Rip"; |
|
99 |
voicepack = @"Robot"; |
|
100 |
fort = @"UFO"; |
|
101 |
break; |
|
102 |
} |
|
4281 | 103 |
|
6104 | 104 |
NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity:HW_getMaxNumberOfHogs()]; |
4281 | 105 |
for (int i = 0; i < HW_getMaxNumberOfHogs(); i++) { |
106 |
NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys: |
|
6104 | 107 |
[NSNumber numberWithInt:(shouldAITakeOver ? 4 : 0)],@"level", |
108 |
[customNames objectAtIndex:i],@"hogname", |
|
109 |
[customHats objectAtIndex:i],@"hat", |
|
4281 | 110 |
nil]; |
111 |
[hedgehogs addObject:hog]; |
|
112 |
[hog release]; |
|
113 |
} |
|
6104 | 114 |
[customHats release]; |
115 |
[customNames release]; |
|
4281 | 116 |
|
117 |
NSDictionary *theTeam = [[NSDictionary alloc] initWithObjectsAndKeys: |
|
118 |
@"0",@"hash", |
|
6104 | 119 |
grave,@"grave", |
120 |
fort,@"fort", |
|
121 |
voicepack,@"voicepack", |
|
122 |
flag,@"flag", |
|
4281 | 123 |
hedgehogs,@"hedgehogs", |
124 |
nil]; |
|
125 |
[hedgehogs release]; |
|
126 |
||
127 |
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", teamsDirectory, nameWithoutExt]; |
|
128 |
||
129 |
[theTeam writeToFile:teamFile atomically:YES]; |
|
130 |
[teamFile release]; |
|
131 |
[theTeam release]; |
|
132 |
} |
|
133 |
||
6103 | 134 |
#pragma mark Weapons |
135 |
+(void) createWeaponNamed:(NSString *)nameWithoutExt { |
|
136 |
[CreationChamber createWeaponNamed:nameWithoutExt ofType:0]; |
|
137 |
} |
|
138 |
||
139 |
+(void) createWeaponNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type { |
|
4281 | 140 |
NSString *weaponsDirectory = WEAPONS_DIRECTORY(); |
141 |
||
142 |
if (![[NSFileManager defaultManager] fileExistsAtPath: weaponsDirectory]) { |
|
143 |
[[NSFileManager defaultManager] createDirectoryAtPath:weaponsDirectory |
|
144 |
withIntermediateDirectories:NO |
|
145 |
attributes:nil |
|
146 |
error:NULL]; |
|
147 |
} |
|
148 |
||
5200
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
149 |
NSInteger ammolineSize = HW_getNumberOfWeapons(); |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
150 |
NSString *qt, *prob, *delay, *crate; |
4281 | 151 |
switch (type) { |
4607 | 152 |
default: //default |
5200
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
153 |
qt = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_QT length:ammolineSize encoding:NSUTF8StringEncoding]; |
5376 | 154 |
prob = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_PROB length:ammolineSize encoding:NSUTF8StringEncoding]; |
155 |
delay = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_DELAY length:ammolineSize encoding:NSUTF8StringEncoding]; |
|
156 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
|
4281 | 157 |
break; |
6104 | 158 |
case 1: //crazy |
5200
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
159 |
qt = [[NSString alloc] initWithBytes:AMMOLINE_CRAZY_QT length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
160 |
prob = [[NSString alloc] initWithBytes:AMMOLINE_CRAZY_PROB length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
161 |
delay = [[NSString alloc] initWithBytes:AMMOLINE_CRAZY_DELAY length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
162 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_CRAZY_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
4281 | 163 |
break; |
6104 | 164 |
case 2: //pro mode |
5200
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
165 |
qt = [[NSString alloc] initWithBytes:AMMOLINE_PROMODE_QT length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
166 |
prob = [[NSString alloc] initWithBytes:AMMOLINE_PROMODE_PROB length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
167 |
delay = [[NSString alloc] initWithBytes:AMMOLINE_PROMODE_DELAY length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
168 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_PROMODE_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
4281 | 169 |
break; |
6104 | 170 |
case 3: //shoppa |
5200
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
171 |
qt = [[NSString alloc] initWithBytes:AMMOLINE_SHOPPA_QT length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
172 |
prob = [[NSString alloc] initWithBytes:AMMOLINE_SHOPPA_PROB length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
173 |
delay = [[NSString alloc] initWithBytes:AMMOLINE_SHOPPA_DELAY length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
174 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_SHOPPA_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
4281 | 175 |
break; |
6104 | 176 |
case 4: //clean slate |
5200
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
177 |
qt = [[NSString alloc] initWithBytes:AMMOLINE_CLEAN_QT length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
178 |
prob = [[NSString alloc] initWithBytes:AMMOLINE_CLEAN_PROB length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
179 |
delay = [[NSString alloc] initWithBytes:AMMOLINE_CLEAN_DELAY length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
180 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_CLEAN_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
4281 | 181 |
break; |
6104 | 182 |
case 5: //minefield |
5200
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
183 |
qt = [[NSString alloc] initWithBytes:AMMOLINE_MINES_QT length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
184 |
prob = [[NSString alloc] initWithBytes:AMMOLINE_MINES_PROB length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
185 |
delay = [[NSString alloc] initWithBytes:AMMOLINE_MINES_DELAY length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
186 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_MINES_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
4284
57a501a69e5f
update iFrontend with new schemes and weaps, fix up smaller glitches
koda
parents:
4281
diff
changeset
|
187 |
break; |
6104 | 188 |
case 6: //thinking with portals |
5200
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
189 |
qt = [[NSString alloc] initWithBytes:AMMOLINE_PORTALS_QT length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
190 |
prob = [[NSString alloc] initWithBytes:AMMOLINE_PORTALS_PROB length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
191 |
delay = [[NSString alloc] initWithBytes:AMMOLINE_PORTALS_DELAY length:ammolineSize encoding:NSUTF8StringEncoding]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
192 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_PORTALS_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
4281 | 193 |
break; |
194 |
} |
|
195 |
||
5200
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
196 |
NSDictionary *theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: qt,@"ammostore_initialqt", |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
197 |
prob,@"ammostore_probability", delay,@"ammostore_delay", crate,@"ammostore_crate", nil]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
198 |
[qt release]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
199 |
[prob release]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
200 |
[delay release]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
201 |
[crate release]; |
7440fe992e73
* move ammo lines from .cpp.in to .h so that it is readable from the ios frontend (and who knows, maybe from other frontends as well)
koda
parents:
5185
diff
changeset
|
202 |
|
4281 | 203 |
NSString *weaponFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", weaponsDirectory, nameWithoutExt]; |
204 |
[theWeapon writeToFile:weaponFile atomically:YES]; |
|
205 |
[weaponFile release]; |
|
206 |
[theWeapon release]; |
|
207 |
} |
|
208 |
||
6103 | 209 |
#pragma mark Schemes |
210 |
+(void) createSchemeNamed:(NSString *)nameWithoutExt { |
|
211 |
[CreationChamber createSchemeNamed:nameWithoutExt ofType:0]; |
|
212 |
} |
|
213 |
||
214 |
+(void) createSchemeNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type { |
|
4281 | 215 |
NSString *schemesDirectory = SCHEMES_DIRECTORY(); |
216 |
||
217 |
if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) { |
|
218 |
[[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory |
|
219 |
withIntermediateDirectories:NO |
|
220 |
attributes:nil |
|
221 |
error:NULL]; |
|
222 |
} |
|
223 |
||
5181 | 224 |
// load data to get the size of the arrays and their default values |
5185
7607a64e1853
remove the trailing _en from scheme data and use the macros available instead of creating a string every time
koda
parents:
5181
diff
changeset
|
225 |
NSArray *basicSettings = [[NSArray alloc] initWithContentsOfFile:BASICFLAGS_FILE()]; |
5181 | 226 |
NSMutableArray *basicArray = [[NSMutableArray alloc] initWithCapacity:[basicSettings count]]; |
227 |
for (NSDictionary *basicDict in basicSettings) |
|
228 |
[basicArray addObject:[basicDict objectForKey:@"default"]]; |
|
229 |
[basicSettings release]; |
|
4281 | 230 |
|
5185
7607a64e1853
remove the trailing _en from scheme data and use the macros available instead of creating a string every time
koda
parents:
5181
diff
changeset
|
231 |
NSArray *mods = [[NSArray alloc] initWithContentsOfFile:GAMEMODS_FILE()]; |
5181 | 232 |
NSMutableArray *gamemodArray= [[NSMutableArray alloc] initWithCapacity:[mods count]]; |
233 |
for (int i = 0; i < [mods count]; i++) |
|
234 |
[gamemodArray addObject:[NSNumber numberWithBool:NO]]; |
|
235 |
[mods release]; |
|
236 |
||
5984 | 237 |
switch (type) { |
6104 | 238 |
default: // default |
5984 | 239 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
240 |
break; |
|
6104 | 241 |
case 1: // pro mode |
5984 | 242 |
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:15]]; |
243 |
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:0]]; |
|
244 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:0]]; |
|
245 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
246 |
[gamemodArray replaceObjectAtIndex:14 withObject:[NSNumber numberWithBool:YES]]; |
|
247 |
break; |
|
6104 | 248 |
case 2: // shoppa |
5984 | 249 |
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:30]]; |
250 |
[basicArray replaceObjectAtIndex:3 withObject:[NSNumber numberWithInt:50]]; |
|
251 |
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:1]]; |
|
252 |
[basicArray replaceObjectAtIndex:8 withObject:[NSNumber numberWithInt:0]]; |
|
253 |
[basicArray replaceObjectAtIndex:9 withObject:[NSNumber numberWithInt:25]]; |
|
254 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:0]]; |
|
255 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:0]]; |
|
256 |
[gamemodArray replaceObjectAtIndex:1 withObject:[NSNumber numberWithBool:YES]]; |
|
257 |
[gamemodArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithBool:YES]]; |
|
258 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
259 |
[gamemodArray replaceObjectAtIndex:14 withObject:[NSNumber numberWithBool:YES]]; |
|
260 |
[gamemodArray replaceObjectAtIndex:15 withObject:[NSNumber numberWithBool:YES]]; |
|
261 |
[gamemodArray replaceObjectAtIndex:19 withObject:[NSNumber numberWithBool:YES]]; |
|
262 |
break; |
|
6104 | 263 |
case 3: // clean slate |
5984 | 264 |
[gamemodArray replaceObjectAtIndex:6 withObject:[NSNumber numberWithBool:YES]]; |
265 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
266 |
[gamemodArray replaceObjectAtIndex:18 withObject:[NSNumber numberWithBool:YES]]; |
|
267 |
[gamemodArray replaceObjectAtIndex:19 withObject:[NSNumber numberWithBool:YES]]; |
|
268 |
break; |
|
6104 | 269 |
case 4: // minefield |
5984 | 270 |
[basicArray replaceObjectAtIndex:0 withObject:[NSNumber numberWithInt:50]]; |
271 |
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:30]]; |
|
272 |
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:0]]; |
|
273 |
[basicArray replaceObjectAtIndex:10 withObject:[NSNumber numberWithInt:0]]; |
|
274 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:80]]; |
|
275 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:0]]; |
|
276 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
277 |
[gamemodArray replaceObjectAtIndex:14 withObject:[NSNumber numberWithBool:YES]]; |
|
278 |
[gamemodArray replaceObjectAtIndex:15 withObject:[NSNumber numberWithBool:YES]]; |
|
279 |
break; |
|
6104 | 280 |
case 5: // barrel mayhem |
5984 | 281 |
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:30]]; |
282 |
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:0]]; |
|
283 |
[basicArray replaceObjectAtIndex:10 withObject:[NSNumber numberWithInt:0]]; |
|
284 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:0]]; |
|
285 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:40]]; |
|
286 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
287 |
[gamemodArray replaceObjectAtIndex:14 withObject:[NSNumber numberWithBool:YES]]; |
|
288 |
break; |
|
6104 | 289 |
case 6: // tunnel hogs |
5984 | 290 |
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:30]]; |
291 |
[basicArray replaceObjectAtIndex:9 withObject:[NSNumber numberWithInt:3]]; |
|
292 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:10]]; |
|
293 |
[basicArray replaceObjectAtIndex:12 withObject:[NSNumber numberWithInt:10]]; |
|
294 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:10]]; |
|
295 |
[gamemodArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithBool:YES]]; |
|
296 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
297 |
[gamemodArray replaceObjectAtIndex:14 withObject:[NSNumber numberWithBool:YES]]; |
|
298 |
[gamemodArray replaceObjectAtIndex:15 withObject:[NSNumber numberWithBool:YES]]; |
|
299 |
[gamemodArray replaceObjectAtIndex:16 withObject:[NSNumber numberWithBool:YES]]; |
|
300 |
break; |
|
6104 | 301 |
case 7: // fort mode |
5984 | 302 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:0]]; |
303 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:0]]; |
|
304 |
[gamemodArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithBool:YES]]; |
|
305 |
[gamemodArray replaceObjectAtIndex:3 withObject:[NSNumber numberWithBool:YES]]; |
|
306 |
[gamemodArray replaceObjectAtIndex:10 withObject:[NSNumber numberWithBool:YES]]; |
|
307 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
308 |
break; |
|
6104 | 309 |
case 8: // timeless |
5984 | 310 |
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:100]]; |
311 |
[basicArray replaceObjectAtIndex:4 withObject:[NSNumber numberWithInt:0]]; |
|
312 |
[basicArray replaceObjectAtIndex:5 withObject:[NSNumber numberWithInt:0]]; |
|
313 |
[basicArray replaceObjectAtIndex:9 withObject:[NSNumber numberWithInt:30]]; |
|
314 |
[basicArray replaceObjectAtIndex:10 withObject:[NSNumber numberWithInt:5]]; |
|
315 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:3]]; |
|
316 |
[basicArray replaceObjectAtIndex:12 withObject:[NSNumber numberWithInt:10]]; |
|
317 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
318 |
[gamemodArray replaceObjectAtIndex:20 withObject:[NSNumber numberWithBool:YES]]; |
|
319 |
break; |
|
6104 | 320 |
case 9: // thinking with portals |
5984 | 321 |
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:2]]; |
322 |
[basicArray replaceObjectAtIndex:8 withObject:[NSNumber numberWithInt:25]]; |
|
323 |
[basicArray replaceObjectAtIndex:10 withObject:[NSNumber numberWithInt:4]]; |
|
324 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:5]]; |
|
325 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:5]]; |
|
326 |
[gamemodArray replaceObjectAtIndex:9 withObject:[NSNumber numberWithBool:YES]]; |
|
327 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
328 |
break; |
|
6104 | 329 |
case 10: // king mode |
5984 | 330 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
331 |
[gamemodArray replaceObjectAtIndex:12 withObject:[NSNumber numberWithBool:YES]]; |
|
332 |
break; |
|
333 |
} |
|
5181 | 334 |
|
4281 | 335 |
NSMutableDictionary *theScheme = [[NSMutableDictionary alloc] initWithObjectsAndKeys: |
336 |
basicArray,@"basic", |
|
337 |
gamemodArray,@"gamemod", |
|
338 |
nil]; |
|
339 |
[gamemodArray release]; |
|
340 |
[basicArray release]; |
|
5984 | 341 |
|
4281 | 342 |
NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", schemesDirectory, nameWithoutExt]; |
343 |
||
344 |
[theScheme writeToFile:schemeFile atomically:YES]; |
|
345 |
[schemeFile release]; |
|
346 |
[theScheme release]; |
|
347 |
} |
|
6103 | 348 |
|
349 |
@end |