Test fixes

This commit is contained in:
Anuken
2019-04-07 14:53:53 -04:00
parent 9699d9467a
commit 7dfb0a81e3
5 changed files with 15 additions and 7 deletions

View File

@ -261,6 +261,8 @@ public class BlockIndexer{
}
private void updateQuadrant(Tile tile){
if(structQuadrants == null) return;
//this quadrant is now 'dirty', re-scan the whole thing
int quadrantX = tile.x / structQuadrantSize;
int quadrantY = tile.y / structQuadrantSize;

View File

@ -90,7 +90,7 @@ public class Pathfinder{
* This only occurs for active teams.*/
private void update(Tile tile, Team team){
//make sure team exists
if(paths[team.ordinal()] != null && paths[team.ordinal()].weights != null){
if(paths != null && paths[team.ordinal()] != null && paths[team.ordinal()].weights != null){
PathData path = paths[team.ordinal()];
//impassable tiles have a weight of float.max

View File

@ -5,8 +5,7 @@ import io.anuke.arc.collection.Array;
import io.anuke.arc.collection.IntArray;
import io.anuke.arc.math.Angles;
import io.anuke.arc.math.Mathf;
import io.anuke.arc.util.Time;
import io.anuke.arc.util.Tmp;
import io.anuke.arc.util.*;
import io.anuke.mindustry.content.Blocks;
import io.anuke.mindustry.content.Fx;
import io.anuke.mindustry.entities.Damage;
@ -120,11 +119,13 @@ public class WaveSpawner{
for(int x = 0; x < world.width(); x++){
for(int y = 0; y < world.height(); y++){
if(world.tile(x, y).block() == Blocks.spawn){
addSpawns(x, y);
//hide spawnpoints, they have served their purpose
world.tile(x, y).setBlock(Blocks.air);
Log.info("Add spawn "+ x + " " + y);
}
}
}

View File

@ -25,9 +25,14 @@ import static org.junit.jupiter.api.Assertions.*;
public class ApplicationTests{
static Map testMap;
static boolean initialized;
@BeforeAll
static void launchApplication(){
//only gets called once
if(initialized) return;
initialized = true;
try{
boolean[] begins = {false};
Throwable[] exceptionThrown = {null};
@ -102,6 +107,7 @@ public class ApplicationTests{
@Test
void spawnWaves(){
world.loadMap(testMap);
assertTrue(world.spawner.countSpawns() > 0, "No spawns present.");
logic.runWave();
//force trigger delayed spawns
Time.setDeltaProvider(() -> 1000f);
@ -109,7 +115,7 @@ public class ApplicationTests{
Time.update();
Time.setDeltaProvider(() -> 1f);
unitGroups[waveTeam.ordinal()].updateEvents();
assertFalse(unitGroups[waveTeam.ordinal()].isEmpty());
assertFalse(unitGroups[waveTeam.ordinal()].isEmpty(), "No enemies spawned.");
}
@Test

View File

@ -1,7 +1,6 @@
import io.anuke.arc.collection.Array;
import io.anuke.arc.collection.ObjectSet;
import io.anuke.arc.util.Structs;
import io.anuke.arc.util.Time;
import io.anuke.arc.util.*;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.Zone;
@ -51,7 +50,7 @@ public class ZoneTests{
}
assertTrue(hasSpawnPoint, "Zone \"" + zone.name + "\" has no spawn points.");
//assertTrue(world.spawner.countSpawns() > 0, "Zone \"" + zone.name + "\" has no enemy spawn points: " + world.spawner.countSpawns());
assertTrue(world.spawner.countSpawns() > 0, "Zone \"" + zone.name + "\" has no enemy spawn points: " + world.spawner.countSpawns());
for(Item item : resources){
assertTrue(Structs.contains(zone.resources, item), "Zone \"" + zone.name + "\" is missing item in resource list: \"" + item.name + "\"");