<file_sep>/**
 * Getting Started Course with JavaScript lesson 12
 * In this we will create a Jokenpô (Stone, Paper and Scissors)
 * @author <NAME>
 * Web Developer and Mobile
 */

 // Main function

 function jogar(){
    if(document.getElementById("pedra").checked == false &&  
       document.getElementById("papel").checked == false && 
       document.getElementById("tesoura").checked == false ){
        
       alert("Selecione uma opção");
    }
    else{
        var sorteio = Math.floor(Math.random() * 3);
        switch(sorteio){
            case 0:
                document.getElementById("pc").src = "imagens_sons/pcpedra.png";
                break;

            case 1:
                document.getElementById("pc").src = "imagens_sons/pcpapel.png";
                break;

            case 2:
                document.getElementById("pc").src = "imagens_sons/pctesoura.png";
                break;
        }

        // Check the winner or declare a tie.

        if((document.getElementById("pedra").checked == true && sorteio == 0) ||  
           (document.getElementById("papel").checked == true && sorteio == 1) || 
           (document.getElementById("tesoura").checked == true && sorteio == 2)){

          document.getElementById("placar").innerHTML = "Empate";

          }
          
          else if
            ((document.getElementById("pedra").checked == true && sorteio == 2) ||  
             (document.getElementById("papel").checked == true && sorteio == 0) || 
             (document.getElementById("tesoura").checked == true && sorteio == 1)){

            document.getElementById("placar").innerHTML = "Jogador Venceu";

          }
          
          else{
            document.getElementById("placar").innerHTML = "Computador Venceu";
          }

    }
 }
 
 function resetar(){
    document.getElementById("pc").src = "imagens_sons/pc.png";

    document.getElementById("placar").innerHTML = "";
 }