コード例 #1
0
 def __init__(self):
     self.gui = gui.GUI()
     self._name = "KARATE CAT"
     self.player1 = None
     self.player2 = None
     # Make sure that there is always a logs file present
     self.save_file = file_handlers.SaveFileHandler()
     self._show_main_screen()
コード例 #2
0
    def play_game(self, game):
        self.game_start_time = time()

        if self.use_gui:
            from gui import gui
            self.game_gui = gui.GUI()
            game.gui = self.game_gui  # I thought this would not be too terrible

        # Main game loop.  Tells players when to take their turn.
        while not game.is_game_over()[0]:
            for player in self.players:
                if game.is_turn(player):
                    action_to_perform = player.take_turn(game)

                    player_info = game.get_player_info(player)
                    if self.use_gui:
                        self.game_gui.update(game)

                    # Perform action.
                    action_result = game.perform_action(
                        player, action_to_perform)

                    player.on_action_complete(game, action_result)

                    # Print results.  This happens after the action is performed so the timing is correct when drawing
                    # destinations.
                    if self.print_debug:
                        game.print_face_up_cards()
                        print "Player %s: %s\nDoing Action: %s" % \
                              (player.name, player_info, action_to_perform)

                        debug_print = player.debug_print(game)

                        if debug_print != "":
                            print debug_print

                        print ""

                    # If the action fails, raise an exception indicating what went wrong.
                    if not action_result[0] and self.exception_on_bad_action:
                        raise Exception("Failure",
                                        FailureCause.str(action_result[1]))

                    if self.pause_between_turns > 0:
                        sleep(self.pause_between_turns)

                    break

        self.game_over(game)
        if self.use_gui:
            self.game_gui.close()
コード例 #3
0
ファイル: main.py プロジェクト: MaciejMarkiewicz/captionizer
from gui import gui

if __name__ == '__main__':
    ui = gui.GUI()
    ui.render()
コード例 #4
0
ファイル: app.py プロジェクト: jviding/DataDaddyPython
from multicast import multicast
from http import http
from gui import gui
import threading
import sys, os

MCAST_GROUP = "224.0.0.251"
MCAST_PORT = 3003
HTTP_PORT = 8080
BASE_PATH = os.path.dirname(os.path.realpath(__file__))

# Create User Interface object
gui = gui.GUI(MCAST_GROUP, MCAST_PORT, BASE_PATH)
# Create http server and inject gui
files_path = BASE_PATH + "/Files"
http = http.HTTP(HTTP_PORT, gui.newDownloadable, files_path)
http.start()
# Create multicast socket and inject gui
multicast.start(MCAST_GROUP, MCAST_PORT, gui.newUser)
# Set gui http functions
gui.setSendFunction(http.sendFile)
gui.setDownloadFunction(http.downloadFile)
# Start gui
gui.start()

# Exit everything, including all threads
os._exit(1)
コード例 #5
0
ファイル: app.py プロジェクト: pyotrr/TM_Grupa3
from gui import gui
from tkinter import Tk

root = Tk()
gui_instance = gui.GUI(root)

root.mainloop()