mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-20 20:57:59 +07:00
Additional tests, inventory fixes
This commit is contained in:
@ -106,7 +106,7 @@ public class TurretBlocks extends BlockList implements ContentList{
|
||||
|
||||
arc = new PowerTurret("arc"){{
|
||||
shootType = AmmoTypes.arc;
|
||||
reload = 80f;
|
||||
reload = 75f;
|
||||
shootShake = 1f;
|
||||
shootCone = 40f;
|
||||
rotatespeed = 8f;
|
||||
|
@ -304,7 +304,7 @@ public class TurretBullets extends BulletList implements ContentList{
|
||||
}
|
||||
};
|
||||
|
||||
arc = new BulletType(0.001f, 30){
|
||||
arc = new BulletType(0.001f, 26){
|
||||
{
|
||||
lifetime = 1;
|
||||
despawneffect = Fx.none;
|
||||
|
@ -193,7 +193,7 @@ public abstract class InputHandler extends InputAdapter{
|
||||
}
|
||||
|
||||
//call tapped event
|
||||
if(tile.getTeam() == player.getTeam()){
|
||||
if(!consumed && tile.getTeam() == player.getTeam()){
|
||||
Call.onTileTapped(player, tile);
|
||||
}
|
||||
|
||||
|
@ -32,4 +32,13 @@ public class Map{
|
||||
public String getDisplayName(){
|
||||
return meta.tags.get("name", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Map{" +
|
||||
"name='" + name + '\'' +
|
||||
", custom=" + custom +
|
||||
", meta=" + meta +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -37,4 +37,13 @@ public class MapMeta{
|
||||
public boolean hasOreGen(){
|
||||
return !tags.get("oregen", "0").equals("0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "MapMeta{" +
|
||||
"tags=" + tags +
|
||||
", width=" + width +
|
||||
", height=" + height +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package io.anuke.mindustry.type;
|
||||
|
||||
/**
|
||||
* Used to store ammo amounts in units and turrets.
|
||||
*/
|
||||
/**Used to store ammo amounts in turrets.*/
|
||||
public class AmmoEntry{
|
||||
public AmmoType type;
|
||||
public int amount;
|
||||
|
@ -43,7 +43,7 @@ public abstract class BaseBlock extends MappableContent{
|
||||
/**Returns the amount of items this block can accept.*/
|
||||
public int acceptStack(Item item, int amount, Tile tile, Unit source){
|
||||
if(acceptItem(item, tile, tile) && hasItems && (source == null || source.getTeam() == tile.getTeam())){
|
||||
return Math.min(getMaximumAccepted(tile, item), amount);
|
||||
return Math.min(getMaximumAccepted(tile, item) - tile.entity.items.get(item), amount);
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
|
@ -152,11 +152,6 @@ public class Smelter extends Block{
|
||||
Effects.effect(craftEffect, flameColor, tile.drawx(), tile.drawy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumAccepted(Tile tile, Item item){
|
||||
return itemCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
boolean isInput = false;
|
||||
|
@ -31,8 +31,6 @@ public class IOSLauncher extends IOSApplication.Delegate {
|
||||
Net.setClientProvider(new KryoClient());
|
||||
Net.setServerProvider(new KryoServer());
|
||||
|
||||
Unit.dp.addition -= 0.2f;
|
||||
|
||||
if(UIDevice.getCurrentDevice().getUserInterfaceIdiom() == UIUserInterfaceIdiom.Pad){
|
||||
Unit.dp.addition = 0.5f;
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user