mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-04-27 07:50:54 -07:00
Merged current Anuke master into branch
This commit is contained in:
commit
a9517096f9
159 changed files with 2844 additions and 3027 deletions
|
|
@ -4,17 +4,23 @@ import com.badlogic.gdx.backends.headless.HeadlessApplicationConfiguration;
|
|||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.content.UnitTypes;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.content.blocks.CraftingBlocks;
|
||||
import io.anuke.mindustry.content.blocks.PowerBlocks;
|
||||
import io.anuke.mindustry.content.blocks.StorageBlocks;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.core.Logic;
|
||||
import io.anuke.mindustry.core.NetServer;
|
||||
import io.anuke.mindustry.core.World;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
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.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Edges;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
|
|
@ -205,7 +211,14 @@ public class ApplicationTests{
|
|||
}
|
||||
|
||||
@Test
|
||||
void edgeTest(){
|
||||
void inventoryDeposit(){
|
||||
depositTest(CraftingBlocks.smelter, Items.copper);
|
||||
depositTest(StorageBlocks.vault, Items.copper);
|
||||
depositTest(PowerBlocks.thoriumReactor, Items.thorium);
|
||||
}
|
||||
|
||||
@Test
|
||||
void edges(){
|
||||
GridPoint2[] edges = Edges.getEdges(1);
|
||||
assertEquals(edges[0], new GridPoint2(1, 0));
|
||||
assertEquals(edges[1], new GridPoint2(0, 1));
|
||||
|
|
@ -215,4 +228,22 @@ public class ApplicationTests{
|
|||
GridPoint2[] edges2 = Edges.getEdges(2);
|
||||
assertEquals(8, edges2.length);
|
||||
}
|
||||
|
||||
void depositTest(Block block, Item item){
|
||||
BaseUnit unit = UnitTypes.alphaDrone.create(Team.none);
|
||||
Tile tile = new Tile(0, 0, Blocks.air.id, block.id);
|
||||
int capacity = tile.block().itemCapacity;
|
||||
|
||||
int deposited = tile.block().acceptStack(item, capacity - 1, tile, unit);
|
||||
assertEquals(capacity - 1, deposited);
|
||||
|
||||
tile.block().handleStack(item, capacity - 1, tile, unit);
|
||||
assertEquals(tile.entity.items.get(item), capacity - 1);
|
||||
|
||||
int overflow = tile.block().acceptStack(item, 10, tile, unit);
|
||||
assertEquals(1, overflow);
|
||||
|
||||
tile.block().handleStack(item, 1, tile, unit);
|
||||
assertEquals(capacity, tile.entity.items.get(item));
|
||||
}
|
||||
}
|
||||
34
tests/src/test/java/IOTests.java
Normal file
34
tests/src/test/java/IOTests.java
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import io.anuke.mindustry.io.TypeIO;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class IOTests{
|
||||
|
||||
@Test
|
||||
void writeEnglish(){
|
||||
ByteBuffer buffer = ByteBuffer.allocate(500);
|
||||
TypeIO.writeString(buffer, "asd asd asd asd asdagagasasjakbgeah;jwrej 23424234");
|
||||
buffer.position(0);
|
||||
assertEquals(TypeIO.readString(buffer), "asd asd asd asd asdagagasasjakbgeah;jwrej 23424234");
|
||||
}
|
||||
|
||||
@Test
|
||||
void writeChinese(){
|
||||
ByteBuffer buffer = ByteBuffer.allocate(500);
|
||||
TypeIO.writeString(buffer, "这个服务器可以用自己的语言说话");
|
||||
buffer.position(0);
|
||||
assertEquals(TypeIO.readString(buffer), "这个服务器可以用自己的语言说话");
|
||||
}
|
||||
|
||||
@Test
|
||||
void writeNull(){
|
||||
ByteBuffer buffer = ByteBuffer.allocate(500);
|
||||
TypeIO.writeString(buffer, null);
|
||||
buffer.position(0);
|
||||
assertEquals(TypeIO.readString(buffer), null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@ public class SectorTests{
|
|||
* This is achieved by adding at least one mission which defines a spawn point.
|
||||
*/
|
||||
@Test
|
||||
void test_sectorHasACore(){
|
||||
void sectorHasACore(){
|
||||
for(SectorPresets.SectorPreset preset : this.presets.getPresets().values()){
|
||||
assertTrue(spawnPointIsDefined(preset.missions), "Sector at (" + preset.x + "|" + preset.y + ") contains no missions which define a spawn point. Add a battle or wave mission.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue