

////////////////////////////////////////////////////////////////////////
// Performance snippet
////////////////////////////////////////////////////////////////////////
CFTimeInterval start = CACurrentMediaTime();

// DO STUFF

CFTimeInterval end = CACurrentMediaTime();
NSLog(@"Took:%f",(end - start));

////////////////////////////////////////////////////////////////////////
// Promote an ability
////////////////////////////////////////////////////////////////////////
AbilityLevel* abilityLevel2  = [[GameFactory sharedUserManager].userPlayer.abilities getAbility:ABILITY_TODO_SB_2];
[abilityLevel2 addExp:100];
[abilityLevel2 promote];
[abilityLevel2 promote];
[abilityLevel2 promote];

////////////////////////////////////////////////////////////////////////
// File Download/import
////////////////////////////////////////////////////////////////////////
[self displayPopup:[GameViewFactory popupDownloadWithURL:@"http://lazyboydevelopments.com/gamedata/FootballSuperstar2/Data/Formula1.zip"
                             destPath:[[FileHelper getDownloadFolder] stringByAppendingPathComponent:@"Data.zip"]
                       completedBlock:^{
    
    [[GameFactory sharedUserManager].gameData importDataFile:@"Data.zip"];
}]];

////////////////////////////////////////////////////////////////////////
// Auto Join team
////////////////////////////////////////////////////////////////////////
Team* t1                = [[GameFactory sharedUserManager].gameData findTeamInRegion:@"Scotland" :@"East Fife"];
ContractOffer* tc       = [[ContractOffer alloc] init:t1];
[tc agreeWage:1000];
[[GameFactory sharedUserManager].userPlayer joinTeam:tc];

////////////////////////////////////////////////////////////////////////
// Show specific event
////////////////////////////////////////////////////////////////////////
Class<EventProtocol> eventClass = (Class<EventProtocol>)NSClassFromString(@"GameEventIntro");
[self vcShow:[GameViewFactory eventView:[eventClass buildEvent:nil]]];

////////////////////////////////////////////////////////////////////////
// Continue Game person injection! - Need to change person so it just saves UUID only
////////////////////////////////////////////////////////////////////////
-(void) continueGame {
    LoadedGameData* ldg         = [GameDataLoader loadFromFileSystem:[RemoteConfigFactory sharedInstance].realNames];
    
    if ([_allPlayers count] != [ldg.allPlayers count]) {
        NSLog(@"Continue Error - Players: %d != %d", (int)[_allPlayers count], (int)[ldg.allPlayers count]);
        exit(0);
    }
    
    int indx = 0;
    for (FootyPerson* fp in _allPlayers) {
        FootyPerson* loaded = [ldg.allPlayers objectAtIndex:indx++];
        if (loaded.uuid != fp.uuid) {
            NSLog(@"_allPlayers: uuid sequesnce error!");
            exit(0);
        }
        
        [fp setAge:loaded.age];
        [fp setName:loaded.firstName :loaded.surname];
        [fp setCountryCode:loaded.countryCode];
    }
    
    if ([_allManagers count] != [ldg.allManagers count]) {
        NSLog(@"Continue Error - Managers: %d != %d", (int)[_allManagers count], (int)[ldg.allManagers count]);
        exit(0);
    }
    
    indx = 0;
    for (FootyManager* fp in _allManagers) {
        FootyManager* loaded = [ldg.allManagers objectAtIndex:indx++];
        if (loaded.uuid != fp.uuid) {
            NSLog(@"_allManagers: uuid sequesnce error!");
            exit(0);
        }
        
        [fp setAge:loaded.age];
        [fp setName:loaded.firstName :loaded.surname];
        [fp setCountryCode:loaded.countryCode];
    }

    NSLog(@"Done");
}


////////////////////////////////////////////////////////////////////////
// World Cup viewer
////////////////////////////////////////////////////////////////////////
Team* t1            = [[GameFactory sharedUserManager].gameData getNationalTeamForCountryCode:@"SCO"];
Team* t2            = [[GameFactory sharedUserManager].gameData getNationalTeamForCountryCode:@"ENG"];
FixtureEntry* f     = [[FixtureEntry alloc] initFixtureEntry:FIXTURE_TYPE_WORLD_CUP_KNOCKOUT weekNo:0 batchNo:0 homeTeamUUID:t1.uuid awayTeamUUID:t2.uuid];
[MatchSimulator playFixture:f doPostProcessing:YES];

FootyPlayer* best   = [[t1 getPlayers] objectAtIndex:0];
NSArray* top        = @[[[t1 getPlayers] objectAtIndex:0], [[t1 getPlayers] objectAtIndex:1], [[t1 getPlayers] objectAtIndex:2]];

[self vcShow:[GameViewFactory worldCupSummaryView:f bestPlayer:best topScorers:top]];


////////////////////////////////////////////////////////////////////////
// 1v1
////////////////////////////////////////////////////////////////////////
Team* t1 = [[GameFactory sharedUserManager].gameData findTeamInRegion:@"Scotland" :@"Rangers"];
Team* t2 = [[GameFactory sharedUserManager].gameData findTeamInRegion:@"Scotland" :@"Aberdeen"];

FootyPlayer* p1 = [HelperMaths pickRandomFromArray:t1.getPlayers];
FootyPlayer* p2 = [HelperMaths pickRandomFromArray:t2.getPlayers];

UserAbilities* a1 = [UserAbilities generateUserAbilitiesForReputation:p1.getReputation];
UserAbilities* a2 = [UserAbilities generateUserAbilitiesForReputation:p2.getReputation];

NSArray<NSString*>* abilityKeys = [HelperMaths pickRandomFromArray:[UserAbilities listAllAbilityKeys:NO] :[HelperMaths randomInt:1 :6]];

[self vcShow:[GameViewFactory player1V1PopupView:@"Event Desc"
                                     abilityKeys:abilityKeys
                                      playerLeft:p1 playerRight:p2
                                   abilitiesLeft:a1 abilitiesRight:a2
                                   completeBlock:^(FootyPlayer * _Nonnull winner) {
    NSLog(@"Winner:%@", winner.getName);
}]];


////////////////////////////////////////////////////////////////////////
// 1v1 Pen Compeetition
////////////////////////////////////////////////////////////////////////

NSArray<NSString*>* selLeft     = @[ABILITY_CONFIDENCE,
                                    ABILITY_COMPOSURE,
                                    ABILITY_TECHNIQUE,
                                    ABILITY_SHOOTING_SHORT,
                                    ABILITY_STRENGTH_LEG];

NSArray<NSString*>* selRight    = @[ABILITY_ANTICIPATION,
                                    ABILITY_GK_REFLEXES,
                                    ABILITY_GK_PARRYING];

//NOTE: if this doesnt worlk make sure your using REAL names!!!!!
Team* t1 = [[GameFactory sharedUserManager].gameData findTeamInRegion:@"Scotland" :@"Rangers"];
Team* t2 = [[GameFactory sharedUserManager].gameData findTeamInRegion:@"Scotland" :@"Aberdeen"];

FootyPlayer* playerLeft  = [HelperMaths pickRandomFromArray:[t1 getAttackers]];
FootyPlayer* playerRight = [HelperMaths pickRandomFromArray:[t2 getGoalKeepers]];

UserAbilities* abilitiesLeft    = [UserAbilities generateUserAbilitiesForRole:playerLeft.role reputation:playerLeft.getReputation];
UserAbilities* abilitiesRight   = [UserAbilities generateUserAbilitiesForRole:playerRight.role reputation:playerRight.getReputation];

UIViewController* vc = [GameViewFactory player1V1PopupView:[LanguageHelper get:@"1v1_001"]
                                     selectedAbilitiesLeft:selLeft selectedAbilitiesRight:selRight
                                                playerLeft:playerLeft playerRight:playerRight
                                             playerPosLeft:playerLeft.role playerPosRight:playerRight.role
                                             abilitiesLeft:abilitiesLeft abilitiesRight:abilitiesRight
                                              autoProgress:NO
                                             completeBlock:^(FootyPlayer * _Nonnull winner) {
}];

[self displayPopup:vc animated:NO];

////////////////////////////////////////////////////////////////////////
// Ttoal Exp & Money given for all relationship rewards
////////////////////////////////////////////////////////////////////////
int expTotal = 0;
int moneyTotal = 0;
for (int indx = 0; indx < [[GameFactory sharedUserManager].userRelationships getHappinessRewardTotal]; indx++) {
    expTotal   += [[GameFactory sharedUserManager].userRelationships getHappinessExpRewardForLevel:indx];
    moneyTotal += [[GameFactory sharedUserManager].userRelationships getHappinessMoneyRewardForLevel:indx];
}

NSLog(@"Exp[%@]  money[%@]", [Helper commasToLongLongNumber:expTotal], [Helper commasToLongLongNumber:moneyTotal]);


////////////////////////////////////////////////////////////////////////
// Add Happiness and update Relationship VC
////////////////////////////////////////////////////////////////////////
[[GameFactory sharedUserManager].userRelationships addHappiness:2000];
[[GameFactory sharedUserManager].userRelationships weeklyProcessing];
[self refreshHappiness:NO];
[_tblReward reloadData];

////////////////////////////////////////////////////////////////////////
// smaz string compression test - working
////////////////////////////////////////////////////////////////////////
NSString* start = @"Scott Baillie";

NSData* sbCompressed = [SBSmallStringCompression compress:start];
NSString* sbDecompressed = [SBSmallStringCompression decompress:sbCompressed];

NSLog(@"--------------");
NSLog(@"start:      %@", start);
NSLog(@"encoded:    %@", sbCompressed);
NSLog(@"decoded:    %@", sbDecompressed);
NSLog(@"--------------");


////////////////////////////////////////////////////////////////////////
// Translating Game Events - after translating check these
////////////////////////////////////////////////////////////////////////
1v1_Misc        - Just copy from Eng verion as no text
1v1_FreeKick    - copy <LANG>_Goal_FreeKick and replace |<GOAL> (to end of line) and with |<1v1_011>
1v1_Pen         - 3 lines in translated text, copy them until total of 17 lines THEN add panenka entry and make sure it ends with |<1v1_007>


////////////////////////////////////////////////////////////////////////
// PLay all fixtures - performance testing
////////////////////////////////////////////////////////////////////////
CFTimeInterval start = CACurrentMediaTime();

NSMutableArray<FixtureEntry*>* all = [[NSMutableArray alloc] init];
for (Region* r in [[GameFactory sharedUserManager].gameData getRegions]) {
   for (DomesticLeague* l in r.leagues) {
       [all addObjectsFromArray:[l getAllFixtures]];
   }
}

NSLog(@"Fixture Count:%d", (int)[all count]);
[MatchSimulator playFixtures:all doPostProcess:YES];

CFTimeInterval end = CACurrentMediaTime();
NSLog(@"Took:%f",(end - start));


////////////////////////////////////////////////////////////////////////
// Multi Save
////////////////////////////////////////////////////////////////////////
[self animateOutButton:sender completionBlock:^{
    [self displayPopup:[GameViewFactory popupSaveSelectCsv1:[CSVContainer build:@"1,Rangers"]
                                                       csv2:[CSVContainer build:@"2,Aberdeen"]
                                                       csv2:nil
                                             completedBlock:^(NSString * _Nonnull selected) {
        NSLog(@"Selecetd: %@", selected);
    }]];
}];

////////////////////////////////////////////////////////////////////////
// 6 group test
////////////////////////////////////////////////////////////////////////
[self vcShow:[GameViewFactory groupDraw6View:[LanguageHelper get:@"EL_GroupStartTitle"]
                                       teams:[[GameFactory sharedUserManager].gameData.allTeam subarrayWithRange:NSMakeRange(0, 24)]]];
