|
From: Geisschaes <gei...@us...> - 2005-05-29 16:24:45
|
Update of /cvsroot/macattrick/macattrick In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14757 Modified Files: Devel Macattrick-Info.plist HattrickOrg.m Player.h Player.m Properties.h Properties.m Log Message: downloaded files are now copied to ~Library/Application Support/Macattrick/, too Index: Properties.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/Properties.m,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Properties.m 14 Mar 2005 19:30:52 -0000 1.14 --- Properties.m 29 May 2005 16:23:54 -0000 1.15 *************** *** 30,45 **** #import "Properties.h" @implementation Properties +(NSString*) libraryPath { ! NSString *path = @"~/Library/Application Support/Macattrick"; return [path stringByExpandingTildeInPath]; } +(NSString*) playersFile { NSString *path = [self libraryPath]; return [path stringByAppendingString:@"/players.xml"]; } - +(NSString*) economyFile { NSString *path = [self libraryPath]; --- 30,53 ---- #import "Properties.h" + @interface Properties(Private) + +(NSString*) file:(NSString*) file withPath: (NSString*)path; + @end @implementation Properties +(NSString*) libraryPath { ! NSString *path = [NSString stringWithString:@"~/Library/Application Support/Macattrick"]; return [path stringByExpandingTildeInPath]; } + +(NSString*) currentEnvironmentPath { + NSCalendarDate *now = [NSCalendarDate calendarDate]; + NSString *dateString = [now descriptionWithCalendarFormat:[self dateFormat]]; + return [NSString stringWithFormat:@"%@/%@",[self libraryPath], dateString] ; + } + +(NSString*) playersFile { NSString *path = [self libraryPath]; return [path stringByAppendingString:@"/players.xml"]; } +(NSString*) economyFile { NSString *path = [self libraryPath]; *************** *** 79,82 **** --- 87,119 ---- } + +(NSString*) playersFileInPath: (NSString*)path { + return [self file:@"players.xml" withPath: path]; + } + +(NSString*) economyFileInPath: (NSString*)path { + return [self file:@"economy.xml" withPath: path]; + } + +(NSString*) teamDetailsFileInPath: (NSString*)path { + return [self file:@"teamDetails.xml" withPath: path]; + } + +(NSString*) leagueDetailsFileInPath: (NSString*)path { + return [self file:@"leagueDetails.xml" withPath: path]; + } + +(NSString*) clubFileInPath: (NSString*)path { + return [self file:@"club.xml" withPath: path]; + } + +(NSString*) trainingFileInPath: (NSString*)path { + return [self file:@"training.xml" withPath: path]; + } + +(NSString*) arenaDetailsInPath: (NSString*)path { + return [self file:@"arenaDetails.xml" withPath: path]; + } + +(NSString*) worldDetailsFileInPath: (NSString*)path { + return [self file:@"worldDetails.xml" withPath: path]; + } + + +(NSString*) file:(NSString*) file withPath: (NSString*)path { + return [NSString stringWithFormat: @"%@/%@", path, file]; + } + +(float) currentVersion { NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; *************** *** 93,96 **** --- 130,138 ---- } + + +(NSString*) dateFormat { + return @"%Y-%m-%d"; + } + +(void) initializeUserDefaults { NSArray *keys = [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] allKeys]; Index: Player.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/Player.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Player.h 29 May 2005 13:16:55 -0000 1.18 --- Player.h 29 May 2005 16:23:54 -0000 1.19 *************** *** 36,39 **** --- 36,40 ---- NSString *playerName; PlayerState *currentState; + NSMutableDictionary *formerStates; int countryID; int leadership; *************** *** 42,61 **** int aggressiveness; int honesty; - - /* int tsi; - int salary; - int age; - int injuryLevel; - int cards; - int experience; - int playerForm; - int staminaSkill; - int keeperSkill; - int playmakerSkill; - int scorerSkill; - int passingSkill; - int wingerSkill; - int defenderSkill; - int setPiecesSkill;*/ } --- 43,46 ---- *************** *** 106,118 **** - (int) setPiecesSkill; - - -(double)teamCaptain; - // overall skill setting - - (void)setStaminaSkill: (int) newStaminaSkill keeperSkill: (int) newKeeperSkill - playmakerSkill: (int) newPlaymakerSkill scorerSkill: (int) newScorerSkill - passingSkill: (int) newPassingSkill wingerSkill: (int) newWingerSkill - defenderSkill: (int) newDefenderSkill setPiecesSkill: (int) newSetPiecesSkill; - (double)calculatePositionValue: (Position*)position; --- 91,96 ---- *************** *** 121,124 **** --- 99,117 ---- -(Position*) bestPosition; + /*! + @method addState + @abstract add a former state + @discussion add the state for a given date + */ + - (void) addState: (PlayerState*)state forDate: (NSString*) date ; + + /*! + @method stateAtDate:date: + @abstract get the state of the player at a given date + @discussion nil if there is no state available for the given date + @result state of the player at a given date + */ + - (PlayerState*) stateAtDate: (NSString*) date; + -(NSArray*) possiblePlayerSkillsAbilities; -(NSArray*) possiblePlayerStaminaAbilities; Index: HattrickOrg.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/HattrickOrg.m,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** HattrickOrg.m 20 May 2005 18:30:35 -0000 1.22 --- HattrickOrg.m 29 May 2005 16:23:54 -0000 1.23 *************** *** 34,37 **** --- 34,38 ---- -(int) download: (NSString*) urlString toFile: (NSString*) file; -(NSURLRequest*) buildRequest: (NSString*) urlString ; + - (void) copyToCurrentEnvironment; @end *************** *** 107,113 **** --- 108,133 ---- errorCode = [self downloadTraining]; if(errorCode) {return errorCode;} errorCode = [self logout]; + if(errorCode == 0) { + [self copyToCurrentEnvironment]; + } return errorCode; } + - (void) copyToCurrentEnvironment { + NSFileManager *fileManager = [NSFileManager defaultManager]; + if([fileManager fileExistsAtPath:[Properties currentEnvironmentPath]]) { + [fileManager removeFileAtPath:[Properties currentEnvironmentPath]handler:nil]; + } + [fileManager createDirectoryAtPath:[Properties currentEnvironmentPath] attributes:nil]; + [fileManager copyPath:[Properties playersFile] toPath: [Properties playersFileInPath:[Properties currentEnvironmentPath]] handler: nil]; + [fileManager copyPath:[Properties worldDetailsFile] toPath: [Properties worldDetailsFileInPath:[Properties currentEnvironmentPath]] handler: nil]; + [fileManager copyPath:[Properties arenaDetailsFile] toPath: [Properties arenaDetailsInPath:[Properties currentEnvironmentPath]] handler: nil]; + [fileManager copyPath:[Properties clubFile] toPath: [Properties clubFileInPath:[Properties currentEnvironmentPath]] handler: nil]; + [fileManager copyPath:[Properties economyFile] toPath: [Properties economyFileInPath:[Properties currentEnvironmentPath]] handler: nil]; + [fileManager copyPath:[Properties leagueDetailsFile] toPath: [Properties leagueDetailsFileInPath:[Properties currentEnvironmentPath]] handler: nil]; + [fileManager copyPath:[Properties teamDetailsFile] toPath: [Properties teamDetailsFileInPath:[Properties currentEnvironmentPath]] handler: nil]; + [fileManager copyPath:[Properties trainingFile] toPath: [Properties trainingFileInPath:[Properties currentEnvironmentPath]] handler: nil]; + } + - (int) login { NSString *urlString = [[NSString alloc] initWithFormat:@"http://%s/Common/default.asp?outputType=XML&actionType=login&loginType=CHPP&Loginname=%s&readonlypassword=%s", Index: Properties.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/Properties.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Properties.h 14 Mar 2005 19:30:51 -0000 1.8 --- Properties.h 29 May 2005 16:23:54 -0000 1.9 *************** *** 47,50 **** --- 47,57 ---- /*! + @method currentEnvironmentPath + @abstract path the the current macattrick files + @discussion this path is usually "libraryPath/$date" + */ + +(NSString*) currentEnvironmentPath; + + /*! @method playersFile @abstract local address of the xml file containing the current players.asp *************** *** 115,118 **** --- 122,134 ---- +(NSString*) worldDetailsFile; + +(NSString*) playersFileInPath: (NSString*)path; + +(NSString*) economyFileInPath: (NSString*)path; + +(NSString*) teamDetailsFileInPath: (NSString*)path; + +(NSString*) leagueDetailsFileInPath: (NSString*)path; + +(NSString*) clubFileInPath: (NSString*)path; + +(NSString*) trainingFileInPath: (NSString*)path; + +(NSString*) arenaDetailsInPath: (NSString*)path; + +(NSString*) worldDetailsFileInPath: (NSString*)path; + /*! @method currentVersion *************** *** 138,142 **** +(void) initializeUserDefaults; ! @end --- 154,163 ---- +(void) initializeUserDefaults; ! /*! ! @method dateFormat ! @abstract get the format for macattrick dates ! @discussion used to store the former data, usually @"%Y-%m-%d" ! */ ! +(NSString*) dateFormat; @end Index: Player.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/Player.m,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Player.m 29 May 2005 13:17:03 -0000 1.22 --- Player.m 29 May 2005 16:23:54 -0000 1.23 *************** *** 68,71 **** --- 68,72 ---- if (self) { currentState = [[PlayerState alloc] init]; + formerStates = [[NSMutableDictionary alloc] init]; } return self; *************** *** 73,76 **** --- 74,86 ---- + + - (void) addState: (PlayerState*)state forDate: (NSString*) date { + [formerStates setObject:state forKey:date]; + } + + - (PlayerState*) stateAtDate: (NSString*) date { + return [formerStates objectForKey:date]; + } + // NSCopying Protocal *************** *** 206,210 **** } - - (int) aggressiveness { return aggressiveness; } - (void) setAggressiveness: (int) newAggressiveness { --- 216,219 ---- *************** *** 212,216 **** } - - (int) honesty { return honesty; } - (void) setHonesty: (int) newHonesty { --- 221,224 ---- *************** *** 218,223 **** } - - - (int) specialty { return specialty; } - (void) setSpecialty: (int) newSpecialty { --- 226,229 ---- *************** *** 225,231 **** } - - (int)experience {return [currentState experience];} - - (void)setExperience:(int)newExperience { [currentState setExperience: newExperience]; --- 231,235 ---- *************** *** 233,245 **** - (int)leadership { return leadership;} - - (void)setLeadership:(int)newLeadership { ! if (leadership != newLeadership) { ! leadership = newLeadership; ! } } - (int)playerForm {return [currentState playerForm];} - - (void)setPlayerForm:(int)newPlayerForm { [currentState setPlayerForm: newPlayerForm]; --- 237,245 ---- - (int)leadership { return leadership;} - (void)setLeadership:(int)newLeadership { ! leadership = newLeadership; } - (int)playerForm {return [currentState playerForm];} - (void)setPlayerForm:(int)newPlayerForm { [currentState setPlayerForm: newPlayerForm]; *************** *** 248,252 **** - (int)staminaSkill {return [currentState staminaSkill];} - - (void)setStaminaSkill:(int)newStaminaSkill { [currentState setStaminaSkill:newStaminaSkill]; --- 248,251 ---- *************** *** 254,258 **** - (int)keeperSkill {return [currentState keeperSkill];} - - (void)setKeeperSkill:(int)newKeeperSkill { [currentState setKeeperSkill:newKeeperSkill]; --- 253,256 ---- *************** *** 260,264 **** - (int)playmakerSkill {return [currentState playmakerSkill];} - - (void)setPlaymakerSkill:(int)newPlaymakerSkill { [currentState setPlaymakerSkill: newPlaymakerSkill]; --- 258,261 ---- *************** *** 266,270 **** - (int)scorerSkill {return [currentState scorerSkill];} - - (void)setScorerSkill:(int)newScorerSkill { [currentState setScorerSkill:newScorerSkill]; --- 263,266 ---- *************** *** 272,276 **** - (int)passingSkill {return [currentState passingSkill];} - - (void)setPassingSkill:(int)newPassingSkill { [currentState setPassingSkill: newPassingSkill]; --- 268,271 ---- *************** *** 278,282 **** - (int)wingerSkill { return [currentState wingerSkill];} - - (void)setWingerSkill:(int)newWingerSkill { [currentState setWingerSkill:newWingerSkill]; --- 273,276 ---- *************** *** 284,288 **** - (int)defenderSkill {return [currentState defenderSkill];} - - (void)setDefenderSkill:(int)newDefenderSkill { [currentState setDefenderSkill: newDefenderSkill]; --- 278,281 ---- *************** *** 290,294 **** - (int)setPiecesSkill { return [currentState setPiecesSkill];} - - (void)setSetPiecesSkill:(int)newSetPiecesSkill { [currentState setSetPiecesSkill: newSetPiecesSkill]; --- 283,286 ---- *************** *** 300,334 **** - // overall skill accessor - /*- (void)setStaminaSkill: (int) newStaminaSkill keeperSkill: (int) newKeeperSkill - playmakerSkill: (int) newPlaymakerSkill scorerSkill: (int) newScorerSkill - passingSkill: (int) newPassingSkill wingerSkill: (int) newWingerSkill - defenderSkill: (int) newDefenderSkill setPiecesSkill: (int) newSetPiecesSkill { - if (staminaSkill != newStaminaSkill) { - staminaSkill = newStaminaSkill; - } - if (keeperSkill != newKeeperSkill) { - keeperSkill = newKeeperSkill; - } - if (playmakerSkill != newPlaymakerSkill) { - playmakerSkill = newPlaymakerSkill; - } - if (scorerSkill != newScorerSkill) { - scorerSkill = newScorerSkill; - } - if (passingSkill != newPassingSkill) { - passingSkill = newPassingSkill; - } - if (wingerSkill != newWingerSkill) { - wingerSkill = newWingerSkill; - } - if (defenderSkill != newDefenderSkill) { - defenderSkill = newDefenderSkill; - } - if (setPiecesSkill != newSetPiecesSkill) { - setPiecesSkill = newSetPiecesSkill; - } - }*/ - -(void) setValue:(id)value forUndefinedKey: (id) key { // undefined keys are just ignored --- 292,295 ---- *************** *** 341,345 **** - (double) calculatePositionValue: (Position*) position withinState: (PlayerState*) state{ - //(playerForm * 0.075 + 0.4) return ((([state playerForm] * [position playerFormRate] * 0.125 + 0.4) * ([state staminaSkill] * [position staminaRate] + [state keeperSkill] * [position keeperRate] + [state playmakerSkill] * [position playmakingRate] + [state scorerSkill] * [position scorerRate] --- 302,305 ---- *************** *** 420,423 **** --- 380,384 ---- - (void)dealloc { [currentState release]; + [formerStates release]; [playerName release]; [super dealloc]; Index: Devel Macattrick-Info.plist =================================================================== RCS file: /cvsroot/macattrick/macattrick/Devel Macattrick-Info.plist,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Devel Macattrick-Info.plist 27 Feb 2005 15:14:43 -0000 1.5 --- Devel Macattrick-Info.plist 29 May 2005 16:23:54 -0000 1.6 *************** *** 22,26 **** <string>Roman Bertolami</string> <key>CFBundleVersion</key> ! <string>0.5</string> <key>NSMainNibFile</key> <string>MainMenu</string> --- 22,26 ---- <string>Roman Bertolami</string> <key>CFBundleVersion</key> ! <string>0.6</string> <key>NSMainNibFile</key> <string>MainMenu</string> |