project_files/HedgewarsMobile/Classes/CreationChamber.m
changeset 5200 7440fe992e73
parent 5185 7607a64e1853
child 5206 db775bddf771
equal deleted inserted replaced
5199:5eae5da831e1 5200:7440fe992e73
    18  * File created on 12/11/2010.
    18  * File created on 12/11/2010.
    19  */
    19  */
    20 
    20 
    21 
    21 
    22 #import "CreationChamber.h"
    22 #import "CreationChamber.h"
       
    23 #import "hwconsts.h"
       
    24 
    23 
    25 
    24 void createTeamNamed (NSString *nameWithoutExt) {
    26 void createTeamNamed (NSString *nameWithoutExt) {
    25     NSString *teamsDirectory = TEAMS_DIRECTORY();
    27     NSString *teamsDirectory = TEAMS_DIRECTORY();
    26 
    28 
    27     if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) {
    29     if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) {
    70                                   withIntermediateDirectories:NO
    72                                   withIntermediateDirectories:NO
    71                                                    attributes:nil
    73                                                    attributes:nil
    72                                                         error:NULL];
    74                                                         error:NULL];
    73     }
    75     }
    74 
    76 
    75     NSDictionary *theWeapon = nil;
    77     NSInteger ammolineSize = HW_getNumberOfWeapons();
       
    78     NSString *qt, *prob, *delay, *crate;
    76     switch (type) {
    79     switch (type) {
    77         default: //default
    80         default: //default
    78             theWeapon = [[NSDictionary alloc] initWithObjects:
    81             qt = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_QT length:ammolineSize encoding:NSUTF8StringEncoding];
    79                          [NSArray arrayWithObjects:
    82             prob = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_QT length:ammolineSize encoding:NSUTF8StringEncoding];
    80                           @"93919294221991210322351110012010000002111101010111200",
    83             delay = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_QT length:ammolineSize encoding:NSUTF8StringEncoding];
    81                           @"04050405416006555465544647765766666661555101011154100",
    84             crate = [[NSString alloc] initWithBytes:AMMOLINE_DEFAULT_QT length:ammolineSize encoding:NSUTF8StringEncoding];
    82                           @"00000000000002055000000400070040000000002000000006000",
       
    83                           @"13111103121111111231141111111111111112111111011111200",
       
    84                           nil]
       
    85                                                       forKeys: [NSArray arrayWithObjects:
       
    86                                                                 @"ammostore_initialqt",
       
    87                                                                 @"ammostore_probability",
       
    88                                                                 @"ammostore_delay",
       
    89                                                                 @"ammostore_crate", nil]];
       
    90             break;
    85             break;
    91         case 1: //crazy
    86         case 1: //crazy
    92             theWeapon = [[NSDictionary alloc] initWithObjects:
    87             qt = [[NSString alloc] initWithBytes:AMMOLINE_CRAZY_QT length:ammolineSize encoding:NSUTF8StringEncoding];
    93                          [NSArray arrayWithObjects:
    88             prob = [[NSString alloc] initWithBytes:AMMOLINE_CRAZY_PROB length:ammolineSize encoding:NSUTF8StringEncoding];
    94                           @"99999999999999999929999999999999992999999999099999900",
    89             delay = [[NSString alloc] initWithBytes:AMMOLINE_CRAZY_DELAY length:ammolineSize encoding:NSUTF8StringEncoding];
    95                           @"11111101111111111111111111111111111111111111011111100",
    90             crate = [[NSString alloc] initWithBytes:AMMOLINE_CRAZY_CRATE length:ammolineSize encoding:NSUTF8StringEncoding];
    96                           @"00000000000000000000000000000000000000000000000000000",
       
    97                           @"13111103121111111231141111111111111112111101011111100",
       
    98                           nil]
       
    99                                                       forKeys: [NSArray arrayWithObjects:
       
   100                                                                 @"ammostore_initialqt",
       
   101                                                                 @"ammostore_probability",
       
   102                                                                 @"ammostore_delay",
       
   103                                                                 @"ammostore_crate", nil]];
       
   104             break;
    91             break;
   105         case 2: //pro mode
    92         case 2: //pro mode
   106             theWeapon = [[NSDictionary alloc] initWithObjects:
    93             qt = [[NSString alloc] initWithBytes:AMMOLINE_PROMODE_QT length:ammolineSize encoding:NSUTF8StringEncoding];
   107                          [NSArray arrayWithObjects:
    94             prob = [[NSString alloc] initWithBytes:AMMOLINE_PROMODE_PROB length:ammolineSize encoding:NSUTF8StringEncoding];
   108                           @"90900090000000000000090000000000000000000000000000000",
    95             delay = [[NSString alloc] initWithBytes:AMMOLINE_PROMODE_DELAY length:ammolineSize encoding:NSUTF8StringEncoding];
   109                           @"00000000000000000000000000000000000000000000000000000",
    96             crate = [[NSString alloc] initWithBytes:AMMOLINE_PROMODE_CRATE length:ammolineSize encoding:NSUTF8StringEncoding];
   110                           @"00000000000002055000000400070040000000002000000000000",
       
   111                           @"11111111111111111111111111111111111111111001011111100",
       
   112                           nil]
       
   113                                                       forKeys: [NSArray arrayWithObjects:
       
   114                                                                 @"ammostore_initialqt",
       
   115                                                                 @"ammostore_probability",
       
   116                                                                 @"ammostore_delay",
       
   117                                                                 @"ammostore_crate", nil]];
       
   118             break;
    97             break;
   119         case 3: //shoppa
    98         case 3: //shoppa
   120             theWeapon = [[NSDictionary alloc] initWithObjects:
    99             qt = [[NSString alloc] initWithBytes:AMMOLINE_SHOPPA_QT length:ammolineSize encoding:NSUTF8StringEncoding];
   121                          [NSArray arrayWithObjects:
   100             prob = [[NSString alloc] initWithBytes:AMMOLINE_SHOPPA_PROB length:ammolineSize encoding:NSUTF8StringEncoding];
   122                           @"00000099000000000000000000000000000000000000000000000",
   101             delay = [[NSString alloc] initWithBytes:AMMOLINE_SHOPPA_DELAY length:ammolineSize encoding:NSUTF8StringEncoding];
   123                           @"44444100442444022101121212224220000000020004000100100",
   102             crate = [[NSString alloc] initWithBytes:AMMOLINE_SHOPPA_CRATE length:ammolineSize encoding:NSUTF8StringEncoding];
   124                           @"00000000000000000000000000000000000000000000000000000",
       
   125                           @"11111111111111111111111111111111111111111011011111100",
       
   126                           nil]
       
   127                                                       forKeys: [NSArray arrayWithObjects:
       
   128                                                                 @"ammostore_initialqt",
       
   129                                                                 @"ammostore_probability",
       
   130                                                                 @"ammostore_delay",
       
   131                                                                 @"ammostore_crate", nil]];
       
   132             break;
   103             break;
   133         case 4: //clean slate
   104         case 4: //clean slate
   134             theWeapon = [[NSDictionary alloc] initWithObjects:
   105             qt = [[NSString alloc] initWithBytes:AMMOLINE_CLEAN_QT length:ammolineSize encoding:NSUTF8StringEncoding];
   135                          [NSArray arrayWithObjects:
   106             prob = [[NSString alloc] initWithBytes:AMMOLINE_CLEAN_PROB length:ammolineSize encoding:NSUTF8StringEncoding];
   136                           @"10100090000100000110000000000000000000000000000010000",
   107             delay = [[NSString alloc] initWithBytes:AMMOLINE_CLEAN_DELAY length:ammolineSize encoding:NSUTF8StringEncoding];
   137                           @"04050405416006555465544647765766666661555101011154100",
   108             crate = [[NSString alloc] initWithBytes:AMMOLINE_CLEAN_CRATE length:ammolineSize encoding:NSUTF8StringEncoding];
   138                           @"00000000000000000000000000000000000000000000000000000",
       
   139                           @"13111103121111111231141111111111111112111111011111100",
       
   140                           nil]
       
   141                                                       forKeys: [NSArray arrayWithObjects:
       
   142                                                                 @"ammostore_initialqt",
       
   143                                                                 @"ammostore_probability",
       
   144                                                                 @"ammostore_delay",
       
   145                                                                 @"ammostore_crate", nil]];
       
   146             break;
   109             break;
   147         case 5: //minefield
   110         case 5: //minefield
   148             theWeapon = [[NSDictionary alloc] initWithObjects:
   111             qt = [[NSString alloc] initWithBytes:AMMOLINE_MINES_QT length:ammolineSize encoding:NSUTF8StringEncoding];
   149                          [NSArray arrayWithObjects:
   112             prob = [[NSString alloc] initWithBytes:AMMOLINE_MINES_PROB length:ammolineSize encoding:NSUTF8StringEncoding];
   150                           @"00000099000900000003000000000000000000000000000000000",
   113             delay = [[NSString alloc] initWithBytes:AMMOLINE_MINES_DELAY length:ammolineSize encoding:NSUTF8StringEncoding];
   151                           @"00000000000000000000000000000000000000000000000000000",
   114             crate = [[NSString alloc] initWithBytes:AMMOLINE_MINES_CRATE length:ammolineSize encoding:NSUTF8StringEncoding];
   152                           @"00000000000002055000000400070040000000002000000006000",
       
   153                           @"11111111111111111111111111111111111111111111011111100",
       
   154                           nil]
       
   155                                                       forKeys: [NSArray arrayWithObjects:
       
   156                                                                 @"ammostore_initialqt",
       
   157                                                                 @"ammostore_probability",
       
   158                                                                 @"ammostore_delay",
       
   159                                                                 @"ammostore_crate", nil]];
       
   160             break;
   115             break;
   161         case 6: //thinking with portals
   116         case 6: //thinking with portals
   162             theWeapon = [[NSDictionary alloc] initWithObjects:
   117             qt = [[NSString alloc] initWithBytes:AMMOLINE_PORTALS_QT length:ammolineSize encoding:NSUTF8StringEncoding];
   163                          [NSArray arrayWithObjects:
   118             prob = [[NSString alloc] initWithBytes:AMMOLINE_PORTALS_PROB length:ammolineSize encoding:NSUTF8StringEncoding];
   164                           @"90000090020000000021000000000000001100000900000000000",
   119             delay = [[NSString alloc] initWithBytes:AMMOLINE_PORTALS_DELAY length:ammolineSize encoding:NSUTF8StringEncoding];
   165                           @"04050405416006555465544647765766666661555101011154100",
   120             crate = [[NSString alloc] initWithBytes:AMMOLINE_PORTALS_CRATE length:ammolineSize encoding:NSUTF8StringEncoding];
   166                           @"00000000000002055000000400070040000000002000000006000",
       
   167                           @"13111103121111111231141111111111111112111111011111100",
       
   168                           nil]
       
   169                                                       forKeys: [NSArray arrayWithObjects:
       
   170                                                                 @"ammostore_initialqt",
       
   171                                                                 @"ammostore_probability",
       
   172                                                                 @"ammostore_delay",
       
   173                                                                 @"ammostore_crate", nil]];
       
   174             break;
   121             break;
   175     }
   122     }
   176 
   123 
       
   124     NSDictionary *theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: qt,@"ammostore_initialqt",
       
   125                                prob,@"ammostore_probability", delay,@"ammostore_delay", crate,@"ammostore_crate", nil];
       
   126     [qt release];
       
   127     [prob release];
       
   128     [delay release];
       
   129     [crate release];
       
   130 
   177     NSString *weaponFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", weaponsDirectory, nameWithoutExt];
   131     NSString *weaponFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", weaponsDirectory, nameWithoutExt];
   178 
       
   179     [theWeapon writeToFile:weaponFile atomically:YES];
   132     [theWeapon writeToFile:weaponFile atomically:YES];
   180     [weaponFile release];
   133     [weaponFile release];
   181     [theWeapon release];
   134     [theWeapon release];
   182 }
   135 }
   183 
   136