// this was added to matchreport view contrller to test injurioes/ suspensions. might be handy

if (sender == _btnResults) {
//        Injury* current = [[GameFactory sharedUserManager].userPlayer getInjury];
//        if (current == nil) {
//            int injuryIndx      = [Helper getRandomIndexUsingWeightings:[InjuryDAO getInjuries]];
//            Injury* injury      = [[InjuryDAO getInjuries] objectAtIndex:injuryIndx];
//            int weeksOut        = [HelperMaths randomInt:injury.weeksOutMin :injury.weeksOutMax];
//            [[GameFactory sharedUserManager].userPlayer setInjury:injuryIndx :18];
//        }


Suspension* current = [[GameFactory sharedUserManager].userPlayer getSuspension];
if (current == nil) {
int suspendIndx      = [Helper getRandomIndexUsingWeightings:[SuspensionDAO getGoalkeeperSuspensions]];
Suspension* suspend      = [[SuspensionDAO getGoalkeeperSuspensions] objectAtIndex:suspendIndx];
[[GameFactory sharedUserManager].userPlayer setSuspension:suspendIndx :suspend.matchesSuspended];
}
}


////////////////////////////////////////////////////////////////////////
// Performance snippet
////////////////////////////////////////////////////////////////////////

int count = 1000;

CFTimeInterval start = CACurrentMediaTime();
for (int i = 0; i < count; i++) {
[TimeHelper sameYearMonthDay:date1 :date2];
}

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

////////////////////////////////////////////////////////////////////////
// to show if no teams interested for age/rep
////////////////////////////////////////////////////////////////////////


for (int age = 14; age <= 40; age++) {
NSLog(@"----------------------------------");
for (int rep = 5; rep <= 99; rep++) {
NSArray* interested = [[GameFactory sharedUserManager].userTransferCentre getAllInterestedTeams:age :rep :YES :YES];
if ([interested count] == 0) {
NSLog(@"  ==== NONE : age:%d   rep:%d", age, rep);
}
}
}

////////////////////////////////////////////////////////////////////////
// sign to specific team for testing
////////////////////////////////////////////////////////////////////////

Team* currentTeam   = [[GameFactory sharedUserManager].userPlayer getTeam];
if (currentTeam == nil) {
Region* r = [[GameFactory sharedDataManager].gameData getRegion:@"England"];
Team* team = [[GameFactory sharedDataManager].gameData findTeamInRegion:r :@"Barnsley"];

TransferOffer* to = [[TransferOffer alloc] initTransferInterest:team :[GameFactory sharedUserManager].userSeason.gameDate];
[to acceptOffer:0 :0 :[GameFactory sharedUserManager].userSeason.gameDate];

Contract* c = [[Contract alloc] initFromPlayer:to
:[GameFactory sharedUserManager].userPlayer
:[GameFactory sharedUserManager].userSeason.gameDate
:[[GameFactory sharedUserManager].userSeason getCurrentSeasonStartDate]
:0
];

[[GameFactory sharedUserManager] signForTeam:team :c :100];
}


////////////////////////////////////////////////////////////////////////
// match view re-positon for iphonex
////////////////////////////////////////////////////////////////////////

-(void) viewDidLayoutSubviews {

// safeAreaLayoutGuide only av in iOS 11 and above
if (@available(iOS 11.0, *)) {

// if safe area is not used then 0.0. > 0.0f if used - only adjust if used!
if (self.view.safeAreaLayoutGuide.layoutFrame.origin.x > 0.0f) {

// for iPhones with notch - the table auto works but the UIViews don't so we reposition if needed.

// get new X position of the Trade view
float newX = (self.view.safeAreaLayoutGuide.layoutFrame.origin.x + self.view.safeAreaLayoutGuide.layoutFrame.size.width) - _viewParentRewards.frame.size.width;

// keep difference as we need to reduce the table view so this has room now we've moved it.
float diff = newX - _viewParentRewards.frame.origin.x;
_viewParentRewards.frame = CGRectMake(newX,
_viewParentRewards.frame.origin.y,
_viewParentRewards.frame.size.width,
_viewParentRewards.frame.size.height);

// reduce width as we moved above left a bit to fit
_viewParentMatch.frame = CGRectMake(_viewParentMatch.frame.origin.x,
_viewParentMatch.frame.origin.y,
_viewParentMatch.frame.size.width + diff,
_viewParentMatch.frame.size.height);

_viewParentAbilities.frame = CGRectMake(_viewParentAbilities.frame.origin.x,
_viewParentAbilities.frame.origin.y,
_viewParentAbilities.frame.size.width + diff,
_viewParentAbilities.frame.size.height);

}
}

// set this after reposition(if needed -ie iphonex)
_destRectMatchView           = _viewParentMatch.frame;
_destRectAbilityView         = _viewParentAbilities.frame;

}

////////////////////////////////////////////////////////////////////////
// logo import
////////////////////////////////////////////////////////////////////////
UIStoryboard*  sb = [UIStoryboard storyboardWithName:[Helper getStoryboardForDevice] bundle:nil];
HttpRenameViewController* vc = [sb instantiateViewControllerWithIdentifier:@"HttpRenameViewController"];
[vc view]; // this wires the IBOutlets, which seem to be nil unlees this isc alled
[self vcShow:vc];
