project_files/HedgewarsMobile/Classes/CreationChamber.m
author koda
Tue, 03 May 2011 23:16:47 +0200
changeset 5200 7440fe992e73
parent 5185 7607a64e1853
child 5206 db775bddf771
permissions -rw-r--r--
* 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) * increase the max team number from 6 to 8 like engine supports * update ios project file for uCursor
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4281
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
     1
/*
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
     2
 * Hedgewars-iOS, a Hedgewars port for iOS devices
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4950
diff changeset
     3
 * Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com>
4281
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
     4
 *
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
     8
 *
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    12
 * GNU General Public License for more details.
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    13
 *
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    17
 *
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    18
 * File created on 12/11/2010.
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    19
 */
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    20
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    21
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    22
#import "CreationChamber.h"
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
    23
#import "hwconsts.h"
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
    24
4281
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    25
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    26
void createTeamNamed (NSString *nameWithoutExt) {
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    27
    NSString *teamsDirectory = TEAMS_DIRECTORY();
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    28
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    29
    if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) {
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    30
        [[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    31
                                  withIntermediateDirectories:NO
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    32
                                                   attributes:nil
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    33
                                                        error:NULL];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    34
    }
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    35
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    36
    NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity: HW_getMaxNumberOfHogs()];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    37
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    38
    for (int i = 0; i < HW_getMaxNumberOfHogs(); i++) {
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    39
        NSString *hogName = [[NSString alloc] initWithFormat:@"hedgehog %d",i];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    40
        NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys:
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    41
                             [NSNumber numberWithInt:0],@"level",
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    42
                             hogName,@"hogname",
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    43
                             @"NoHat",@"hat",
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    44
                             nil];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    45
        [hogName release];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    46
        [hedgehogs addObject:hog];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    47
        [hog release];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    48
    }
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    49
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    50
    NSDictionary *theTeam = [[NSDictionary alloc] initWithObjectsAndKeys:
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    51
                             @"0",@"hash",
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    52
                             @"Statue",@"grave",
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    53
                             @"Plane",@"fort",
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    54
                             @"Default",@"voicepack",
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    55
                             @"hedgewars",@"flag",
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    56
                             hedgehogs,@"hedgehogs",
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    57
                             nil];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    58
    [hedgehogs release];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    59
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    60
    NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", teamsDirectory, nameWithoutExt];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    61
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    62
    [theTeam writeToFile:teamFile atomically:YES];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    63
    [teamFile release];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    64
    [theTeam release];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    65
}
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    66
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    67
void createWeaponNamed (NSString *nameWithoutExt, int type) {
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    68
    NSString *weaponsDirectory = WEAPONS_DIRECTORY();
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    69
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    70
    if (![[NSFileManager defaultManager] fileExistsAtPath: weaponsDirectory]) {
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    71
        [[NSFileManager defaultManager] createDirectoryAtPath:weaponsDirectory
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    72
                                  withIntermediateDirectories:NO
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    73
                                                   attributes:nil
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    74
                                                        error:NULL];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    75
    }
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    76
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
    77
    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
    78
    NSString *qt, *prob, *delay, *crate;
4281
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    79
    switch (type) {
4607
7f683c2357a0 update weapons
koda
parents: 4605
diff changeset
    80
        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
    81
            qt = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_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
    82
            prob = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_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
    83
            delay = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_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
    84
            crate = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_QT length:ammolineSize encoding:NSUTF8StringEncoding];
4281
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    85
            break;
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    86
        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
    87
            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
    88
            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
    89
            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
    90
            crate = [[NSString alloc] initWithBytes:AMMOLINE_CRAZY_CRATE length:ammolineSize encoding:NSUTF8StringEncoding];
4281
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    91
            break;
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    92
        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
    93
            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
    94
            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
    95
            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
    96
            crate = [[NSString alloc] initWithBytes:AMMOLINE_PROMODE_CRATE length:ammolineSize encoding:NSUTF8StringEncoding];
4281
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    97
            break;
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
    98
        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
    99
            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
   100
            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
   101
            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
   102
            crate = [[NSString alloc] initWithBytes:AMMOLINE_SHOPPA_CRATE length:ammolineSize encoding:NSUTF8StringEncoding];
4281
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   103
            break;
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   104
        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
   105
            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
   106
            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
   107
            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
   108
            crate = [[NSString alloc] initWithBytes:AMMOLINE_CLEAN_CRATE length:ammolineSize encoding:NSUTF8StringEncoding];
4281
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   109
            break;
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   110
        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
   111
            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
   112
            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
   113
            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
   114
            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
   115
            break;
57a501a69e5f update iFrontend with new schemes and weaps, fix up smaller glitches
koda
parents: 4281
diff changeset
   116
        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
   117
            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
   118
            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
   119
            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
   120
            crate = [[NSString alloc] initWithBytes:AMMOLINE_PORTALS_CRATE length:ammolineSize encoding:NSUTF8StringEncoding];
4281
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   121
            break;
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   122
    }
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   123
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
   124
    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
   125
                               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
   126
    [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
   127
    [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
   128
    [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
   129
    [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
   130
4281
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   131
    NSString *weaponFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", weaponsDirectory, nameWithoutExt];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   132
    [theWeapon writeToFile:weaponFile atomically:YES];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   133
    [weaponFile release];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   134
    [theWeapon release];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   135
}
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   136
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   137
void createSchemeNamed (NSString *nameWithoutExt) {
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   138
    NSString *schemesDirectory = SCHEMES_DIRECTORY();
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   139
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   140
    if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) {
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   141
        [[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   142
                                  withIntermediateDirectories:NO
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   143
                                                   attributes:nil
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   144
                                                        error:NULL];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   145
    }
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   146
5181
102fef5ca5fc add getawaytime and tagteam mode to ios
koda
parents: 4976
diff changeset
   147
    // 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
   148
    NSArray *basicSettings = [[NSArray alloc] initWithContentsOfFile:BASICFLAGS_FILE()];
5181
102fef5ca5fc add getawaytime and tagteam mode to ios
koda
parents: 4976
diff changeset
   149
    NSMutableArray *basicArray  = [[NSMutableArray alloc] initWithCapacity:[basicSettings count]];
102fef5ca5fc add getawaytime and tagteam mode to ios
koda
parents: 4976
diff changeset
   150
    for (NSDictionary *basicDict in basicSettings)
102fef5ca5fc add getawaytime and tagteam mode to ios
koda
parents: 4976
diff changeset
   151
        [basicArray addObject:[basicDict objectForKey:@"default"]];
102fef5ca5fc add getawaytime and tagteam mode to ios
koda
parents: 4976
diff changeset
   152
    [basicSettings release];
4281
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   153
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
   154
    NSArray *mods = [[NSArray alloc] initWithContentsOfFile:GAMEMODS_FILE()];
5181
102fef5ca5fc add getawaytime and tagteam mode to ios
koda
parents: 4976
diff changeset
   155
    NSMutableArray *gamemodArray= [[NSMutableArray alloc] initWithCapacity:[mods count]];
102fef5ca5fc add getawaytime and tagteam mode to ios
koda
parents: 4976
diff changeset
   156
    for (int i = 0; i < [mods count]; i++)
102fef5ca5fc add getawaytime and tagteam mode to ios
koda
parents: 4976
diff changeset
   157
        [gamemodArray addObject:[NSNumber numberWithBool:NO]];
102fef5ca5fc add getawaytime and tagteam mode to ios
koda
parents: 4976
diff changeset
   158
    [mods release];
102fef5ca5fc add getawaytime and tagteam mode to ios
koda
parents: 4976
diff changeset
   159
102fef5ca5fc add getawaytime and tagteam mode to ios
koda
parents: 4976
diff changeset
   160
    // workaround for randomorder that has to be set to YES
102fef5ca5fc add getawaytime and tagteam mode to ios
koda
parents: 4976
diff changeset
   161
    [gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]];
102fef5ca5fc add getawaytime and tagteam mode to ios
koda
parents: 4976
diff changeset
   162
4281
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   163
    NSMutableDictionary *theScheme = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   164
                                      basicArray,@"basic",
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   165
                                      gamemodArray,@"gamemod",
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   166
                                      nil];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   167
    [gamemodArray release];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   168
    [basicArray release];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   169
    
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   170
    NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", schemesDirectory, nameWithoutExt];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   171
    
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   172
    [theScheme writeToFile:schemeFile atomically:YES];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   173
    [schemeFile release];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   174
    [theScheme release];
e033cf015b2c redo once again file updating, moving stuff around
koda
parents:
diff changeset
   175
}