-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrass.js
More file actions
43 lines (41 loc) · 1.33 KB
/
Grass.js
File metadata and controls
43 lines (41 loc) · 1.33 KB
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
var LivingCreuture = require("./LivingCreuture.js")
module.exports = class Grass extends LivingCreuture {
mul() {
this.energy++;
let chooseCells = this.chooseCell(0);
let newCell = chooseCells[Math.floor(Math.random() * chooseCells.length)]
if (weather == "Summer") {
if (newCell && this.energy > 1) {
let x = newCell[0];
let y = newCell[1];
matrix[y][x] = 1;
let grass = new Grass(x, y);
grassArr.push(grass);
this.energy = 0;
grassHashiv++
}
}
else if (weather == "Spring") {
if (newCell && this.energy > 5) {
let x = newCell[0];
let y = newCell[1];
matrix[y][x] = 1;
let grass = new Grass(x, y);
grassArr.push(grass);
this.energy = 0;
grassHashiv++
}
}
else if(weather == "Winter"){
if (newCell && this.energy > 10) {
let x = newCell[0];
let y = newCell[1];
matrix[y][x] = 1;
let grass = new Grass(x, y);
grassArr.push(grass);
this.energy = 0;
grassHashiv++
}
}
}
}