def run_user_interface() -> None:
    print('FULL')

    (game_class.BOARD_COLUMNS, game_class.BOARD_ROWS, game_class.BOARD_INPUT,
     game_class.TURN, game_class.WINNING_RULE) = get_board()
    Game = game_class.game()
    while not Game.game_over():
        Game.print_count()
        Game.print_board()
        Game.print_turn()
        game_progress(Game)
    Game.get_winner()
 def _start_game(self) -> None:
     self._set_button = tkinter.Button(master=self._board_window,
                                       text='New game',
                                       command=self._start_new_game).grid(
                                           row=5, column=0)
     game_class.BOARD_INPUT = self.board_input
     self.Game = game_class.game()
     self._canvas.bind('<Configure>', self._draw_the_board)
     self._update_info()
     if self.Game.game_over():
         self._end_game()
     else:
         self._canvas.bind('<Button-1>', self._make_move)
def randomGame(n=1):
    """Runs tic_tac_toe gameObj a number of defined times with random style of gameObjplay"""
    for _ in range(n):
        gameObj = game()

        playFirst = randint(1, 2)
        for moveCount in range(4):
            index1 = randint(0, 2)
            index2 = randint(0, 2)
            if playFirst == 1:
                while gameObj.emptyCheck(index1, index2) == False:
                    index1 = randint(0, 2)
                    index2 = randint(0, 2)
                gameObj.insert(1, index1, index2)  #insert player onto board

                #Checks for winner
                if moveCount > 2:
                    if gameObj.winCheck(1) == True or gameObj.winCheck(
                            2) == True:
                        break

                while gameObj.emptyCheck(index1, index2) == False:
                    index1 = randint(0, 2)
                    index2 = randint(0, 2)
                gameObj.insert(2, index1, index2)
            else:
                while gameObj.emptyCheck(index1, index2) == False:
                    index1 = randint(0, 2)
                    index2 = randint(0, 2)
                gameObj.insert(2, index1, index2)

                #Checks for winner
                if moveCount > 2:
                    if gameObj.winCheck(1) == True or gameObj.winCheck(
                            2) == True:
                        break

                while gameObj.emptyCheck(index1, index2) == False:
                    index1 = randint(0, 2)
                    index2 = randint(0, 2)
                gameObj.insert(1, index1, index2)

            # gameObj.printBoard()
            # print("")
            #Checks if there is a winner after the 2nd cycle
            if moveCount > 2:
                if gameObj.winCheck(1) == True or gameObj.winCheck(2) == True:
                    break

        if gameObj.winCheck(1) == True:
            print("Player one wins!")
        elif gameObj.winCheck(2) == True:
            print("Player two wins!")
        else:
            index1 = randint(0, 2)
            index2 = randint(0, 2)
            if playFirst == 1:
                while gameObj.emptyCheck(index1, index2) == False:
                    index1 = randint(0, 2)
                    index2 = randint(0, 2)
                gameObj.insert(1, index1, index2)
            else:
                while gameObj.emptyCheck(index1, index2) == False:
                    index1 = randint(0, 2)
                    index2 = randint(0, 2)
                gameObj.insert(2, index1, index2)
            if gameObj.winCheck(1) == True:
                print("Player one wins!")
            elif gameObj.winCheck(2) == True:
                print("Player two wins!")
            else:
                print("It's a tie!")
Exemple #4
0
import pygame
import map_class
import player_class
import game_class
import commands

game_1 = game_class.game()

monster_list = {21: player_class.zombie, 25: player_class.chest_armour_zombie}

game_1.new_map(100, 100, 16, monster_list, 7)

game_1.new_screen(625, 625)

game_1.player.weapons = ["claws", "tester melee"]

while 1:
    game_1.screen.fill((255, 255, 255))
    game_1.draw()
    pygame.display.flip()

    command = raw_input("<-->")

    if command == "quit":
        print "quiting...."
        break

    commands.commands(game_1, command)
Exemple #5
0
        continue

    # HANDSHAKE
    if data['action'] == "handshake":

        # Vars
        ses_id = data['session_id']
        confirm = "no"
        name = data['user']

        # New session
        if ses_id == 0:
            ses_id = len(sessions) + 1

            # Create new session
            new_session = game_class.game(ses_id)
            sessions.append(new_session)

            # Add user
            confirm, name = new_session.set_player(name, addr, conn)

        # Join session
        else:
            # Add user
            confirm, name = sessions[ses_id - 1].set_player(name, addr, conn)

        # Sent confirmation
        to_sent = {
            "action": "handshake",
            "session_id": ses_id,
            "user": name,