-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCropField.java
102 lines (82 loc) · 2.53 KB
/
CropField.java
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
package model.farm.building.crop_field;
import model.InGameTime;
import model.Position;
import model.farm.Currency;
import model.farm.building.Buildable;
import model.farm.data.item.Crop;
import model.farm.data.item.CropGrowthStage;
import model.farm.building.crop_field.state.CropFieldState;
import model.farm.building.crop_field.state.NotPlanted;
import model.region.RectangleRegion;
import model.region.Region;
import java.util.Objects;
public class CropField extends Buildable {
private CropFieldState state;
public CropField(Position topLeft) {
super(topLeft);
this.state = new NotPlanted();
}
@Override
public Currency getBuildPrice() {
return new Currency(3500);
}
@Override
public int getWidth() {
return 4;
}
@Override
public int getHeight() {
return 4;
}
@Override
public Region getUntraversableRegion() {
return new RectangleRegion(
this.getTopLeftPosition().getTranslated(new Position(1, 1)),
this.getWidth() - 2,
this.getHeight() - 2);
}
@Override
public Region getInteractiveRegion() {
return new RectangleRegion(this.getTopLeftPosition(), this.getWidth(), this.getHeight());
}
@Override
public String getName() {
return "CROPFIELD";
}
public void setState(CropFieldState state) {
this.state = state;
}
public CropFieldState getState() {
return this.state;
}
public CropGrowthStage getCropGrowthStage() {
InGameTime remainingTime = this.state.getRemainingTime();
return this.state.getCrop().getCurrentGrowthStage(remainingTime);
}
public Crop getCrop() {
return this.state.getCrop();
}
public InGameTime getRemainingTime() {
return this.state.getRemainingTime();
}
public void setRemainingTime(InGameTime time) {
this.state.setRemainingTime(time);
}
public void changeHarvestAmount(double quantity) {
this.state.changeHarvestAmount(quantity);
}
public int getHarvestAmount() {
return this.state.getHarvestAmount();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
CropField cropField = (CropField) o;
return Objects.equals(this.getTopLeftPosition(), cropField.getTopLeftPosition());
}
@Override
public int hashCode() {
return Objects.hash(this.getTopLeftPosition());
}
}