author | koda |
Mon, 26 Mar 2012 03:24:50 +0200 | |
changeset 6822 | 206db098f8c5 |
parent 6700 | e04da46ee43c |
child 6832 | fae8fd118da9 |
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 |
* File created on 12/11/2010. |
|
19 |
*/ |
|
20 |
||
21 |
||
22 |
#import "CreationChamber.h" |
|
6103 | 23 |
|
24 |
@implementation CreationChamber |
|
25 |
||
26 |
#pragma mark Settings |
|
27 |
+(void) createSettings { |
|
5206 | 28 |
NSUserDefaults *settings = [NSUserDefaults standardUserDefaults]; |
29 |
[settings setObject:[NSNumber numberWithBool:NO] forKey:@"alternate"]; |
|
30 |
[settings setObject:[NSNumber numberWithBool:YES] forKey:@"music"]; |
|
31 |
[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
|
32 |
[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
|
33 |
|
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
34 |
// 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
|
35 |
if ([settings objectForKey:@"username"] == nil) |
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
36 |
[settings setObject:@"" forKey:@"username"]; |
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
37 |
if ([settings objectForKey:@"password"] == nil) |
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
38 |
[settings setObject:@"" forKey:@"password"]; |
5206 | 39 |
|
40 |
[settings synchronize]; |
|
41 |
} |
|
4281 | 42 |
|
6103 | 43 |
#pragma mark Teams |
44 |
+(void) createTeamNamed:(NSString *)nameWithoutExt { |
|
45 |
[CreationChamber createTeamNamed:nameWithoutExt ofType:0 controlledByAI:NO]; |
|
46 |
} |
|
47 |
||
48 |
+(void) createTeamNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type { |
|
49 |
[CreationChamber createTeamNamed:nameWithoutExt ofType:type controlledByAI:NO]; |
|
50 |
} |
|
51 |
||
6104 | 52 |
+(void) createTeamNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type controlledByAI:(BOOL) shouldAITakeOver { |
4281 | 53 |
NSString *teamsDirectory = TEAMS_DIRECTORY(); |
54 |
||
55 |
if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) { |
|
56 |
[[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory |
|
57 |
withIntermediateDirectories:NO |
|
58 |
attributes:nil |
|
59 |
error:NULL]; |
|
60 |
} |
|
61 |
||
6104 | 62 |
NSArray *customNames; |
63 |
NSArray *customHats; |
|
64 |
NSString *flag, *grave, *voicepack, *fort; |
|
65 |
switch (type) { |
|
66 |
default: // default |
|
67 |
customNames = [[NSArray alloc] initWithObjects:@"No Name",@"Unnamed",@"Anonymous",@"Nameless",@"Incognito",@"Unidentified", |
|
68 |
@"Uknown",@"Secret",nil]; |
|
69 |
customHats = [[NSArray alloc] initWithObjects:@"NoHat",@"NoHat",@"NoHat",@"NoHat",@"NoHat",@"NoHat",@"NoHat",@"NoHat",nil]; |
|
70 |
flag = @"hedgewars"; |
|
71 |
grave = @"Statue"; |
|
72 |
voicepack = @"Default"; |
|
73 |
fort = @"Plane"; |
|
74 |
break; |
|
75 |
case 1: // ninjas |
|
76 |
customNames = [[NSArray alloc] initWithObjects:@"Shinobi",@"Ukemi",@"Godai",@"Ninpo",@"Tatsujin",@"Arashi",@"Bushi",@"Itami",nil]; |
|
77 |
customHats = [[NSArray alloc] initWithObjects:@"NinjaFull",@"NinjaStraight",@"NinjaTriangle",@"NinjaFull",@"NinjaStraight", |
|
78 |
@"NinjaTriangle",@"NinjaFull",@"NinjaTriangle",nil]; |
|
79 |
flag = @"japan"; |
|
80 |
grave = @"bp2"; |
|
81 |
voicepack = @"Singer"; |
|
82 |
fort = @"Wood"; |
|
83 |
break; |
|
84 |
case 2: // pirates |
|
85 |
customNames = [[NSArray alloc] initWithObjects:@"Toothless Wayne",@"Long-nose Kidd",@"Eye-patch Jim",@"Rackham Blood",@"One-eyed Ayee", |
|
86 |
@"Dirty Ben",@"Morris",@"Cruise Seymour",nil]; |
|
87 |
customHats = [[NSArray alloc] initWithObjects:@"pirate_jack_bandana",@"pirate_jack",@"dwarf",@"pirate_jack_bandana",@"pirate_jack", |
|
88 |
@"dwarf",@"pirate_jack_bandana",@"pirate_jack",nil]; |
|
89 |
flag = @"cm_pirate"; |
|
90 |
grave = @"chest"; |
|
91 |
voicepack = @"Pirate"; |
|
92 |
fort = @"Hydrant"; |
|
93 |
break; |
|
94 |
case 3: // robots |
|
95 |
customNames = [[NSArray alloc] initWithObjects:@"HAL",@"R2-D2",@"Wall-E",@"Robocop",@"Optimus Prime",@"Terminator",@"C-3PO",@"KITT",nil]; |
|
96 |
customHats = [[NSArray alloc] initWithObjects:@"cyborg1",@"cyborg2",@"cyborg1",@"cyborg2",@"cyborg1",@"cyborg2",@"cyborg1", |
|
97 |
@"cyborg2",nil]; |
|
98 |
flag = @"cm_binary"; |
|
99 |
grave = @"Rip"; |
|
100 |
voicepack = @"Robot"; |
|
101 |
fort = @"UFO"; |
|
102 |
break; |
|
103 |
} |
|
4281 | 104 |
|
6104 | 105 |
NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity:HW_getMaxNumberOfHogs()]; |
4281 | 106 |
for (int i = 0; i < HW_getMaxNumberOfHogs(); i++) { |
107 |
NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys: |
|
6104 | 108 |
[NSNumber numberWithInt:(shouldAITakeOver ? 4 : 0)],@"level", |
109 |
[customNames objectAtIndex:i],@"hogname", |
|
110 |
[customHats objectAtIndex:i],@"hat", |
|
4281 | 111 |
nil]; |
112 |
[hedgehogs addObject:hog]; |
|
113 |
[hog release]; |
|
114 |
} |
|
6104 | 115 |
[customHats release]; |
116 |
[customNames release]; |
|
4281 | 117 |
|
118 |
NSDictionary *theTeam = [[NSDictionary alloc] initWithObjectsAndKeys: |
|
119 |
@"0",@"hash", |
|
6104 | 120 |
grave,@"grave", |
121 |
fort,@"fort", |
|
122 |
voicepack,@"voicepack", |
|
123 |
flag,@"flag", |
|
4281 | 124 |
hedgehogs,@"hedgehogs", |
125 |
nil]; |
|
126 |
[hedgehogs release]; |
|
127 |
||
128 |
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", teamsDirectory, nameWithoutExt]; |
|
129 |
||
130 |
[theTeam writeToFile:teamFile atomically:YES]; |
|
131 |
[teamFile release]; |
|
132 |
[theTeam release]; |
|
133 |
} |
|
134 |
||
6103 | 135 |
#pragma mark Weapons |
136 |
+(void) createWeaponNamed:(NSString *)nameWithoutExt { |
|
137 |
[CreationChamber createWeaponNamed:nameWithoutExt ofType:0]; |
|
138 |
} |
|
139 |
||
140 |
+(void) createWeaponNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type { |
|
4281 | 141 |
NSString *weaponsDirectory = WEAPONS_DIRECTORY(); |
142 |
||
143 |
if (![[NSFileManager defaultManager] fileExistsAtPath: weaponsDirectory]) { |
|
144 |
[[NSFileManager defaultManager] createDirectoryAtPath:weaponsDirectory |
|
145 |
withIntermediateDirectories:NO |
|
146 |
attributes:nil |
|
147 |
error:NULL]; |
|
148 |
} |
|
149 |
||
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
|
150 |
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
|
151 |
NSString *qt, *prob, *delay, *crate; |
4281 | 152 |
switch (type) { |
4607 | 153 |
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
|
154 |
qt = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_QT length:ammolineSize encoding:NSUTF8StringEncoding]; |
5376 | 155 |
prob = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_PROB length:ammolineSize encoding:NSUTF8StringEncoding]; |
156 |
delay = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_DELAY length:ammolineSize encoding:NSUTF8StringEncoding]; |
|
157 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
|
4281 | 158 |
break; |
6104 | 159 |
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
|
160 |
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
|
161 |
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
|
162 |
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
|
163 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_CRAZY_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
4281 | 164 |
break; |
6104 | 165 |
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
|
166 |
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
|
167 |
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
|
168 |
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
|
169 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_PROMODE_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
4281 | 170 |
break; |
6104 | 171 |
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
|
172 |
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
|
173 |
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
|
174 |
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
|
175 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_SHOPPA_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
4281 | 176 |
break; |
6104 | 177 |
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
|
178 |
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
|
179 |
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
|
180 |
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
|
181 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_CLEAN_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
4281 | 182 |
break; |
6104 | 183 |
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
|
184 |
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
|
185 |
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
|
186 |
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
|
187 |
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
|
188 |
break; |
6104 | 189 |
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
|
190 |
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
|
191 |
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
|
192 |
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
|
193 |
crate = [[NSString alloc] initWithBytes:AMMOLINE_PORTALS_CRATE length:ammolineSize encoding:NSUTF8StringEncoding]; |
4281 | 194 |
break; |
195 |
} |
|
196 |
||
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
|
197 |
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
|
198 |
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
|
199 |
[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
|
200 |
[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
|
201 |
[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
|
202 |
[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
|
203 |
|
4281 | 204 |
NSString *weaponFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", weaponsDirectory, nameWithoutExt]; |
205 |
[theWeapon writeToFile:weaponFile atomically:YES]; |
|
206 |
[weaponFile release]; |
|
207 |
[theWeapon release]; |
|
208 |
} |
|
209 |
||
6103 | 210 |
#pragma mark Schemes |
211 |
+(void) createSchemeNamed:(NSString *)nameWithoutExt { |
|
212 |
[CreationChamber createSchemeNamed:nameWithoutExt ofType:0]; |
|
213 |
} |
|
214 |
||
215 |
+(void) createSchemeNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type { |
|
4281 | 216 |
NSString *schemesDirectory = SCHEMES_DIRECTORY(); |
217 |
||
218 |
if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) { |
|
219 |
[[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory |
|
220 |
withIntermediateDirectories:NO |
|
221 |
attributes:nil |
|
222 |
error:NULL]; |
|
223 |
} |
|
224 |
||
5181 | 225 |
// 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
|
226 |
NSArray *basicSettings = [[NSArray alloc] initWithContentsOfFile:BASICFLAGS_FILE()]; |
5181 | 227 |
NSMutableArray *basicArray = [[NSMutableArray alloc] initWithCapacity:[basicSettings count]]; |
228 |
for (NSDictionary *basicDict in basicSettings) |
|
229 |
[basicArray addObject:[basicDict objectForKey:@"default"]]; |
|
230 |
[basicSettings release]; |
|
4281 | 231 |
|
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
|
232 |
NSArray *mods = [[NSArray alloc] initWithContentsOfFile:GAMEMODS_FILE()]; |
5181 | 233 |
NSMutableArray *gamemodArray= [[NSMutableArray alloc] initWithCapacity:[mods count]]; |
234 |
for (int i = 0; i < [mods count]; i++) |
|
235 |
[gamemodArray addObject:[NSNumber numberWithBool:NO]]; |
|
236 |
[mods release]; |
|
237 |
||
5984 | 238 |
switch (type) { |
6104 | 239 |
default: // default |
5984 | 240 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
241 |
break; |
|
6104 | 242 |
case 1: // pro mode |
5984 | 243 |
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:15]]; |
244 |
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:0]]; |
|
245 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:0]]; |
|
246 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
247 |
[gamemodArray replaceObjectAtIndex:14 withObject:[NSNumber numberWithBool:YES]]; |
|
248 |
break; |
|
6104 | 249 |
case 2: // shoppa |
5984 | 250 |
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:30]]; |
251 |
[basicArray replaceObjectAtIndex:3 withObject:[NSNumber numberWithInt:50]]; |
|
252 |
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:1]]; |
|
253 |
[basicArray replaceObjectAtIndex:8 withObject:[NSNumber numberWithInt:0]]; |
|
254 |
[basicArray replaceObjectAtIndex:9 withObject:[NSNumber numberWithInt:25]]; |
|
255 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:0]]; |
|
256 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:0]]; |
|
257 |
[gamemodArray replaceObjectAtIndex:1 withObject:[NSNumber numberWithBool:YES]]; |
|
258 |
[gamemodArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithBool:YES]]; |
|
259 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
260 |
[gamemodArray replaceObjectAtIndex:14 withObject:[NSNumber numberWithBool:YES]]; |
|
261 |
[gamemodArray replaceObjectAtIndex:15 withObject:[NSNumber numberWithBool:YES]]; |
|
262 |
[gamemodArray replaceObjectAtIndex:19 withObject:[NSNumber numberWithBool:YES]]; |
|
263 |
break; |
|
6104 | 264 |
case 3: // clean slate |
5984 | 265 |
[gamemodArray replaceObjectAtIndex:6 withObject:[NSNumber numberWithBool:YES]]; |
266 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
267 |
[gamemodArray replaceObjectAtIndex:18 withObject:[NSNumber numberWithBool:YES]]; |
|
268 |
[gamemodArray replaceObjectAtIndex:19 withObject:[NSNumber numberWithBool:YES]]; |
|
269 |
break; |
|
6104 | 270 |
case 4: // minefield |
5984 | 271 |
[basicArray replaceObjectAtIndex:0 withObject:[NSNumber numberWithInt:50]]; |
272 |
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:30]]; |
|
273 |
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:0]]; |
|
274 |
[basicArray replaceObjectAtIndex:10 withObject:[NSNumber numberWithInt:0]]; |
|
275 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:80]]; |
|
276 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:0]]; |
|
277 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
278 |
[gamemodArray replaceObjectAtIndex:14 withObject:[NSNumber numberWithBool:YES]]; |
|
279 |
[gamemodArray replaceObjectAtIndex:15 withObject:[NSNumber numberWithBool:YES]]; |
|
280 |
break; |
|
6104 | 281 |
case 5: // barrel mayhem |
5984 | 282 |
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:30]]; |
283 |
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:0]]; |
|
284 |
[basicArray replaceObjectAtIndex:10 withObject:[NSNumber numberWithInt:0]]; |
|
285 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:0]]; |
|
286 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:40]]; |
|
287 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
288 |
[gamemodArray replaceObjectAtIndex:14 withObject:[NSNumber numberWithBool:YES]]; |
|
289 |
break; |
|
6104 | 290 |
case 6: // tunnel hogs |
5984 | 291 |
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:30]]; |
292 |
[basicArray replaceObjectAtIndex:9 withObject:[NSNumber numberWithInt:3]]; |
|
293 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:10]]; |
|
294 |
[basicArray replaceObjectAtIndex:12 withObject:[NSNumber numberWithInt:10]]; |
|
295 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:10]]; |
|
296 |
[gamemodArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithBool:YES]]; |
|
297 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
298 |
[gamemodArray replaceObjectAtIndex:14 withObject:[NSNumber numberWithBool:YES]]; |
|
299 |
[gamemodArray replaceObjectAtIndex:15 withObject:[NSNumber numberWithBool:YES]]; |
|
300 |
[gamemodArray replaceObjectAtIndex:16 withObject:[NSNumber numberWithBool:YES]]; |
|
301 |
break; |
|
6104 | 302 |
case 7: // fort mode |
5984 | 303 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:0]]; |
304 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:0]]; |
|
305 |
[gamemodArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithBool:YES]]; |
|
306 |
[gamemodArray replaceObjectAtIndex:3 withObject:[NSNumber numberWithBool:YES]]; |
|
307 |
[gamemodArray replaceObjectAtIndex:10 withObject:[NSNumber numberWithBool:YES]]; |
|
308 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
309 |
break; |
|
6104 | 310 |
case 8: // timeless |
5984 | 311 |
[basicArray replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:100]]; |
312 |
[basicArray replaceObjectAtIndex:4 withObject:[NSNumber numberWithInt:0]]; |
|
313 |
[basicArray replaceObjectAtIndex:5 withObject:[NSNumber numberWithInt:0]]; |
|
314 |
[basicArray replaceObjectAtIndex:9 withObject:[NSNumber numberWithInt:30]]; |
|
315 |
[basicArray replaceObjectAtIndex:10 withObject:[NSNumber numberWithInt:5]]; |
|
316 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:3]]; |
|
317 |
[basicArray replaceObjectAtIndex:12 withObject:[NSNumber numberWithInt:10]]; |
|
318 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
319 |
[gamemodArray replaceObjectAtIndex:20 withObject:[NSNumber numberWithBool:YES]]; |
|
320 |
break; |
|
6104 | 321 |
case 9: // thinking with portals |
5984 | 322 |
[basicArray replaceObjectAtIndex:7 withObject:[NSNumber numberWithInt:2]]; |
323 |
[basicArray replaceObjectAtIndex:8 withObject:[NSNumber numberWithInt:25]]; |
|
324 |
[basicArray replaceObjectAtIndex:10 withObject:[NSNumber numberWithInt:4]]; |
|
325 |
[basicArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithInt:5]]; |
|
326 |
[basicArray replaceObjectAtIndex:13 withObject:[NSNumber numberWithInt:5]]; |
|
327 |
[gamemodArray replaceObjectAtIndex:9 withObject:[NSNumber numberWithBool:YES]]; |
|
328 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
329 |
break; |
|
6104 | 330 |
case 10: // king mode |
5984 | 331 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
332 |
[gamemodArray replaceObjectAtIndex:12 withObject:[NSNumber numberWithBool:YES]]; |
|
333 |
break; |
|
334 |
} |
|
5181 | 335 |
|
4281 | 336 |
NSMutableDictionary *theScheme = [[NSMutableDictionary alloc] initWithObjectsAndKeys: |
337 |
basicArray,@"basic", |
|
338 |
gamemodArray,@"gamemod", |
|
339 |
nil]; |
|
340 |
[gamemodArray release]; |
|
341 |
[basicArray release]; |
|
5984 | 342 |
|
4281 | 343 |
NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", schemesDirectory, nameWithoutExt]; |
344 |
||
345 |
[theScheme writeToFile:schemeFile atomically:YES]; |
|
346 |
[schemeFile release]; |
|
347 |
[theScheme release]; |
|
348 |
} |
|
6103 | 349 |
|
350 |
@end |