-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
59 lines (49 loc) · 1.42 KB
/
index.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
56
57
//On require la classe Demineur
import Demineur, {Mine, Num} from './Demineur.js';
const start = new Vue({
el:'#start',
data:{
width: 5,
height: 5,
start: false,
Win: false,
Defait: false,
demineur: undefined,
},
methods:{
start_game: function(x,y){
if (x > 0 && y > 0){
this.start = true;
console.log(x);
console.log(y);
this.demineur = new Demineur(x, y);
this.grid = this.demineur.grid;
this.Win = this.demineur.Win;
this.Defait = this.demineur.Defait;
this.nbrMine = this.demineur.NUMBER_FO_MINES;
return false;
}else{
return true;
}
},
condition_over: function(){
this.Win;
this.Defait;
return !this.Win && !this.Defait;
},
clicks: function (x, y, e) {
if (this.condition_over() === true){
e.preventDefault()
this.demineur.click(x, y);
this.Defait = this.demineur.Defait;
this.Win = this.demineur.Win;
}
},
flags: function (x, y, e) {
e.preventDefault();
if (this.condition_over() === true) {
this.demineur.flag(x, y);
}
},
},
})