0
I will receive a JSON containing 2 objects: Player 1 and Player 2.
It would contain the following structure:
player 1:
playerid
socketid
name
points
jogada
player 2:
player 1:
playerid
socketid
name
points
jogada
I ended up creating this:
const player = require('../models/User');
const jogada = {
pedra:{
id:1
},
papel:{
id:2
},
tesoura:{
id:3
}
};
const socketId = null
class Player {
constructor({socket, name = "", jogada = "", points = ""}) {
socketId = socket.socket.id
this.id = player.id;
this.name = player.name;
this.points = player.points
this.jogada = jogada;
}
}
module.exports = Player;
In java it would be easier I would create a Players List and add these two players in it
But I was in doubt as I would do something like this in javascript?
Create 2 players with my json attributes that I will receive
Thanks @Miqueias Moureira
– gabriel