-
Notifications
You must be signed in to change notification settings - Fork 0
/
canal.js
71 lines (66 loc) · 2.16 KB
/
canal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const QuemSouEu = require("./jogos/quemsoueu.js");
class Canal {
canal;
jogo;
mensagem;
jogadores;
partidaStatus;
//Construtor da classe
constructor(mensagem, dadosCanal, codJogo, tituloJogo, anfitriao){
//Instaciando classe
this.canal = dadosCanal;
this.jogo = {"id": codJogo, "titulo": tituloJogo};
this.mensagem = mensagem;
this.jogadores = [{"usuario": anfitriao}];
//anfitriao.setActivity("-gb help ou -gb ajuda", {type: "PLAYING"});
//anfitriao.presence.status = "Jogando " + tituloJogo;
this.partidaStatus = 0;
//Mensagem Convite
this.canal.send(
anfitriao.username + " " + this.mensagem.jogadorInvite + this.jogo.titulo + ".\n",
{ tts: true }
);
this.canal.send(this.mensagem.jogadorInvite2);
}
mensagem(texto){
this.canal.send(texto);
}
//Embaralhar ordem da fila de jogadores
shuffle() {
var j, x, i;
for (i = this.jogadores.length - 1; i > 0; i--) {
j = Math.floor(Math.random() * (i + 1));
x = this.jogadores[i];
this.jogadores[i] = this.jogadores[j];
this.jogadores[j] = x;
}
}
//Iniciar partida do jogo selecionado
partidaStart(){
var listaJogadores = "";
this.jogadores.forEach(function (j, index) {
listaJogadores += "\n" + (index+1) + ". " + j.usuario.username;
});
this.canal.send(this.mensagem.jogadores + listaJogadores);
this.partidaStatus = 1;
this.shuffle();
switch (this.jogo.id){
case 1:
console.log(this.jogadores);
this.jogo.partida = new QuemSouEu(this.mensagem, this.canal, this.jogadores);
break;
}
}
partidaRestart(msg){
this.shuffle();
switch(this.jogo.id){
case 1:
if (this.placar.length===0){
this.canal.send(msg.author.username + " " + this.mensagem.quemRefazerPersonagem, { tts: true });
}
break;
}
this.partidaStart();
}
}
module.exports = Canal;