mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-25 07:08:07 +07:00
Fixed unit tests / Fixed zones having incorrect waves
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.ApplicationCore;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.backends.headless.HeadlessApplication;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.math.geom.Point2;
|
||||
import io.anuke.arc.util.Log;
|
||||
import io.anuke.arc.util.Time;
|
||||
@ -11,11 +11,13 @@ import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest;
|
||||
import io.anuke.mindustry.entities.type.BaseUnit;
|
||||
import io.anuke.mindustry.entities.type.base.Spirit;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.game.Content;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.io.BundleLoader;
|
||||
import io.anuke.mindustry.io.SaveIO;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.BlockPart;
|
||||
import org.junit.jupiter.api.*;
|
||||
@ -266,39 +268,6 @@ public class ApplicationTests{
|
||||
assertTrue(world.tile(1, 1).block() instanceof BlockPart);
|
||||
}
|
||||
|
||||
@Test
|
||||
void zoneEmptyWaves(){
|
||||
for(Zone zone : content.zones()){
|
||||
Array<SpawnGroup> spawns = zone.rules.get().spawns;
|
||||
for(int i = 1; i <= 100; i++){
|
||||
int total = 0;
|
||||
for(SpawnGroup spawn : spawns){
|
||||
total += spawn.getUnitsSpawned(i);
|
||||
}
|
||||
|
||||
assertNotEquals(0, total, "Zone " + zone + " has no spawned enemies at wave " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void zoneOverflowWaves(){
|
||||
for(Zone zone : content.zones()){
|
||||
Array<SpawnGroup> spawns = zone.rules.get().spawns;
|
||||
|
||||
for(int i = 1; i <= 40; i++){
|
||||
int total = 0;
|
||||
for(SpawnGroup spawn : spawns){
|
||||
total += spawn.getUnitsSpawned(i);
|
||||
}
|
||||
|
||||
if(total >= 140){
|
||||
fail("Zone '" + zone + "' has too many spawned enemies at wave " + i + " : " + total);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildingDestruction(){
|
||||
initBuilding();
|
||||
|
@ -3,6 +3,7 @@ import io.anuke.arc.collection.ObjectSet;
|
||||
import io.anuke.arc.util.Structs;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.game.SpawnGroup;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.Zone;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
@ -10,6 +11,7 @@ import io.anuke.mindustry.world.blocks.storage.CoreBlock;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.DynamicTest.dynamicTest;
|
||||
|
||||
@ -28,7 +30,7 @@ public class ZoneTests{
|
||||
}
|
||||
|
||||
@TestFactory
|
||||
DynamicTest[] testZoneResources(){
|
||||
DynamicTest[] testZoneValidity(){
|
||||
Array<DynamicTest> out = new Array<>();
|
||||
|
||||
for(Zone zone : content.zones()){
|
||||
@ -36,6 +38,7 @@ public class ZoneTests{
|
||||
zone.generator.init(zone.loadout);
|
||||
logic.reset();
|
||||
world.loadGenerator(zone.generator);
|
||||
zone.rules.accept(state.rules);
|
||||
ObjectSet<Item> resources = new ObjectSet<>();
|
||||
boolean hasSpawnPoint = false;
|
||||
|
||||
@ -51,15 +54,25 @@ public class ZoneTests{
|
||||
}
|
||||
}
|
||||
|
||||
Array<SpawnGroup> spawns = state.rules.spawns;
|
||||
for(int i = 1; i <= 100; i++){
|
||||
int total = 0;
|
||||
for(SpawnGroup spawn : spawns){
|
||||
total += spawn.getUnitsSpawned(i);
|
||||
}
|
||||
|
||||
assertNotEquals(0, total, "Zone " + zone + " has no spawned enemies at wave " + i);
|
||||
}
|
||||
|
||||
assertTrue(hasSpawnPoint, "Zone \"" + zone.name + "\" has no spawn points.");
|
||||
assertTrue(world.spawner.countSpawns() > 0 || (zone.rules.get().attackMode && !state.teams.get(waveTeam).cores.isEmpty()), "Zone \"" + zone.name + "\" has no enemy spawn points: " + world.spawner.countSpawns());
|
||||
assertTrue(world.spawner.countSpawns() > 0 || (state.rules.attackMode && !state.teams.get(waveTeam).cores.isEmpty()), "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 + "\"");
|
||||
}
|
||||
|
||||
for(Item item : zone.resources){
|
||||
assertTrue(resources.contains(item), "Zone \"" + zone.name + "\" has unnecessary item in resoruce list: \"" + item.name + "\"");
|
||||
assertTrue(resources.contains(item), "Zone \"" + zone.name + "\" has unnecessary item in resource list: \"" + item.name + "\"");
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
Reference in New Issue
Block a user