[customwars] r757 committed - Return construction percentage instead of boolean

0 views
Skip to first unread message

codesite...@google.com

unread,
Aug 26, 2012, 11:34:05 AM8/26/12
to customwar...@googlegroups.com
Revision: 757
Author: ace.stef
Date: Sun Aug 26 08:33:53 2012
Log: Return construction percentage instead of boolean
http://code.google.com/p/customwars/source/detail?r=757

Modified:
/trunk/v2/src/com/customwars/client/action/unit/ConstructCityAction.java
/trunk/v2/src/com/customwars/client/model/CWGameController.java
/trunk/v2/src/com/customwars/client/model/GameController.java

=======================================
---
/trunk/v2/src/com/customwars/client/action/unit/ConstructCityAction.java
Sun Mar 20 06:49:26 2011
+++
/trunk/v2/src/com/customwars/client/action/unit/ConstructCityAction.java
Sun Aug 26 08:33:53 2012
@@ -4,8 +4,6 @@
import com.customwars.client.action.ActionCommandEncoder;
import com.customwars.client.action.DirectAction;
import com.customwars.client.model.GameController;
-import com.customwars.client.model.gameobject.City;
-import com.customwars.client.model.gameobject.CityFactory;
import com.customwars.client.model.gameobject.Unit;
import com.customwars.client.model.map.Location;
import com.customwars.client.network.MessageSender;
@@ -45,23 +43,21 @@
}

private void constructCity() {
- boolean constructionComplete = gameController.constructCity(unit,
cityID, to);
- logConstructingProgress(constructionComplete);
+ int constructionPercentage = gameController.constructCity(unit,
cityID, to);
+ logConstructingProgress(constructionPercentage);
if (App.isMultiplayer()) sendConstructCity();
}

- private void logConstructingProgress(boolean constructionComplete) {
- City city = CityFactory.getCity(cityID);
-
- if (constructionComplete) {
+ private void logConstructingProgress(int constructionPercentage) {
+ if (constructionPercentage == 100) {
logger.debug(
String.format("%s constructed a %s",
- unit.getStats().getName(), city.getName())
+ unit.getStats().getName(), cityID)
);
} else {
logger.debug(
- String.format("%s is constructing a %s",
- unit.getStats().getName(), city.getName())
+ String.format("%s is constructing a %s (%s/100)",
+ unit.getStats().getName(), cityID, constructionPercentage)
);
}
}
=======================================
--- /trunk/v2/src/com/customwars/client/model/CWGameController.java Mon Mar
21 08:15:29 2011
+++ /trunk/v2/src/com/customwars/client/model/CWGameController.java Sun Aug
26 08:33:53 2012
@@ -181,7 +181,7 @@
}

@Override
- public boolean constructCity(Unit unit, String cityID, Location
location) {
+ public int constructCity(Unit unit, String cityID, Location location) {
City city;
if (map.isConstructingCityAt(location)) {
city = map.getCityUnderConstructionAt(location);
@@ -196,9 +196,9 @@
if (unit.isConstructionComplete()) {
stopConstructingCity(unit, location);
addCityToTile(location, city, unit.getOwner());
- return true;
+ return 100;
} else {
- return false;
+ return city.getCapCountPercentage();
}
}

=======================================
--- /trunk/v2/src/com/customwars/client/model/GameController.java Sun Mar
20 06:49:26 2011
+++ /trunk/v2/src/com/customwars/client/model/GameController.java Sun Aug
26 08:33:53 2012
@@ -80,7 +80,7 @@

/**
* Transform the terrain on the location to the transformToTerrain
terrain.
- * Transforming terrains costs construction points.
+ * Transforming a terrain costs 1 construction point.
*/
void transformTerrain(Unit unit, Location location, Terrain
transformToTerrain);

@@ -91,11 +91,16 @@
void flare(Unit unit, Location flareCenter, int numOfTilesToReveal);

/**
- * The unit constructs a new city on the location.
+ * The unit start constructing a new city on the location.
* Constructing might take several turns before completion.
- * Constructing a city costs construction materials.
+ * The construction materials are decreased by 1 if the city has been
constructed.
+ *
+ * @param unit The unit that wants to construct a new city
+ * @param location The location to construct the city
+ * @param cityID The name of the city that is to be placed on the
location
+ * @return the current construction percentage
*/
- boolean constructCity(Unit unit, String cityID, Location location);
+ int constructCity(Unit unit, String cityID, Location location);

void dive(Unit unit);

Reply all
Reply to author
Forward
0 new messages