Ignore:
Timestamp:
07/16/22 21:31:18 (2 years ago)
Author:
anastasovv <simon@…>
Branches:
main
Children:
e903234
Parents:
55701f0
Message:

Now you need to activate your account via email & also added mail sending after server crash

Location:
pages/api/blackjack
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pages/api/blackjack/gameStates.js

    r55701f0 re007fcd  
    1414export let game = {
    1515  credits: -1,
     16  username: '',
     17  displayName: '',
    1618  deck: [...deck],
    1719  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  
    1111 * Set up a room
    1212 */
    13 function createARoom(session_id) {
     13function createARoom(session_id, displayName, username) {
    1414  let room = {
    15     ...game, playerCards: [...game.playerCards], dealerCards: [...game.dealerCards],
     15    ...game, displayName: displayName, username: username, playerCards: [...game.playerCards], dealerCards: [...game.dealerCards],
    1616  }
    1717
     
    241241        rooms[session_id] = room;
    242242
     243        update_rooms_to_database();
     244
    243245        if (room.sideBetName !== '' && room.sideBetName !== 'none') {
    244246          room.sideBetEarnings = calculateSideBetEarnings(room);
     
    257259         
    258260          rooms[session_id] = room;
    259 
    260           update_rooms_to_database();
    261261
    262262          axios.get(`${process.env.HOME_URL}/api/postgre/?action=add_credits&session_id=${session_id}&credits=${room.sideBetEarnings}`).then(postgreRes => {
     
    348348    /**
    349349     * /---------------------- GET ----------------------/
    350      * Remove a room from the rooms array.
    351      * @action remove_room
    352      * @param session_id
    353      */
    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 ----------------------/
    370350     * Updates the state periodically
    371351     * @action update_state
     
    399379          }
    400380          else {
    401             createARoom(session_id);
     381            createARoom(session_id, postgreRes.data?.displayName, postgreRes.data?.username);
    402382          }
    403383   
Note: See TracChangeset for help on using the changeset viewer.