4281
|
1 |
/*
|
|
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices
|
|
3 |
* Copyright (c) 2009-2010 Vittorio Giovara <vittorio.giovara@gmail.com>
|
|
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) {
|
|
77 |
case 0: //default
|
|
78 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys:
|
|
79 |
@"9391929422199121032235111001201000000211110101011",@"ammostore_initialqt",
|
|
80 |
@"0405040541600655546554464776576666666155510101117",@"ammostore_probability",
|
|
81 |
@"0000000000000205500000040007004000000000200000000",@"ammostore_delay",
|
|
82 |
@"1311110312111111123114111111111111111211111101111",@"ammostore_crate", nil];
|
|
83 |
break;
|
|
84 |
case 1: //crazy
|
|
85 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys:
|
|
86 |
@"9999999999999999992999999999999999299999999909999",@"ammostore_initialqt",
|
|
87 |
@"1111110111111111111111111111111111111111111101111",@"ammostore_probability",
|
|
88 |
@"0000000000000000000000000000000000000000000000000",@"ammostore_delay",
|
|
89 |
@"1311110312111111123114111111111111111211110101111",@"ammostore_crate", nil];
|
|
90 |
break;
|
|
91 |
case 2: //pro mode
|
|
92 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys:
|
|
93 |
@"9090009000000000000009000000000000000000000000000",@"ammostore_initialqt",
|
|
94 |
@"0000000000000000000000000000000000000000000000000",@"ammostore_probability",
|
|
95 |
@"0000000000000205500000040007004000000000200000000",@"ammostore_delay",
|
|
96 |
@"1111111111111111111111111111111111111111100101111",@"ammostore_crate", nil];
|
|
97 |
break;
|
|
98 |
case 3: //shoppa
|
|
99 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys:
|
|
100 |
@"0000009900000000000000000000000000000000000000000",@"ammostore_initialqt",
|
|
101 |
@"4444410044244402210112121222422000000002000400010",@"ammostore_probability",
|
|
102 |
@"0000000000000000000000000000000000000000000000000",@"ammostore_delay",
|
|
103 |
@"1111111111111111111111111111111111111111101101111",@"ammostore_crate", nil];
|
|
104 |
break;
|
|
105 |
case 4: //clean slate
|
|
106 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys:
|
|
107 |
@"1010009000010000011000000000000000000000000000001",@"ammostore_initialqt",
|
|
108 |
@"0405040541600655546554464776576666666155510101117",@"ammostore_probability",
|
|
109 |
@"0000000000000205500000040007004000000000200000000",@"ammostore_delay",
|
|
110 |
@"1311110312111111123114111111111111111211111101111",@"ammostore_crate", nil];
|
|
111 |
break;
|
|
112 |
case 5: //minefield
|
|
113 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys:
|
|
114 |
@"0000009900090000000300000000000000000000000000000",@"ammostore_initialqt",
|
|
115 |
@"0000000000000000000000000000000000000000000000000",@"ammostore_probability",
|
|
116 |
@"0000000000000205500000040007004000000000200000000",@"ammostore_delay",
|
|
117 |
@"1111111111111111111111111111111111111111111101111",@"ammostore_crate", nil];
|
|
118 |
break;
|
|
119 |
default:
|
|
120 |
NSLog(@"Nope");
|
|
121 |
break;
|
|
122 |
}
|
|
123 |
|
|
124 |
NSString *weaponFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", weaponsDirectory, nameWithoutExt];
|
|
125 |
|
|
126 |
[theWeapon writeToFile:weaponFile atomically:YES];
|
|
127 |
[weaponFile release];
|
|
128 |
[theWeapon release];
|
|
129 |
}
|
|
130 |
|
|
131 |
void createSchemeNamed (NSString *nameWithoutExt) {
|
|
132 |
NSString *schemesDirectory = SCHEMES_DIRECTORY();
|
|
133 |
|
|
134 |
if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) {
|
|
135 |
[[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory
|
|
136 |
withIntermediateDirectories:NO
|
|
137 |
attributes:nil
|
|
138 |
error:NULL];
|
|
139 |
}
|
|
140 |
|
|
141 |
NSMutableArray *basicArray = [[NSMutableArray alloc] initWithObjects:
|
|
142 |
[NSNumber numberWithInt:100], //initialhealth
|
|
143 |
[NSNumber numberWithInt:45], //turntime
|
|
144 |
[NSNumber numberWithInt:100], //damagemodifier
|
|
145 |
[NSNumber numberWithInt:15], //suddendeathtimeout
|
|
146 |
[NSNumber numberWithInt:47], //waterrise
|
|
147 |
[NSNumber numberWithInt:5], //healthdecrease
|
|
148 |
[NSNumber numberWithInt:5], //cratedrops
|
|
149 |
[NSNumber numberWithInt:35], //healthprob
|
|
150 |
[NSNumber numberWithInt:25], //healthamount
|
|
151 |
[NSNumber numberWithInt:3], //minestime
|
|
152 |
[NSNumber numberWithInt:4], //minesnumber
|
|
153 |
[NSNumber numberWithInt:0], //dudmines
|
|
154 |
[NSNumber numberWithInt:2], //explosives
|
|
155 |
nil];
|
|
156 |
|
|
157 |
NSMutableArray *gamemodArray= [[NSMutableArray alloc] initWithObjects:
|
|
158 |
[NSNumber numberWithBool:NO], //fortmode
|
|
159 |
[NSNumber numberWithBool:NO], //divideteam
|
|
160 |
[NSNumber numberWithBool:NO], //solidland
|
|
161 |
[NSNumber numberWithBool:NO], //addborder
|
|
162 |
[NSNumber numberWithBool:NO], //lowgravity
|
|
163 |
[NSNumber numberWithBool:NO], //lasersight
|
|
164 |
[NSNumber numberWithBool:NO], //invulnerable
|
|
165 |
[NSNumber numberWithBool:NO], //resethealth
|
|
166 |
[NSNumber numberWithBool:NO], //vampirism
|
|
167 |
[NSNumber numberWithBool:NO], //karma
|
|
168 |
[NSNumber numberWithBool:NO], //artillery
|
|
169 |
[NSNumber numberWithBool:YES], //randomorder
|
|
170 |
[NSNumber numberWithBool:NO], //king
|
|
171 |
[NSNumber numberWithBool:NO], //placehedgehogs
|
|
172 |
[NSNumber numberWithBool:NO], //clansharesammo
|
|
173 |
[NSNumber numberWithBool:NO], //disablegirders
|
|
174 |
[NSNumber numberWithBool:NO], //disablelandobjects
|
|
175 |
[NSNumber numberWithBool:NO], //aisurvival
|
|
176 |
[NSNumber numberWithBool:NO], //infattack
|
|
177 |
[NSNumber numberWithBool:NO], //resetweaps
|
|
178 |
[NSNumber numberWithBool:NO], //perhogammo
|
|
179 |
nil];
|
|
180 |
|
|
181 |
NSMutableDictionary *theScheme = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
|
|
182 |
basicArray,@"basic",
|
|
183 |
gamemodArray,@"gamemod",
|
|
184 |
nil];
|
|
185 |
[gamemodArray release];
|
|
186 |
[basicArray release];
|
|
187 |
|
|
188 |
NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", schemesDirectory, nameWithoutExt];
|
|
189 |
|
|
190 |
[theScheme writeToFile:schemeFile atomically:YES];
|
|
191 |
[schemeFile release];
|
|
192 |
[theScheme release];
|
|
193 |
}
|