mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-10 07:07:03 +07:00
Fixed unit tests / Fixed zones having incorrect waves
This commit is contained in:
parent
18328320c1
commit
5cfab33ada
@ -1,7 +1,8 @@
|
||||
package io.anuke.mindustry.content;
|
||||
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.game.ContentList;
|
||||
import io.anuke.mindustry.game.SpawnGroup;
|
||||
import io.anuke.mindustry.maps.generators.MapGenerator;
|
||||
import io.anuke.mindustry.maps.generators.MapGenerator.Decoration;
|
||||
import io.anuke.mindustry.maps.zonegen.DesertWastesGenerator;
|
||||
@ -25,11 +26,11 @@ public class Zones implements ContentList{
|
||||
conditionWave = 5;
|
||||
launchPeriod = 5;
|
||||
resources = new Item[]{Items.copper, Items.scrap, Items.lead, Items.sand};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
waveTimer = true;
|
||||
waveSpacing = 60 * 60 * 2;
|
||||
}};
|
||||
rules = r -> {
|
||||
r.waves = true;
|
||||
r.waveTimer = true;
|
||||
r.waveSpacing = 60 * 60 * 2;
|
||||
};
|
||||
}};
|
||||
|
||||
desertWastes = new Zone("desertWastes", new DesertWastesGenerator(260, 260)){{
|
||||
@ -39,12 +40,12 @@ public class Zones implements ContentList{
|
||||
loadout = Loadouts.advancedShard;
|
||||
zoneRequirements = ZoneRequirement.with(groundZero, 20);
|
||||
resources = new Item[]{Items.copper, Items.lead, Items.coal, Items.sand};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
waveTimer = true;
|
||||
launchWaveMultiplier = 3f;
|
||||
waveSpacing = 60 * 50f;
|
||||
spawns = Array.with(
|
||||
rules = r -> {
|
||||
r.waves = true;
|
||||
r.waveTimer = true;
|
||||
r.launchWaveMultiplier = 3f;
|
||||
r.waveSpacing = 60 * 50f;
|
||||
r.spawns = Array.with(
|
||||
new SpawnGroup(UnitTypes.crawler){{
|
||||
unitScaling = 3f;
|
||||
}},
|
||||
@ -77,7 +78,7 @@ public class Zones implements ContentList{
|
||||
spacing = 20;
|
||||
}}
|
||||
);
|
||||
}};
|
||||
};
|
||||
}};
|
||||
|
||||
saltFlats = new Zone("saltFlats", new MapGenerator("saltFlats")){{
|
||||
@ -88,15 +89,15 @@ public class Zones implements ContentList{
|
||||
launchPeriod = 5;
|
||||
zoneRequirements = ZoneRequirement.with(desertWastes, 60);
|
||||
resources = new Item[]{Items.copper, Items.scrap, Items.lead, Items.coal, Items.sand};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
waveTimer = true;
|
||||
attackMode = true;
|
||||
waveSpacing = 60 * 60;
|
||||
buildCostMultiplier = 0.5f;
|
||||
unitBuildSpeedMultiplier = 0.5f;
|
||||
enemyCheat = true;
|
||||
}};
|
||||
rules = r -> {
|
||||
r.waves = true;
|
||||
r.waveTimer = true;
|
||||
r.attackMode = true;
|
||||
r.waveSpacing = 60 * 60;
|
||||
r.buildCostMultiplier = 0.5f;
|
||||
r.unitBuildSpeedMultiplier = 0.5f;
|
||||
r.enemyCheat = true;
|
||||
};
|
||||
}};
|
||||
|
||||
craters = new Zone("craters", new MapGenerator("craters", 1).dist(0).decor(new Decoration(Blocks.snow, Blocks.sporeCluster, 0.01))){{
|
||||
@ -105,11 +106,11 @@ public class Zones implements ContentList{
|
||||
zoneRequirements = ZoneRequirement.with(groundZero, 10);
|
||||
blockRequirements = new Block[]{Blocks.router};
|
||||
resources = new Item[]{Items.copper, Items.lead, Items.coal};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
waveTimer = true;
|
||||
waveSpacing = 60 * 60 * 1.5f;
|
||||
}};
|
||||
rules = r -> {
|
||||
r.waves = true;
|
||||
r.waveTimer = true;
|
||||
r.waveSpacing = 60 * 60 * 1.5f;
|
||||
};
|
||||
}};
|
||||
|
||||
frozenForest = new Zone("frozenForest", new MapGenerator("frozenForest", 1)
|
||||
@ -120,11 +121,11 @@ public class Zones implements ContentList{
|
||||
conditionWave = 10;
|
||||
zoneRequirements = ZoneRequirement.with(craters, 10);
|
||||
resources = new Item[]{Items.copper, Items.lead, Items.coal};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
waveTimer = true;
|
||||
waveSpacing = 60 * 60 * 1.5f;
|
||||
}};
|
||||
rules = r -> {
|
||||
r.waves = true;
|
||||
r.waveTimer = true;
|
||||
r.waveSpacing = 60 * 60 * 1.5f;
|
||||
};
|
||||
}};
|
||||
|
||||
overgrowth = new Zone("overgrowth", new MapGenerator("overgrowth")){{
|
||||
@ -135,11 +136,11 @@ public class Zones implements ContentList{
|
||||
zoneRequirements = ZoneRequirement.with(frozenForest, 40);
|
||||
blockRequirements = new Block[]{Blocks.router};
|
||||
resources = new Item[]{Items.copper, Items.lead, Items.coal, Items.titanium, Items.sand, Items.thorium, Items.scrap};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
waveTimer = true;
|
||||
waveSpacing = 60 * 100f;
|
||||
}};
|
||||
rules = r -> {
|
||||
r.waves = true;
|
||||
r.waveTimer = true;
|
||||
r.waveSpacing = 60 * 100f;
|
||||
};
|
||||
}};
|
||||
|
||||
ruinousShores = new Zone("ruinousShores", new MapGenerator("ruinousShores", 1).dist(3f, true)){{
|
||||
@ -151,11 +152,11 @@ public class Zones implements ContentList{
|
||||
zoneRequirements = ZoneRequirement.with(desertWastes, 20, craters, 15);
|
||||
blockRequirements = new Block[]{Blocks.graphitePress, Blocks.combustionGenerator};
|
||||
resources = new Item[]{Items.copper, Items.scrap, Items.lead, Items.coal, Items.sand};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
waveTimer = true;
|
||||
waveSpacing = 60 * 80;
|
||||
}};
|
||||
rules = r -> {
|
||||
r.waves = true;
|
||||
r.waveTimer = true;
|
||||
r.waveSpacing = 60 * 80;
|
||||
};
|
||||
}};
|
||||
|
||||
stainedMountains = new Zone("stainedMountains", new MapGenerator("stainedMountains", 2)
|
||||
@ -168,11 +169,11 @@ public class Zones implements ContentList{
|
||||
zoneRequirements = ZoneRequirement.with(frozenForest, 15);
|
||||
blockRequirements = new Block[]{Blocks.pneumaticDrill};
|
||||
resources = new Item[]{Items.copper, Items.scrap, Items.lead, Items.coal, Items.titanium, Items.sand};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
waveTimer = true;
|
||||
waveSpacing = 60 * 60 * 2;
|
||||
}};
|
||||
rules = r -> {
|
||||
r.waves = true;
|
||||
r.waveTimer = true;
|
||||
r.waveSpacing = 60 * 60 * 2;
|
||||
};
|
||||
}};
|
||||
|
||||
tarFields = new Zone("tarFields", new MapGenerator("tarFields")
|
||||
@ -185,11 +186,11 @@ public class Zones implements ContentList{
|
||||
zoneRequirements = ZoneRequirement.with(ruinousShores, 20);
|
||||
blockRequirements = new Block[]{Blocks.coalCentrifuge};
|
||||
resources = new Item[]{Items.copper, Items.scrap, Items.lead, Items.coal, Items.titanium, Items.sand};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
waveTimer = true;
|
||||
waveSpacing = 60 * 60 * 2;
|
||||
}};
|
||||
rules = r -> {
|
||||
r.waves = true;
|
||||
r.waveTimer = true;
|
||||
r.waveSpacing = 60 * 60 * 2;
|
||||
};
|
||||
}};
|
||||
|
||||
desolateRift = new Zone("desolateRift", new MapGenerator("desolateRift").dist(2f)){{
|
||||
@ -201,11 +202,11 @@ public class Zones implements ContentList{
|
||||
zoneRequirements = ZoneRequirement.with(tarFields, 20);
|
||||
blockRequirements = new Block[]{Blocks.thermalGenerator};
|
||||
resources = new Item[]{Items.copper, Items.scrap, Items.lead, Items.coal, Items.titanium, Items.sand, Items.thorium};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
waveTimer = true;
|
||||
waveSpacing = 60 * 60 * 2.5f;
|
||||
}};
|
||||
rules = r -> {
|
||||
r.waves = true;
|
||||
r.waveTimer = true;
|
||||
r.waveSpacing = 60 * 60 * 2.5f;
|
||||
};
|
||||
}};
|
||||
|
||||
nuclearComplex = new Zone("nuclearComplex", new MapGenerator("nuclearProductionComplex", 1)
|
||||
@ -218,11 +219,11 @@ public class Zones implements ContentList{
|
||||
zoneRequirements = ZoneRequirement.with(stainedMountains, 20);
|
||||
blockRequirements = new Block[]{Blocks.thermalGenerator};
|
||||
resources = new Item[]{Items.copper, Items.scrap, Items.lead, Items.coal, Items.titanium, Items.thorium, Items.sand};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
waveTimer = true;
|
||||
waveSpacing = 60 * 60 * 2;
|
||||
}};
|
||||
rules = r -> {
|
||||
r.waves = true;
|
||||
r.waveTimer = true;
|
||||
r.waveSpacing = 60 * 60 * 2;
|
||||
};
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ public class Control implements ApplicationListener{
|
||||
ui.loadAnd(() -> {
|
||||
logic.reset();
|
||||
world.loadGenerator(zone.generator);
|
||||
state.rules = zone.rules.get();
|
||||
zone.rules.accept(state.rules);
|
||||
state.rules.zone = zone;
|
||||
for(Tile core : state.teams.get(defaultTeam).cores){
|
||||
for(ItemStack stack : zone.getStartingItems()){
|
||||
|
@ -4,7 +4,6 @@ import io.anuke.arc.Core;
|
||||
import io.anuke.arc.Events;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.function.Consumer;
|
||||
import io.anuke.arc.function.Supplier;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.util.Structs;
|
||||
@ -25,7 +24,7 @@ public class Zone extends UnlockableContent{
|
||||
public Block[] blockRequirements = {};
|
||||
public ZoneRequirement[] zoneRequirements = {};
|
||||
public Item[] resources = {};
|
||||
public Supplier<Rules> rules = Rules::new;
|
||||
public Consumer<Rules> rules = rules -> {};
|
||||
public boolean alwaysUnlocked;
|
||||
public int conditionWave = Integer.MAX_VALUE;
|
||||
public int configureWave = 15;
|
||||
|
@ -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 + "\"");
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user