#๐Ÿ”’ Pitch Game Making

47 messages ยท Page 1 of 1 (latest)

tight surgeBOT
#

@kind helm

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

kind helm
#

k

#

do you see my code?

lyric prawn
#

no

kind helm
#

one sec

#

def determine_trick_winner(played_cards, chosen_suit):
highest_card = None
winning_player_index = None

for i in range(len(played_cards)):
    card, _ = played_cards[i]
   
    if card[1] == chosen_suit[0]:
        if not highest_card or card_value(card) > card_value(highest_card):
            highest_card = card
            winning_player_index = i
    else:
        if not highest_card or card_value(card) > card_value(highest_card):
            highest_card = card
            winning_player_index = i
           
return winning_player_index
tight surgeBOT
#

Hey @kind helm!

It looks like you're trying to paste code into this channel.

Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
kind helm
#
def determine_trick_winner(played_cards, chosen_suit):
    highest_card = None
    winning_player_index = None
   
    for i in range(len(played_cards)):
        card, _ = played_cards[i]
       
        if card[1] == chosen_suit[0]:
            if not highest_card or card_value(card) > card_value(highest_card):
                highest_card = card
                winning_player_index = i
        else:
            if not highest_card or card_value(card) > card_value(highest_card):
                highest_card = card
                winning_player_index = i
               
    return winning_player_index
#

there

#

see it now

#

so I am making pitch

#

and I want to determine the winner of the trick

#

and it is comparing cards to what players played

#

but its not working

#

@lyric prawn

lyric prawn
#

you gotta explain what's the game

kind helm
#

you know Pitch?

lyric prawn
#

nope

kind helm
#

damn

lyric prawn
#

and if I know it

#

it's under a different name

kind helm
#

want me too send the full code

#

to make it understand better

lyric prawn
#

just tell me what you're trying to achieve with that code

kind helm
#

basically after each player there is 4, I am comparing each card, and whoever has the highest card wins, and deals the next round

#

but its not comparing cards right

lyric prawn
#

can you print played cards

kind helm
#

yeah

#

it does in my code, I have a print card function

#
def card_value(card):
    values = {'A': 14, 'K': 13, 'Q': 12, 'J': 11, '10': 10, '9': 9, '8': 8, '7': 7, '6': 6, '5': 5, '4': 4, '3': 3, '2': 2,}
    rank = card[:-1]
    if rank.isdigit():  
        rank = int(rank)  
    return values.get(rank)
#

here is the card value function

lyric prawn
#

i need to know how played_cards is

kind helm
#

k one sec

#
def play_round(players, hands, current_player_index, chosen_suit, highest_bidder):
    while any(hands):
        played_cards = []
        for i in range(len(players)):
            current_player = players[current_player_index]
            if hands[current_player_index]:
                print(f"\n{current_player}'s turn:")
                print_hand(hands[current_player_index])
                played_card_index = int(input(f'Which card do you want to play {highest_bidder}? (Enter the number 1-6): ')) - 1
                played_card = hands[current_player_index].pop(played_card_index)
                print(f"{current_player} played {simplificator(*played_card)[0]}")
                played_cards.append(played_card)
            current_player_index = (current_player_index + 1) % len(players)

        winning_player_index = determine_trick_winner(played_cards, chosen_suit)
        print(f"\n{players[winning_player_index]} wins the trick!")
#

its a list

lyric prawn
#

but

#

is it a list of ints

kind helm
#

yeah what about it

lyric prawn
#

I needed to know that

kind helm
#

sorry

lyric prawn
#

recently someone did some code that does what you need

#

#esoteric-python message

#

is that what you need, a max value and it's index?

kind helm
#

yeah

#

it is

tight surgeBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.