-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
184 lines (130 loc) · 3.87 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!DOCTYPE html>
<html lang="en">
<style>
input{
width: 20%;
font-size: large;
}
</style>
<head>
<meta charset="UTF-8">
<title>Persona</title>
<link rel="stylesheet" href="style/style.css">
</head>
<body onload="eski()">
<center>
<table>
<th>Oyuncular</th>
<th>Mekanlar</th>
<tr>
<td>
<textarea placeholder="Oyuncular" id="oyuncular" rows="20">
Hansel
Kırmızı Başlıklı Kız
Sindirella</textarea>
</td>
<td>
<textarea placeholder="Mekanlar" id="mekanlar" rows="20">
Gemi
Uçak
İnşaat
Okul
Orman
New York
Trodos
Karpaz
Kantara
Mağusa
Girne
Lefkoşa
Güzelyurt
Salamis Antik Kenti
Beşparmak Dağları
Issız Ada
Kuzey Kutbu
Askeri Üs
Laboratuar
Kafeterya
Futbol Sahası
Basketbol Sahası
Mesarya Ovası
Deniz
Uzay</textarea>
</td>
</tr>
<tr>
<td>
Kaç Casus? <input id="kacCasus" value=1 type="number">
</td>
</tr>
</table>
<button type="button" id="onaybut" onclick="salla()">Çalkala</button>
<br>
<a href="kural.html"><button>Oynanış</button></a>
</center>
</body>
</html>
<script>
var casuslar = [];
var mekan = '';
function salla(){
casSay = parseInt(document.getElementById("kacCasus").value);
document.getElementById("oyuncular").value = ele("oyuncular");
document.getElementById("mekanlar").value = ele("mekanlar");
var geciciText = '';
geciciText = document.getElementById("oyuncular").value
var yeniText = geciciText.replace(/^\s*[\r\n]/gm, '');
document.getElementById("oyuncular").value = yeniText;
geciciText = document.getElementById("mekanlar").value
var yeniText = geciciText.replace(/^\s*[\r\n]/gm, '');
document.getElementById("mekanlar").value = yeniText;
document.getElementById("onaybut").disabled= true;
const oyuncular = document.getElementById("oyuncular").value.split("\n");
const mekanlar = document.getElementById("mekanlar").value.split("\n");
const taht = Math.floor(Math.random() * mekanlar.length);
mekan = mekanlar[taht];
while (casuslar.length < casSay){
var casus = '';
let baht = Math.floor(Math.random() * oyuncular.length);
casus = oyuncular[baht];
if (!casuslar.includes(casus)) {
casuslar.push(casus);
console.log(casuslar);
}
}
for (kisi of oyuncular){
var b = document.createElement("button");
b.textContent = kisi;
if (casuslar.includes(kisi)){
b.onclick = function(){
alert("Casus");
this.disabled=true;
};
}else{
b.onclick = function(){
alert(mekan);
this.disabled = true;
};
}
document.body.appendChild(b);
}
localStorage.setItem("oyuncular", document.getElementById("oyuncular").value);
localStorage.setItem("mekanlar", document.getElementById("mekanlar").value);
}
function eski(){
if(localStorage.getItem("oyuncular").length > 1){
document.getElementById("oyuncular").value = localStorage.getItem("oyuncular");
document.getElementById("mekanlar").value = localStorage.getItem("mekanlar");
}
}
function ele(nerden){
var ham = document.getElementById(nerden).value.split("\n");
var yeniText = '';
for (line of ham){
if (line.length > 0){
yeniText = yeniText.concat("\n", line);
}
}
return yeniText;
}
</script>