Fixed some tests failing

This commit is contained in:
Anuken
2019-03-10 00:10:33 -05:00
parent 671823b4fa
commit 6b074ed4b2
4 changed files with 13 additions and 6 deletions

View File

@@ -159,6 +159,9 @@ public class Vars{
Version.init(); Version.init();
content = new ContentLoader(); content = new ContentLoader();
if(!headless){
content.setVerbose();
}
playerGroup = Entities.addGroup(Player.class).enableMapping(); playerGroup = Entities.addGroup(Player.class).enableMapping();
tileGroup = Entities.addGroup(TileEntity.class, false); tileGroup = Entities.addGroup(TileEntity.class, false);

View File

@@ -34,7 +34,7 @@ import static io.anuke.arc.Core.files;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class ContentLoader{ public class ContentLoader{
private boolean loaded = false; private boolean loaded = false;
private boolean verbose = true; private boolean verbose = false;
private ObjectMap<String, MappableContent>[] contentNameMap = new ObjectMap[ContentType.values().length]; private ObjectMap<String, MappableContent>[] contentNameMap = new ObjectMap[ContentType.values().length];
private Array<Content>[] contentMap = new Array[ContentType.values().length]; private Array<Content>[] contentMap = new Array[ContentType.values().length];
@@ -57,6 +57,10 @@ public class ContentLoader{
new LegacyColorMapper(), new LegacyColorMapper(),
}; };
public void setVerbose(){
verbose = true;
}
/**Creates all content types.*/ /**Creates all content types.*/
public void load(){ public void load(){
if(loaded){ if(loaded){

View File

@@ -106,7 +106,7 @@ public class PowerGraph{
public float chargeBatteries(float excess){ public float chargeBatteries(float excess){
float capacity = getBatteryCapacity(); float capacity = getBatteryCapacity();
if(Mathf.isEqual(capacity, 0f)){ return 0f; } if(Mathf.isEqual(capacity, 0f)) return 0f;
for(Tile battery : batteries){ for(Tile battery : batteries){
Consumers consumes = battery.block().consumes; Consumers consumes = battery.block().consumes;
@@ -123,7 +123,7 @@ public class PowerGraph{
public void distributePower(float needed, float produced){ public void distributePower(float needed, float produced){
//distribute even if not needed. this is because some might be requiring power but not requesting it; it updates consumers //distribute even if not needed. this is because some might be requiring power but not requesting it; it updates consumers
float coverage = Math.min(1, produced / (Mathf.isZero(needed) ? 1f : needed)); float coverage = Mathf.isZero(needed) ? 1f : Math.min(1, produced / needed);
for(Tile consumer : consumers){ for(Tile consumer : consumers){
Consumers consumes = consumer.block().consumes; Consumers consumes = consumer.block().consumes;
if(consumes.has(ConsumePower.class)){ if(consumes.has(ConsumePower.class)){

View File

@@ -16,13 +16,13 @@ public class DirectConsumerTests extends PowerTestFixture{
@Test @Test
void noPowerRequestedWithNoItems(){ void noPowerRequestedWithNoItems(){
testUnitFactory(0, 0, 0.08f, 0.08f, 0f); testUnitFactory(0, 0, 0.08f, 0.08f, 1f);
} }
@Test @Test
void noPowerRequestedWithInsufficientItems(){ void noPowerRequestedWithInsufficientItems(){
testUnitFactory(30, 0, 0.08f, 0.08f, 0f); testUnitFactory(30, 0, 0.08f, 0.08f, 1f);
testUnitFactory(0, 30, 0.08f, 0.08f, 0f); testUnitFactory(0, 30, 0.08f, 0.08f, 1f);
} }
@Test @Test