Changeset e007fcd for pages/api/roulette
- Timestamp:
- 07/16/22 21:31:18 (2 years ago)
- Branches:
- main
- Children:
- e903234
- Parents:
- 55701f0
- Location:
- pages/api/roulette
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pages/api/roulette/gameStates.js
r55701f0 re007fcd 26 26 game.status = '_1_ongoing_timer'; 27 27 28 let inactivePlayers = [] 29 28 30 game.players.forEach(player => { 29 31 player.whichBets = []; … … 37 39 player.status = '_1_no_placed_bet'; 38 40 player.gotResults = false; 41 42 const d = Date.now(); 43 44 if (d - player.lastActivity > 200000) { 45 inactivePlayers.push(player); 46 } 39 47 }) 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 } 40 54 } 41 55 … … 68 82 } 69 83 70 export function addPlayer(session_id, name ) {84 export function addPlayer(session_id, name, username) { 71 85 if (game.players.map(e=>e.session_id).indexOf(session_id) === -1) { 72 86 game.players.push({ 87 lastActivity: Date.now(), 73 88 session_id: session_id, 89 username: username, 74 90 name: name, 75 91 whichBets: [], -
pages/api/roulette/index.js
r55701f0 re007fcd 78 78 }, 79 79 player.credits = postgreRes.data?.credits; 80 player.lastActivity = Date.now(); 80 81 } 81 82 }); … … 97 98 98 99 let extraAction = ""; 100 let extraAction2 = ""; 99 101 let magicNumber = -1; 100 102 let winningBets = []; … … 107 109 108 110 player.gotResults = true; 111 } 112 if (game.timeToStart > game.COUNTDOWN_FROM + game.WAIT_BEFORE - 15) { 113 extraAction2 = "keep_alert"; 109 114 } 110 115 } … … 121 126 }, 122 127 extraAction: extraAction, 128 extraAction2: extraAction2, 123 129 magicNumber: magicNumber, 124 130 winningBets: winningBets, … … 138 144 axios.get(`${process.env.HOME_URL}/api/postgre?action=check_if_logged_in&session_id=${session_id}`).then(postgreRes => { 139 145 if (postgreRes.data?.success) { 140 addPlayer(session_id, postgreRes.data?.displayName );146 addPlayer(session_id, postgreRes.data?.displayName, postgreRes.data?.username); 141 147 142 148 res.json({
Note:
See TracChangeset
for help on using the changeset viewer.