IAMAGENIUS (and i fixed the skipping

This commit is contained in:
Kasper Rynning-Tønnesen
2015-04-16 11:43:33 +02:00
parent 2baac2d1d5
commit a2c1a9d40d

View File

@@ -182,14 +182,15 @@ io.on('connection', function(socket){
db.collection(coll).find({skip: false}, function(err, docs){
if(docs.length == 1)
{
if(lists[coll].length/2 <= docs[0]["skips"].length+1)
if(lists[coll].length/2 <= docs[0]["skips"].length+1 && !contains(docs[0]["skips"], guid))
{
change_song(coll);
}else{
}else if(!contains(docs[0]["skips"], guid)){
db.collection(coll).update({views:{$exists:true}}, {$push:{skips:guid}}, function(err, d){
//reply with skips or something
socket.emit("toast", (Math.ceil(lists[coll].length/2) - docs[0]["skips"].length+1) + " more are needed to skip!");
socket.emit("toast", (Math.ceil(lists[coll].length/2) - docs[0]["skips"].length-1) + " more are needed to skip!");
});
}else{
socket.emit("toast", "You've already voted to skip!");
}
}else
socket.emit("toast", "No Skipping!");