pingpoli.de



Creating a Euro Cup Betting Game Website

Betting the games with friends and family for extra incentive

08.06.2021 - 12:29
Like almost everything else, the 2020 Euro Cup fell victim to the pandemic. It was postponed to this year and will begin in a few days on Friday the 11th.

I am very excited and looking forward to watching some international football again, even though I haven’t even been following football as much in recent years in favor of the NFL, but I always enjoy events like the World Cup or the Euro Cup.

Watching German World/Euro Cup games in a group is always a lot of fun. However, with the pandemic still around, it’s probably not going to be possible. But there is another method of adding a bit of extra spice to the games: Betting on them. I don’t bet real money on sports, but even bragging rights among friends and family members is incentive enough.

World Cup betting game

I have already created a betting game for the 2018 World Cup. However, I didn’t do it properly and made it very hard-coded only for that event. There was no way to add a new event with new games to bet on, which turned out to be very short-sighted.

I could have just deleted the 2018 World Cup data and filled in the new Euro Cup 2021 games, which could have been done in half an hour or so. However, I don’t like deleting data and in any case, I would have had the same problem again next year for the 2022 World Cup. So instead, I did some major changes to the website so it can support multiple events.

The upcoming games and a form to place your bets on them:


Updating the game

The most obvious change was adding an event table to the database to keep track of the different events and easily add new ones. Then I had to update the team table, which proofed to be difficult because I had to keep the original 32 teams from the World Cup with their old IDs. I ended up making the team name unique and then added the Euro Cup teams. If a team was already in the database the unique constraint would prevent it from being added again.

Similar to the team table, I couldn’t completely change the user table either because the user IDs had to stay the same. But I had to implement a way to keep track of which user took part in which event. Many users can take part in many events, which makes it a classic many-to-many relationship. Therefore, I added a new table for this and also moved the points and other statistics from the user table to the new table.

Finally, I added an event ID foreign key to the game table so every game is associated with an event. Luckily, the bet table could remain unchanged because bets only care about the game they are linked to.

UI changes

With the database and some of the backend code updated, it was time to work on the user interface. I didn’t end up doing a lot besides making sure everything works with the new system. Because the event only changes every few years, I added a current event ID config value, which I can update by hand when it is time for a new event. This way, I could just pass that value to the necessary functions, which then load and display the correct data.

Although I’m not very happy with how the website looks at the moment. It’s a three-year-old design and even back then I didn’t create a real design and only did the bare minimum to make the website functional. And unfortunately, I don’t have a lot of time at the moment either, but I hope that I can find some spare time during the event to update the website's design.

The rankings from the 2018 World Cup:




Watching a football game is always more fun when there is something extra on the line. You could bet real money on the games, but I am neither brave nor rich enough to do that. Instead, we have a small private betting game with some friends and family members. To simplify the bookkeeping, I have created a small website for the 2018 World Cup, which I have now updated for the upcoming Euro Cup. Even though I have almost no idea of the teams’ strengths, I am still looking forward to watching the games and betting on them.




by Christian - 08.06.2021 - 12:29


Comments

Social Media:  © pingpoli.de 2020 All rights reservedCookiesImpressum generated in 55 ms