Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var vetor=new Array(30);
- for(i=0;i<30;i++){
- vetor[i]=0;
- }
- var start=0;
- var jogadas=0;
- var cora=0;
- var wins=0;
- var lose=0;
- var bomba=0;
- var conta;
- var contax=0;
- var FM=0;
- function sorteio(t,q){
- for(i=1;i<=parseInt(q);i++){
- do{
- u=Math.floor((Math.random() * 29) + 1);
- }while(vetor[u]!=0);
- vetor[u]=parseInt(t);
- }
- }
- function depois(){
- for(i=0;i<30;i++){
- document.getElementById('t' + i).innerHTML=' ';
- document.getElementById('t' + i).className="";
- vetor[i]=0;
- }
- document.getElementById('w1').innerHTML=0;
- document.getElementById('w2').innerHTML=0;
- document.getElementById('w3').innerHTML=0;
- }
- function clica(){
- depois();
- start=1;
- sorteio(1,5);
- sorteio(2,1);
- sorteio(3,6);
- document.getElementById('tabela').style="background-color: #4dc3ff;";
- document.getElementById('butao').disabled="disabled";
- }
- function ok(){
- document.getElementById('butao').disabled="";
- bomba=0;
- contax=0;
- FM=0;
- document.getElementById('w1').innerHTML=0;
- document.getElementById('w2').innerHTML=0;
- document.getElementById('w3').innerHTML=0;
- clearTimeout(conta);
- }
- function cronometro(){
- if(contax>=2){
- clearTimeout(conta);
- alert("Perdeu,Encontrou duas Bombas Temporizadas");
- ok();
- start=0;
- }
- }
- function fim(){
- document.getElementById('fm1').style.visibility = "hidden";
- document.getElementById('fg').style.visibility = "visible";
- document.getElementById('crl').style.visibility = "hidden";
- document.getElementById('crl').style.display = "none";
- document.getElementById('cli').style.visibility = "visible";
- ok();
- clearTimeout(conta);
- }
- function acabou(){
- if(bomba==1){
- alert("Ups, Escolheu um bomba!");
- ok();
- start=0
- document.getElementById('o2').innerHTML=parseInt(document.getElementById('o2').innerHTML)+1;
- }
- else{
- if(FM==6 && contax!=5){
- clearTimeout(conta);
- alert("Ganhou");
- fim();
- start=0;
- document.getElementById('o1').innerHTML=parseInt(document.getElementById('o1').innerHTML)+1;
- }
- }
- }
- function rt(x){
- if(start==1){
- if(document.getElementById('t' + x).innerHTML==' '){
- jogadas++;
- console.log(jogadas);
- document.getElementById('cli').value++;
- document.getElementById('t' + x).className="escolha";
- switch (vetor[x]) {
- //--------------------Temporizador--------
- case 1: document.getElementById('t' + x).innerHTML='⏱';
- conta=setTimeout(function(){ alert("Perdeu, Não Encontrou o Bombeiro"); clearTimeout(conta); ok();}, 3000);
- contax++;
- document.getElementById('w2').innerHTML=parseInt(document.getElementById('w2').innerHTML)+1;
- cronometro();
- break;
- //--------------------Bomba--------------
- case 2: document.getElementById('t' + x).innerHTML='💣';
- document.getElementById('w1').innerHTML=parseInt(document.getElementById('w1').innerHTML)+1;
- bomba++;
- clearTimeout(conta);
- acabou();
- break;
- //--------------------Bombeiro-----------
- case 3: document.getElementById('t' + x).innerHTML='👨‍🚒';
- document.getElementById('w3').innerHTML=parseInt(document.getElementById('w3').innerHTML)+1;
- FM++;
- if(contax>=1){
- contax=contax-1;
- clearTimeout(conta);
- }
- acabou();
- break;
- }
- }
- }
- else
- if(start==0){
- alert("Tem de começar o jogo!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment