lcox74 / snailrace

A fun discord bot where you can race snails against other members.
0 stars 0 forks source link

Betting Stage #5

Closed lcox74 closed 1 year ago

lcox74 commented 1 year ago

After the race entry has been open for 10 seconds it will close and display the entrants for the race. This is the "betting" phase, where other users can place bets on the entrants to win rewards. This phase lasts for 30 seconds and will display a drop down form of the entrants and how much to bet on (5g, 10g, 20g) as defaults. By selecting the form you can make multiple bets, but you can't undo a bet.

Listing Entrants

The race message must include a list of the racing snails (along with their owner). It is very important to also include the Odds for each snail as well, this should be calculated using the following formula:

def snailOdds(snail Snail, entrants Snail[]): float
    # Calculate modifier from normalized stats
    norm_speed = snail.speed / sum([snail.speed for snail in entrants])
    norm_stamina = snail.stamina / sum([snail.stamina for snail in entrants])
    stat_mod = 1.0 - (norm_speed + norm_stamina)

    # Check the snail's win history
    win_rate = 1.0
    if snail.wins > 0:
        win_rate = 1.0 - (snail.wins / snail.races)
            if win_rate == 0:
                return 10.0 * stat_mod

    return 10.0 * win_rate * stat_mod

Flags

In this stage it's also very important to handle 2 of the flags when hosting:

lcox74 commented 1 year ago

After the 10 seconds of the Race: Open stage, the message changes to the following:

image

I haven't handled the no-bets or dont-fill flags. I also havent handled snail odds.

I've decided to use the modal to allow the user to submit how much they want to bet. It needs some rework but it looks like the following:

image

lcox74 commented 1 year ago

I didn't like the modal and went back to the 3 buttons (5g, 10g, 20g)