-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
130 lines (114 loc) · 5.63 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt-br" lang="pt-br"><head>
<strong>JOGO DE ADVINHAÇÃO</strong>
<style type="text/css">
<!--
.superior {
background-color: #4e42f5;
color: #FFFFFF
}
table {
border: inset 3px #421717;
background-color: #19d4222d;
}
body {
font: 13px 'Trebuchet MS', 'Segoe UI', Verdana, sans-serif;
background-color: #f9fcfc;
}
.titulo {
font: small-caps 25px Tahoma, sans-serif;
color: #130a8f;
background-color: #f3f3f3
}
-->
</style>
<script type="text/javascript">
<!--
//declaração das funçoes
function chutar(evt){
console.log(evt);
debugger;
}
n = new Array
n[1]= "Muito facil"
n[2] = "fácil";
n[3] = "médio";
n[4] = "difícil";
nivel = 40; // Nível padrão
max = 10; // Escolha máxima padrão do usuário
Pensar(); // O PC "pensa" em um número dentro do intervalo solicitado
function Pensar() {
numeroSecreto = Math.round(Math.random()* max); // Fórmula que o PC usa para "pensar" num número
contador = 0; // Zera o contador
}
function Testar() {
valorUsuario = document.form.chute.value; // A escolha do usuário
if (valorUsuario > max || valorUsuario < 0 || isNaN(valorUsuario) || valorUsuario == "") {
alert('Você deve escolher um valor numérico entre 0 e ' + max +'! Vamos lá...')
// Aqui testa se a escolha do usuário está dentro do intervalo permitido
// E também testa se deixou em branco ou inseriu letras
}
else if (numeroSecreto < valorUsuario) {
contador++; // Incrementa o contador
alert('Eu estou pensando num número que é MENOR do que o número que você chutou: ' + valorUsuario);
}
else if (numeroSecreto > valorUsuario) {
contador++;
alert('Eu estou pensando num número que é MAIOR do que o número que você chutou: ' + valorUsuario);
}
else {
contador++;
alert('Parabéns! Você conseguiu adivinhar o número em que eu estava pensando, que era ' + numeroSecreto + ', em ' + contador + ' tentativa(s). Agora vou pensar em outro número...');
if (contador < record[nivel]) {
record[nivel] = contador;
AtualizarRecord();
alert('É isso aí! Você fez um novo record no nível ' + n[nivel] + '!');
}
Pensar();
}
document.form.chute.value = ""; // Limpa o campo p/ facilitar a vida do usuário
document.form.chute.focus();
return false; // Retorna falso, isto é, não submete o formulário
}
function MudarNivel() { // Esta função é usada para mudar o nível de dificuldade, sendo chamada no evento onchange
nivel = document.form.dificuldade.value; // Atualiza o nível
max = Math.pow(10,nivel); // Atualiza o valor máximo permitido
alert('Eu tinha pensado no ' + numeroSecreto + '. Agora, no nível ' + n[nivel] + ' escolha um número entre 1 e ' + max);
document.form.chute.focus();
Pensar(); // O PC "pensa" em outro número, logo zera o contador
}
function InicioRecord() {
record = new Array;
record[1] = record[2] = record[3] = record[4] = record[5] = record[6] =999; // Inicializa as variáveis
}
function AtualizarRecord() {
document.form.n1.value = record[1]; // Atualiza os recordes
document.form.n2.value = record[2];
document.form.n3.value = record[3];
document.form.n4.value = record[4];
document.form.n5.value = record[5];
document.form.n6.value = record[6];
}
//-->
</script>
</head>
<body onload="document.form.chute.focus(); InicioRecord()">
<span></span><br>
<h4>Nível muito fácil: de 1 a 10;<br>Nível fácil: de 1 a 100;<br>Nível médio: de 1 a 1000;<br>Nível difícil: de 1 a 10000;<br></h4>
<form name="form" onsubmit="return Testar()" method="post" action="#">
Nível de dificuldade:
<select name="dificuldade" onchange="MudarNivel()">
<option value="1" selected>clique</option>
<option value="2">Fácil</option>
<option value="3">Médio</option>
<option value="4">Difícil</option>
</select><br><br>
Chute um valor: <input type="text" size="42" name="chute">
<input type="submit" name="arriscar" value="jogar"jogar" onmouseout=" jogar" style=" ">
<input type="button" value="Parar" onclick="alert('O número que eu escolhi foi: ' + numeroSecreto + '. Pena que você desistiu! Tente novamente, eu vou pensar em outro número, OK?'); Pensar()"><br><br>
<div id="sfcqe4p88y1rlxx9ybh7773qprjfcr96x6x"></div>
<script type="text/javascript" src="https://counter3.stat.ovh/private/counter.js?c=qe4p88y1rlxx9ybh7773qprjfcr96x6x&down=async" async></script>
<br><a href=" ">contador de jogadas</a><noscript><a href=" " title="contador de jogadas"><img src="https://counter3.stat.ovh/private/webcontadores.php?c=qe4p88y1rlxx9ybh7773qprjfcr96x6x" border="0" title="contador de visitas para blog" alt="contador de jogadas"></a></noscript>
<table cellspacing="0" cellpadding="10" summary="records"> <!-- Tabela de records -->
<tbody><tr class="superior">
</html>
</body>