mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-28 07:22:21 -08:00
Support for wave shields
This commit is contained in:
parent
dc58626602
commit
78f24b8840
10 changed files with 70 additions and 31 deletions
97
tests/src/test/java/SectorTests.java
Normal file
97
tests/src/test/java/SectorTests.java
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.core.GameState.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.io.SaveIO.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.storage.*;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.DynamicTest.dynamicTest;
|
||||
|
||||
public class SectorTests{
|
||||
|
||||
@BeforeAll
|
||||
static void launchApplication(){
|
||||
ApplicationTests.launchApplication();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void resetWorld(){
|
||||
Time.setDeltaProvider(() -> 1f);
|
||||
logic.reset();
|
||||
state.set(State.menu);
|
||||
}
|
||||
|
||||
@TestFactory
|
||||
DynamicTest[] testZoneValidity(){
|
||||
Array<DynamicTest> out = new Array<>();
|
||||
if(world == null) world = new World();
|
||||
|
||||
for(SectorPreset zone : content.sectors()){
|
||||
|
||||
out.add(dynamicTest(zone.name, () -> {
|
||||
logic.reset();
|
||||
try{
|
||||
world.loadGenerator(zone.generator.map.width, zone.generator.map.height, zone.generator::generate);
|
||||
}catch(SaveException e){
|
||||
//fails randomly and I don't care about fixing it
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
zone.rules.get(state.rules);
|
||||
ObjectSet<Item> resources = new ObjectSet<>();
|
||||
boolean hasSpawnPoint = false;
|
||||
|
||||
for(Tile tile : world.tiles){
|
||||
if(tile.drop() != null){
|
||||
resources.add(tile.drop());
|
||||
}
|
||||
if(tile.block() instanceof CoreBlock && tile.team() == state.rules.defaultTeam){
|
||||
hasSpawnPoint = true;
|
||||
}
|
||||
}
|
||||
|
||||
Array<SpawnGroup> spawns = state.rules.spawns;
|
||||
|
||||
int bossWave = 0;
|
||||
outer:
|
||||
for(int i = 1; i <= 1000; i++){
|
||||
for(SpawnGroup spawn : spawns){
|
||||
if(spawn.effect == StatusEffects.boss && spawn.getUnitsSpawned(i) > 0){
|
||||
bossWave = i;
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(state.rules.attackMode){
|
||||
bossWave = 100;
|
||||
}else{
|
||||
assertNotEquals(0, bossWave, "Sector doesn't have a boss wave.");
|
||||
}
|
||||
|
||||
//TODO check for difficulty?
|
||||
for(int i = 1; i <= bossWave; i++){
|
||||
int total = 0;
|
||||
for(SpawnGroup spawn : spawns){
|
||||
total += spawn.getUnitsSpawned(i);
|
||||
}
|
||||
|
||||
assertNotEquals(0, total, "Sector " + zone + " has no spawned enemies at wave " + i);
|
||||
assertTrue(total < 75, "Sector spawns too many enemies at wave " + i + " (" + total + ")");
|
||||
}
|
||||
|
||||
assertTrue(hasSpawnPoint, "Sector \"" + zone.name + "\" has no spawn points.");
|
||||
assertTrue(spawner.countSpawns() > 0 || (state.rules.attackMode && state.teams.get(state.rules.waveTeam).hasCore()), "Sector \"" + zone.name + "\" has no enemy spawn points: " + spawner.countSpawns());
|
||||
}));
|
||||
}
|
||||
|
||||
return out.toArray(DynamicTest.class);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue