"use strict"
const JoinRoom = require("./JoinRoom.js").JoinRoom;
// const debug = require("debug")("test");
const commonVar = require("../Constants").commonVar;
const selectGame = require("../Constants").selectGame;
// const StartAndarbharGame = require("../gameplay/Andarbhar").StartAndarbharGame;

const StartClassicAndarbharGame = require("../controllers/classicAndarBahar.js").StartAndarbharGame;

async function MatchPlayer(data, io, alreadyIn=false) {

    let result = await JoinRoom(data);

    // console.log(`(((((((()))))) ~ MatchMaking.js:14 ~ MatchPlayer ~ join room result:`, result);

    if (result.result === commonVar.success) {

        data[commonVar.roomName] = result[commonVar.roomName];

        // console.log(`(((((((()))))) ~ MatchMaking.js:20 ~ MatchPlayer ~ data[commonVar.roomName]:`, data[commonVar.roomName]);

    }
    
    // console.log(`(((((((()))))) ~ MatchMaking.js:28 ~ MatchPlayer ~ selectGame[6]:`, data);
    switch (data[commonVar.roomName]) {
        
        
        case selectGame[6]: StartClassicAndarbharGame(data, io); break;
      
        default: break;
    }

}

module.exports.MatchPlayer = MatchPlayer;