Changeset e007fcd for pages/api/roulette


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/roulette
Files:
2 edited

Legend:

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

    r55701f0 re007fcd  
    2626    game.status = '_1_ongoing_timer';
    2727
     28    let inactivePlayers = []
     29
    2830    game.players.forEach(player => {
    2931        player.whichBets = [];
     
    3739        player.status = '_1_no_placed_bet';
    3840        player.gotResults = false;
     41
     42        const d = Date.now();
     43
     44        if (d - player.lastActivity > 200000) {
     45            inactivePlayers.push(player);
     46        }
    3947    })
     48
     49    for (let i = 0; i < inactivePlayers.length; i++) {
     50        if (game.players.indexOf(inactivePlayers[i]) !== -1) {
     51            game.players.splice(game.players.indexOf(inactivePlayers[i]), 1);
     52        }
     53    }
    4054}
    4155
     
    6882}
    6983
    70 export function addPlayer(session_id, name) {
     84export function addPlayer(session_id, name, username) {
    7185    if (game.players.map(e=>e.session_id).indexOf(session_id) === -1) {
    7286        game.players.push({
     87            lastActivity: Date.now(),
    7388            session_id: session_id,
     89            username: username,
    7490            name: name,
    7591            whichBets: [],
  • pages/api/roulette/index.js

    r55701f0 re007fcd  
    7878                        },
    7979                        player.credits = postgreRes.data?.credits;
     80                        player.lastActivity = Date.now();
    8081                    }
    8182                });
     
    9798
    9899            let extraAction = "";
     100            let extraAction2 = "";
    99101            let magicNumber = -1;
    100102            let winningBets = [];
     
    107109
    108110                    player.gotResults = true;
     111                }
     112                if (game.timeToStart > game.COUNTDOWN_FROM + game.WAIT_BEFORE - 15) {
     113                    extraAction2 = "keep_alert";
    109114                }
    110115            }
     
    121126                },
    122127                extraAction: extraAction,
     128                extraAction2: extraAction2,
    123129                magicNumber: magicNumber,
    124130                winningBets: winningBets,
     
    138144            axios.get(`${process.env.HOME_URL}/api/postgre?action=check_if_logged_in&session_id=${session_id}`).then(postgreRes => {
    139145                if (postgreRes.data?.success) {
    140                     addPlayer(session_id, postgreRes.data?.displayName);
     146                    addPlayer(session_id, postgreRes.data?.displayName, postgreRes.data?.username);
    141147               
    142148                    res.json({
Note: See TracChangeset for help on using the changeset viewer.