Changeset e007fcd for pages/api/blackjack
- Timestamp:
- 07/16/22 21:31:18 (2 years ago)
- Branches:
- main
- Children:
- e903234
- Parents:
- 55701f0
- Location:
- pages/api/blackjack
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pages/api/blackjack/gameStates.js
r55701f0 re007fcd 14 14 export let game = { 15 15 credits: -1, 16 username: '', 17 displayName: '', 16 18 deck: [...deck], 17 19 status: '_1_room_created', // statuses: _1_room_created, _2_made_initial_bet, _3_made_side_bet, _4_cards_on_the_table, _5_game_over -
pages/api/blackjack/index.js
r55701f0 re007fcd 11 11 * Set up a room 12 12 */ 13 function createARoom(session_id ) {13 function createARoom(session_id, displayName, username) { 14 14 let room = { 15 ...game, playerCards: [...game.playerCards], dealerCards: [...game.dealerCards],15 ...game, displayName: displayName, username: username, playerCards: [...game.playerCards], dealerCards: [...game.dealerCards], 16 16 } 17 17 … … 241 241 rooms[session_id] = room; 242 242 243 update_rooms_to_database(); 244 243 245 if (room.sideBetName !== '' && room.sideBetName !== 'none') { 244 246 room.sideBetEarnings = calculateSideBetEarnings(room); … … 257 259 258 260 rooms[session_id] = room; 259 260 update_rooms_to_database();261 261 262 262 axios.get(`${process.env.HOME_URL}/api/postgre/?action=add_credits&session_id=${session_id}&credits=${room.sideBetEarnings}`).then(postgreRes => { … … 348 348 /** 349 349 * /---------------------- GET ----------------------/ 350 * Remove a room from the rooms array.351 * @action remove_room352 * @param session_id353 */354 if (req.query.action === 'remove_room' && req.query?.session_id) {355 const session_id = req.query.session_id;356 357 if (rooms[session_id] !== undefined) {358 delete rooms[session_id];359 }360 361 res.json({362 success: true,363 })364 365 update_rooms_to_database();366 }367 368 /**369 * /---------------------- GET ----------------------/370 350 * Updates the state periodically 371 351 * @action update_state … … 399 379 } 400 380 else { 401 createARoom(session_id );381 createARoom(session_id, postgreRes.data?.displayName, postgreRes.data?.username); 402 382 } 403 383
Note:
See TracChangeset
for help on using the changeset viewer.