|
From: Geisschaes <gei...@us...> - 2005-01-24 20:21:49
|
Update of /cvsroot/macattrick/macattrick In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1323 Modified Files: LineUpController.m Player-Sorting.h Player-Sorting.m PlayerDetailsController.m Position.h Position.m PositionsController.m Log Message: new positions philosophy added Index: Position.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/Position.m,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Position.m 20 Jan 2005 20:46:01 -0000 1.6 --- Position.m 24 Jan 2005 20:18:29 -0000 1.7 *************** *** 29,35 **** --- 29,44 ---- #import "Position.h" + static NSDictionary* defaultPositionsDictionary; + static NSMutableDictionary *positionsDictionary; + + @interface Position (Private) + + (void) loadDefaultPositions; + + (void) loadPositions; + + @end @implementation Position + /* + (Position*) positionKeeper { return [[Position alloc] initWithIdentifier:@"Keeper" staminaRate:0 keeperRate:1 playmakingRate:0 scorerRate:0 *************** *** 115,127 **** passingRate:0.32 wingerRate:0 defenderRate:0 setPiecesRate:0]; } ! - (Position*) initWithIdentifier: (NSString*) newIdentifier staminaRate: (double) newStaminaRate keeperRate: (double) newKeeperRate playmakingRate: (double) newPlaymakingRate scorerRate: (double) newScorerRate passingRate: (double) newPassingRate wingerRate: (double) newWingerRate ! defenderRate: (double) newDefenderRate setPiecesRate: (double) newSetPiecesRate ! playerFormRate: (double) newPlayerFormRate experienceRate: (double) newExperienceRate { self = [super init]; identifier = [newIdentifier copy]; --- 124,157 ---- passingRate:0.32 wingerRate:0 defenderRate:0 setPiecesRate:0]; } + */ ! -(Position*) initFromUserDefaults: (NSString*) newIdentifier { ! NSArray *values = [[NSUserDefaults standardUserDefaults] arrayForKey:newIdentifier]; ! if(!values) { ! return nil; ! } ! else { ! self = [super init]; ! identifier = newIdentifier; ! playerFormRate = [[values objectAtIndex:0] doubleValue]; ! experienceRate = [[values objectAtIndex:1] doubleValue]; ! staminaRate = [[values objectAtIndex:2] doubleValue]; ! keeperRate = [[values objectAtIndex:3]doubleValue]; ! playmakingRate = [[values objectAtIndex:4] doubleValue]; ! passingRate = [[values objectAtIndex:5] doubleValue]; ! wingerRate = [[values objectAtIndex:6] doubleValue]; ! defenderRate = [[values objectAtIndex:7] doubleValue]; ! scorerRate = [[values objectAtIndex:8] doubleValue]; ! setPiecesRate = [[values objectAtIndex:9] doubleValue]; ! return self; ! } ! } - (Position*) initWithIdentifier: (NSString*) newIdentifier + playerFormRate: (double) newPlayerFormRate experienceRate: (double) newExperienceRate staminaRate: (double) newStaminaRate keeperRate: (double) newKeeperRate playmakingRate: (double) newPlaymakingRate scorerRate: (double) newScorerRate passingRate: (double) newPassingRate wingerRate: (double) newWingerRate ! defenderRate: (double) newDefenderRate setPiecesRate: (double) newSetPiecesRate { self = [super init]; identifier = [newIdentifier copy]; *************** *** 199,204 **** --- 229,254 ---- } + + -(void) saveToUserDefaults { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSArray *array = [NSArray arrayWithObjects: + [NSNumber numberWithDouble:playerFormRate], + [NSNumber numberWithDouble:experienceRate], + [NSNumber numberWithDouble:staminaRate], + [NSNumber numberWithDouble:keeperRate], + [NSNumber numberWithDouble:playmakingRate], + [NSNumber numberWithDouble:passingRate], + [NSNumber numberWithDouble:wingerRate], + [NSNumber numberWithDouble:defenderRate], + [NSNumber numberWithDouble:scorerRate], + [NSNumber numberWithDouble:setPiecesRate],nil]; + [[NSUserDefaults standardUserDefaults] setObject:array forKey:[self identifier]]; + [pool release]; + } + -(BOOL) isEqual:(id) anObject { return [identifier isEqualToString:[anObject identifier]] && + playerFormRate == [anObject playerFormRate] && + experienceRate == [anObject experienceRate] && staminaRate == [anObject staminaRate] && keeperRate == [anObject keeperRate] && *************** *** 211,238 **** } + (NSArray*) possiblePositions { NSArray *positions = [NSArray arrayWithObjects: ! [Position positionKeeper], ! [Position positionCentralDefender], ! [Position positionCentralDefenderTowardsWing], ! [Position positionCentralDefenderOffensive], ! [Position positionWingback], ! [Position positionWingbackOffensive], ! [Position positionWingbackDefensive], ! [Position positionWingbackTowardsMiddle], ! [Position positionInnerMidfield], ! [Position positionInnerMidfieldDefensive], ! [Position positionInnerMidfieldOffensive], ! [Position positionInnerMidfieldTowardsWing], ! [Position positionWinger], ! [Position positionWingerDefensive], ! [Position positionWingerOffensive], ! [Position positionWingerTowardsMiddle], ! [Position positionForward], ! [Position positionForwardDefensive], nil]; return positions; } - (void)dealloc { [identifier release]; --- 261,375 ---- } + + +(Position*) positionWithIdentifier: (NSString*) positionsIdentifier { + Position *pos = [positionsDictionary objectForKey:positionsIdentifier]; + if(!pos) { + pos= [Position defaultPositionWithIdentifier: positionsIdentifier]; + } + return pos; + } + + +(Position*) defaultPositionWithIdentifier: (NSString*) positionIdentifier { + return [defaultPositionsDictionary objectForKey: positionIdentifier]; + } + + (NSArray*) possiblePositions { NSArray *positions = [NSArray arrayWithObjects: ! [Position positionWithIdentifier:@"Keeper"], ! [Position positionWithIdentifier:@"Central Defender"], ! [Position positionWithIdentifier:@"Central Defender Towards Wing"], ! [Position positionWithIdentifier:@"Central Defender Offensive"], ! [Position positionWithIdentifier:@"Wingback"], ! [Position positionWithIdentifier:@"Wingback Offensive"], ! [Position positionWithIdentifier:@"Wingback Defensive"], ! [Position positionWithIdentifier:@"Wingback Towards Middle"], ! [Position positionWithIdentifier:@"Inner Midfield"], ! [Position positionWithIdentifier:@"Inner Midfield Defensive"], ! [Position positionWithIdentifier:@"Inner Midfield Offensive"], ! [Position positionWithIdentifier:@"Inner Midfield Towards Wing"], ! [Position positionWithIdentifier:@"Winger"], ! [Position positionWithIdentifier:@"Winger Defensive"], ! [Position positionWithIdentifier:@"Winger Offensive"], ! [Position positionWithIdentifier:@"Winger Towards Middle"], ! [Position positionWithIdentifier:@"Forward"], ! [Position positionWithIdentifier:@"Forward Defensive"], nil]; return positions; } + + (NSArray*) positionsIdentifiers { + return [NSArray arrayWithObjects:@"Keeper", + @"Central Defender",@"Central Defender Towards Wing",@"Central Defender Offensive", + @"Wingback",@"Wingback Towards Middle",@"Wingback Offensive",@"Wingback Defensive", + @"Inner Midfield",@"Inner Midfield Towards Wing",@"Inner Midfield Offensive" ,@"Inner Midfield Defensive", + @"Winger",@"Winger Towards Middle",@"Winger Offensive",@"Winger Defensive", + @"Forward",@"Forward Defensive",nil]; + + } + + (void) initialize { + [Position loadPositions]; + [Position loadDefaultPositions]; + } + + + + + (void) loadPositions { + positionsDictionary = [[NSMutableDictionary alloc]init]; + NSArray *keys = [Position positionsIdentifiers]; + NSEnumerator *en = [keys objectEnumerator]; + NSString *ident = nil; + while (ident = [en nextObject]) { + Position *pos = [[Position alloc] initFromUserDefaults: ident]; + if(pos) { + [positionsDictionary setValue:pos forKey:ident]; + [pos release]; + } + } + } + + + (void) loadDefaultPositions { + NSArray *keys = [Position positionsIdentifiers]; + NSArray *objects = [[NSArray alloc] initWithObjects: + [[Position alloc] initWithIdentifier:@"Keeper" staminaRate:0 keeperRate:1 playmakingRate:0 scorerRate:0 + passingRate:0 wingerRate:0 defenderRate:0 setPiecesRate:0], + [[Position alloc] initWithIdentifier:@"Central Defender" staminaRate:0.1 keeperRate:0 playmakingRate:0.02 scorerRate:0 + passingRate:0.15 wingerRate:0 defenderRate:0.75 setPiecesRate:0], + [[Position alloc] initWithIdentifier:@"Central Defender Towards Wing" staminaRate:0.1 keeperRate:0 playmakingRate:0 scorerRate:0 + passingRate:0.1 wingerRate:0.15 defenderRate:0.65 setPiecesRate:0], + [[Position alloc] initWithIdentifier:@"Central Defender Offensive" staminaRate:0.1 keeperRate:0 playmakingRate:0.1 scorerRate:0 + passingRate:0.2 wingerRate:0 defenderRate:0.6 setPiecesRate:0], + [[Position alloc] initWithIdentifier:@"Wingback" staminaRate:0.1 keeperRate:0 playmakingRate:0 scorerRate:0 + passingRate:0.1 wingerRate:0.2 defenderRate:0.6 setPiecesRate:0], + [[Position alloc] initWithIdentifier:@"Wingback Towards Middle" staminaRate:0.1 keeperRate:0 playmakingRate:0 scorerRate:0 + passingRate:0.08 wingerRate:0.17 defenderRate:0.65 setPiecesRate:0], + [[Position alloc] initWithIdentifier:@"Wingback Offensive" staminaRate:0.1 keeperRate:0 playmakingRate:0.1 scorerRate:0 + passingRate:0.2 wingerRate:0.25 defenderRate:0.35 setPiecesRate:0], + [[Position alloc] initWithIdentifier:@"Wingback Defensive" staminaRate:0.05 keeperRate:0 playmakingRate:0 scorerRate:0 + passingRate:0.05 wingerRate:0.1 defenderRate:0.8 setPiecesRate:0], + [[Position alloc] initWithIdentifier:@"Inner Midfield" staminaRate:0.25 keeperRate:0 playmakingRate:0.5 scorerRate:0 + passingRate:0.15 wingerRate:0 defenderRate:0.1 setPiecesRate:0], + [[Position alloc] initWithIdentifier:@"Inner Midfield Towards Wing" staminaRate:0.2 keeperRate:0 playmakingRate:0.35 scorerRate:0 + passingRate:0.15 wingerRate:0.2 defenderRate:0.1 setPiecesRate:0], + [[Position alloc] initWithIdentifier:@"Inner Midfield Offensive" staminaRate:0.2 keeperRate:0 playmakingRate:0.5 scorerRate:0 + passingRate:0.25 wingerRate:0 defenderRate:0.05 setPiecesRate:0], + [[Position alloc] initWithIdentifier:@"Inner Midfield Defensive" staminaRate:0.15 keeperRate:0 playmakingRate:0.5 scorerRate:0 + passingRate:0.15 wingerRate:0 defenderRate:0.2 setPiecesRate:0], + [[Position alloc] initWithIdentifier:@"Winger" staminaRate:0.15 keeperRate:0 playmakingRate:0.25 scorerRate:0 + passingRate:0.05 wingerRate:0.5 defenderRate:0.05 setPiecesRate:0], + [[Position alloc] initWithIdentifier:@"Winger Towards Middle" staminaRate:0.15 keeperRate:0 playmakingRate:0.3 scorerRate:0 + passingRate:0.1 wingerRate:0.35 defenderRate:0.1 setPiecesRate:0], + [[Position alloc] initWithIdentifier:@"Winger Offensive" staminaRate:0.15 keeperRate:0 playmakingRate:0.15 scorerRate:0 + passingRate:0.1 wingerRate:0.6 defenderRate:0 setPiecesRate:0], + [[Position alloc] initWithIdentifier:@"Winger Defensive" staminaRate:0.1 keeperRate:0 playmakingRate:0.2 scorerRate:0 + passingRate:0.1 wingerRate:0.35 defenderRate:0.25 setPiecesRate:0], + [[Position alloc] initWithIdentifier:@"Forward" staminaRate:0.1 keeperRate:0 playmakingRate:0 scorerRate:0.6 + passingRate:0.3 wingerRate:0 defenderRate:0 setPiecesRate:0], + [[Position alloc] initWithIdentifier:@"Forward Defensive" staminaRate:0.1 keeperRate:0 playmakingRate:0.13 scorerRate:0.45 + passingRate:0.32 wingerRate:0 defenderRate:0 setPiecesRate:0], + nil]; + defaultPositionsDictionary = [[NSDictionary alloc] initWithObjects:objects forKeys:keys]; + [objects release]; + } + - (void)dealloc { [identifier release]; Index: LineUpController.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/LineUpController.m,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** LineUpController.m 5 Dec 2004 21:50:44 -0000 1.16 --- LineUpController.m 24 Jan 2005 20:18:27 -0000 1.17 *************** *** 108,112 **** positions = [NSMutableArray arrayWithCapacity:11]; // keeper at index 0 ! [positions insertObject:[Position positionKeeper] atIndex:0]; // central defenders at index 1 and 2 [self loadCentralDefender]; --- 108,112 ---- positions = [NSMutableArray arrayWithCapacity:11]; // keeper at index 0 ! [positions insertObject:[Position positionWithIdentifier:@"Keeper"] atIndex:0]; // central defenders at index 1 and 2 [self loadCentralDefender]; *************** *** 123,131 **** - (NSArray*) substitutesPositions { NSMutableArray *subPositions = [NSMutableArray array]; ! [subPositions addObject: [Position positionKeeper]]; ! [subPositions addObject: [Position positionCentralDefender]]; ! [subPositions addObject: [Position positionInnerMidfield]]; ! [subPositions addObject: [Position positionWinger]]; ! [subPositions addObject: [Position positionForward]]; return subPositions; } --- 123,131 ---- - (NSArray*) substitutesPositions { NSMutableArray *subPositions = [NSMutableArray array]; ! [subPositions addObject: [Position positionWithIdentifier:@"Keeper"]]; ! [subPositions addObject: [Position positionWithIdentifier:@"Central Defender"]]; ! [subPositions addObject: [Position positionWithIdentifier:@"Inner Midfield"]]; ! [subPositions addObject: [Position positionWithIdentifier:@"Winger"]]; ! [subPositions addObject: [Position positionWithIdentifier:@"Forward"]]; return subPositions; } *************** *** 133,158 **** - (void) loadForward { if([[specForward1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionForward] atIndex:9]; } if([[specForward1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Defensive",@"Defensive")]) { ! [positions insertObject:[Position positionForwardDefensive] atIndex:9]; } if([[specForward1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Inner Midfield",@"Extra Inner Midfield")]) { ! [positions insertObject:[Position positionInnerMidfield] atIndex:9]; } if([[specForward1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Central Defender",@"Extra Central Defender")]) { ! [positions insertObject:[Position positionCentralDefender] atIndex:9]; } if([[specForward2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionForward] atIndex:10]; } if([[specForward2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Defensive",@"Defensive")]) { ! [positions insertObject:[Position positionForwardDefensive] atIndex:10]; } if([[specForward2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Inner Midfield",@"Extra Inner Midfield")]) { ! [positions insertObject:[Position positionInnerMidfield] atIndex:10]; } if([[specForward2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Central Defender",@"Extra Central Defender")]) { ! [positions insertObject:[Position positionCentralDefender] atIndex:10]; } } --- 133,158 ---- - (void) loadForward { if([[specForward1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Forward"] atIndex:9]; } if([[specForward1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Defensive",@"Defensive")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Forward Defensive"] atIndex:9]; } if([[specForward1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Inner Midfield",@"Extra Inner Midfield")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Inner Midfield"] atIndex:9]; } if([[specForward1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Central Defender",@"Extra Central Defender")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Central Defender"] atIndex:9]; } if([[specForward2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Forward"] atIndex:10]; } if([[specForward2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Defensive",@"Defensive")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Forward Defensive"] atIndex:10]; } if([[specForward2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Inner Midfield",@"Extra Inner Midfield")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Inner Midfield"] atIndex:10]; } if([[specForward2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Central Defender",@"Extra Central Defender")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Central Defender"] atIndex:10]; } } *************** *** 160,235 **** - (void) loadWinger { if([[specRightWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionWinger] atIndex:7]; } if([[specRightWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Offensive",@"Offensive")]) { ! [positions insertObject:[Position positionWingerOffensive] atIndex:7]; } if([[specRightWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Defensive",@"Defensive")]) { ! [positions insertObject:[Position positionWingerDefensive] atIndex:7]; } if([[specRightWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Towards Middle",@"Towards Middle")]) { ! [positions insertObject:[Position positionWingerTowardsMiddle] atIndex:7]; } if([[specRightWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Forward",@"Extra Forward")]) { ! [positions insertObject:[Position positionForward] atIndex:7]; } if([[specRightWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Central Defender",@"Extra Central Defender")]) { ! [positions insertObject:[Position positionCentralDefender] atIndex:7]; } if([[specLeftWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionWinger] atIndex:8]; } if([[specLeftWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Offensive",@"Offensive")]) { ! [positions insertObject:[Position positionWingerOffensive] atIndex:8]; } if([[specLeftWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Defensive",@"Defensive")]) { ! [positions insertObject:[Position positionWingerDefensive] atIndex:8]; } if([[specLeftWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Towards Middle",@"Towards Middle")]) { ! [positions insertObject:[Position positionWingerTowardsMiddle] atIndex:8]; } if([[specLeftWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Forward",@"Extra Forward")]) { ! [positions insertObject:[Position positionForward] atIndex:8]; } if([[specLeftWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Central Defender",@"Extra Central Defender")]) { ! [positions insertObject:[Position positionCentralDefender] atIndex:8]; } } - (void) loadInnerMidfield { if([[specInnerMidfield1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionInnerMidfield] atIndex:5]; } if([[specInnerMidfield1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Offensive",@"Offensive")]) { ! [positions insertObject:[Position positionInnerMidfieldOffensive] atIndex:5]; } if([[specInnerMidfield1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Defensive",@"Defensive")]) { ! [positions insertObject:[Position positionInnerMidfieldDefensive] atIndex:5]; } if([[specInnerMidfield1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Towards Wing",@"Towards Wing")]) { ! [positions insertObject:[Position positionInnerMidfieldTowardsWing] atIndex:5]; } if([[specInnerMidfield1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Forward",@"Extra Forward")]) { ! [positions insertObject:[Position positionForward] atIndex:5]; } if([[specInnerMidfield1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Central Defender",@"Extra Central Defender")]) { ! [positions insertObject:[Position positionCentralDefender] atIndex:5]; } if([[specInnerMidfield2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionInnerMidfield] atIndex:6]; } if([[specInnerMidfield2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Offensive",@"Offensive")]) { ! [positions insertObject:[Position positionInnerMidfieldOffensive] atIndex:6]; } if([[specInnerMidfield2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Defensive",@"Defensive")]) { ! [positions insertObject:[Position positionInnerMidfieldDefensive] atIndex:6]; } if([[specInnerMidfield2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Towards Wing",@"Towards Wing")]) { ! [positions insertObject:[Position positionInnerMidfieldTowardsWing] atIndex:6]; } if([[specInnerMidfield2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Forward",@"Extra Forward")]) { ! [positions insertObject:[Position positionForward] atIndex:6]; } if([[specInnerMidfield2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Central Defender",@"Extra Central Defender")]) { ! [positions insertObject:[Position positionCentralDefender] atIndex:6]; } } --- 160,235 ---- - (void) loadWinger { if([[specRightWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Winger"] atIndex:7]; } if([[specRightWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Offensive",@"Offensive")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Winger Offensive"] atIndex:7]; } if([[specRightWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Defensive",@"Defensive")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Winger Defensive"] atIndex:7]; } if([[specRightWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Towards Middle",@"Towards Middle")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Winger Towards Middle"] atIndex:7]; } if([[specRightWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Forward",@"Extra Forward")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Forward"] atIndex:7]; } if([[specRightWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Central Defender",@"Extra Central Defender")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Central Defender"] atIndex:7]; } if([[specLeftWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Winger"] atIndex:8]; } if([[specLeftWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Offensive",@"Offensive")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Winger Offensive"] atIndex:8]; } if([[specLeftWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Defensive",@"Defensive")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Winger Defensive"] atIndex:8]; } if([[specLeftWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Towards Middle",@"Towards Middle")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Winger Towards Middle"] atIndex:8]; } if([[specLeftWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Forward",@"Extra Forward")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Forward"] atIndex:8]; } if([[specLeftWinger titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Central Defender",@"Extra Central Defender")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Central Defender"] atIndex:8]; } } - (void) loadInnerMidfield { if([[specInnerMidfield1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Inner Midfield"] atIndex:5]; } if([[specInnerMidfield1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Offensive",@"Offensive")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Inner Midfield Offensive"] atIndex:5]; } if([[specInnerMidfield1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Defensive",@"Defensive")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Inner Midfield Defensive"] atIndex:5]; } if([[specInnerMidfield1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Towards Wing",@"Towards Wing")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Inner Midfield Towards Wing"] atIndex:5]; } if([[specInnerMidfield1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Forward",@"Extra Forward")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Forward"] atIndex:5]; } if([[specInnerMidfield1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Central Defender",@"Extra Central Defender")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Central Defender"] atIndex:5]; } if([[specInnerMidfield2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Inner Midfield"] atIndex:6]; } if([[specInnerMidfield2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Offensive",@"Offensive")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Inner Midfield Offensive"] atIndex:6]; } if([[specInnerMidfield2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Defensive",@"Defensive")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Inner Midfield Defensive"] atIndex:6]; } if([[specInnerMidfield2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Towards Wing",@"Towards Wing")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Inner Midfield Towards Wing"] atIndex:6]; } if([[specInnerMidfield2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Forward",@"Extra Forward")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Forward"] atIndex:6]; } if([[specInnerMidfield2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Central Defender",@"Extra Central Defender")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Central Defender"] atIndex:6]; } } *************** *** 238,275 **** - (void) loadBackWings { if([[specRightBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionWingback] atIndex:3]; } if([[specRightBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Offensive",@"Offensive")]) { ! [positions insertObject:[Position positionWingbackOffensive] atIndex:3]; } if([[specRightBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Defensive",@"Defensive")]) { ! [positions insertObject:[Position positionWingbackDefensive] atIndex:3]; } if([[specRightBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Towards Middle",@"Towards Middle")]) { ! [positions insertObject:[Position positionWingbackTowardsMiddle] atIndex:3]; } if([[specRightBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Forward",@"Extra Forward")]) { ! [positions insertObject:[Position positionForward] atIndex:3]; } if([[specRightBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Inner Midfield",@"Extra Inner Midfield")]) { ! [positions insertObject:[Position positionInnerMidfield] atIndex:3]; } if([[specLeftBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionWingback] atIndex:4]; } if([[specLeftBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Offensive",@"Offensive")]) { ! [positions insertObject:[Position positionWingbackOffensive] atIndex:4]; } if([[specLeftBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Defensive",@"Defensive")]) { ! [positions insertObject:[Position positionWingbackDefensive] atIndex:4]; } if([[specLeftBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Towards Middle",@"Towards Middle")]) { ! [positions insertObject:[Position positionWingbackTowardsMiddle] atIndex:4]; } if([[specLeftBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Forward",@"Extra Forward")]) { ! [positions insertObject:[Position positionForward] atIndex:4]; } if([[specLeftBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Inner Midfield",@"Extra Inner Midfield")]) { ! [positions insertObject:[Position positionInnerMidfield] atIndex:4]; } } --- 238,275 ---- - (void) loadBackWings { if([[specRightBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Wingback"] atIndex:3]; } if([[specRightBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Offensive",@"Offensive")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Wingback Offensive"] atIndex:3]; } if([[specRightBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Defensive",@"Defensive")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Wingback Defensive"] atIndex:3]; } if([[specRightBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Towards Middle",@"Towards Middle")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Wingback Towards Middle"] atIndex:3]; } if([[specRightBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Forward",@"Extra Forward")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Forward"] atIndex:3]; } if([[specRightBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Inner Midfield",@"Extra Inner Midfield")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Inner Midfield"] atIndex:3]; } if([[specLeftBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Wingback"] atIndex:4]; } if([[specLeftBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Offensive",@"Offensive")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Wingback Offensive"] atIndex:4]; } if([[specLeftBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Defensive",@"Defensive")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Wingback Defensive"] atIndex:4]; } if([[specLeftBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Towards Middle",@"Towards Middle")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Wingback Towards Middle"] atIndex:4]; } if([[specLeftBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Forward",@"Extra Forward")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Forward"] atIndex:4]; } if([[specLeftBack titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Inner Midfield",@"Extra Inner Midfield")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Inner Midfield"] atIndex:4]; } } *************** *** 277,308 **** - (void) loadCentralDefender { if([[specCentralDefender1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionCentralDefender] atIndex:1]; } if([[specCentralDefender1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Offensive",@"Offensive")]) { ! [positions insertObject:[Position positionCentralDefenderOffensive] atIndex:1]; } if([[specCentralDefender1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Towards Wing",@"Towards Wing")]) { ! [positions insertObject:[Position positionCentralDefenderTowardsWing] atIndex:1]; } if([[specCentralDefender1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Forward",@"Extra Forward")]) { ! [positions insertObject:[Position positionForward] atIndex:1]; } if([[specCentralDefender1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Inner Midfield",@"Extra Inner Midfield")]) { ! [positions insertObject:[Position positionInnerMidfield] atIndex:1]; } if([[specCentralDefender2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionCentralDefender] atIndex:2]; } if([[specCentralDefender2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Offensive",@"Offensive")]) { ! [positions insertObject:[Position positionCentralDefenderOffensive] atIndex:2]; } if([[specCentralDefender2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Towards Wing",@"Towards Wing")]) { ! [positions insertObject:[Position positionCentralDefenderTowardsWing] atIndex:2]; } if([[specCentralDefender2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Forward",@"Extra Forward")]) { ! [positions insertObject:[Position positionForward] atIndex:2]; } if([[specCentralDefender2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Inner Midfield",@"Extra Inner Midfield")]) { ! [positions insertObject:[Position positionInnerMidfield] atIndex:2]; } } --- 277,308 ---- - (void) loadCentralDefender { if([[specCentralDefender1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Central Defender"] atIndex:1]; } if([[specCentralDefender1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Offensive",@"Offensive")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Central Defender Offensive"] atIndex:1]; } if([[specCentralDefender1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Towards Wing",@"Towards Wing")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Central Defender Towards Wing"] atIndex:1]; } if([[specCentralDefender1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Forward",@"Extra Forward")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Forward"] atIndex:1]; } if([[specCentralDefender1 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Inner Midfield",@"Extra Inner Midfield")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Inner Midfield"] atIndex:1]; } if([[specCentralDefender2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Normal",@"Normal")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Central Defender"] atIndex:2]; } if([[specCentralDefender2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Offensive",@"Offensive")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Central Defender Offensive"] atIndex:2]; } if([[specCentralDefender2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Towards Wing",@"Towards Wing")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Central Defender Towards Wing"] atIndex:2]; } if([[specCentralDefender2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Forward",@"Extra Forward")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Forward"] atIndex:2]; } if([[specCentralDefender2 titleOfSelectedItem] isEqualToString: NSLocalizedString(@"Extra Inner Midfield",@"Extra Inner Midfield")]) { ! [positions insertObject:[Position positionWithIdentifier:@"Inner Midfield"] atIndex:2]; } } Index: Player-Sorting.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/Player-Sorting.m,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Player-Sorting.m 10 Jan 2005 21:43:45 -0000 1.5 --- Player-Sorting.m 24 Jan 2005 20:18:29 -0000 1.6 *************** *** 37,40 **** --- 37,41 ---- } + /* -(NSComparisonResult) staminaSkillComparison: (Player*) otherPlayer { int result =[self intComparison: otherPlayer identifier: @"staminaSkill"]; *************** *** 65,73 **** return result; } -(NSComparisonResult) setPiecesSkillComparison: (Player*) otherPlayer{ int result =[self intComparison: otherPlayer identifier: @"setPiecesSkill"]; return result; } ! -(NSComparisonResult) injuryLevelComparison: (Player*) otherPlayer{ int result =[self intComparison: otherPlayer identifier: @"injuryLevel"]; --- 66,75 ---- return result; } + */ -(NSComparisonResult) setPiecesSkillComparison: (Player*) otherPlayer{ int result =[self intComparison: otherPlayer identifier: @"setPiecesSkill"]; return result; } ! /* -(NSComparisonResult) injuryLevelComparison: (Player*) otherPlayer{ int result =[self intComparison: otherPlayer identifier: @"injuryLevel"]; *************** *** 90,94 **** } ! -(NSComparisonResult) intComparison: (Player*) otherPlayer identifier: (NSString*) identifier { --- 92,96 ---- } ! */ -(NSComparisonResult) intComparison: (Player*) otherPlayer identifier: (NSString*) identifier { *************** *** 111,114 **** --- 113,117 ---- + /* -(NSComparisonResult) positionKeeperComparison: (Player*) otherPlayer { int result = [self compareDouble: [self calculatePositionValue: [Position positionKeeper]] *************** *** 201,204 **** --- 204,208 ---- return result; } + */ -(int) compareDouble: (double) myValue otherDouble: (double) otherValue { *************** *** 209,211 **** --- 213,216 ---- else NSOrderedSame; } + @end Index: Position.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/Position.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Position.h 20 Jan 2005 20:46:01 -0000 1.5 --- Position.h 24 Jan 2005 20:18:29 -0000 1.6 *************** *** 32,35 **** --- 32,37 ---- @interface Position : NSObject { NSString *identifier; + double playerFormRate; + double experienceRate; double staminaRate; double keeperRate; *************** *** 40,47 **** double scorerRate; double setPiecesRate; ! double playerFormRate; ! double experienceRate; } - (Position*) initWithIdentifier: (NSString*) newIdentifier staminaRate: (double) newStaminaRate keeperRate: (double) newKeeperRate --- 42,54 ---- double scorerRate; double setPiecesRate; ! } + /*! + @method initFromUserDefaults: newIdentifier + @abstract init a Position from the user defaults. Returns nil if no values are found in the user defaults + */ + -(Position*) initFromUserDefaults: (NSString*) newIdentifier; + - (Position*) initWithIdentifier: (NSString*) newIdentifier staminaRate: (double) newStaminaRate keeperRate: (double) newKeeperRate *************** *** 51,60 **** - (Position*) initWithIdentifier: (NSString*) newIdentifier ! staminaRate: (double) newStaminaRate keeperRate: (double) newKeeperRate playmakingRate: (double) newPlaymakingRate scorerRate: (double) newScorerRate passingRate: (double) newPassingRate wingerRate: (double) newWingerRate ! defenderRate: (double) newDefenderRate setPiecesRate: (double) newSetPiecesRate ! playerFormRate: (double) newPlayerFormRate experienceRate: (double) newExperienceRate; ! - (NSString *)identifier; --- 58,67 ---- - (Position*) initWithIdentifier: (NSString*) newIdentifier ! playerFormRate: (double) newPlayerFormRate experienceRate: (double) newExperienceRate ! staminaRate: (double) newStaminaRate keeperRate: (double) newKeeperRate playmakingRate: (double) newPlaymakingRate scorerRate: (double) newScorerRate passingRate: (double) newPassingRate wingerRate: (double) newWingerRate ! defenderRate: (double) newDefenderRate setPiecesRate: (double) newSetPiecesRate; ! - (NSString *)identifier; *************** *** 72,75 **** --- 79,89 ---- -(BOOL) isEqual:(id) anObject; + -(void) saveToUserDefaults; + + +(Position*) positionWithIdentifier: (NSString*) positionsIdentifier; + +(Position*) defaultPositionWithIdentifier: (NSString*) positionIdentifier; + + (NSArray*) positionsIdentifiers; + + /* + (Position*) positionKeeper; + (Position*) positionCentralDefender; *************** *** 91,95 **** + (Position*) positionForwardDefensive; + (NSArray*) possiblePositions; ! --- 105,109 ---- + (Position*) positionForwardDefensive; + (NSArray*) possiblePositions; ! */ Index: Player-Sorting.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/Player-Sorting.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Player-Sorting.h 4 Jun 2004 08:22:10 -0000 1.3 --- Player-Sorting.h 24 Jan 2005 20:18:28 -0000 1.4 *************** *** 31,35 **** --- 31,38 ---- @interface Player(Sorting) + -(NSComparisonResult) playerNameComparison: (Player*) otherPlayer; + + /* -(NSComparisonResult) staminaSkillComparison: (Player*) otherPlayer; -(NSComparisonResult) keeperSkillComparison: (Player*) otherPlayer; *************** *** 39,47 **** -(NSComparisonResult) wingerSkillComparison: (Player*) otherPlayer; -(NSComparisonResult) defenderSkillComparison: (Player*) otherPlayer; -(NSComparisonResult) setPiecesSkillComparison: (Player*) otherPlayer; ! -(NSComparisonResult) injuryLevelComparison: (Player*) otherPlayer; -(NSComparisonResult) ageComparison: (Player*) otherPlayer; -(NSComparisonResult) teamCaptainComparison: (Player*) otherPlayer; ! -(NSComparisonResult) positionKeeperComparison: (Player*) otherPlayer; -(NSComparisonResult) positionCentralDefenderComparison: (Player*) otherPlayer; -(NSComparisonResult) positionCentralDefenderOffensiveComparison: (Player*) otherPlayer; --- 42,55 ---- -(NSComparisonResult) wingerSkillComparison: (Player*) otherPlayer; -(NSComparisonResult) defenderSkillComparison: (Player*) otherPlayer; + */ -(NSComparisonResult) setPiecesSkillComparison: (Player*) otherPlayer; ! /*-(NSComparisonResult) injuryLevelComparison: (Player*) otherPlayer; -(NSComparisonResult) ageComparison: (Player*) otherPlayer; + */ -(NSComparisonResult) teamCaptainComparison: (Player*) otherPlayer; ! ! static int comparePosition(id player1, id player2, void *positionIdentifier); ! ! /*-(NSComparisonResult) positionKeeperComparison: (Player*) otherPlayer; -(NSComparisonResult) positionCentralDefenderComparison: (Player*) otherPlayer; -(NSComparisonResult) positionCentralDefenderOffensiveComparison: (Player*) otherPlayer; *************** *** 61,65 **** -(NSComparisonResult) positionForwardComparison: (Player*) otherPlayer; -(NSComparisonResult) positionForwardDefensiveComparison: (Player*) otherPlayer; ! --- 69,73 ---- -(NSComparisonResult) positionForwardComparison: (Player*) otherPlayer; -(NSComparisonResult) positionForwardDefensiveComparison: (Player*) otherPlayer; ! */ Index: PlayerDetailsController.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerDetailsController.m,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PlayerDetailsController.m 18 Jan 2005 21:05:46 -0000 1.6 --- PlayerDetailsController.m 24 Jan 2005 20:18:29 -0000 1.7 *************** *** 102,107 **** - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex{ ! SEL selector = NSSelectorFromString([NSString stringWithFormat:@"position%s",[[aTableColumn identifier] cString]]); ! id position = [Position performSelector: selector]; return [NSNumber numberWithDouble: [tryPlayer calculatePositionValue:position]]; } --- 102,109 ---- - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex{ ! SEL selector =@selector(positionWithIdentifier:); ! id position = [Position performSelector:selector withObject:[aTableColumn identifier] ]; ! //SEL selector = NSSelectorFromString([NSString stringWithFormat:@"position%s",[[aTableColumn identifier] cString]]); ! //id position = [Position performSelector: selector]; return [NSNumber numberWithDouble: [tryPlayer calculatePositionValue:position]]; } Index: PositionsController.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/PositionsController.m,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PositionsController.m 18 Jan 2005 19:37:28 -0000 1.6 --- PositionsController.m 24 Jan 2005 20:18:30 -0000 1.7 *************** *** 29,32 **** --- 29,33 ---- #import "PositionsController.h" #import "MainController.h" + #import "Position.h" @implementation PositionsController *************** *** 63,68 **** } else { ! SEL selector = NSSelectorFromString([NSString stringWithFormat:@"position%s",[[aTableColumn identifier] cString]]); ! id position = [Position performSelector: selector]; return [NSNumber numberWithDouble: [player calculatePositionValue:position]]; } --- 64,70 ---- } else { ! // SEL selector = NSSelectorFromString([NSString stringWithFormat:@"position%s",[[aTableColumn identifier] cString]]); ! SEL selector =@selector(positionWithIdentifier:); ! id position = [Position performSelector:selector withObject:[aTableColumn identifier] ]; return [NSNumber numberWithDouble: [player calculatePositionValue:position]]; } *************** *** 92,101 **** if([[tableColumn identifier] isEqualToString:@"playerName"]) { columnSortSelector = NSSelectorFromString(@"playerNameComparison:"); } else { ! columnSortSelector = NSSelectorFromString([NSString ! stringWithFormat: @"position%@Comparison:",[tableColumn identifier]]); } ! [[team playerList] sortUsingSelector: columnSortSelector]; } [tableView setIndicatorImage: (sortDescending ? --- 94,106 ---- if([[tableColumn identifier] isEqualToString:@"playerName"]) { columnSortSelector = NSSelectorFromString(@"playerNameComparison:"); + [[team playerList] sortUsingSelector: columnSortSelector]; } else { ! [[[team playerList] playerList] sortUsingFunction: comparePosition context:[tableColumn identifier]]; ! // columnSortSelector = NSSelectorFromString([NSString ! // stringWithFormat: @"position%@Comparison:",[tableColumn identifier]]); ! } ! } [tableView setIndicatorImage: (sortDescending ? *************** *** 106,109 **** --- 111,121 ---- } + static int comparePosition(id player1, id player2, void *positionIdentifier){ + NSString *positionID = positionIdentifier; + int result = [player1 compareDouble: [player1 calculatePositionValue: [Position positionWithIdentifier:positionID]] + otherDouble: [player2 calculatePositionValue: [Position positionWithIdentifier:positionID]]]; + return result; + } + -(Player*) selectedPlayer { int selected = [positionsTable selectedRow]; |