Logo

dev-resources.site

for different kinds of informations.

Everyday is an API day with BlackJack

Published at
11/29/2020
Categories
mulesofthackathon
blackjack
mulesoft
api
Author
kevinmaru2020
Author
13 person written this
kevinmaru2020
open
Everyday is an API day with BlackJack

Although they say 'What Happens in Vegas, Stays in Vegas.', but there is one thing that you definitely want to get back home to re-live your memories and that would be the Casino games. Even though you might not be able to Visit Vegas at this point in time due to the present Pandemic situation, we have got you covered. We present to you the online version of Black Jack that you can enjoy playing in your leisure time.

Alt Text

This project has been implemented using React JS & MuleSoft. The APIs used in the project have been created using MuleSoft & deployed on CloudHub. CloudHub is an integration platform as a service (iPaaS) where you can deploy sophisticated cross-cloud integration applications in the cloud, create new APIs on top of existing data sources, integrate on-premises applications with cloud services, and much more.

This project also makes use of Object Store, to store the player's data. Object Store lets CloudHub applications store data and states across batch processes, Mule components, and applications, from within an application or by using the Object Store REST API.

MuleSoft APIs description:

  • /initialize -
    This is the first API to be invoked when the player enters the name. The client sends this name as a query parameter named 'uid'. This query param is mandatory in all other APIs as well. MuleSoft creates an object in Object Store & sets initial coins which is configurable through the config.properties.

  • /bet -
    At the start of each turn, the player needs to bet a certain amount that is less than or equal to its coin balance. This value is sent from Client to MuleSoft through 'betAmount' query parameter. This API generates 2 cards for the dealer (One of them hidden) as well as the player and returns it to the source. At the same time, card data along with updated balance is set in object-store.

  • /hit -
    Whenever the player hits, this API is invoked which draws a new card from the deck. It re-calculates the player's hand & returns it to the caller along with the state of the game (Win/Continue/Bust) & the updated coin balance. Based on the state returned, the client allows the user to continue playing or declare win or bust.

  • /stand -
    When the player fears getting busted and doesn't want to draw any new card, the dealer's hidden card is revealed and his hand value is calculated. Until the dealer's hand value crosses 17, a new card is pulled out of the deck. Based on Player's and Dealer's Hand value, the winner is declared.

  • /delete -
    This resets the game by deleting the player's data from Object Store.

Alt Text

How to play -

Rules:

  • The goal of blackjack is to beat the dealer's hand without going over 21.
  • Face cards are worth 10. Aces are worth 1 or 11, whichever makes a better hand.
  • Player and Dealer starts with two cards, one of the dealer's cards is hidden until the player stands
  • To 'Hit' is to ask for another card. To 'Stand' is to hold your total and end your turn.
  • If you go over 21 you bust, and the dealer wins regardless of the dealer's hand.
  • If you are dealt 21 from the start (Ace and 10), you got a blackjack.
  • You win when your hand totals higher than the dealer's hand or the dealer busts.

Configuration:

As this application is hosted on github.io which is HTTPS and it invokes the MuleSoft application hosted on CloudHub, you might see the mixed content error. To fix this please follow the below steps -

Step 1. Click on the lock icon near the URL and then click on the site settings.

Alt Text

Step 2. Select Allow from the dropdown for Insecure content.

Alt Text

Step 3. You are all set! Click here to launch the game and have fun.

Project URLs -

Team -

Challenges & Future Scope -

We could understand the true potential of MuleSoft as we could leverage most of the capabilities provided by MuleSoft ranging from Design Center for designing APIs and testing RAMLs to Anypoint Studio for building actual APIs to using Object Store all the way till application deployment on MuleSoft's very own CloudHub. We also learned transforming messages into dataweave by exploring its vast set of capabilities.

While we were facing the issue with the Mixed Content error due to HTTPS in github.io & HTTP at the API end, we will be working towards configuring TLS and exposing our BlackJack APIs over HTTPS.

This application would further be enhanced by adding multi-player capabilities over the internet. We also plan to publish a connector for this application.

References -
  1. https://docs.mulesoft.com/runtime-manager/cloudhub
  2. https://docs.mulesoft.com/object-store/
mulesofthackathon Article's
30 articles in total
Favicon
Top Use Cases of MuleSoft API Manager
Favicon
Introducing Sowoe Creative Agency: Crafting Bold, Impactful Stories for Your Brand
Favicon
Download the song Kar from the past work
Favicon
How the Kellogg Innovation Network is Transforming Collaboration and Innovation
Favicon
How a Tech Company in Pakistan is Driving Innovation
Favicon
Unlocking the Power of Integration with MuleSoft
Favicon
Transform Your Body at Home: Effective Weight Loss Exercises Without a Gym
Favicon
Hello Mule (Mulesoft)
Favicon
Best practices for Mulesoft SAP integration
Favicon
Learn MuleSoft Training to become a Master in Anypoint Studio
Favicon
Mulesoft Training Interview Questions and Answers 2023
Favicon
Updating Record in Salesforce With Mulesoft
Favicon
What does MuleSoft Composer let you do?
Favicon
Why businesses should consider resorting to MuleSoft?
Favicon
Working of Mulesoft?
Favicon
Where to Learn Mulesoft?
Favicon
Mulesoft external API for custom alerts creation, automatic application restart and Jira ticket creation - Mule version 4
Favicon
Everyday is an API day with Jotto 2020
Favicon
Missing kids alerting system
Favicon
Slack Bot for Support Personnel build with API Led Connectivity
Favicon
Movid - An Alexa skill that provides Covid-19 symptom checking and real time information.
Favicon
Share your Dinosaurs
Favicon
Everyday is an API day with BlackJack
Favicon
TravelZoom- Mule Integration With Everyday API's
Favicon
IoT + MuleSoft - Sense room temperature and send message to mobile
Favicon
Cloud Hub Alexa Skill Set -Command your IAAS to work for you
Favicon
Control Your Mule Infra Via Bot
Favicon
Good Sleep: Controlling the temperature in a remote room through IOT devices and MuleSoft!
Favicon
Talk to your Toaster with Mule
Favicon
Subscription Model for News and Stocks via MuleSoft and Kafka

Featured ones: