Exemplo n.º 1
0
def reset_game():
    constants.BOARD = classes.Board(constants.START_POS, 0)
    constants.BOARD_DEAD = classes.Board(constants.DEAD_POS, 8)
    constants.TURN = 1
    constants.CHECK = 0
    constants.RUNNING = True

    constants.MOVES = 0
    constants.ROUND_COUNT += 1
Exemplo n.º 2
0
import classes

board = classes.Board()
player = classes.Player()

for i in range(100):
    player.turn(board)
    space = player.getCurrentSpace(board)
    print(space.spaceType)
    print(space.name)
    if space.spaceType == "card_space":
        if space.cardType == "Chance":
            print("take a chance")
            card = board.drawChance(player)
            print(card.message)
        elif space.cardType == "Chest":
            print("take a chest")
            card = board.drawChest(player)
            print(card.message)

    input()
Exemplo n.º 3
0
FIELD_CHOSEN = 0
FIELD_MOVE = 0
############################



########## BOARDS ##########
START_POS = [[[2,2],[2,3],[2,4],[2,5],[2,6],[2,4],[2,3],[2,2]],
             [[2,1],[2,1],[2,1],[2,1],[2,1],[2,1],[2,1],[2,1]],
             [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],
             [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],
             [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],
             [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],
             [[1,1],[1,1],[1,1],[1,1],[1,1],[1,1],[1,1],[1,1]],
             [[1,2],[1,3],[1,4],[1,5],[1,6],[1,4],[1,3],[1,2],[0,0]]]
BOARD = classes.Board(START_POS, 0)

DEAD_POS = [[[0,0],[0,0],[0,0],[0,0]],
            [[0,0],[0,0],[0,0],[0,0]],
            [[0,0],[0,0],[0,0],[0,0]],
            [[0,0],[0,0],[0,0],[0,0]],
            [[0,0],[0,0],[0,0],[0,0]],
            [[0,0],[0,0],[0,0],[0,0]],
            [[0,0],[0,0],[0,0],[0,0]],
            [[0,0],[0,0],[0,0],[0,0]]]
BOARD_DEAD = classes.Board(DEAD_POS, 8)

MARKER_COLOR = (255,0,0)
FIELD_SIZE = 100
############################
Exemplo n.º 4
0
 def __init__(self, playerCount, boardFilePath="./boards/UK.board"):
     self.players = [classes.Player() for _ in range(playerCount)]
     self.board = classes.Board(boardFilePath)
Exemplo n.º 5
0
def game():
    clear()
    print("Hello Player!")
    print("Welcome to blacjack!")

    player = cl.Player()
    computer = cl.Computer()
    deck = cl.Deck()
    board = cl.Board()

    while True:
        #new game
        player.new_game()
        computer.new_game()

        #Player give a bet
        print(f"Your credits equals {player.money}$")
        board.bet = player.bet()
        game_continue()
        clear()
        deck.shuffle()

        #Players takes cards
        for i in range(0, 2):
            player.take_card(deck.pop_card())
            computer.take_card(deck.pop_card())

        #lambda expressions
        value_player = lambda: deck.player_value(player.hand)
        value_computer_one = lambda: deck.player_value([computer.hand[0]])
        value_computer = lambda: deck.player_value(computer.hand)

        board_print_one_card = lambda: board.table_one_card(
            player.hand, value_player(), computer.hand, value_computer_one())
        board_print_all_cards = lambda: board.table_all_card(
            player.hand, value_player(), computer.hand, value_computer())

        #Printing first board
        board_print_one_card()

        #True if BUST
        bust = lambda a: board.do_bust(deck.player_value(a))

        #Hit or Stand while not BUST or Stand
        while not bust(player.hand) and player.hit_or_stand():
            player.take_card(deck.pop_card())
            board_print_one_card()

        #Computer takes cards if player not bust and has less points than player
        if not bust(player.hand):
            while value_computer() < value_player():
                computer.take_card(deck.pop_card())

        board_print_all_cards()

        #checking who win
        if bust(player.hand):
            print("Player BUST")
            print("Computer WINS")
        elif bust(computer.hand):
            print("Computer BUST")
            print("Player WINS")
            player.money += 2 * board.bet
        elif value_player() > value_computer():
            print("Player WINS")
            player.money += 2 * board.bet
        elif value_player() == value_computer():
            print("DRAW")
            player.money += board.bet
        else:
            print("Computer WINS")

        #does player have any money?
        if player.money == 0:
            print("You are out of cash!")

        #pleyer out of money or wants to end the game
        if player.money == 0 or end_of_game():
            print("Thank you for game!")
            if player.money != 0:
                print(f"Your credits equals {player.money}$")
            break
        else:
            clear()
Exemplo n.º 6
0
""" This is the main game. """
import classes
import control
import interactions

BOARD = classes.Board()
POSITIONS = classes.Positions()
BOARD.update_board(POSITIONS.get_positions())
BOARD.show_board()

print(
    '--------------------------------------------------------------------\n' +
    '|              Welcome to "Check yourself, mate!"                  |\n' +
    '--------------------------------------------------------------------\n' +
    '\nTo play you simply take turns entering your moves according to\n' +
    'the format <start position><end position>, for example  "E2E4"\n' +
    'would move the piece from E2 to the square E4.\n\n')
NAMES = interactions.request_player_name()

PLAYERS = []
# Set player names
for name in NAMES:
    PLAYERS.append(classes.Player(name))

# Assign teams. Happens just before starting each the game loop.
SECOND_TEAM = PLAYERS[0].assign_first_team()
PLAYERS[1].assign_second_team(SECOND_TEAM)
QUEUE = classes.player_queue(PLAYERS)

# Start play loop
GAME_STATUS = True