AddPlayer gefixt
This commit is contained in:
parent
0dcea91752
commit
ea153db8a9
1 changed files with 9 additions and 2 deletions
|
@ -6,7 +6,7 @@ let reloadButton = document.getElementById("reload");
|
|||
let saveButton = document.getElementById("save");
|
||||
var players = [];
|
||||
let Id = Math.floor(Math.random()*10000000000000000).toString(16)
|
||||
var ws = new WebSocket("ws:10.9.1.129:8080/" + Id);
|
||||
var ws = new WebSocket("wss://nerfingen.de:8080/" + Id);
|
||||
document.getElementById("p4").innerHTML = "" + Id;
|
||||
|
||||
|
||||
|
@ -140,7 +140,7 @@ changeTickButton.onclick = function() {
|
|||
changeIdButton.onclick = function() {
|
||||
Id = document.getElementById("D").value;
|
||||
ws.close();
|
||||
ws = new WebSocket("ws:10.9.1.129:8080/" + Id);
|
||||
ws = new WebSocket("wss://nerfingen.de:8080/" + Id);
|
||||
document.getElementById("p4").innerHTML = "" + Id;
|
||||
}
|
||||
|
||||
|
@ -165,11 +165,14 @@ function PlayerList(){
|
|||
|
||||
/*Updates the current Player according to the Player with the smallest Tick in players.*/
|
||||
function CurrentPlayer(){
|
||||
if (players.length > 0 ){
|
||||
document.getElementById("p2").innerHTML = players[0].Name;
|
||||
document.getElementById("p1").innerHTML = "" + players[0].Tick;
|
||||
}
|
||||
}
|
||||
|
||||
function AddPlayer(player){
|
||||
var hinzugefügt = false;
|
||||
if (player.Tick == "Abwarten"){
|
||||
players.push(player);
|
||||
}
|
||||
|
@ -186,8 +189,12 @@ function AddPlayer(player){
|
|||
for (i = 0; i<players.length;i++){
|
||||
if (player.Tick < players[i].Tick){
|
||||
players.splice(i,0,player);
|
||||
hinzugefügt = true;
|
||||
break;
|
||||
}
|
||||
if (i == players.length -1 && hinzugefügt == false){
|
||||
players.push(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue