Ir ao conteúdo
  • Cadastre-se

Ajuda com código javascript


Posts recomendados

Boa noite, estou tentando entender esse flagmento de código javascript, mais trabalho mais com desenvolvimento desktop(.NET) e to apanhando, entendo pouco de javascript.

netSpeed = Math.min(upSpeed, (downSpeed * 2));netPlayers = netSpeed / 0.33;RAMPlayers = (RAMAmount * 0.75) / 64;maxPlayers = Math.round(Math.min(RAMPlayers, netPlayers));

Esse código é usado para descobrir quantos jogadores uma maquina com tal velocidade de upload,download e RAM consegue suportar em um servidor de uma game.

Código inteiro

function doStuff(){    upSpeed = $('#UpSpeed').val();    downSpeed = $('#DownSpeed').val();    RAMAmount = $('#RamMB').val();    if (isNaN(upSpeed) | isNaN(downSpeed) | isNaN(RAMAmount)) { alert("Please enter numbers only, no suffixes such as MB or Mbits"); return; }    netSpeed = Math.min(upSpeed, (downSpeed * 2));    netPlayers = netSpeed / 0.33;    RAMPlayers = (RAMAmount * 0.75) / 64;    maxPlayers = Math.round(Math.min(RAMPlayers, netPlayers));    topMessage = "";    reasonMessage = "";    afterMessage = "You're probably better off renting a server instead to have a decent experience.";    if (maxPlayers < 16) {        if (netPlayers < RAMPlayers) {            reasonMessage = "The problem is that the internet connection speed is too slow to send and recieve data the data for more than " + maxPlayers + " people at the same time.";        }        else {            reasonMessage = "You don't have enough RAM in your system to cope with storing data for more than " + maxPlayers + " people at the same time.";                        if (maxPlayers > 10) {                afterMessage = "If you want to have more players, then you should probably consider renting a (bigger) server instead.";            }        }    } else {        reasonMessage = "You've got a fast enough internet connection and enough RAM to cope with a decent number of players.";        if (maxPlayers <= 32) {            afterMessage = "If you want to have more players, then you should probably consider renting a (bigger) server instead.";        }        else {            afterMessage = "Looks like you're all set up to play. Enjoy!";        }    }    if (maxPlayers < 2) { topMessage = "No, sorry!"; }    else if (maxPlayers < 6) { topMessage = "Not really."; }    else if (maxPlayers < 10) { topMessage = "Sorta, but you're pushing it!"; }    else if (maxPlayers < 16) { topMessage = "Yes!"; }    else if (maxPlayers < 20) { topMessage = "Nicely so"; }    else if (maxPlayers < 30) { topMessage = "Easily"; }    else { topMessage = "Yes, a million times!"; }    $(".resultNum").text(maxPlayers);    $("#resultText").text("Result: " + topMessage);    $("#reason").text(reasonMessage);    $("#after").text(afterMessage);    $("#cover").show();    return (false);}function hideStuff() {    $("#cover").hide();}
Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...