-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadyToHarvest.java
50 lines (41 loc) · 1.36 KB
/
ReadyToHarvest.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
package model.farm.building.crop_field.state;
import model.InGameTime;
import model.farm.building.crop_field.CropField;
import model.farm.data.item.Crop;
public class ReadyToHarvest implements CropFieldState {
private CropField cropField;
private Crop crop;
private double harvestAmount; // double so that small but in great quantity changes can have an effect
public ReadyToHarvest(CropField cropField, Crop crop, double harvestAmount) {
this.cropField = cropField;
this.crop = crop;
this.harvestAmount = harvestAmount;
}
@Override
public InGameTime getRemainingTime() {
return new InGameTime(0);
}
@Override
public void setRemainingTime(InGameTime time) {}
@Override
public Crop getCrop() {
return this.crop;
}
@Override
public int getHarvestAmount() {
return (int) this.harvestAmount;
}
@Override
public void changeHarvestAmount(double harvestAmount) {
// when readyToHarvest only bad effects take place
// what would be a good effect while crop was in growth stage
// will rot it when ready to harvest
if (harvestAmount > 0) {
harvestAmount *= -1;
}
this.harvestAmount += harvestAmount;
if (this.harvestAmount <= 0) {
this.cropField.setState(new NotPlanted());
}
}
}