This repository has been archived by the owner on Sep 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tile.java
81 lines (69 loc) · 2.25 KB
/
Tile.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
import java.io.Serializable;
public class Tile implements Serializable{
private static final long serialVersionUID = 1L;
public double soilQuality;
public double environmentQuality;
private double temperature;
private Biome biome;
public Plant plant;
public Improvement improvement;
public Player owner;
public Tile(Biome biome) {
this.biome = biome;
this.soilQuality = 5 + Math.random() * 5;
this.environmentQuality = 5 + Math.random() * 5;
this.temperature = biome.avgTemperature + Math.random() * 0.50 * biome.avgTemperature - 0.25 * biome.avgTemperature;
this.plant = null;
this.improvement = null;
this.owner = null;
}
public double getTemperature(){
return this.temperature;
}
public void setTemperature(double temperature){
Biome newBiome = this.biome;
if(this.biome.name.equals("mountains") || this.biome.name.equals("hills")){
do{
newBiome = Biome.generateSimilarBiome(temperature, Biome.naturalBiomes);
}while(!(newBiome.name.equals("mountains") || newBiome.name.equals("hills")));
}else if(temperature < this.biome.avgTemperature - 20 || temperature > this.biome.avgTemperature + 20 ){
do{
newBiome = Biome.generateSimilarBiome(temperature, Biome.naturalBiomes);
}while(this.biome.isLiquid != newBiome.isLiquid);
}
this.biome = newBiome;
this.temperature = temperature;
}
public void terraformTile(double temperature){
this.biome = Biome.generateSimilarBiome(temperature, Biome.allBiomes);
this.temperature = temperature;
}
public Biome getBiome(){
return this.biome;
}
public double getPlayerDamage(double[] tempRange){
double dmg = 0;
dmg += biome.additionalPlayerDamage;
if(improvement != null){
dmg += improvement.playerDamage;
}
if(temperature < tempRange[0]){
dmg += tempRange[0] - temperature;
}else if(temperature > tempRange[1]){
dmg += temperature - tempRange[1];
}
return dmg;
}
public double getPlayerMovementCost(){
double moveCost = 0;
moveCost += biome.movementChange;
if(improvement != null){
moveCost += improvement.movementChange;
}
return moveCost;
}
@Override
public String toString(){
return this.biome.name + ": (Temperature: " + this.temperature + ", Environment: " + this.environmentQuality + ", Soil: " + this.soilQuality + ")";
}
}