Esempio n. 1
0
def postGame(win,canvas,playerWon):
    """Roser eller skjeller ut spilleren, alt ettersom han vant eller tapte"""

    canvas.clear()

    #Sett parametere basert på om spilleren vant eller ikke
    if playerWon:
        canvas.setBackground("darkslategray4")
        messages = ["Du vant!","Hurra!","Tjo-ho!","Du er best!","Jippi!","Alle elsker deg!","Sjette sans for skip?","Hvordan klarte du det?","Et geni uten like!",
                    "Verden er reddet!","Fryd!","Gammen!","Mesterstratèg","Ikke dårlig!","Imponerende!","Gratulerer!","Alle skip er senket!","Fantastisk!",
                    "Ingen over, ingen ved siden", "Nei, nå har jeg aldri","Hipp hipp!","Du seirer!"]
        messageColor = "green"
    else:
        canvas.setBackground("bisque2")
        messages = ["Du tapte!","Bu-hu!","Krigen er tapt!","Det var din feil!","Elendig strategi!","Fysj!","Skam deg!","Slått av en AI?","Gratulerer med ingenting..",
                    "Alt var forgjeves!","Ditt land utviser deg","Gå og legg deg!","Du rykker ned til kadett","En skam for marinen!","En skam for familien din!",
                    "Alle mann er døde","Du er bekjempet","Enden er nær!","Vær trist!","Forferdelig!"]
        messageColor = "red"

    canvas.setColor(messageColor)

    #Ros eller skjell ut spilleren i ca 8 sekunder
    for i in range(40):
        canvas.setTextFont("arial","bold",randint(4,50))
        canvas.drawText(randint(0,SCREEN_WIDTH-50),randint(0,SCREEN_HEIGHT-10),choice(messages))
        sleep(0.2)

    #Avslutt spillet
    win.close()
    sys.exit(0)
Esempio n. 2
0
def publicationDetails(p):
    # p is the passed publication name
    search_query = scholarly.search_pubs(p)
    pd = next(search_query).fill()

    print(pd.bibtex)
    timer.sleep(5)
Esempio n. 3
0
def check_arguments():
    if len(sys.argv) is not 3:
        print("Arguments Mismatch, Try Again.")
        for i in range(1, 10):
            print("Wait %d" % i)
            timer.sleep(1)
        exit()
    else:
        global input_file
        global output_file
        input_file = sys.argv[1]
        output_file = sys.argv[2]
        if not os.path.exists(input_file):
            print("Input File not Found.")
            exit()
        else:
            purge_file()
Esempio n. 4
0
def main():
    try:
        is_one_player, game_length, bot_depth, is_player_white = screen.starting_screen(
        )
        timer.set_game_length(game_length)
        screen.add_squares_to_board()
        white_team = Team(True)
        black_team = Team(False)
        place_pieces(white_team, black_team)
        bot_team = black_team if is_player_white else white_team
        game_loop(white_team, black_team, is_one_player, bot_depth, bot_team)

    except exceptions.UserExitGame:
        return

    except exceptions.GameEnd:
        print("Game ended.")
        timer.sleep(10)
        # TODO: Return to main screen.
        return
Esempio n. 5
0
def testReturn(logger):
    timer.sleep(random.random())
    logger.debug('going to return')
    return ['o', 'u', 'c', 'h']
Esempio n. 6
0
def testRaise(logger):
    timer.sleep(random.random())
    logger.debug('going to raise an error!')
    raise Exception("ouch!")
Esempio n. 7
0
    print(i, n)
    # Get address
    searchresult = cg.address(street=geodata['street'].iloc[i], city=geodata['city'].iloc[i], state=geodata['state'].iloc[i], zipcode=geodata['zip'].iloc[i])

    percentage = round((i/n), 5)
    sys.stdout.write("\033[F") # Cursor up one line
    print('address {} downloading...\t{} done'.format(i, percentage))

    # If address search result empty, continue to next, else, save info
    if searchresult is []:

        # Info
        print('\t\n no results found! Retrying downloading ...')

        # wait 3 sec and retry, if then still empty, continue
        timer.sleep(3)
        searchresult = cg.address(street=geodata['street'].iloc[i], city=geodata['city'].iloc[i], state=geodata['state'].iloc[i], zipcode=geodata['zip'].iloc[i])

        if searchresult is []:
            print('\t\n no results found!')
            continue
    else:

        # Save infos
        try:
            geodata.at[i, 'matchedAddress'] = searchresult[0]['matchedAddress']
            geodata.at[i, 'x'] = searchresult[0]['coordinates']['x']
            geodata.at[i, 'y'] = searchresult[0]['coordinates']['y']
            geodata.at[i, 'tigerLineId'] = searchresult[0]['tigerLine']['tigerLineId']
            geodata.at[i, 'side'] = searchresult[0]['tigerLine']['side']
            geodata.at[i, 'SUFFIX'] = searchresult[0]['geographies']['2010 Census Blocks'][0]['SUFFIX']
Esempio n. 8
0
def func1():
    i = 0
    while True:
        timer.sleep(1)
        i += 1
        print(i//3600,(i//60)%60,i%60,sep=':')
Esempio n. 9
0
def testReturn(logger):
    timer.sleep(random.random())
    logger.debug('going to return')
    return ['o', 'u', 'c', 'h']
Esempio n. 10
0
def testRaise(logger):
    timer.sleep(random.random())
    logger.debug('going to raise an error!')
    raise Exception("ouch!")
Esempio n. 11
0
def func(bis=2):
    sleep(bis)