-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.js
57 lines (49 loc) · 1.37 KB
/
helper.js
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
helper.randomEl = function () {
return Math.floor(Math.random() * 100);
}
helper.gemiYoxlama = function (a, b,c) {
yoxlamaArr = [];
if (a - b >= 0) yoxlamaArr.push(1); // left side
if (a + b <= 9) yoxlamaArr.push(2); // rigth side
if ((c - ((b - 1) * 10)) >= 0) yoxlamaArr.push(3); // upper side
if ((c + ((b - 1) * 10) < 100)) yoxlamaArr.push(4); // lower side
return yoxlamaArr;
};
//istiqamet choxlugundan bir eded istiqamet sechimi
helper.istiqamet = function (yoxlama_Arr) {
let ranDom = yoxlama_Arr[Math.floor(Math.random() * yoxlama_Arr.length)];
return ranDom;
};
// Iki ve daha chox xanali gemilerin hedef secimi
helper.hedefYerleshmesi = function (a, t, n, h) { // a - istiqamet , t = secilen birici noqte , n - gemi xana sayi, h- hedef coxlugu
let m = 0
h.push(t);
if (a == 1) {
while (m < n - 1) {
t = t - 1;
h.push(t);
m++;
};
};
if (a == 2) {
while (m < n - 1) {
t = t + 1;
h.push(t);
m++;
};
};
if (a == 3) {
while (m < n - 1) {
t = t - 10;
h.push(t);
m++;
};
};
if (a == 4) {
while (m < n - 1) {
t = t + 10;
h.push(t);
m++;
};
};
};