cocoaTouch/otherSrc/CommodityFunctions.m
author palewolf
Sat, 17 Apr 2010 23:03:52 +0000
changeset 3355 dc9e61e67484
parent 3352 ac5d14a35482
child 3365 37ac593e9027
permissions -rw-r--r--
cWindSpeed recalculation assumed GetRandom returns a value between 0.0-1.0 while in fact is in the 0.0-0.5 range; Halve cMaxWindSpeed to compensate.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3325
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
     1
//
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
     2
//  CommodityFunctions.m
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
     3
//  HedgewarsMobile
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
     4
//
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
     5
//  Created by Vittorio on 08/04/10.
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
     7
//
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
     8
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
     9
#import "CommodityFunctions.h"
3335
2520ee7a5484 new manager for handling (future) rotations
koda
parents: 3330
diff changeset
    10
#import "SDL_uikitappdelegate.h"
3325
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    11
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    12
void createTeamNamed (NSString *nameWithoutExt) {
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    13
    NSString *teamsDirectory = TEAMS_DIRECTORY();
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    14
    
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    15
    if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) {
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    16
        [[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory 
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    17
                                  withIntermediateDirectories:NO 
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    18
                                                   attributes:nil 
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    19
                                                        error:NULL];
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    20
    }
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    21
    
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    22
    NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity: MAX_HOGS];
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    23
    
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    24
    for (int i = 0; i < MAX_HOGS; i++) {
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    25
        NSString *hogName = [[NSString alloc] initWithFormat:@"hedgehog %d",i];
3339
d558bc5a73c5 lots of untested stuff for the ifrontend
koda
parents: 3335
diff changeset
    26
	NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys:@"100",@"health", [NSNumber numberWithInt:0],@"level",
3325
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    27
                             hogName,@"hogname", @"NoHat",@"hat", nil];
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    28
        [hogName release];
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    29
        [hedgehogs addObject:hog];
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    30
        [hog release];
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    31
    }
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    32
    
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    33
    NSDictionary *theTeam = [[NSDictionary alloc] initWithObjectsAndKeys:@"0",@"hash", nameWithoutExt,@"teamname",
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    34
                             @"Statue",@"grave", @"Plane",@"fort", @"Default",@"voicepack",
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    35
                             @"hedgewars",@"flag", hedgehogs,@"hedgehogs", nil];
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    36
    [hedgehogs release];
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    37
    
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    38
    NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", teamsDirectory, nameWithoutExt];
3352
ac5d14a35482 complete previews on the team settings
koda
parents: 3340
diff changeset
    39
3325
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    40
    [theTeam writeToFile:teamFile atomically:YES];
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    41
    [teamFile release];
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    42
    [theTeam release];
652a8ebdf667 moved around team creation
koda
parents:
diff changeset
    43
}
3330
987ec27b6042 add support for modifying the name of the team
koda
parents: 3325
diff changeset
    44
3335
2520ee7a5484 new manager for handling (future) rotations
koda
parents: 3330
diff changeset
    45
BOOL rotationManager (UIInterfaceOrientation interfaceOrientation) {
2520ee7a5484 new manager for handling (future) rotations
koda
parents: 3330
diff changeset
    46
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
2520ee7a5484 new manager for handling (future) rotations
koda
parents: 3330
diff changeset
    47
        return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
2520ee7a5484 new manager for handling (future) rotations
koda
parents: 3330
diff changeset
    48
    else
2520ee7a5484 new manager for handling (future) rotations
koda
parents: 3330
diff changeset
    49
        return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
2520ee7a5484 new manager for handling (future) rotations
koda
parents: 3330
diff changeset
    50
2520ee7a5484 new manager for handling (future) rotations
koda
parents: 3330
diff changeset
    51
}