Untested rank system / 'Fixed' junction speed / Balancing

This commit is contained in:
Anuken
2019-02-13 18:28:36 -05:00
parent 12ca4cda91
commit a708c8b7ea
9 changed files with 75 additions and 19 deletions

View File

@@ -668,7 +668,7 @@ public class Blocks implements ContentList{
}};
titaniumConveyor = new Conveyor("titanium-conveyor"){{
requirements(Category.distribution, ItemStack.with(Items.copper, 2, Items.titanium, 1));
requirements(Category.distribution, ItemStack.with(Items.copper, 2, Items.lead, 1, Items.titanium, 1));
health = 65;
speed = 0.07f;
}};
@@ -681,7 +681,7 @@ public class Blocks implements ContentList{
}};
itemBridge = new BufferedItemBridge("bridge-conveyor"){{
requirements(Category.distribution, ItemStack.with(Items.titanium, 8, Items.copper, 8));
requirements(Category.distribution, ItemStack.with(Items.lead, 8, Items.copper, 8));
range = 4;
speed = 60f;
bufferCapacity = 15;
@@ -695,7 +695,7 @@ public class Blocks implements ContentList{
}};
sorter = new Sorter("sorter"){{
requirements(Category.distribution, ItemStack.with(Items.titanium, 4, Items.copper, 4));
requirements(Category.distribution, ItemStack.with(Items.lead, 4, Items.copper, 4));
}};
@@ -705,13 +705,12 @@ public class Blocks implements ContentList{
}};
distributor = new Router("distributor"){{
requirements(Category.distribution, ItemStack.with(Items.titanium, 8, Items.copper, 8));
requirements(Category.distribution, ItemStack.with(Items.lead, 8, Items.copper, 8));
size = 2;
}};
overflowGate = new OverflowGate("overflow-gate"){{
requirements(Category.distribution, ItemStack.with(Items.titanium, 4, Items.copper, 8));
requirements(Category.distribution, ItemStack.with(Items.lead, 4, Items.copper, 8));
}};
massDriver = new MassDriver("mass-driver"){{

View File

@@ -322,10 +322,11 @@ public class Zones implements ContentList{
}};
impact = new Zone("impact0079", new MapGenerator("impact0079", 2)
.core(Blocks.coreFoundation)
.decor(
new Decoration(Blocks.snow, Blocks.sporeCluster, 0.01),
new Decoration(Blocks.metalFloor, Blocks.metalFloorDamaged, 0.02)
).drops(ItemStack.with(Items.copper, 2000, Items.lead, 1500, Items.silicon, 1000, Items.graphite, 1000, Items.pyratite, 2000, Items.titanium, 2000, Items.metaglass, 1000))){{
).drops(ItemStack.with(Items.copper, 2000, Items.lead, 1500, Items.silicon, 1000, Items.graphite, 2000, Items.pyratite, 2000, Items.titanium, 2000, Items.metaglass, 1000, Items.coal, 2000))){{
deployCost = ItemStack.with(Items.copper, 2500, Items.lead, 1000, Items.silicon, 300);
startingItems = ItemStack.with(Items.copper, 2000, Items.lead, 500, Items.silicon, 200);
itemRequirements = ItemStack.with(Items.silicon, 8000, Items.titanium, 6000, Items.graphite, 4000);
@@ -492,7 +493,7 @@ public class Zones implements ContentList{
nuclearComplex = new Zone("nuclearComplex", new MapGenerator("nuclearProductionComplex", 1)
.drops(ItemStack.with(Items.copper, 2000, Items.lead, 1500, Items.silicon, 1000, Items.graphite, 1000, Items.thorium, 200, Items.titanium, 2000, Items.metaglass, 1000))
.decor(new Decoration(Blocks.snow, Blocks.sporeCluster, 0.01))
.core(Blocks.coreFoundation)){{
.core(Blocks.coreNucleus)){{
deployCost = ItemStack.with(Items.copper, 3000, Items.lead, 2000, Items.silicon, 1000, Items.metaglass, 500);
startingItems = ItemStack.with(Items.copper, 2500, Items.lead, 1500, Items.silicon, 800, Items.metaglass, 400);
itemRequirements = ItemStack.with(Items.copper, 10000, Items.titanium, 8000, Items.metaglass, 6000, Items.plastanium, 2000);

View File

@@ -1,8 +1,12 @@
package io.anuke.mindustry.game;
import io.anuke.annotations.Annotations.Serialize;
import io.anuke.arc.collection.Array;
import io.anuke.arc.collection.ObjectIntMap;
import io.anuke.arc.math.Mathf;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.ItemType;
import io.anuke.mindustry.type.Zone;
@Serialize
public class Stats{
@@ -21,7 +25,49 @@ public class Stats{
/**Friendly buildings destroyed.*/
public int buildingsDestroyed;
public Rank calculateRank(boolean launched){
return Rank.F;
public RankResult calculateRank(Zone zone, Rules rules, boolean launched){
float score = 0;
//each new launch period adds onto the rank 1.5 'points'
if(wavesLasted >= zone.conditionWave){
score += (float)((zone.conditionWave - wavesLasted) / zone.launchPeriod + 1) * 1.5f;
}
//building more stuff gives a better score slightly
score += (buildingsBuilt - buildingsDeconstructed)*0.001f;
//destroyed buildings penalize score
score -= buildingsDestroyed * 0.003f;
int capacity = zone.generator.coreBlock.itemCapacity;
//weigh used fractions of
float frac = 0f;
Array<Item> obtainable = Array.with(zone.resources).select(i -> i.type == ItemType.material);
for(Item item : obtainable){
frac += Mathf.clamp((float)itemsDelivered.get(item, 0) / capacity) / (float)obtainable.size;
}
score += frac*3f;
if(!launched){
score *= 0.5f;
}
int rankIndex = Mathf.clamp((int)score, 0, Rank.values().length-1);
Rank rank = Rank.values()[rankIndex];
String sign = Math.abs((rankIndex + 0.5f) - score) < 0.2f || rank.name().contains("S") ? "" : (rankIndex + 0.5f) < score ? "-" : "+";
return new RankResult(rank, sign);
}
public static class RankResult{
public final Rank rank;
/**+ or -*/
public final String modifier;
public RankResult(Rank rank, String modifier){
this.rank = rank;
this.modifier = modifier;
}
}
}

View File

@@ -36,7 +36,7 @@ public class MapGenerator extends Generator{
public boolean distortFloor = false;
/**Items randomly added to containers and vaults.*/
public ItemStack[] storageDrops = ItemStack.with(Items.copper, 300, Items.lead, 300, Items.silicon, 200, Items.graphite, 200, Items.blastCompound, 200);
public Block coreBlock;
public Block coreBlock = Blocks.coreShard;
public MapGenerator(String mapName){
this.mapName = mapName;

View File

@@ -6,7 +6,7 @@ import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.mindustry.game.Rules;
import io.anuke.mindustry.game.UnlockableContent;
import io.anuke.mindustry.maps.generators.Generator;
import io.anuke.mindustry.maps.generators.MapGenerator;
import io.anuke.mindustry.world.Block;
import static io.anuke.mindustry.Vars.data;
@@ -14,7 +14,7 @@ import static io.anuke.mindustry.Vars.state;
public class Zone extends UnlockableContent{
public final String name;
public final Generator generator;
public final MapGenerator generator;
public ItemStack[] deployCost = {};
public ItemStack[] startingItems = {};
public Block[] blockRequirements = {};
@@ -27,7 +27,7 @@ public class Zone extends UnlockableContent{
public int configureWave = 50;
public int launchPeriod = 10;
public Zone(String name, Generator generator){
public Zone(String name, MapGenerator generator){
this.name = name;
this.generator = generator;
}

View File

@@ -2,6 +2,7 @@ package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.Core;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.game.Stats.RankResult;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.Item.Icon;
@@ -67,6 +68,12 @@ public class GameOverDialog extends FloatingDialog{
}
}
}
if(world.isZone()){
RankResult result = state.stats.calculateRank(world.getZone(), state.rules, state.launched);
cont.add(Core.bundle.format("stat.rank", result.rank + result.modifier));
cont.row();
}
}).pad(12);
if(world.isZone()){

View File

@@ -149,10 +149,12 @@ public class BlockInventoryFragment extends Fragment{
public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
if(!canPick.get() || !tile.entity.items.has(item)) return false;
int amount = Math.min(1, player.maxAccepted(item));
Call.requestItem(player, tile, item, amount);
lastItem = item;
holding = true;
holdTime = 0f;
if(amount > 0){
Call.requestItem(player, tile, item, amount);
lastItem = item;
holding = true;
holdTime = 0f;
}
return true;
}

View File

@@ -74,7 +74,7 @@ public class Junction extends Block{
if(entity == null || relative == -1 || entity.buffers[relative].full())
return false;
Tile to = tile.getNearby(relative);
return to != null && to.block().acceptItem(item, to, tile);
return to != null;
}
@Override