docker build --tag blackjack .
docker run --rm -p 8000:8000 blackjack
Now use SERVER_BASE=http://localhost:8000/v2 ./play.sh
to play via command line or use a browser at http://localhost:8000/play.html
If you have Docker installed you can play via:
docker run -it --rm livepeerci/curl-jq bash -c "$(curl -sfLS https://raw.githubusercontent.com/oglimmer/blackjack-rest-api/master/play.sh)"
To play on your local terminal, you need to have curl and jq installed.
bash -c "$(curl -sfLS https://raw.githubusercontent.com/oglimmer/blackjack-rest-api/master/play.sh)"
You need to have oat++ and oat-swagger installed, see https://oatpp.io/docs/installation/unix-linux/
For Unix/macOS do this:
# oatpp
git clone https://github.com/oatpp/oatpp.git --depth=1
cd oatpp/
mkdir build
cd build
cmake ..
make install
# oatpp-swagger
git clone https://github.com/oatpp/oatpp-swagger.git --depth=1
cd oatpp-swagger/
mkdir build
cd build
make install
For the UI you also need to have node, npm installed.
This is how you build blackjack itself:
# get the Ace editor (UI only)
git clone https://github.com/ajaxorg/ace-builds/ /tmp/ace
cp -r /tmp/ace/src-min client-res/static/ace
rm -rf /tmp/ace
# build UI (UI only)
cd client-res
npm i
npm run static
cd ..
# build C++ (REST backend)
mkdir build && cd build
cmake ..
make
You need to have java-jre installed.
# generate REST client via openapi-generator (UI only)
curl https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.0.0/openapi-generator-cli-6.0.0.jar -o /tmp/openapi-generator-cli.jar
cd client-res
java -jar /tmp/openapi-generator-cli.jar generate -i https://bj.oglimmer.de/api-docs/oas-3.0.0.json -g javascript -o .
cd ..
To run the server:
export STATIC_ROOT=./client-res/static/
build/blackjack-exe
To play (and thus test the server)
SERVER_BASE=http://localhost:8000/v2 ./play.sh
or open a browser at http://localhost:8000
curl https://bj.oglimmer.de/v2/player -X POST
curl https://bj.oglimmer.de/v2/deck -X POST
curl https://bj.oglimmer.de/v2/player/${PLAYER_ID}
curl https://bj.oglimmer.de/v2/game -d '{"deckId": '${DECK_ID}'}'
curl https://bj.oglimmer.de/v2/game/${GAME_ID}/bet -d '{"playerId": '${PLAYER_ID}', "bet": '${BET}'}'
curl https://bj.oglimmer.de/v2/game/${GAME_ID}/bet/${BET_ID}/hit -X POST
curl https://bj.oglimmer.de/v2/game/${GAME_ID}/bet/${BET_ID}/stand -X POST
curl https://bj.oglimmer.de/v2/game/${GAME_ID}/bet/${BET_ID}/double -X POST
curl https://bj.oglimmer.de/v2/game/${GAME_ID}/bet/${BET_ID}/split -X POST
curl https://bj.oglimmer.de/v2/game/${GAME_ID}/bet/${BET_ID}/insurance -d '{"insurance": "${yes|no}"}'
curl https://bj.oglimmer.de/v2/game/${GAME_ID}/bet/${BET_ID}
Use: https://raw.githubusercontent.com/oglimmer/blackjack-rest-api/master/play.sh to play via bash! (needs curl and jq installed)