Index: pages/api/blackjack/index.js
===================================================================
--- pages/api/blackjack/index.js	(revision 1df3fdea19f18833062284bf7d5869fe3e72f104)
+++ pages/api/blackjack/index.js	(revision 433e0c5f4289ea953d6d2c2d010c6bd651bd0c8f)
@@ -6,5 +6,5 @@
 import { calculateEarnings, calculateSideBetEarnings } from './calculateEarnings';
 
-let rooms = []
+import { rooms, update_rooms_to_database } from '../postgre/index'
 
 /**
@@ -43,4 +43,6 @@
           game: rooms[session_id],
         })
+
+        update_rooms_to_database();
 
         return ;
@@ -99,4 +101,6 @@
               credits: postgreRes.data?.credits,
             })
+
+            update_rooms_to_database();
           }
           else {
@@ -150,4 +154,6 @@
                 credits: postgreRes.data?.credits,
               })
+            
+              update_rooms_to_database();
             }
             else {
@@ -166,4 +172,6 @@
             earnings: rooms[session_id].earnings,
           })
+            
+          update_rooms_to_database();
         }
 
@@ -212,4 +220,6 @@
                 credits: postgreRes.data?.credits,
               })
+            
+              update_rooms_to_database();
             }
             else {
@@ -229,4 +239,6 @@
             sideBetEarnings: rooms[session_id].sideBetEarnings,
           })
+            
+          update_rooms_to_database();
         }
 
@@ -270,4 +282,6 @@
               credits: postgreRes.data?.credits,
             })
+            
+            update_rooms_to_database();
           }
         });
@@ -308,4 +322,6 @@
               credits: postgreRes.data?.credits,
             })
+            
+            update_rooms_to_database();
           }
           else {
@@ -340,4 +356,6 @@
         success: true,
       })
+            
+      update_rooms_to_database();
     }
 
@@ -390,4 +408,6 @@
             credits: postgreRes.data?.credits,
           })
+            
+          update_rooms_to_database();
         }
         else {
Index: pages/api/postgre/index.js
===================================================================
--- pages/api/postgre/index.js	(revision 1df3fdea19f18833062284bf7d5869fe3e72f104)
+++ pages/api/postgre/index.js	(revision 433e0c5f4289ea953d6d2c2d010c6bd651bd0c8f)
@@ -275,4 +275,190 @@
     /**
      * /---------------------- POST ----------------------/
+     * Deposits money from credit card to game account.
+     * @action register
+     * @param session_id
+     * @param data
+     */
+    if (body?.action === 'deposit') {
+      // checks
+      if (body?.session_id == "undefined" || body?.session_id == "null" || body?.session_id == "") {
+        res.json({
+          success: false,
+          message: 'You are not logged in. Please log in first.',
+        });
+        return ;
+      }
+      if (body?.data?.name == "undefined" || body?.data?.name == "null" || body?.data?.name == "") {
+        res.json({
+          success: false,
+          message: 'Name field cannot be empty',
+        });
+        return ;
+      }
+      if (body?.data?.card == "undefined" || body?.data?.card == "null" || body?.data?.card == "") {
+        res.json({
+          success: false,
+          message: 'Card numbers field cannot be empty',
+        });
+        return ;
+      }
+      if (body?.data?.expire == "undefined" || body?.data?.expire == "null" || body?.data?.expire == "") {
+        res.json({
+          success: false,
+          message: 'Expiration date field cannot be empty',
+        });
+        return ;
+      }
+      if (body?.data?.ccv == "undefined" || body?.data?.ccv == "null" || body?.data?.ccv == "") {
+        res.json({
+          success: false,
+          message: 'CCV field cannot be empty',
+        });
+        return ;
+      }
+      if (body?.data?.amount == "undefined" || body?.data?.amount == "null" || body?.data?.amount == "") {
+        res.json({
+          success: false,
+          message: 'Amount field cannot be empty',
+        });
+        return ;
+      }
+
+      let session = sessions.find(session => session.id === body?.session_id)
+
+      if (session) {
+        if (parseInt(body.data.amount) > 0) {
+          session.credits = session.credits + parseInt(body.data.amount)
+
+          pool.query('UPDATE players SET credits = $1 WHERE username = $2', [session.credits, session.username], (error, results) => {
+            if (error) throw error;
+            
+            res.json({
+              success: true,
+              credits: session.credits
+            })
+          });
+        }
+      }
+    }
+
+    /**
+     * /---------------------- POST ----------------------/
+     * Withdraws money from game account to personal account.
+     * @action register
+     * @param session_id
+     * @param data
+     */
+     if (body?.action === 'withdraw') {
+      // checks
+      if (body?.session_id == "undefined" || body?.session_id == "null" || body?.session_id == "") {
+        res.json({
+          success: false,
+          message: 'You are not logged in. Please log in first.',
+        });
+        return ;
+      }
+      if (body?.data?.citibank == "undefined" || body?.data?.citibank == "null" || body?.data?.citibank == "") {
+        res.json({
+          success: false,
+          message: 'Bank name field cannot be empty',
+        });
+        return ;
+      }
+      if (body?.data?.iban == "undefined" || body?.data?.iban == "null" || body?.data?.iban == "") {
+        res.json({
+          success: false,
+          message: 'IBAN code field cannot be empty',
+        });
+        return ;
+      }
+      if (body?.data?.bic == "undefined" || body?.data?.bic == "null" || body?.data?.bic == "") {
+        res.json({
+          success: false,
+          message: 'BIC code field cannot be empty',
+        });
+        return ;
+      }
+      if (body?.data?.beneficiary == "undefined" || body?.data?.beneficiary == "null" || body?.data?.beneficiary == "") {
+        res.json({
+          success: false,
+          message: 'Beneficiary name field cannot be empty',
+        });
+        return ;
+      }
+      if (body?.data?.address == "undefined" || body?.data?.address == "null" || body?.data?.address == "") {
+        res.json({
+          success: false,
+          message: 'Bank address field cannot be empty',
+        });
+        return ;
+      }
+      if (body?.data?.amount == "undefined" || body?.data?.amount == "null" || body?.data?.amount == "") {
+        res.json({
+          success: false,
+          message: 'Amount field cannot be empty',
+        });
+        return ;
+      }
+
+      let session = sessions.find(session => session.id === body?.session_id)
+
+      if (session) {
+        if (parseInt(body.data.amount) > 0) {
+          session.credits = Math.max(session.credits - parseInt(body.data.amount), 0)
+
+          pool.query('UPDATE players SET credits = $1 WHERE username = $2', [session.credits, session.username], (error, results) => {
+            if (error) throw error;
+
+            res.json({
+              success: true,
+              credits: session.credits
+            })
+          });
+        }
+      }
+    }
+
+    /**
+     * /---------------------- POST ----------------------/
+     * Sends a complaint.
+     * @action complain
+     * @param session_id
+     * @param description
+     */
+     if (body?.action === 'complain') {
+      // checks
+      if (body?.session_id == "undefined" || body?.session_id == "null" || body?.session_id == "") {
+        res.json({
+          success: false,
+          message: 'You are not logged in. Please log in first.',
+        });
+        return ;
+      }
+      if (body?.description == "undefined" || body?.description == "null" || body?.description == "") {
+        res.json({
+          success: false,
+          message: 'You cannot submit an empty complaint.',
+        });
+        return ;
+      }
+
+      let session = sessions.find(session => session.id === body.session_id)
+
+      if (session) {
+        // date, by, description, answered
+        const date = new Date();
+        pool.query('INSERT INTO complaints (date, by, description, answered) VALUES ($1, $2, $3, $4)', [date, session.username, body.description, false], (error, complaintResults) => {
+          if (error) throw error;
+
+          res.json({
+            success: true,
+          })
+        });
+      }
+    }
+
+    /**
+     * /---------------------- POST ----------------------/
      * Checks if the entered account info is good, and registers a new user in the database if so.
      * @action register
@@ -539,3 +725,40 @@
 }
 load_game_from_database();
- 
+
+/**
+ *  Blackjack game data
+ */
+export var rooms = []
+  
+export function update_rooms_to_database() {
+  let tmpRooms = [];
+  
+  for (let key in rooms) {
+    if (key === "loaded") continue ;
+
+    tmpRooms.push(rooms[key]);
+    tmpRooms[tmpRooms.length - 1].id = key;
+  }
+
+  pool.query('UPDATE blackjack SET data = $1 WHERE identifier = $2', [JSON.stringify(tmpRooms), 'blackjack_data'], (error, results) => {
+    if (error) throw error;
+  });
+}
+     
+export async function load_rooms_from_database() {
+  pool.query('SELECT data FROM blackjack WHERE identifier = $1', ['blackjack_data'], (error, results) => {
+    if (error) throw error;
+
+    if (results?.rows[0]?.data) {
+      const tmpRooms = JSON.parse(results.rows[0].data);
+
+      tmpRooms.forEach(room => {
+        rooms[room.id] = {...room, id: ''}
+      })
+      
+      rooms["loaded"] = true;
+    }
+  });
+}
+load_rooms_from_database();
+  
Index: pages/api/roulette/calculateWinnings.js
===================================================================
--- pages/api/roulette/calculateWinnings.js	(revision 433e0c5f4289ea953d6d2c2d010c6bd651bd0c8f)
+++ pages/api/roulette/calculateWinnings.js	(revision 433e0c5f4289ea953d6d2c2d010c6bd651bd0c8f)
@@ -0,0 +1,49 @@
+export function getWinningBets(magicNumber) {
+    let winningBets = [];
+    winningBets.push(magicNumber);
+    
+    if (magicNumber != 0) {
+        if ((magicNumber <= 9 && magicNumber % 2 == 1) || (magicNumber > 10 && magicNumber <= 18 && magicNumber % 2 == 0) ||
+            (magicNumber > 19 && magicNumber <= 27 && magicNumber % 2 == 1) || (magicNumber > 27 && magicNumber % 2 == 0)) {
+
+            winningBets.push('Red');
+        }
+        else {
+            winningBets.push('Black');
+        }
+
+        if (magicNumber % 2 === 0)      winningBets.push('Even');
+        else                            winningBets.push('Odd');
+
+        if (magicNumber <= 12)          winningBets.push('1-12');
+        else if (magicNumber <= 24)     winningBets.push('13-24');
+        else                            winningBets.push('25-36');
+
+        if (magicNumber <= 18)          winningBets.push('1-18');
+        else                            winningBets.push('19-36');
+
+        if (magicNumber % 3 === 0)      winningBets.push('Remainder3');
+        else if (magicNumber % 3 === 2) winningBets.push('Remainder2');
+        else                            winningBets.push('Remainder1');
+    }
+
+    return winningBets;
+}
+
+export function calculateWinnings(player) {
+    if (player.outcome === 'lost') return 0;
+
+    let bets = player.whichBets;
+    let bet = player.betAmount;
+
+    if (bets[0] === 'Even' || bets[0] === 'Odd') return 2 * bet;
+    else if (bets[0] === 'Red' || bets[0] === 'Black') return 2 * bet;
+    else if (bets[0].includes('Remainder')) return 3 * bet;
+    else if (bets[0] === '1-12' || bets[0] === '13-24' || bets[0] === '25-36') return 3 * bet;
+    else if (bets[0] === '1-18' || bets[0] === '19-36') return 2 * bet;
+    else if (bets.length === 4) return 9 * bet;
+    else if (bets.length === 2) return 18 * bet;
+    else if (bets.length === 1) return 36 * bet;
+
+    return 0;
+}
Index: pages/api/roulette/gameStates.js
===================================================================
--- pages/api/roulette/gameStates.js	(revision 433e0c5f4289ea953d6d2c2d010c6bd651bd0c8f)
+++ pages/api/roulette/gameStates.js	(revision 433e0c5f4289ea953d6d2c2d010c6bd651bd0c8f)
@@ -0,0 +1,113 @@
+import { calculateWinnings } from './calculateWinnings'
+
+import { game } from '../postgre/index'
+
+import axios from 'axios';
+
+export let samplePlayer = {
+    session_id: '',
+    name: '',
+    whichBets: [],
+    coinPlaced: {
+        x: -1,
+        y: -1,                
+    },
+    credits: -1,
+    betAmount: 0,
+    wonAmount: 0,
+    status: '_1_',
+    outcome: 'none',
+    gotResults: false,
+}
+
+export function resetGame() {
+    game.magicNumber = -1;
+    game.winningBets = [];
+    game.status = '_1_ongoing_timer';
+
+    game.players.forEach(player => {
+        player.whichBets = [];
+        player.betAmount = 0;
+        player.wonAmount = 0;
+        player.coinPlaced = {
+            x: -1,
+            y: -1,                
+        },
+        player.outcome = 'none';
+        player.status = '_1_no_placed_bet';
+        player.gotResults = false;
+    })
+}
+
+export function updateGameWithWinners() {
+    for (let i = 0; i < game.players.length; i++) {
+        const player = game.players[i];
+
+        let playerWon = false;
+        player.whichBets.forEach(bet => {
+            if (game.winningBets.indexOf(bet) !== -1) {
+                playerWon = true;
+            }
+        })
+
+        if (playerWon) {
+            player.outcome = 'won';
+        }
+        else {
+            player.outcome = 'lost';
+        }
+
+        player.wonAmount = calculateWinnings(player);
+
+        axios.get(`${process.env.HOME_URL}/api/postgre/?action=add_credits&session_id=${player.session_id}&credits=${player.wonAmount}&game=roulette&outcome=${player.outcome}`).then(postgreRes => {
+            if (postgreRes.data?.success) {
+                player.credits = postgreRes.data?.credits;
+            }
+        });
+    }
+}
+
+export function addPlayer(session_id, name) {
+    if (game.players.map(e=>e.session_id).indexOf(session_id) === -1) {
+        game.players.push({
+            session_id: session_id,
+            name: name,
+            whichBets: [],
+            coinPlaced: {
+                x: -1,
+                y: -1,                
+            },
+            credits: -1,
+            betAmount: 0,
+            wonAmount: 0,
+            status: '_1_no_placed_bet',
+            outcome: 'none',
+            gotResults: false,
+        })
+    }
+}
+
+export function getPlayer(session_id) {
+    const playerIdx = game.players.map(e=>e.session_id).indexOf(session_id);
+
+    if (playerIdx !== -1) {
+        return {
+            success: true,
+            player: game.players[playerIdx],
+        }
+    }
+
+    return {
+        success: false,
+        player: {...samplePlayer},
+    };
+}
+
+export function restrictGameInfo() {
+    const restrictedPlayers = game.players.map(player=>({...player, session_id: ""}))
+
+    return {
+        ...game,
+        players: restrictedPlayers,
+    }
+}
Index: pages/api/roulette/index.js
===================================================================
--- pages/api/roulette/index.js	(revision 1df3fdea19f18833062284bf7d5869fe3e72f104)
+++ pages/api/roulette/index.js	(revision 433e0c5f4289ea953d6d2c2d010c6bd651bd0c8f)
@@ -5,116 +5,7 @@
 require('dotenv').config();
 
-let samplePlayer = {
-    session_id: '',
-    name: '',
-    whichBets: [],
-    coinPlaced: {
-        x: -1,
-        y: -1,                
-    },
-    credits: -1,
-    betAmount: 0,
-    wonAmount: 0,
-    status: '_1_',
-    outcome: 'none',
-    gotResults: false,
-}
+import { resetGame, updateGameWithWinners, addPlayer, getPlayer, restrictGameInfo } from './gameStates'
 
-function getWinningBets(magicNumber) {
-    let winningBets = [];
-    winningBets.push(magicNumber);
-    
-    if (magicNumber != 0) {
-        if ((magicNumber <= 9 && magicNumber % 2 == 1) || (magicNumber > 10 && magicNumber <= 18 && magicNumber % 2 == 0) ||
-            (magicNumber > 19 && magicNumber <= 27 && magicNumber % 2 == 1) || (magicNumber > 27 && magicNumber % 2 == 0)) {
-
-            winningBets.push('Red');
-        }
-        else {
-            winningBets.push('Black');
-        }
-
-        if (magicNumber % 2 === 0)      winningBets.push('Even');
-        else                            winningBets.push('Odd');
-
-        if (magicNumber <= 12)          winningBets.push('1-12');
-        else if (magicNumber <= 24)     winningBets.push('13-24');
-        else                            winningBets.push('25-36');
-
-        if (magicNumber <= 18)          winningBets.push('1-18');
-        else                            winningBets.push('19-36');
-
-        if (magicNumber % 3 === 0)      winningBets.push('Remainder3');
-        else if (magicNumber % 3 === 2) winningBets.push('Remainder2');
-        else                            winningBets.push('Remainder1');
-    }
-
-    return winningBets;
-}
-
-function updateGameWithWinners() {
-    for (let i = 0; i < game.players.length; i++) {
-        const player = game.players[i];
-
-        let playerWon = false;
-        player.whichBets.forEach(bet => {
-            if (game.winningBets.indexOf(bet) !== -1) {
-                playerWon = true;
-            }
-        })
-
-        if (playerWon) {
-            player.outcome = 'won';
-        }
-        else {
-            player.outcome = 'lost';
-        }
-
-        player.wonAmount = calculateWinnings(player);
-
-        axios.get(`${process.env.HOME_URL}/api/postgre/?action=add_credits&session_id=${player.session_id}&credits=${player.wonAmount}&game=roulette&outcome=${player.outcome}`).then(postgreRes => {
-            if (postgreRes.data?.success) {
-                player.credits = postgreRes.data?.credits;
-            }
-        });
-    }
-}
-
-function resetGame() {
-    game.magicNumber = -1;
-    game.winningBets = [];
-    game.status = '_1_ongoing_timer';
-
-    game.players.forEach(player => {
-        player.whichBets = [];
-        player.betAmount = 0;
-        player.wonAmount = 0;
-        player.coinPlaced = {
-            x: -1,
-            y: -1,                
-        },
-        player.outcome = 'none';
-        player.status = '_1_no_placed_bet';
-        player.gotResults = false;
-    })
-}
-
-function calculateWinnings(player) {
-    if (player.outcome === 'lost') return 0;
-
-    let bets = player.whichBets;
-    let bet = player.betAmount;
-
-    if (bets[0] === 'Even' || bets[0] === 'Odd') return 2 * bet;
-    else if (bets[0] === 'Red' || bets[0] === 'Black') return 2 * bet;
-    else if (bets[0].includes('Remainder')) return 3 * bet;
-    else if (bets[0] === '1-12' || bets[0] === '13-24' || bets[0] === '25-36') return 3 * bet;
-    else if (bets[0] === '1-18' || bets[0] === '19-36') return 2 * bet;
-    else if (bets.length === 4) return 9 * bet;
-    else if (bets.length === 2) return 18 * bet;
-    else if (bets.length === 1) return 36 * bet;
-
-    return 0;
-}
+import { getWinningBets } from './calculateWinnings'
 
 (function() {
@@ -151,49 +42,4 @@
     game.winningBets = [];
     game.players = [];
-}
-
-function addPlayer(session_id, name) {
-    if (game.players.map(e=>e.session_id).indexOf(session_id) === -1) {
-        game.players.push({
-            session_id: session_id,
-            name: name,
-            whichBets: [],
-            coinPlaced: {
-                x: -1,
-                y: -1,                
-            },
-            credits: -1,
-            betAmount: 0,
-            wonAmount: 0,
-            status: '_1_no_placed_bet',
-            outcome: 'none',
-            gotResults: false,
-        })
-    }
-}
-
-export function getPlayer(session_id) {
-    const playerIdx = game.players.map(e=>e.session_id).indexOf(session_id);
-
-    if (playerIdx !== -1) {
-        return {
-            success: true,
-            player: game.players[playerIdx],
-        }
-    }
-
-    return {
-        success: false,
-        player: {...samplePlayer},
-    };
-}
-
-export function restrictGameInfo() {
-    const restrictedPlayers = game.players.map(player=>({...player, session_id: ""}))
-
-    return {
-        ...game,
-        players: restrictedPlayers,
-    }
 }
 
Index: pages/index.js
===================================================================
--- pages/index.js	(revision 1df3fdea19f18833062284bf7d5869fe3e72f104)
+++ pages/index.js	(revision 433e0c5f4289ea953d6d2c2d010c6bd651bd0c8f)
@@ -11,4 +11,5 @@
 import Stats from '../components/Stats'
 import ManageCredits from '../components/ManageCredits'
+import ComplainScreen from '../components/Complain'
 
 export default function Home() {
@@ -49,4 +50,6 @@
 
       <ManageCredits/>
+
+      <ComplainScreen/>
     </div>
   )
