Fix command card cancel menu icon, fix terrain handling missing cliff, improve build food cost handling

This commit is contained in:
Retera 2020-12-24 08:46:56 -05:00
parent 6849d269ac
commit 5283b7a038
5 changed files with 18 additions and 2 deletions

View File

@ -244,6 +244,10 @@ public class Terrain {
// Cliff Textures
for (final War3ID cliffTile : w3eFile.getCliffTiles()) {
final Element cliffInfo = this.cliffTable.get(cliffTile.asStringValue());
if(cliffInfo == null) {
System.err.println("Missing cliff type: " + cliffTile.asStringValue());
continue;
}
final String texDir = cliffInfo.getField("texDir");
final String texFile = cliffInfo.getField("texFile");
try (InputStream imageStream = dataSource.getResourceAsStream(texDir + "\\" + texFile + texturesExt)) {

View File

@ -40,7 +40,12 @@ public abstract class AbstractCAbilityBuild extends AbstractCAbility implements
final CPlayer player = game.getPlayer(unit.getPlayerIndex());
if (player.getGold() >= unitType.getGoldCost()) {
if (player.getLumber() >= unitType.getLumberCost()) {
receiver.useOk();
if ((player.getFoodUsed() + unitType.getFoodUsed()) <= player.getFoodCap()) {
receiver.useOk();
}
else {
receiver.notEnoughResources(ResourceType.FOOD);
}
}
else {
receiver.notEnoughResources(ResourceType.LUMBER);

View File

@ -59,6 +59,9 @@ public class CAbilityOrcBuild extends AbstractCAbilityBuild {
}
final CPlayer player = game.getPlayer(caster.getPlayerIndex());
player.chargeFor(unitType);
if (unitType.getFoodUsed() != 0) {
player.setFoodUsed(player.getFoodUsed() + unitType.getFoodUsed());
}
return this.buildBehavior.reset(point, orderId, getBaseOrderId());
}

View File

@ -14,6 +14,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CAbstractRangedBehavior;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.pathing.CBuildingPathingType;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer;
public class CBehaviorOrcBuild extends CAbstractRangedBehavior {
private int highlightOrderId;
@ -63,6 +64,7 @@ public class CBehaviorOrcBuild extends CAbstractRangedBehavior {
constructedStructure.setWorkerInside(this.unit);
constructedStructure.setLife(simulation,
constructedStructure.getMaximumLife() * WarsmashConstants.BUILDING_CONSTRUCT_START_LIFE);
constructedStructure.setFoodUsed(unitTypeToCreate.getFoodUsed());
constructedStructure.add(simulation,
new CAbilityBuildInProgress(simulation.getHandleIdAllocator().createId()));
for (final CAbility ability : constructedStructure.getAbilities()) {
@ -74,6 +76,8 @@ public class CBehaviorOrcBuild extends CAbstractRangedBehavior {
simulation.unitConstructedEvent(this.unit, constructedStructure);
}
else {
CPlayer player = simulation.getPlayer(this.unit.getPlayerIndex());
player.setFoodUsed(player.getFoodUsed() - unitTypeToCreate.getFoodUsed());
simulation.getCommandErrorListener().showCantPlaceError();
}
return this.unit.pollNextOrderBehavior(simulation);

View File

@ -117,7 +117,7 @@ public class CommandCardIcon extends AbstractRenderableFrame implements Clickabl
@Override
public UIFrame touchDown(final float screenX, final float screenY, final int button) {
if (isVisible() && this.renderBounds.contains(screenX, screenY)) {
if (this.orderId != 0) {
if (this.orderId != 0 || menuButton) {
return this;
}
}