|
From: Geisschaes <gei...@us...> - 2005-04-25 20:23:17
|
Update of /cvsroot/macattrick/macattrick In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29600 Modified Files: LineUpController.h LineUpController.m LineUpTree.h LineUpTree.m Position.h Position.m Log Message: some line up statistics added. but do not seem correct yet Index: Position.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/Position.m,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Position.m 6 Feb 2005 19:36:18 -0000 1.8 --- Position.m 25 Apr 2005 20:22:37 -0000 1.9 *************** *** 32,35 **** --- 32,36 ---- static NSMutableDictionary *positionsDictionary; + @interface Position (Private) - (void) setPlayerFormRate: (double) newPlayerFormRate; *************** *** 47,50 **** --- 48,54 ---- + (void) loadDefaultPositions; + (void) loadPositions; + + (NSArray*) defenseSectionIdentifier; + + (NSArray*) midfieldSectionIdentifier; + + (NSArray*) attackSectionIdentifier; @end *************** *** 199,202 **** --- 203,221 ---- } + -(BOOL) belongsToSection: (NSString*) section { + if([section isEqualToString:@"Total"]) { + return YES; + } + if([section isEqualToString:@"Defense"] && [[Position defenseSectionIdentifier] containsObject:[self identifier]]) { + return YES; + } + else if([section isEqualToString:@"Midfield"] && [[Position midfieldSectionIdentifier] containsObject:[self identifier]]) { + return YES; + } + else if([section isEqualToString:@"Attack"] && [[Position attackSectionIdentifier] containsObject:[self identifier]]) { + return YES; + } + return NO; + } -(void) saveToUserDefaults { *************** *** 238,241 **** --- 257,261 ---- + +(Position*) positionWithIdentifier: (NSString*) positionsIdentifier { Position *pos = [positionsDictionary objectForKey:positionsIdentifier]; *************** *** 283,286 **** --- 303,322 ---- } + + + (NSArray *) defenseSectionIdentifier{ + return [NSArray arrayWithObjects: @"Keeper",@"Central Defender",@"Central Defender Towards Wing",@"Central Defender Offensive", + @"Wingback",@"Wingback Offensive",@"Wingback Defensive",@"Wingback Towards Middle",nil]; + } + + (NSArray*) midfieldSectionIdentifier { + return [NSArray arrayWithObjects:@"Inner Midfield",@"Inner Midfield Defensive",@"Inner Midfield Offensive",@"Inner Midfield Towards Wing", + @"Winger",@"Winger Defensive",@"Winger Offensive",@"Winger Towards Middle", nil ]; + } + + + (NSArray*) attackSectionIdentifier { + return [NSArray arrayWithObjects:@"Forward",@"Forward Defensive", nil]; + } + + + + (void) initialize { [Position loadPositions]; Index: LineUpController.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/LineUpController.m,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** LineUpController.m 28 Mar 2005 08:40:20 -0000 1.19 --- LineUpController.m 25 Apr 2005 20:22:37 -0000 1.20 *************** *** 30,33 **** --- 30,49 ---- #import "PositionHeap.h" + @interface LineUpController (Private) + + - (NSArray*) teamFromLineUp: (NSArray*) lineUp; + -(void)setPiecesPlayer: (NSArray*) team; + -(void)teamCaptainPlayer: (NSArray*) team; + - (void) displayLineUp: (NSArray*) lineUp; + -(void) displaySubstitutes: (NSArray*) substitutes ; + - (NSArray*) substitutesPositions; + - (void) loadPositions; + - (void) loadForward; + - (void) loadWinger; + - (void) loadInnerMidfield; + - (void) loadBackWings; + - (void) loadCentralDefender; + - (void) displayStrenght: (LineUpTree*) tree; + @end @implementation LineUpController *************** *** 44,49 **** ! - (IBAction)recalculate:(id)sender ! { [self loadPositions]; LineUpTree *lineUpTree = [[LineUpTree alloc] initWithPositions:positions]; --- 60,64 ---- ! - (IBAction)recalculate:(id)sender { [self loadPositions]; LineUpTree *lineUpTree = [[LineUpTree alloc] initWithPositions:positions]; *************** *** 60,63 **** --- 75,79 ---- NSArray *substitutes = [subLineUpTree bestLineUp]; [self displaySubstitutes: substitutes]; + [self displayStrenght:lineUpTree]; [lineUpTree release]; [subLineUpTree release]; *************** *** 109,112 **** --- 125,141 ---- } + - (void) displayStrenght: (LineUpTree*) tree { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init]; + NSString *totalString = [NSString stringWithFormat:@"%.2f", [tree strength:@"Total"]]; + NSString *defenseString = [NSString stringWithFormat:@"%.2f", [tree strength:@"Defense"]]; + NSString *midfieldString = [NSString stringWithFormat:@"%.2f", [tree strength:@"Midfield"]]; + NSString *attackString = [NSString stringWithFormat:@"%.2f", [tree strength:@"Attack"]]; + [totalStrength setStringValue: totalString]; + [defenseStrength setStringValue:defenseString]; + [midfieldStrength setStringValue:midfieldString]; + [attackStrength setStringValue:attackString]; + [pool release]; + } + - (void) loadPositions { positions = [NSMutableArray arrayWithCapacity:11]; Index: Position.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/Position.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Position.h 6 Feb 2005 19:36:18 -0000 1.7 --- Position.h 25 Apr 2005 20:22:37 -0000 1.8 *************** *** 79,82 **** --- 79,88 ---- -(BOOL) isEqual:(id) anObject; + /*! + @method belongsToSection + @abstract returns true if the position belongs to a given section. + @discussion currently supported values for sections are: Total, Defense, Midfield, Attack + */ + -(BOOL) belongsToSection: (NSString*) section; -(void) saveToUserDefaults; Index: LineUpTree.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/LineUpTree.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LineUpTree.h 19 Sep 2004 17:06:42 -0000 1.4 --- LineUpTree.h 25 Apr 2005 20:22:37 -0000 1.5 *************** *** 42,49 **** --- 42,58 ---- + /*! + @method strength + @abstract calculate the strength of a line up for a given section + @discussion section might be one of the following values: Total, Defense, Midfield, Attack + */ + - (double) strength: (NSString*) section; + - (NSArray *) positions; - (NSArray*) bestLineUp; + - (NSSet*) unusedPlayersByBestLineUp; + - (LineUpTreeLayer*) finalLayer; @end Index: LineUpTree.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/LineUpTree.m,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LineUpTree.m 30 Jun 2004 10:37:30 -0000 1.5 --- LineUpTree.m 25 Apr 2005 20:22:37 -0000 1.6 *************** *** 54,59 **** --- 54,75 ---- } + -(double) strength: (NSString*) section { + double strength = 0.0; + NSArray *lineUp = [self bestLineUp]; + if(!([lineUp count] == [[self positions] count])) { + return -1; + } + int i; + for (i=0; i<[lineUp count]; i++) { + if([[positions objectAtIndex:i] belongsToSection: section]) { + strength += [[[lineUp objectAtIndex:i] player] calculatePositionValue:[positions objectAtIndex:i]]; + } + } + return strength; + } + - (NSArray *) positions { return positions; } + - (NSArray*) bestLineUp { LineUpTreeNode *node = [[self finalLayer] bestScoringNode]; Index: LineUpController.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/LineUpController.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LineUpController.h 5 Dec 2004 21:50:44 -0000 1.5 --- LineUpController.h 25 Apr 2005 20:22:37 -0000 1.6 *************** *** 62,65 **** --- 62,69 ---- IBOutlet NSTextField *subWinger; IBOutlet NSTextField *teamCaptain; + IBOutlet NSTextField *totalStrength; + IBOutlet NSTextField *defenseStrength; + IBOutlet NSTextField *midfieldStrength; + IBOutlet NSTextField *attackStrength; IBOutlet NSPopUpButton *specCentralDefender1; IBOutlet NSPopUpButton *specCentralDefender2; *************** *** 73,76 **** --- 77,81 ---- IBOutlet NSPopUpButton *specRightWinger; + } |