Exemple #1
0
def cellar(p: Player, scr: Screen) -> bool:

    cards = [i for i in p.current_hand]

    scr.show_main_content([
        "Which cards do you want to discard?",
        "Separate your choices with a comma."
    ] + format_cards(cards, r_main_content.width))

    chosen_cards = input_cards_selection(cards,
                                         scr,
                                         min=1,
                                         max=len(p.current_hand))

    if chosen_cards == []: return False

    p.add_actions(1, scr)

    for card in chosen_cards:
        scr.log("Discarding: {0}".format(card.name))
        p.current_hand.remove(card.name)
        p.discardpile.append(card.name)

    p.draw_cards(len(chosen_cards), scr)

    return True
Exemple #2
0
def refresh():

    is_authenticated = current_user.is_authenticated
    if not is_authenticated:
        return render_template('sessions.html',
                               is_authenticated=is_authenticated)

    # Only authenticated user comes to the following lines
    g = app.g
    # an authenticated user is correctly logged in the game
    if current_user.id not in app.current_user_ids:
        game_login_current_user()

    info = {}
    user_playerids = app.current_user_info[current_user.id]  #[0, 2, 4]
    oppo_playerids = [0, 1, 2, 3, 4, 5]
    info['user_players'] = []
    info['oppo_players'] = []
    info['round_player'] = g.get_round_player_id()
    info['round_cards'] = format_cards(g.get_table()[1])
    info['round_last'] = g.get_table()[0]

    for i in user_playerids:
        player = {}
        player['id'] = i
        player['cards'] = format_cards(g.get_cards(i))
        info['user_players'].append(player)

    for j in oppo_playerids:
        player = {}
        player['id'] = j
        player['cnt'] = g.get_ncards(j)
        info['oppo_players'].append(player)

    #print(url_for('static', filename='cards.css'))

    return render_template('sessions.html',
                           is_authenticated=is_authenticated,
                           online_users=app.current_user_ids,
                           **info)
Exemple #3
0
def chapel(p: Player, scr: Screen) -> bool:

    cards = [i for i in p.current_hand]

    scr.show_main_content([
        "Which cards do you want to remove from your deck?",
        "Separate your choices with a comma."
    ] + format_cards(cards, r_main_content.width))

    chosen_cards = input_cards_selection(cards, scr, min=1, max=4)

    if chosen_cards == []: return False

    for card in chosen_cards:
        p.trash_hand_card(card.name, scr)

    return True
Exemple #4
0
def routine(scr: Screen, p: Player) -> None:
    """
    Store routine. Allows player to view and buy cards.
    """

    content: [] = []
    content.append(
        ("=#= Welcome to the store! =#=".center(r_main_content.width, " "), 1))
    content.append("Any bought item will go onto your discard pile.")
    content.append("Items for sale:")

    content = content + format_cards(list(s_store.keys()),
                                     r_main_content.width,
                                     show_description=True,
                                     show_type=True,
                                     show_cost=True,
                                     custom_lines=[
                                         "  - Left in stock: {0}".format(
                                             s_store.get(i))
                                         for i in list(s_store.keys())
                                     ])

    content.append("You have: {0} (+{1}) - {2} = ${3} left.".format(
        p.current_hand_balance, p.bonus_coins, p.amount_spent,
        p.current_hand_balance + p.bonus_coins - p.amount_spent))

    scr.show_main_content(content)

    done = False
    # while we're not done with buying something, stay in this loop.
    while not done:
        card: Card = input_card_selection(list(s_store.keys()), scr)

        # Check if cards was picked
        if card is None:
            # scr.clear_main_content()
            done = True
            continue

        if (p.purchases_left <= 0):
            scr.log("You don't have any purchases left.", 2)
            continue

        done = purchase_card(p, card.name, scr)

    scr.clear_main_content()
Exemple #5
0
def mine(p: Player, scr: Screen) -> bool:
    money_cards = {}
    for card in p.current_hand:
        if "money" in load_card(card).cardtype:
            money_cards.update({card: card})

    if len(money_cards.keys()) == 0:
        scr.log("No money cards to upgrade!", 2)
        return False

    scr.show_main_content(
        ["Which card do you want to upgrade?"] +
        format_cards(money_cards.keys(), r_main_content.width))

    chosen_card = input_card_selection(list(money_cards.keys()), scr)

    if chosen_card is None: return

    card_name = chosen_card.name

    upgrade_card = ""
    if card_name == "platinum coin":
        scr.log("Sorry, the fun stops here.", 2)
        return False
    elif card_name == "gold coin":
        upgrade_card = "platinum coin"

    elif card_name == "silver coin":
        upgrade_card = "gold coin"

    elif card_name == "copper coin":
        upgrade_card = "silver coin"
    else:
        return False

    if store.gift_card(p, upgrade_card, scr, pile="hand"):
        p.trash_hand_card(money_cards[card_name], scr)
        return True
    else:
        return False
Exemple #6
0
def routine(p: Player, scr: Screen) -> None:
    """
    Action routine. Allows player to play action cards.
    """
    if p.actions_left <= 0:
        scr.log("You don't have any actions left.", 2)
        return
    action_cards: [str] = [
        card for card in p.current_hand if "action" in load_card(card).cardtype
    ]
    if len(action_cards) == 0:
        scr.log("You don't have any action cards to play.", 2)
        return

    scr.show_main_content(["Which action do you want to play?"] + format_cards(
        action_cards, r_main_content.width, show_description=True))

    card: Card = input_card_selection(action_cards, scr)

    if card is None: return

    perform_action(p, card.name, scr)
Exemple #7
0
while c != "q":
    main_screen.move_cursor_to_userinput()

    # Update screen regions
    main_screen.update_top_dynamic_values(mainguy.get_deck_score())
    main_screen.update_hand_card(mainguy.get_hand_cards())

    # Display cards in hand
    card_set = {}
    for card in mainguy.current_hand:
        card_set[card] = card_set.get(card, 0) + 1

    content = []
    content.append(("=#= Cards currently in your hand: =#=".center(r_main_content.width, " "), 1))
    content = content + format_cards([card for card in card_set.keys()], r_main_content.width
        , show_description=True, show_type=True
        )
    main_screen.show_main_content(content)

    # Get userinput
    c = main_screen.retrieve_user_input().lower()

    # End turn
    if (c == "e"):
        turns.end_turn(mainguy, main_screen)
        turns.start_turn(mainguy, main_screen)
    
    # Store
    elif (c == "s"):
        store.routine(main_screen, mainguy)