author | koda |
Wed, 27 Apr 2011 02:34:38 +0200 | |
changeset 5181 | 102fef5ca5fc |
parent 4976 | 088d40d8aba2 |
child 5185 | 7607a64e1853 |
permissions | -rw-r--r-- |
4281 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
4976 | 3 |
* Copyright (c) 2009-2011 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" |
|
23 |
||
24 |
void createTeamNamed (NSString *nameWithoutExt) { |
|
25 |
NSString *teamsDirectory = TEAMS_DIRECTORY(); |
|
26 |
||
27 |
if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) { |
|
28 |
[[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory |
|
29 |
withIntermediateDirectories:NO |
|
30 |
attributes:nil |
|
31 |
error:NULL]; |
|
32 |
} |
|
33 |
||
34 |
NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity: HW_getMaxNumberOfHogs()]; |
|
35 |
||
36 |
for (int i = 0; i < HW_getMaxNumberOfHogs(); i++) { |
|
37 |
NSString *hogName = [[NSString alloc] initWithFormat:@"hedgehog %d",i]; |
|
38 |
NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys: |
|
39 |
[NSNumber numberWithInt:0],@"level", |
|
40 |
hogName,@"hogname", |
|
41 |
@"NoHat",@"hat", |
|
42 |
nil]; |
|
43 |
[hogName release]; |
|
44 |
[hedgehogs addObject:hog]; |
|
45 |
[hog release]; |
|
46 |
} |
|
47 |
||
48 |
NSDictionary *theTeam = [[NSDictionary alloc] initWithObjectsAndKeys: |
|
49 |
@"0",@"hash", |
|
50 |
@"Statue",@"grave", |
|
51 |
@"Plane",@"fort", |
|
52 |
@"Default",@"voicepack", |
|
53 |
@"hedgewars",@"flag", |
|
54 |
hedgehogs,@"hedgehogs", |
|
55 |
nil]; |
|
56 |
[hedgehogs release]; |
|
57 |
||
58 |
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", teamsDirectory, nameWithoutExt]; |
|
59 |
||
60 |
[theTeam writeToFile:teamFile atomically:YES]; |
|
61 |
[teamFile release]; |
|
62 |
[theTeam release]; |
|
63 |
} |
|
64 |
||
65 |
void createWeaponNamed (NSString *nameWithoutExt, int type) { |
|
66 |
NSString *weaponsDirectory = WEAPONS_DIRECTORY(); |
|
67 |
||
68 |
if (![[NSFileManager defaultManager] fileExistsAtPath: weaponsDirectory]) { |
|
69 |
[[NSFileManager defaultManager] createDirectoryAtPath:weaponsDirectory |
|
70 |
withIntermediateDirectories:NO |
|
71 |
attributes:nil |
|
72 |
error:NULL]; |
|
73 |
} |
|
74 |
||
75 |
NSDictionary *theWeapon = nil; |
|
76 |
switch (type) { |
|
4607 | 77 |
default: //default |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
78 |
theWeapon = [[NSDictionary alloc] initWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
79 |
[NSArray arrayWithObjects: |
4950
941f17b2dd9f
disable the two last workinprogress weapons on the ios release
koda
parents:
4945
diff
changeset
|
80 |
@"93919294221991210322351110012010000002111101010111200", |
941f17b2dd9f
disable the two last workinprogress weapons on the ios release
koda
parents:
4945
diff
changeset
|
81 |
@"04050405416006555465544647765766666661555101011154100", |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
82 |
@"00000000000002055000000400070040000000002000000006000", |
4950
941f17b2dd9f
disable the two last workinprogress weapons on the ios release
koda
parents:
4945
diff
changeset
|
83 |
@"13111103121111111231141111111111111112111111011111200", |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
84 |
nil] |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
85 |
forKeys: [NSArray arrayWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
86 |
@"ammostore_initialqt", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
87 |
@"ammostore_probability", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
88 |
@"ammostore_delay", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
89 |
@"ammostore_crate", nil]]; |
4281 | 90 |
break; |
91 |
case 1: //crazy |
|
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
92 |
theWeapon = [[NSDictionary alloc] initWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
93 |
[NSArray arrayWithObjects: |
4950
941f17b2dd9f
disable the two last workinprogress weapons on the ios release
koda
parents:
4945
diff
changeset
|
94 |
@"99999999999999999929999999999999992999999999099999900", |
941f17b2dd9f
disable the two last workinprogress weapons on the ios release
koda
parents:
4945
diff
changeset
|
95 |
@"11111101111111111111111111111111111111111111011111100", |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
96 |
@"00000000000000000000000000000000000000000000000000000", |
4950
941f17b2dd9f
disable the two last workinprogress weapons on the ios release
koda
parents:
4945
diff
changeset
|
97 |
@"13111103121111111231141111111111111112111101011111100", |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
98 |
nil] |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
99 |
forKeys: [NSArray arrayWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
100 |
@"ammostore_initialqt", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
101 |
@"ammostore_probability", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
102 |
@"ammostore_delay", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
103 |
@"ammostore_crate", nil]]; |
4281 | 104 |
break; |
105 |
case 2: //pro mode |
|
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
106 |
theWeapon = [[NSDictionary alloc] initWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
107 |
[NSArray arrayWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
108 |
@"90900090000000000000090000000000000000000000000000000", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
109 |
@"00000000000000000000000000000000000000000000000000000", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
110 |
@"00000000000002055000000400070040000000002000000000000", |
4950
941f17b2dd9f
disable the two last workinprogress weapons on the ios release
koda
parents:
4945
diff
changeset
|
111 |
@"11111111111111111111111111111111111111111001011111100", |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
112 |
nil] |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
113 |
forKeys: [NSArray arrayWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
114 |
@"ammostore_initialqt", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
115 |
@"ammostore_probability", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
116 |
@"ammostore_delay", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
117 |
@"ammostore_crate", nil]]; |
4281 | 118 |
break; |
119 |
case 3: //shoppa |
|
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
120 |
theWeapon = [[NSDictionary alloc] initWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
121 |
[NSArray arrayWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
122 |
@"00000099000000000000000000000000000000000000000000000", |
4950
941f17b2dd9f
disable the two last workinprogress weapons on the ios release
koda
parents:
4945
diff
changeset
|
123 |
@"44444100442444022101121212224220000000020004000100100", |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
124 |
@"00000000000000000000000000000000000000000000000000000", |
4950
941f17b2dd9f
disable the two last workinprogress weapons on the ios release
koda
parents:
4945
diff
changeset
|
125 |
@"11111111111111111111111111111111111111111011011111100", |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
126 |
nil] |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
127 |
forKeys: [NSArray arrayWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
128 |
@"ammostore_initialqt", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
129 |
@"ammostore_probability", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
130 |
@"ammostore_delay", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
131 |
@"ammostore_crate", nil]]; |
4281 | 132 |
break; |
133 |
case 4: //clean slate |
|
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
134 |
theWeapon = [[NSDictionary alloc] initWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
135 |
[NSArray arrayWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
136 |
@"10100090000100000110000000000000000000000000000010000", |
4950
941f17b2dd9f
disable the two last workinprogress weapons on the ios release
koda
parents:
4945
diff
changeset
|
137 |
@"04050405416006555465544647765766666661555101011154100", |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
138 |
@"00000000000000000000000000000000000000000000000000000", |
4950
941f17b2dd9f
disable the two last workinprogress weapons on the ios release
koda
parents:
4945
diff
changeset
|
139 |
@"13111103121111111231141111111111111112111111011111100", |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
140 |
nil] |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
141 |
forKeys: [NSArray arrayWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
142 |
@"ammostore_initialqt", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
143 |
@"ammostore_probability", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
144 |
@"ammostore_delay", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
145 |
@"ammostore_crate", nil]]; |
4281 | 146 |
break; |
147 |
case 5: //minefield |
|
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
148 |
theWeapon = [[NSDictionary alloc] initWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
149 |
[NSArray arrayWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
150 |
@"00000099000900000003000000000000000000000000000000000", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
151 |
@"00000000000000000000000000000000000000000000000000000", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
152 |
@"00000000000002055000000400070040000000002000000006000", |
4950
941f17b2dd9f
disable the two last workinprogress weapons on the ios release
koda
parents:
4945
diff
changeset
|
153 |
@"11111111111111111111111111111111111111111111011111100", |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
154 |
nil] |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
155 |
forKeys: [NSArray arrayWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
156 |
@"ammostore_initialqt", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
157 |
@"ammostore_probability", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
158 |
@"ammostore_delay", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
159 |
@"ammostore_crate", nil]]; |
4284
57a501a69e5f
update iFrontend with new schemes and weaps, fix up smaller glitches
koda
parents:
4281
diff
changeset
|
160 |
break; |
57a501a69e5f
update iFrontend with new schemes and weaps, fix up smaller glitches
koda
parents:
4281
diff
changeset
|
161 |
case 6: //thinking with portals |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
162 |
theWeapon = [[NSDictionary alloc] initWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
163 |
[NSArray arrayWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
164 |
@"90000090020000000021000000000000001100000900000000000", |
4950
941f17b2dd9f
disable the two last workinprogress weapons on the ios release
koda
parents:
4945
diff
changeset
|
165 |
@"04050405416006555465544647765766666661555101011154100", |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
166 |
@"00000000000002055000000400070040000000002000000006000", |
4950
941f17b2dd9f
disable the two last workinprogress weapons on the ios release
koda
parents:
4945
diff
changeset
|
167 |
@"13111103121111111231141111111111111112111111011111100", |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
168 |
nil] |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
169 |
forKeys: [NSArray arrayWithObjects: |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
170 |
@"ammostore_initialqt", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
171 |
@"ammostore_probability", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
172 |
@"ammostore_delay", |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4607
diff
changeset
|
173 |
@"ammostore_crate", nil]]; |
4281 | 174 |
break; |
175 |
} |
|
176 |
||
177 |
NSString *weaponFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", weaponsDirectory, nameWithoutExt]; |
|
178 |
||
179 |
[theWeapon writeToFile:weaponFile atomically:YES]; |
|
180 |
[weaponFile release]; |
|
181 |
[theWeapon release]; |
|
182 |
} |
|
183 |
||
184 |
void createSchemeNamed (NSString *nameWithoutExt) { |
|
185 |
NSString *schemesDirectory = SCHEMES_DIRECTORY(); |
|
5181 | 186 |
NSString *path = nil; |
4281 | 187 |
|
188 |
if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) { |
|
189 |
[[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory |
|
190 |
withIntermediateDirectories:NO |
|
191 |
attributes:nil |
|
192 |
error:NULL]; |
|
193 |
} |
|
194 |
||
5181 | 195 |
// load data to get the size of the arrays and their default values |
196 |
path = [NSString stringWithFormat:@"%@/basicFlags_en.plist",IFRONTEND_DIRECTORY()]; |
|
197 |
NSArray *basicSettings = [[NSArray alloc] initWithContentsOfFile:path]; |
|
198 |
NSMutableArray *basicArray = [[NSMutableArray alloc] initWithCapacity:[basicSettings count]]; |
|
199 |
for (NSDictionary *basicDict in basicSettings) |
|
200 |
[basicArray addObject:[basicDict objectForKey:@"default"]]; |
|
201 |
[basicSettings release]; |
|
4281 | 202 |
|
5181 | 203 |
path = [NSString stringWithFormat:@"%@/gameFlags_en.plist",IFRONTEND_DIRECTORY()]; |
204 |
NSArray *mods = [[NSArray alloc] initWithContentsOfFile:path]; |
|
205 |
NSMutableArray *gamemodArray= [[NSMutableArray alloc] initWithCapacity:[mods count]]; |
|
206 |
for (int i = 0; i < [mods count]; i++) |
|
207 |
[gamemodArray addObject:[NSNumber numberWithBool:NO]]; |
|
208 |
[mods release]; |
|
209 |
||
210 |
// workaround for randomorder that has to be set to YES |
|
211 |
[gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
|
212 |
||
4281 | 213 |
NSMutableDictionary *theScheme = [[NSMutableDictionary alloc] initWithObjectsAndKeys: |
214 |
basicArray,@"basic", |
|
215 |
gamemodArray,@"gamemod", |
|
216 |
nil]; |
|
217 |
[gamemodArray release]; |
|
218 |
[basicArray release]; |
|
219 |
||
220 |
NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", schemesDirectory, nameWithoutExt]; |
|
221 |
||
222 |
[theScheme writeToFile:schemeFile atomically:YES]; |
|
223 |
[schemeFile release]; |
|
224 |
[theScheme release]; |
|
225 |
} |