コード例 #1
0
ファイル: memory.py プロジェクト: mikyman/Public
def main_menu():
    options = [4, 4]  #  Length, Height of Gamefield
    while True:
        clearscreen.clear()
        draw_banner('Memory')
        print('\t1) New Game')
        print('\t2) Options')
        # print('\t3) Game Rules')
        print('\t0) Exit Game')
        print()
        user_input = input("   Please choose a number: ")

        clearscreen.clear()
        if not user_input:
            continue

        if user_input[0] in COMMANDS:
            user_input = user_input[0]
            print()
            if user_input == '1':
                COMMANDS[user_input](options)  # function call with param
            elif user_input == '2':
                options = COMMANDS[user_input](
                    options)  # function call with param and return
            else:
                COMMANDS[user_input]()  # only a function call
コード例 #2
0
def welcome_message():
    '''The first welcome message'''
    clear()

    #The welcome message
    welcome_message = open('files/messages/welcome_message.txt', 'r').read()
    print(welcome_message.format(params['company_name']))

    #Calling the login_deptno function
    login_deptno()
コード例 #3
0
ファイル: bitmapfont.py プロジェクト: Emantor/mensactrl
def test():
    clearscreen.clear()
    client.write(0,0,"Hello World!")
    x = 0
    y = 1
    for c in sorted(FONT.keys()):
        client.blit(x*client.PWIDTH, y*client.PHEIGHT,
            client.PWIDTH, client.PHEIGHT, client.char_to_pixel_segment(c))
        x += 1
        if(x > 15):
            x = 0
            y += 1
コード例 #4
0
ファイル: memory.py プロジェクト: mikyman/Public
def init_game():
    list_of_players = []
    for i in range(get_number_of_players()):
        clearscreen.clear()
        draw_banner('Game Menu')
        while True:
            name = get_name_of_player(i + 1, list_of_players)
            if not is_name_in_list(name, list_of_players):
                list_of_players.append(Player(name))
                break
    shuffle(list_of_players)
    return list_of_players
コード例 #5
0
def test():
    clearscreen.clear()
    client.write(0, 0, "Hello World!")
    x = 0
    y = 1
    for c in sorted(FONT.keys()):
        client.blit(x * client.PWIDTH, y * client.PHEIGHT, client.PWIDTH,
                    client.PHEIGHT, client.char_to_pixel_segment(c))
        x += 1
        if (x > 15):
            x = 0
            y += 1
コード例 #6
0
def logout(userid):
    db.execute(f'UPDATE login SET session_out="{datetime.now()}" WHERE userid="{userid}" AND session_out="0000%"')
    connection.commit()

    clear()

    print(f'You have been logged out!!! {userid}')
    print('The window is closing the 2 sec')
    time.sleep(2)

    clear()
    sys.exit()
コード例 #7
0
def consumerDetails():
    '''This function is the view page for the customers bill generation'''

    clear()

    db.execute('SELECT consumerno from customer')
    detailsconsumerno = db.fetchall()

    mydate = datetime.datetime.now()

    while True:
        try:
            consumerno = int(input('Please enter your consumer no.\n'))
        except ValueError:
            print()
            print("Please enter a valid consumer no")

        if (consumerno, ) not in detailsconsumerno:
            print()
            print(
                'The consumer no does not exists!! \nPlease enter a valid consumer no'
            )
        else:
            break

    db.execute(
        f'SELECT * from customer where consumerno={consumerno} AND month="{mydate.strftime("%B")}"'
    )
    custdetails = db.fetchall()[0]

    if custdetails[-1] == 0:
        print('No bill is not generated for this month!')
    else:
        my_file1 = path.join(THIS_FOLDER, 'files', 'messages',
                             'custdetails.txt')
        with open(my_file1, 'r') as c1:
            fileread = c1.read()
            print(
                fileread.format(params['company_name'], custdetails[3],
                                custdetails[1], custdetails[2], custdetails[4],
                                custdetails[5], custdetails[-1],
                                custdetails[8], custdetails[9]))

    print()
    print('Press anything the exit!!!')
    input()
    print(
        f"Thank you for using the {params['company_name']} ELECTRICITY CUSTOMER DEPARTMENT SERVICES"
    )
    time.sleep(2)
    sys.exit()
コード例 #8
0
ファイル: title.py プロジェクト: imcooley/forest_adventure
def help_menu():
    clear()
    print(
        "Really?! Either play the game or don't... but stop wasting my time.")
    print("Are you ready to try again?")
    print("Yes or No")

    ready = input("> ").lower()
    if ready in ("yes", "y", "1", "ye", "t", "tr", "true"):
        title_screen()
    elif ready in ("no", "n", "2", "f", "false", "fal"):
        sys.exit()
    else:
        sys.exit()
コード例 #9
0
ファイル: scene.py プロジェクト: imcooley/forest_adventure
def get_left_path(pi):
    clear()
    print("The least appealing of the three options, you must be daring.")
    print("This place is dark, danky, and has a odd, almost coppery smell.\n")
    print("After walking through narrow paths for what feels like hours")
    print("you come to a clearing. As you step into the clearing a bright")
    print(
        "peircing light practically blinds you. You fall down to your knees.")
    print("As you look up an angel is standing in front of you. ")
    print("\n ")

    for left_path_item in left_path_items:
        print(left_path_item.capitalize())

    left_path_item = input("> ").lower()
コード例 #10
0
ファイル: gamefield.py プロジェクト: mikyman/Public
    def print_board(self):
        game_board = self.__build_board()
        clearscreen.clear()
        # print head of table
        print()
        print(end='   ')
        for i in range(self.LENGTH):
            print('   {}'.format(i + 1), end='')
        print()
        print('    {}'.format(self.board[0]))

        for column in range(self.HEIGHT):
            print('    {} {}'.format(game_board[column], (column + 1)))
            if column < self.HEIGHT - 1:
                print('    {}'.format(self.board[2]))
        print('    {}'.format(self.board[-1]))
        return 0
コード例 #11
0
ファイル: scene.py プロジェクト: imcooley/forest_adventure
def get_middle_path(pi):
    clear()
    print("\nTaking the middle ground you walk forward."
          "\nAt first this seem like the rest of the forest. Ah, how peaceful!"
          "\n\n\n\t\t\t***LEAVES RUSTLE***"
          "\n\n\nYou are met by a beautiful dryad, an evil looking witch, "
          "and a massive centuar."
          "\nWitch:Three paths before you, three behind."
          "Dryad: Don't be mislead, follow your head."
          "Centuar: For if you don't you will surely will be dead."
          "\nThey seem to want you pick one of them, though the choice seems "
          "dubious."
          "\nWhom do you pick?")

    for key in middle_path_creatures.keys():
        print(key.capitalize())
    middle_path_creature = input("> ").lower()
    if middle_path_creature in middle_path_creatures:
        # If creature exists continue
        if pi.player_class in middle_path_creatures[middle_path_creature][
                'loves']:
            print(middle_path_creatures[middle_path_creature]['classlove'])
            get_mid_point(pi)
        elif pi.player_race in middle_path_creatures[middle_path_creature][
                'loves']:
            print(middle_path_creatures[middle_path_creature]['racelove'])
            get_mid_point(pi)
        elif pi.player_class in middle_path_creatures[middle_path_creature][
                'hates']:
            print(middle_path_creatures[middle_path_creature]['classhate'])
        elif pi.player_race in middle_path_creatures[middle_path_creature][
                'hates']:
            print(middle_path_creatures[middle_path_creature]['racehate'])
        elif pi.player_class in middle_path_creatures[middle_path_creature][
                'neutral']:
            print(middle_path_creatures[middle_path_creature]['classneutral'])
            get_mid_point(pi)
        elif pi.player_race in middle_path_creatures[middle_path_creature][
                'neutral']:
            print(middle_path_creatures[middle_path_creature]['raceneutral'])
            get_mid_point(pi)
    else:
        get_middle_path(pi)
コード例 #12
0
def delete_user(userid,logintime):
    clear()
    #Department No dictionary
    db.execute('SELECT useradmin_id FROM user')
    sqlquery = db.fetchall()
    #Asking to enter the department no
    while True:
        UserAdminId = input('Enter the UserAdminId \n')

        if (UserAdminId,) in sqlquery:
            break
        else:
            print(f'{UserAdminId} UserAdminId is not valid \n Please enter a valid UserAdminId !')

    db.execute(f'DELETE FROM user WHERE useradmin_id="{UserAdminId}"')
    connection.commit()
    print('The user succesfully deleted')
    time.sleep(1)
    adminHome(userid,logintime)
コード例 #13
0
def player_name():
    clear()
    counter = 0
    max_attempts = 5
    while True:
        if counter != None and counter > max_attempts:
            sys.exit()
        print("What's your name")
        name = input(">> ").lower()
        try:
            if not name:
                raise ValueError
        except ValueError:
            print(f"Please enter your name, you have {max_attempts - counter}" \
            " attempts left before exiting.")
            counter += 1
        else:
            clear()
            return name
コード例 #14
0
ファイル: memory.py プロジェクト: mikyman/Public
def new_game(option_list):
    print('\tWelcome to the Memory Game.')
    print()
    player_list = init_game()
    while True:
        clearscreen.clear()
        game = gamefield.Gamefield(option_list[0], option_list[1])
        for player in player_list:
            player.reset_points()

        # changed player until board is not empty
        i = 0
        length_of_playerlist = len(player_list)
        while not game.bord_is_empty():

            player_list[i].add_trials()
            game.print_board()
            choice_return = game.choose_field(player_list[i].name)
            print()

            if choice_return == 2:  # Mainmenu
                clearscreen.clear()
                return

            elif choice_return == 0:  # No error
                print(' hmm... maybe next time...')
                i = (i + 1) % length_of_playerlist
                print('\n  {}'.format(player_list[i].get_name()))

            elif choice_return == 1:  # right try
                player_list[i].add_pairs()
                print('  Right! Keep it up!')

                if not game.bord_is_empty():
                    print()
                    print('  {} It\'s your turn again'.format(
                        player_list[i].get_name()))

            input(' Press Enter to continue...')

        clearscreen.clear()
        player_list = sort_player_list(
            player_list)  # sorted Player after numbers of pairs and Trials
        Player.print_statistics_head()  # print the first player in table
        for player in player_list:
            player.print_statistics_body()  # print all other player

        if not input('\n  Play again?(Y/N) ').lower().startswith('y'):
            clearscreen.clear()
            break
コード例 #15
0
def adminHome(userid,logintime):
    #Here userinput is for the functioncode coming from the other function   
    '''This the admin homepage'''

    clear() #Clear the screen

    #The admin welcome message
    admin_message = open('files/messages/admin_message.txt','r').read()
    print(admin_message.format(params['company_name'],userid,logintime,datetime.now()))
        
    userinput=input()

    funcAdminTuple = ('01#01','05#02','06#03','04#01','00#01','02#01','07#44','03#01')

    if userinput not in funcAdminTuple:
        clear() #Clear the screen
        adminHome(userid,logintime)
    
    else:
        if userinput=='01#01':
            create_user(userid,logintime)
        elif userinput=='05#02':
            delete_user(userid,logintime)
        
        elif userinput=='06#03':
            dumpdata('customer',userid,logintime)
        elif userinput=='07#44':
            dumpdata('user',userid,logintime)
        
        elif userinput=='03#01':
            exportdatatoTable(userid,logintime)

        elif userinput=='02#01':
            bilGenHome(userid, logintime)
        elif userinput=='04#01':
            bilEmailHome(userid, logintime)

        #For the Logout
        elif userinput=='00#01':
            logout(userid)
コード例 #16
0
def player_class():
    clear()
    counter = 0
    max_attempts = 5
    player_classes = ['cleric', 'mage', 'warrior']
    while True:
        if counter != None and counter > max_attempts:
            sys.exit()
        print("What class would you like to play")

        for player_class in player_classes:
            print(player_class.title())

        player_class = input(">> ").lower()
        try:
            if player_class not in player_classes:
                raise ValueError
        except ValueError:
            print(f"Pleaes select a vaild race {max_attempts - counter}" \
            " attempts left before exiting.")
            counter += 1
        else:
            return player_class
コード例 #17
0
def player_race():
    clear()
    counter = 0
    max_attempts = 5
    player_races = ['dwarf', 'elf', 'human']
    while True:
        if counter != None and counter > max_attempts:
            sys.exit()
        print("What race would you like to play")

        for player_race in player_races:
            print(player_race.title())

        player_race = input(">> ").lower()
        try:
            if player_race not in player_races:
                raise ValueError
        except ValueError:
            print(f"Please select a vaild race {max_attempts - counter}" \
            " attempts left before exiting.")
            counter += 1
        else:
            return player_race
コード例 #18
0
ファイル: title.py プロジェクト: imcooley/forest_adventure
def title_screen():
    clear()
    print("""
    #####################################
    ###   Welcome to Elduwin Forest   ###

                ,@@@@@@@,
        ,,,.   ,@@@@@@/@@,  .oo8888o.
        ,&%%&%&&%,@@@@@/@@@@@@,8888\88/8o
    ,%&\%&&%&&%,@@@\@@@/@@@88\88888/88'
    %&&%&%&/%&&%@@\@@/ /@@@88888\88888'
    %&&%/ %&%%&&@@\ V /@@' `88\8 `/88'
    `&%\ ` /%&'    |.|        \ '|8'
        |o|        | |         | |
        |.|        | |         | |
    \\/ ._\//_/__/  ,\_//__\\/.  \_//__/_
    #####################################
                    - Play -
                    - Help -
                    - Quit -
    """)
    print(f"    ###     Copyright {todays_date.year} imcooley   ###")
    title_screen_selections()
コード例 #19
0
def bilEmailHome(userid, logintime):
    '''This is the bill generation department homepage function'''

    mydate = datetime.now()
    clear()  #Clear the screen

    billGenAdmin_message = open('files/messages/billEmailnotAdmin_message.txt',
                                'r').read()
    funcAdminTuple = ('01#02', '00#01')

    print(
        billGenAdmin_message.format(params['company_name'], userid, logintime,
                                    datetime.now(), mydate.strftime("%B")))
    userinput = input()

    if userinput not in funcAdminTuple:
        clear()  #Clear the screen
        bilEmailHome(userid, logintime)

    else:
        if userinput == '01#02':
            sendmailtocustomers(userid, logintime)
        elif userinput == '00#01':
            logout(userid)
コード例 #20
0
def login_user(deptno):
    '''This is the login screen'''
    clear()

    print()
    print('Now please enter your login credentials')
    print('---------------------------------------')
    userid = input('Please enter your USERID\n')
    print('---------------------------------------')
    password = input('Please enter your password\n')
    hashpass = hashlib.md5(password.encode())

    db.execute(
        f'SELECT * FROM user WHERE password="******" AND dept_no="{deptno}" AND useradmin_id="{userid}";'
    )
    query = db.fetchall()

    if query == None or query == []:
        print('The given credentials where wrong')
        print('Please wait for 2 sec!')
        time.sleep(2)
        welcome_message()
    else:
        login_user_in(userid, hashpass.hexdigest(), deptno)
コード例 #21
0
ファイル: memory.py プロジェクト: mikyman/Public
def options_menu(option_list):
    clearscreen.clear()
    length, height = option_list
    while True:
        draw_banner('Options Menu')
        print('\tGamefield Settings')
        print()
        print('\t(L)ength: {}'.format(length))
        print('\t(H)eight: {}'.format(height))
        print()
        print('     (R)eturn    (S)ave settings')
        print()
        print('    Please choose the first letter')
        user_input = input('     (L or H etc.): ')

        clearscreen.clear()
        if not user_input:
            continue
        if user_input[0].lower() in ['l', 'h', 'r', 's']:
            user_input = user_input[0].lower()
            while True:
                try:
                    if user_input == 'l':
                        length = int(input('\n  Enter length (1-9): '))
                    elif user_input == 'h':
                        height = int(input('\n  Enter height (1-9): '))
                except ValueError:
                    print('Please enter only Integer!')
                except Exception as e:
                    print(e)
                else:
                    clearscreen.clear()
                    break

            # go back without saveing
            if user_input == 'r':
                return option_list

            elif user_input == 's':
                if 4 <= length * height <= 81 and 1 <= length <= 9 and 1 <= height <= 9:
                    return [length, height]
                else:
                    print(
                        '\n The valid range of (LENGTH x HEIGHT) must be between 4 and 81!'
                    )
                    print(
                        ' And the valid range of LENGTH and HEIGHT must be between 1 and 9!'
                    )
コード例 #22
0
ファイル: munching.py プロジェクト: tnias/mensactrl
#!/usr/bin/env python2
import client
import random
import time
import clearscreen

if __name__ == "__main__":
    t = 0
    s = 64
    pixels = [0] * client.HEIGHT * client.WIDTH
    clearscreen.clear()
    while True:
        if t == 63:
            time.sleep(1)
        t = (t + 1) % 64
        for x in range(client.WIDTH):
            for y in range(client.HEIGHT):
                #pixels[s * x + y] = 0 if (y == (x^t)) else 1
                pixels[s * x + y] = 0 if ((x & y & t)) else 255
        client.blit(0, 0, client.WIDTH, client.HEIGHT, pixels)
        print t
        #time.sleep(0.09)
コード例 #23
0
ファイル: mainRun.py プロジェクト: vickyjnv/computer-project
# Electricity bill management
# Computer Science project of class 12-Sc-1
# made by Dhruva, Ayush and Smyan

# import cProfile
# import re
# cProfile.run('re.compile("foo|bar")')
# input()

from datetime import datetime
from os import system
from login import welcome_message
from clearscreen import clear

import mysql.connector as c

connection = c.connect(host='localhost',
                       database='electricity_bill',
                       user='******',
                       password='')
db = connection.cursor()

#__main__
#Checks if the user is already logged in
clear()

db.execute(
    f'UPDATE login SET session_out="{datetime.now()}" WHERE session_out="0000%"'
)
connection.commit()
welcome_message()
コード例 #24
0
ファイル: munching.py プロジェクト: Emantor/mensactrl
#!/usr/bin/python
import client
import random
import time
import clearscreen

if __name__=="__main__":
    t = 0
    s = 64
    pixels = [0] * client.HEIGHT * client.WIDTH
    clearscreen.clear()
    while True:
        if t == 63:
            time.sleep(1)
        t = (t+1) % 64
        for x in range(client.WIDTH):
            for y in range(client.HEIGHT):
                #pixels[s * x + y] = 0 if (y == (x^t)) else 1
                pixels[s * x + y] = 0 if ((x&y&t)) else 255 
        client.blit(0, 0, client.WIDTH, client.HEIGHT, pixels)
        print t
        #time.sleep(0.09)

コード例 #25
0
def create_user(userid23,logintime23):
    '''This function is used to create a user of the software'''
    clear() #Clear the screen
    db.execute('SELECT dept_no, deptname from dept')
    dept = db.fetchall()

    #Printing the department no
    print('     Department No       |             Department name')
    print('------------------------------------------------------------')
    for i,j in dept:
        print(f'      {i}                            {j}   ')
    print('Following are the department no')
    print()

    #Department No dictionary
    db.execute('SELECT dept_no FROM dept')
    sqlquery = db.fetchall()

    #Asking to enter the department no
    while True:
        try:
            deptno1 = int(input('Enter the department no\n'))

            if (deptno1,) in sqlquery:
                break
            else:
                print(f'{deptno1} Department No is not valid \n Please enter a valid department no !')
        except:
            print('Enter no not characters!')
    
    #Asking to enter the name
    name1 = input('Please enter the name\n')
    name=''
    for i in name1: 
        if i.isalpha(): name+=i

    while True:
        #ENTERING THE PASSWORD
        password1 = input('Please enter a password\n')
        password2 = input('Please retype the password\n')
        if password1==password2:
            break
        else:
            clear()
            print('Enter again the two password dosen\'t match!')
    
    hashpass1 = hashlib.md5(password1.encode())
    db.execute(f'SELECT deptname FROM dept WHERE dept_no={deptno1}')
    #Getting the branch name
    branch = db.fetchall()[0][0]

    # generating the useradminid
    db.execute(f'select username from user where username="******"')
    occurence = len(db.fetchall())
    useradminid = f'{deptno1}{occurence+1}{name[:2]}#{branch}'

    #Inserting the data into database
    db.execute(f'INSERT INTO user VALUES(NULL,"{name}","{hashpass1.hexdigest()}","{branch}",{deptno1},"{useradminid}")')
    connection.commit()

    #The admin welcome message
    clear()
    created_message = open('files/messages/create_msg.txt','r').read()
    print(created_message.format(name,password1,branch,deptno1,useradminid))
    print()
    input('Press any key to continue')
    adminHome(userid23,logintime23)
コード例 #26
0
ファイル: scene.py プロジェクト: imcooley/forest_adventure
def get_right_path(pi):
    clear()
    print("Which number represents perfection?")
    print("√49 (Square root of 49)")