示例#1
0
def select_option_li(connection, existing_users):

    current_user = users.logged_in_user(connection)

    # Print the currently logged in username
    print('You are currently logged in as {}'.format(current_user))

    # Asking user for an option
    print('Select any of the following options:')
    option = input('1) {}\n2) {}\n3) {}\n'.format('Continue', 'SignOut', 'quit'))

    if option == '1':
        # Passing current user and user's tasks as arguments
        gui.display(connection, current_user, database.get_tasks(connection, current_user))
    elif option == '2':
        users.sign_out(connection, existing_users)
    elif option == '3':
        return
    else:
        print('Invalid option chosen! Please retry!\n')
        select_option_li(connection, existing_users)
 def display(self):
     """
     Displays this Dealer's current configuration in a graphical window
     """
     text = gui.render_dealer(self)
     gui.display(text)
示例#3
0
import sys
import fsa
import gui


def handleInput(fsm, input):
    f = open(input, 'r')
    s = f.read()

    if fsm.isLegal(s):
        print(f'{s} is legal!')
    else:
        print(f'{s} not legal...')


if __name__ == "__main__":
    # main logic
    if len(sys.argv) < 3:
        print('ERROR: too few command-line args')
    else:
        fsaFile = sys.argv[1]
        inputFile = sys.argv[2]

        fsm = fsa.FSA()
        fsm.fromFile(fsaFile)

        handleInput(fsm, inputFile)
        gui = gui.GUI()
        gui.build(fsm)
        gui.display()
示例#4
0
def main(players, display_gui):
    if display_gui:
        import gui
        screen = gui.start()
    
    player_names = []
    for player in players:
        player_names.append(player.__file__.split('/')[-1])
    
    print("Starting game.")
    print("Players:", player_names)
    max_turns_per_round = MAX_NUM_TURNS_PER_PLAYER * len(players)
    
    total_scores = [0] * len(players)
    for rnd in range(1, 11): #12): # 11 rounds -> 10 rounds to make it faster
        print("\n\nStarting round " + str(rnd) + " (" + str(rnd+2) + " cards per player)")
        
        deck = get_deck() + get_deck()
        random.shuffle(deck)
        
        # deal cards to each player, removing them from deck
        hands = get_starting_hands(deck, len(players), rnd+2)
        
        stock = deck # rest of cards form deck
        discard_pile = [stock.pop()] # turn up one card from stock
                
        wildcard_rank = rnd   # round 1 = THREE (1); round 2 = FOUR (2), etc.
        
        winning_player = -1
        picked_up_discard_cards = []
        for i in range(len(players)):
            picked_up_discard_cards.append([])

        cur_player = 0
        num_turns_this_round = 0
        while True: # give each person a turn until round ends
            #print("Stock", hand_to_string(stock))
            #print("Discard pile", hand_to_string(discard_pile))
            
            if cur_player == winning_player:
                # play has come back around, so end the round
                print("Round over.")
                break
            elif num_turns_this_round > max_turns_per_round:
                print("Number of turns exceeded limit, ending round due to timeout.")
                break
            
            print("\n\nRound", rnd, "turn", num_turns_this_round, "(wildcard: " + RANKS_STR[wildcard_rank] + ")")
            player_won = player_turn(players[cur_player], player_names[cur_player], cur_player, hands[cur_player], discard_pile, stock, winning_player, picked_up_discard_cards, wildcard_rank, num_turns_this_round)
            #input("End of turn. Press [return] to continue.")
            if display_gui:
                gui.display(screen, hands, discard_pile[-1], total_scores)
            if player_won and winning_player == -1: # player arranged all their cards and no one has gone out yet
                print("Player has gone out. Giving everyone a final turn.")
                hands[cur_player] = []
                winning_player = cur_player # end the game at the winning player's next turn
            
            cur_player = (cur_player + 1) % len(players)
            num_turns_this_round += 1
        
        # round end
        print("\n\nEnd of round " + str(rnd) + ". Arranging everyone's hands.")
        input("Press [return] to continue.")
        
        # arrange players' hands as much as possible
        for cur_player in range(len(players)):
            arrangement = get_arrangement(tuple(sorted(hands[cur_player])), wildcard_rank)
            # remove all arranged cards from their hand
            for seq in arrangement:
                for card in seq:
                    hands[cur_player].remove(card) # removes first matching element
        
        # tally points of non-arranged cards
        round_end(player_names, hands, total_scores) # modifies total scores
        if display_gui:
            gui.display(screen, hands, total_scores)
        else:
            input("Press [return] to continue.")
    
    # determine winner
    winner = calculate_winner(total_scores)
    print("Player", winner, "has won!")
    if display_gui:
        gui.stop()
示例#5
0
 def display(self):
     """
     Displays this PlayerState configuration in a graphical window
     """
     text = gui.render_player(self)
     gui.display(text)
示例#6
0
import cv2
import gui

import argparse

parser = argparse.ArgumentParser(description='Threshold some images')
parser.add_argument('image', type=str, help='Path to an image')
args = parser.parse_args()

image = cv2.imread(args.image)

while True:
    gui.display(image)
    try:
        gui.refresh()
    except KeyboardInterrupt:
        break

gui.close()
示例#7
0
import gui
from editor import *

p = Pict()

gui = gui.display(p)

gui.mainloop()
示例#8
0
        output = str(self.state)            + "," \
               + str(self.throttleAxis)     + "," \
               + str(self.xAxis)            + "," \
               + str(self.yAxis)            + "," \
               + str(self.turnAxis)
        #print output
        self.commsLock.release()
        return output

    def processPacket(self,packet):
        self.commsLock.acquire()
        if len(packet.split("\t")) == 3:
            #print "[Server Reply] " + str(packet)
            self.gyro = [float(i) for i in packet.split("\t")[0:3]]
            print self.throttleAxis
        self.commsLock.release()

c = Controls()

while True:
    c.update()
    axes = [c.xAxis, c.yAxis, c.turnAxis, c.throttleAxis]
    indicators = [("Gamepad", c.gamepad.isConnected),   \
                  ("Ping", c.comms.isServerPingable),       \
                  ("Comms", c.comms.isConnected)]
    #print axes
    #print c.gamepad.get("LB"), c.gamepad.get("RB")
    gui.display(Controls, c.state, axes, c.gyro, indicators, None, None)

    time.sleep(0.05)
示例#9
0
 def test_display(self):
     gui.display(gui.render_dealer(self.dealer_1))
     gui.display(gui.render_player(self.player_1))