|
From: Geisschaes <gei...@us...> - 2005-05-30 17:47:14
|
Update of /cvsroot/macattrick/macattrick In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23981 Modified Files: Player.h Player.m PlayerState.h PlayerState.m Properties.m Log Message: initwithchanges added Index: Properties.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/Properties.m,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Properties.m 29 May 2005 19:15:59 -0000 1.16 --- Properties.m 30 May 2005 17:46:31 -0000 1.17 *************** *** 56,60 **** BOOL isDir = TRUE; if([[NSFileManager defaultManager] fileExistsAtPath: path isDirectory: &isDir] && isDir) { - NSLog(path); [formerDates addObject:path]; } --- 56,59 ---- Index: PlayerState.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerState.m,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PlayerState.m 30 May 2005 16:15:38 -0000 1.1 --- PlayerState.m 30 May 2005 17:46:31 -0000 1.2 *************** *** 33,37 **** --- 33,58 ---- @implementation PlayerState + - (void) init { + self = [super init]; + return self; + } + - (PlayerState*) initWithChangesFrom: (PlayerState*) formerState to: (PlayerState*) currentState { + self = [super init]; + if (self) { + NSArray *fields = [[NSArray alloc] initWithObjects:@"tsi", @"salary", @"age", @"injuryLevel",@"cards", + @"experience", @"playerForm", @"staminaSkill", @"keeperSkill", + @"playmakerSkill", @"scorerSkill", @"passingSkill", + @"wingerSkill", @"defenderSkill", @"setPiecesSkill", nil]; + NSEnumerator *en = [fields objectEnumerator]; + NSString *current = nil; + while(current = [en nextObject]) { + NSNumber *difference = [[NSNumber alloc] initWithInt:[[currentState valueForKey:current] intValue] - [[formerState valueForKey:current] intValue]]; + [self setValue: difference forKey:current]; + [difference release]; + } + } + return self; + } - (int) tsi { return tsi; } Index: Player.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/Player.m,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Player.m 29 May 2005 19:15:59 -0000 1.24 --- Player.m 30 May 2005 17:46:31 -0000 1.25 *************** *** 84,87 **** --- 84,92 ---- } + - (PlayerState*) stateChangeToDate: (NSString*)date { + PlayerState *former = [self stateAtDate:date]; + return [[PlayerState alloc] initWithChangesFrom: former to: currentState]; + } + // NSCopying Protocal Index: PlayerState.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerState.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PlayerState.h 30 May 2005 16:15:38 -0000 1.1 --- PlayerState.h 30 May 2005 17:46:31 -0000 1.2 *************** *** 34,37 **** --- 34,38 ---- @superclass NSObject @abstract contains all changeable properties of a player + but is also used to carry the differences between two player states */ @interface PlayerState : NSObject { *************** *** 57,60 **** --- 58,65 ---- } + + - (PlayerState*) initWithChangesFrom: (PlayerState*) former to: (PlayerState*) current; + + - (int) tsi; - (void) setTsi: (int) newTsi; Index: Player.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/Player.h,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Player.h 29 May 2005 19:15:49 -0000 1.20 --- Player.h 30 May 2005 17:46:31 -0000 1.21 *************** *** 116,119 **** --- 116,127 ---- - (PlayerState*) stateAtDate: (NSString*) date; + /*! + @method differenceToDate:date: + @abstract returns the difference of the state at date to the current state + @discussion difference is stored in a player state object + @result player state object containing the differences + */ + - (PlayerState*) differenceToDate: (NSString*)date; + -(NSArray*) possiblePlayerSkillsAbilities; -(NSArray*) possiblePlayerStaminaAbilities; |