mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-05 07:49:17 +07:00
Solved multiple small bugs
This commit is contained in:
@ -152,8 +152,8 @@ public class CityBuildings
|
||||
if(building.requiredResource!=null &&
|
||||
!civInfo.getCivResources().keySet().contains(GameBasics.TileResources.get(building.requiredResource)))
|
||||
return false; // Only checks if exists, doesn't check amount - todo
|
||||
|
||||
if(building.unique.equals("SpaceshipPart")){
|
||||
|
||||
if("SpaceshipPart".equals(building.unique)){
|
||||
if(!civInfo.getBuildingUniques().contains("ApolloProgram")) return false;
|
||||
if(civInfo.scienceVictory.requiredParts.get(building.name)==0) return false; // Don't need to build any more of these!
|
||||
}
|
||||
|
@ -119,13 +119,3 @@ public class CivilizationInfo {
|
||||
}
|
||||
}
|
||||
|
||||
class ScienceVictory{
|
||||
public LinqCounter<String> requiredParts = new LinqCounter<String>();
|
||||
public LinqCounter<String> currentParts = new LinqCounter<String>();
|
||||
|
||||
public LinqCounter<String> unconstructedParts() {
|
||||
LinqCounter<String> counter = requiredParts.clone();
|
||||
counter.remove(currentParts);
|
||||
return counter;
|
||||
}
|
||||
}
|
14
core/src/com/unciv/civinfo/ScienceVictory.java
Normal file
14
core/src/com/unciv/civinfo/ScienceVictory.java
Normal file
@ -0,0 +1,14 @@
|
||||
package com.unciv.civinfo;
|
||||
|
||||
import com.unciv.models.LinqCounter;
|
||||
|
||||
public class ScienceVictory{
|
||||
public LinqCounter<String> requiredParts = new LinqCounter<String>();
|
||||
public LinqCounter<String> currentParts = new LinqCounter<String>();
|
||||
|
||||
public LinqCounter<String> unconstructedParts() {
|
||||
LinqCounter<String> counter = requiredParts.clone();
|
||||
counter.remove(currentParts);
|
||||
return counter;
|
||||
}
|
||||
}
|
@ -118,9 +118,9 @@ public class TileInfo
|
||||
|
||||
public void nextTurn()
|
||||
{
|
||||
if(unit !=null) unit.CurrentMovement = unit.MaxMovement;
|
||||
if(unit !=null) unit.currentMovement = unit.maxMovement;
|
||||
|
||||
if (improvementInProgress == null || unit ==null || !unit.Name.equals("Worker")) return;
|
||||
if (improvementInProgress == null || unit ==null || !unit.name.equals("Worker")) return;
|
||||
turnsToImprovement -= 1;
|
||||
if(turnsToImprovement == 0)
|
||||
{
|
||||
@ -129,6 +129,7 @@ public class TileInfo
|
||||
else if(improvementInProgress.equals("Railroad")) roadStatus = RoadStatus.Railroad;
|
||||
else improvement = improvementInProgress;
|
||||
|
||||
CivilizationInfo.current().notifications.add(improvementInProgress+" has been completed!");
|
||||
improvementInProgress = null;
|
||||
}
|
||||
}
|
||||
@ -140,7 +141,7 @@ public class TileInfo
|
||||
if(roadStatus!= RoadStatus.None) SB.append(",\r\n" + roadStatus);
|
||||
if (improvement != null) SB.append(",\r\n" + improvement);
|
||||
if (improvementInProgress != null) SB.append(",\r\n" + improvementInProgress +" in "+this.turnsToImprovement +" turns");
|
||||
if(unit !=null) SB.append(",\r\n" + unit.Name+ "("+ new DecimalFormat("0.#").format(unit.CurrentMovement)+"/"+ unit.MaxMovement+")");
|
||||
if(unit !=null) SB.append(",\r\n" + unit.name + "("+ new DecimalFormat("0.#").format(unit.currentMovement)+"/"+ unit.maxMovement +")");
|
||||
return SB.toString();
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
package com.unciv.civinfo;
|
||||
|
||||
public class Unit{
|
||||
public String Name;
|
||||
public int MaxMovement;
|
||||
public float CurrentMovement;
|
||||
public String name;
|
||||
public int maxMovement;
|
||||
public float currentMovement;
|
||||
|
||||
public Unit(){} // for json parsing, we need to have a default constructor
|
||||
|
||||
public Unit(String name, int maxMovement) {
|
||||
Name = name;
|
||||
MaxMovement = maxMovement;
|
||||
CurrentMovement = maxMovement;
|
||||
this.name = name;
|
||||
this.maxMovement = maxMovement;
|
||||
currentMovement = maxMovement;
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,7 @@ package com.unciv.game;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.scenes.scene2d.Touchable;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Button;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.unciv.civinfo.CivilizationInfo;
|
||||
import com.unciv.game.pickerscreens.PickerScreen;
|
||||
import com.unciv.models.LinqCounter;
|
||||
|
||||
@ -12,15 +10,14 @@ public class ScienceVictoryScreen extends PickerScreen {
|
||||
|
||||
public ScienceVictoryScreen(UnCivGame game) {
|
||||
super(game);
|
||||
LinqCounter<String> spaceshipParts = new LinqCounter<String>();
|
||||
spaceshipParts.add(game.civInfo.spaceshipParts);
|
||||
LinqCounter<String> builtSpaceshipParts = game.civInfo.scienceVictory.currentParts.clone();
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
addPartButton("SS Booster",spaceshipParts);
|
||||
addPartButton("SS Booster",builtSpaceshipParts);
|
||||
}
|
||||
addPartButton("SS Cockpit",spaceshipParts);
|
||||
addPartButton("SS Engine",spaceshipParts);
|
||||
addPartButton("SS Statis Chamber",spaceshipParts);
|
||||
addPartButton("SS Cockpit",builtSpaceshipParts);
|
||||
addPartButton("SS Engine",builtSpaceshipParts);
|
||||
addPartButton("SS Statis Chamber",builtSpaceshipParts);
|
||||
rightSideButton.setVisible(false);
|
||||
|
||||
if(!game.civInfo.getBuildingUniques().contains("ApolloProject"))
|
||||
|
@ -49,8 +49,6 @@ public class TileGroup extends Group {
|
||||
|
||||
|
||||
void update() {
|
||||
|
||||
|
||||
if(!terrainType.equals(tileInfo.getLastTerrain().name)) {
|
||||
terrainType = tileInfo.getLastTerrain().name;
|
||||
String terrainFileName = "TerrainIcons/" + terrainType.replace(' ', '_') + "_(Civ5).png";
|
||||
@ -67,7 +65,7 @@ public class TileGroup extends Group {
|
||||
}
|
||||
|
||||
if (tileInfo.unit != null && unitImage == null) {
|
||||
unitImage = com.unciv.game.utils.ImageGetter.getImageByFilename("StatIcons/" + tileInfo.unit.Name + "_(Civ5).png");
|
||||
unitImage = com.unciv.game.utils.ImageGetter.getImageByFilename("StatIcons/" + tileInfo.unit.name + "_(Civ5).png");
|
||||
addActor(unitImage);
|
||||
unitImage.setSize(20, 20); // not moved - is at bottom left
|
||||
}
|
||||
@ -78,7 +76,9 @@ public class TileGroup extends Group {
|
||||
}
|
||||
|
||||
if(unitImage!=null){
|
||||
if(tileInfo.unit.CurrentMovement==0) unitImage.setColor(Color.GRAY);
|
||||
if(tileInfo.unit.currentMovement ==0 ||
|
||||
(tileInfo.unit.name.equals("Worker") && tileInfo.improvementInProgress!=null))
|
||||
unitImage.setColor(Color.GRAY);
|
||||
else unitImage.setColor(Color.WHITE);
|
||||
}
|
||||
|
||||
|
@ -241,11 +241,11 @@ public class WorldScreen extends com.unciv.game.utils.CameraStageBaseScreen {
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
selectedTile = tileInfo;
|
||||
if(unitTile != null && group.tileInfo.unit == null ) {
|
||||
LinqHashMap<TileInfo, Float> distanceToTiles = game.civInfo.tileMap.getDistanceToTiles(unitTile.position,unitTile.unit.CurrentMovement);
|
||||
LinqHashMap<TileInfo, Float> distanceToTiles = game.civInfo.tileMap.getDistanceToTiles(unitTile.position,unitTile.unit.currentMovement);
|
||||
if(distanceToTiles.containsKey(selectedTile)) {
|
||||
unitTile.unit.CurrentMovement -= distanceToTiles.get(selectedTile);
|
||||
//unitTile.unit.CurrentMovement = round(unitTile.unit.CurrentMovement,3);
|
||||
if(unitTile.unit.CurrentMovement < 0.1) unitTile.unit.CurrentMovement=0; // silly floats which are "almost zero"
|
||||
unitTile.unit.currentMovement -= distanceToTiles.get(selectedTile);
|
||||
//unitTile.unit.currentMovement = round(unitTile.unit.currentMovement,3);
|
||||
if(unitTile.unit.currentMovement < 0.1) unitTile.unit.currentMovement =0; // silly floats which are "almost zero"
|
||||
group.tileInfo.unit = unitTile.unit;
|
||||
unitTile.unit = null;
|
||||
unitTile = null;
|
||||
@ -340,7 +340,7 @@ public class WorldScreen extends com.unciv.game.utils.CameraStageBaseScreen {
|
||||
TextButton moveUnitButton = new TextButton("Move to", skin);
|
||||
if(unitTile == selectedTile) moveUnitButton = new TextButton("Stop movement",skin);
|
||||
moveUnitButton.getLabel().setFontScale(buttonScale);
|
||||
if(selectedTile.unit.CurrentMovement == 0){
|
||||
if(selectedTile.unit.currentMovement == 0){
|
||||
moveUnitButton.setColor(Color.GRAY);
|
||||
moveUnitButton.setTouchable(Touchable.disabled);
|
||||
}
|
||||
@ -356,7 +356,7 @@ public class WorldScreen extends com.unciv.game.utils.CameraStageBaseScreen {
|
||||
|
||||
// Set all tiles transparent except those in unit range
|
||||
for(TileGroup TG : tileGroups.linqValues()) TG.setColor(0,0,0,0.3f);
|
||||
for(TileInfo tile : game.civInfo.tileMap.getDistanceToTiles(unitTile.position,unitTile.unit.CurrentMovement).keySet()){
|
||||
for(TileInfo tile : game.civInfo.tileMap.getDistanceToTiles(unitTile.position,unitTile.unit.currentMovement).keySet()){
|
||||
tileGroups.get(tile.position.toString()).setColor(Color.WHITE);
|
||||
}
|
||||
|
||||
@ -366,7 +366,7 @@ public class WorldScreen extends com.unciv.game.utils.CameraStageBaseScreen {
|
||||
TileTable.add(moveUnitButton).colspan(2)
|
||||
.size(moveUnitButton.getWidth() * buttonScale, moveUnitButton.getHeight() * buttonScale);
|
||||
|
||||
if(selectedTile.unit.Name.equals("Settler")){
|
||||
if(selectedTile.unit.name.equals("Settler")){
|
||||
TextButton foundCityButton = new TextButton("Found City", skin);
|
||||
foundCityButton.getLabel().setFontScale(buttonScale);
|
||||
foundCityButton.addListener(new ClickListener(){
|
||||
@ -394,7 +394,7 @@ public class WorldScreen extends com.unciv.game.utils.CameraStageBaseScreen {
|
||||
.size(foundCityButton.getWidth() * buttonScale, foundCityButton.getHeight() * buttonScale);
|
||||
}
|
||||
|
||||
if(selectedTile.unit.Name.equals("Worker")) {
|
||||
if(selectedTile.unit.name.equals("Worker")) {
|
||||
String improvementButtonText = selectedTile.improvementInProgress == null ?
|
||||
"Construct\r\nimprovement" : selectedTile.improvementInProgress +"\r\nin progress";
|
||||
TextButton improvementButton = new TextButton(improvementButtonText, skin);
|
||||
@ -405,7 +405,7 @@ public class WorldScreen extends com.unciv.game.utils.CameraStageBaseScreen {
|
||||
game.setScreen(new ImprovementPickerScreen(game, selectedTile));
|
||||
}
|
||||
});
|
||||
if(selectedTile.unit.CurrentMovement==0 || selectedTile.isCityCenter() ||
|
||||
if(selectedTile.unit.currentMovement ==0 || selectedTile.isCityCenter() ||
|
||||
!GameBasics.TileImprovements.linqValues().any(new Predicate<TileImprovement>() {
|
||||
@Override
|
||||
public boolean evaluate(TileImprovement arg0) {
|
||||
|
@ -31,7 +31,7 @@ public class TechPickerScreen extends PickerScreen {
|
||||
public TechPickerScreen(final UnCivGame game) {
|
||||
super(game);
|
||||
|
||||
Technology[][] techMatrix = new Technology[12][10]; // Divided into columns, then rows
|
||||
Technology[][] techMatrix = new Technology[16][10]; // Divided into columns, then rows
|
||||
|
||||
for (Technology technology : GameBasics.Technologies.linqValues()) {
|
||||
techMatrix[technology.column.columnNumber-1][technology.row - 1] = technology;
|
||||
@ -40,7 +40,7 @@ public class TechPickerScreen extends PickerScreen {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
topTable.row().pad(5);
|
||||
|
||||
for (int j = 0; j < 10; j++) {
|
||||
for (int j = 0; j < techMatrix.length; j++) {
|
||||
final Technology tech = techMatrix[j][i];
|
||||
if (tech == null) topTable.add(); // empty cell
|
||||
else {
|
||||
|
Reference in New Issue
Block a user