def addRosterUI(ln,tn,defense):
    inp='y'
    if not defense:
        while inp.lower() not in ['n' or 'no']:
            if inp.lower()=='y' or inp.lower()=='yes':
                defen=raw_input('Please enter team name for defense: ').strip()
                while nflgame.standard_team(defen) is None:
                    defen=raw_input('Invalid team name, please try again: ').strip()
                defen=nflgame.standard_team(defen)
                defense.append(defen)
            else:
                print 'invalid input, try again.'
            inp = raw_input('Would you like to add another team for defense? (y/n): ' ).strip()

    testVar=fbTool.addRoster(ln,tn,defense)
    if not testVar:
        print 'Succesfully added roster %s!' % tn
    else:
        print 'Failed to add team...'
        if testVar == 1:
            print 'Team %s already exists in league %s' %(tn,ln)
            anotherVar = ' '
            while anotherVar not in ['y','yes','n','no']:
                anotherVar =raw_input('Try again?(y/n)').strip()
                if anotherVar.lower() in ['y','yes']:
                    tn=getTeamName(ln)
                    return addRosterUI(ln,tn,defense)
                if anotherVar.lower() in ['n','no']:
                    print 'Team not added...'
                    return -1
                if anotherVar.lower() not in ['y','yes','n','no']:
                    print 'Invalid input.  Please try again.'

        if testVar == 2:
            print 'League %s does not exist.'
            userInVar = ' '
            while userInVar not in ['y','yes','n''no']:
                userInVar = raw_input('Would you like to add it? (y/n): ').strip()
                if userInVar.lower() not in ['y','yes','n','no']:
                    print 'invalid input.  please try again.'
                if userInVar.lower() in ['y','yes']:
                    if not fbTool.addLeague(ln):
                        return addRosterUI(ln,tn,defense)
                if userInVar.lower() in ['n','no']:
                    print 'team not added.'
                    return 1
        if testVar >= 3:
            print '%s already used as defense team in league %s'%(defense[testVar-3],ln)
            oneFinalVar = ' '
            while oneFinalVar not in ['y','yes','n','no']:
                oneFinalVar = raw_input('Try again?(y/n) ').strip()
                if oneFinalVar.lower() in ['y','yes']:
                    addRosterUI(ln,tn,[])
                if oneFinalVar.lower() in ['n','no']:
                    print 'Team not added...'
                    return -1
                if oneFinalVar.lower() not in ['y','yes','n','no']:
                    print 'Invalid input, please try again.'
    return 0
def addLeagueUI():
    k=1
    if fbTool.leagueLists:
       k=0 
    ln=getLeagueName(k)
    testVar=fbTool.addLeague(ln)
    if not testVar:
        print 'Successfully added league %s!' % ln
    else:
        print 'Failed to add league...'
        if testVar == 1:
            print 'League %s already exists.'%ln
        else:
            print 'something is horribly broken.'
def addPlayerUI():
    ln=getLeagueName(0)
    tn=getTeamName(ln)
    inp = 'y'
    while inp.lower() in ['y','yes']:
        printPlayers(ln,tn)
        plName=raw_input('Please input the desired player to add\'s name: ')
        plTeam=raw_input('Please input the desired player\'s NFL team: ')
        testVar=fbTool.addPlayer(ln,tn,plName,plTeam)
        if not testVar:
            print 'Succesfully added %s to %s from league %s' % (plName,tn,ln)
        else:
            print 'Failed to add player...'
        if testVar == 1:
            print 'Player already rostered in league %s'%ln
        if testVar == 2:
            print 'Player %s not found in database'%plName
        if testVar == 3:
            print 'Team does not exist.'
            userInVar = ' '
            while userInVar.lower() not in ['y','yes','n','no']:
                userInVar = raw_input('Would you like to add it? (y/n): ').strip()
                if userInVar.lower() not in ['y','yes','n','no']:
                    print 'Invalid input.  Please try again.'
            if userInVar.lower()=='y' or userInVar.lower()=='yes':
                if not addRosterUI(ln,tn,[]):
                    testVar = fbTool.addPlayer(ln,tn,plName,plTeam)
                    if not testVar:
                        print 'Successfully added %s to %s from league %s' %(plName,tn,ln)
                    else:
                        print 'Failed to add player.'
                    if testVar == 1:
                        print 'Player already rostered in league %s'%ln
                    if testVar == 2:
                        print 'Player %s not found in database'%plName
                else:
                    print 'Failed to add roster.'
                    raw_input ('Press return to continue...').strip()
                    return -1
        if testVar == 4:
            print 'League does not exist.'
            userInVar=' '
            while userInVar.lower() not in ['y','yes','n','no']:
                userInVar = raw_input('Would you like to add the league and team? (y/n): ').strip()
                if userInVar.lower() not in ['y','yes','no','n']:
                    print 'Invalid input.  Please try again.'
            if userInVar.lower()=='y' or userInVar.lower()=='yes':
                if not fbTool.addLeague(ln):
                    if not addRosterUI(ln,tn,[]):
                        testVar =fbTool.addPlayer(ln,tn,plName,plTeam)
                        if not testVar:
                            print 'Successfully added %s to %s from league %s' %(plName,tn,ln)
                        else:
                            print 'Failed to add player.'
                        if testVar == 1:
                            print 'Player already rostered in league %s'%ln
                        if testVar == 2:
                            print 'Player %s not found in database'%plName
                    else:
                        print 'failed to add team to league'
                else:
                    print 'something went horribly wrong.'
        inp = raw_input ('Would you like to add another player? (y/n) ')
        while inp.lower() not in ['y','yes','n','no']:
            print 'Invalid input. Please try again...'
            inp = raw_input ('Would you like to add another player? (y/n) ')