remove population summ, improve total CC compute
This commit is contained in:
@@ -72,10 +72,6 @@ public class PowerPlayController {
|
||||
@FXML
|
||||
private TableView<ResultEntry> tblDetail;
|
||||
@FXML
|
||||
private Label resultPopSumm;
|
||||
@FXML
|
||||
private Label detailPopSumm;
|
||||
@FXML
|
||||
private Label resultCCSumm;
|
||||
@FXML
|
||||
private Label detailCCSumm;
|
||||
@@ -186,21 +182,15 @@ public class PowerPlayController {
|
||||
tblDetail.setOnDragDetected(new StarSystemDragDetect(tblDetail));
|
||||
NumberStringConverter converter = new NumberStringConverter("#,##0.##");
|
||||
result.addListener((InvalidationListener) i -> {
|
||||
resultPopSumm.setText(converter.toString(getPopulationSumm(result)));
|
||||
resultCCSumm.setText(getCCSummText(result, getCheckedSystem()));
|
||||
}
|
||||
);
|
||||
detail.addListener((InvalidationListener) i -> {
|
||||
detailPopSumm.setText(converter.toString(getPopulationSumm(detail)));
|
||||
detailCCSumm.setText(getCCSummText(detail, detailSystem));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private long getPopulationSumm(Collection<ResultEntry> collection){
|
||||
return collection.stream().mapToLong(ResultEntry::getPopulation).sum();
|
||||
}
|
||||
|
||||
private String getCCSummText(Collection<ResultEntry> collection, Place starSystem){
|
||||
String ccFormat = Localization.getString("powerplay.label.summcc");
|
||||
String pwCCFormat = Localization.getString("powerplay.label.cc");
|
||||
@@ -210,18 +200,21 @@ public class PowerPlayController {
|
||||
long[] intersectedCc = new long[POWER.values().length];
|
||||
long[] totalCc = new long[POWER.values().length];
|
||||
long contested = 0;
|
||||
long intersected = 0;
|
||||
long summCc = 0;
|
||||
for (ResultEntry entry : collection) {
|
||||
long cc = entry.getCc();
|
||||
summCc += cc;
|
||||
if (entry.getPower() == null || entry.getPowerState() == null) continue;
|
||||
if (entry.getPowerState() != POWER_STATE.NONE){
|
||||
if (hq == null || !entry.getPowerState().isExploited() && !entry.getPowerState().isControl()
|
||||
|| entry.getPower() != hq.getPower()) {
|
||||
if (hq == null || entry.getPowerState().isContested() || entry.getPower() != hq.getPower()) {
|
||||
contested += cc;
|
||||
}
|
||||
if (hq != null && entry.getPowerState().isExploited() && entry.getPower() == hq.getPower()) {
|
||||
intersected += cc;
|
||||
}
|
||||
Set<POWER> powers = entry.getControllingSystems().stream().map(Place::getPower).collect(Collectors.toSet());
|
||||
if (entry.getPowerState() == POWER_STATE.CONTESTED){
|
||||
if (entry.getPowerState().isContested()){
|
||||
for (POWER power : powers){
|
||||
contestedCc[power.ordinal()] += cc;
|
||||
}
|
||||
@@ -229,7 +222,9 @@ public class PowerPlayController {
|
||||
if (entry.getControllingSystems().size()>1){
|
||||
intersectedCc[entry.getPower().ordinal()] += cc;
|
||||
}
|
||||
totalCc[entry.getPower().ordinal()] += cc;
|
||||
if (entry.getPowerState().isControl() || entry.getPowerState().isExploited()) {
|
||||
totalCc[entry.getPower().ordinal()] += cc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -239,7 +234,7 @@ public class PowerPlayController {
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(String.format(ccFormat, summCc, contested, summCc - contested, upkeep, summCc - contested - upkeep));
|
||||
builder.append(String.format(ccFormat, summCc, contested, summCc - contested, upkeep, intersected, summCc - contested - upkeep - intersected));
|
||||
for (int i = 0; i < POWER.values().length; i++) {
|
||||
if (totalCc[i] > 0 || contestedCc[i] > 0){
|
||||
builder.append("\n");
|
||||
|
||||
@@ -286,7 +286,7 @@ powerplay.label.power.systems=Systems of Power:
|
||||
powerplay.label.power.state=State:
|
||||
powerplay.label.populationSumm=Summ populations:
|
||||
powerplay.label.cc=%s: %4d CC Contested: %4d CC Intersected: %4d CC
|
||||
powerplay.label.summcc=Summ: %5d CC Contested: %5d CC Income: %5d CC Upkeep: %5.0f CC Total: %5.0f CC
|
||||
powerplay.label.summcc=Summ: %5d CC Contested: %5d CC Income: %5d CC\nUpkeep: %5.0f CC Already exploited: %5d CC Total: %5.0f CC
|
||||
powerplay.result.title=Analyze result
|
||||
powerplay.column.intersecting=Intersect
|
||||
powerplay.column.intersectCount=Intersect count
|
||||
|
||||
@@ -286,7 +286,7 @@ powerplay.label.power.systems=C\u0438\u0441\u0442\u0435\u043C\u044B \u0441\u0438
|
||||
powerplay.label.power.state=\u0421\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u0435:
|
||||
powerplay.label.populationSumm=\u0421\u0443\u043C\u043C\u0430 \u043D\u0430\u0441\u0435\u043B\u0435\u043D\u0438\u044F:
|
||||
powerplay.label.cc=%s: %4d \u041A\u041A \u041E\u0441\u043F\u0430\u0440\u0438\u0432\u0430\u0435\u043C\u044B\u0445: %4d \u041A\u041A \u041F\u0435\u0440\u0435\u0441\u0435\u043A\u0430\u044E\u0449\u0438\u0445\u0441\u044F: %4d \u041A\u041A
|
||||
powerplay.label.summcc=\u0421\u0443\u043C\u043C\u0430: %5d \u041A\u041A \u041E\u0441\u043F\u0430\u0440\u0438\u0432\u0430\u0435\u043C\u044B\u0445: %5d \u041A\u041A \u0414\u043E\u0445\u043E\u0434: %5d \u041A\u041A \u0420\u0430\u0441\u0445\u043E\u0434\u044B: %5.0f \u041A\u041A \u0418\u0442\u043E\u0433\u043E: %5.0f \u041A\u041A
|
||||
powerplay.label.summcc=\u0421\u0443\u043C\u043C\u0430: %5d \u041A\u041A \u041E\u0441\u043F\u0430\u0440\u0438\u0432\u0430\u0435\u043C\u044B\u0445: %5d \u041A\u041A \u0414\u043E\u0445\u043E\u0434: %5d \u041A\u041A\n\u0420\u0430\u0441\u0445\u043E\u0434\u044B: %5.0f \u041A\u041A \u0423\u0436\u0435 \u044D\u043A\u0441\u043F\u043B\u0443\u0430\u0442\u0438\u0440\u0443\u0435\u043C\u044B\u0445: %5d \u041A\u041A \u0418\u0442\u043E\u0433\u043E: %5.0f \u041A\u041A
|
||||
powerplay.result.title=\u0420\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442\u044B \u0430\u043D\u0430\u043B\u0438\u0437\u0430
|
||||
powerplay.column.intersecting=\u041F\u0435\u0440\u0435\u0441\u0435\u043A\u0430\u0435\u0442\u0441\u044F \u0441
|
||||
powerplay.column.intersectCount=\u041F\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043D\u0438\u0439
|
||||
|
||||
@@ -160,7 +160,6 @@
|
||||
</TableView>
|
||||
<ScrollPane minHeight="50">
|
||||
<VBox spacing="4" padding="$summPadding">
|
||||
<HBox spacing="4"><Label text="%powerplay.label.populationSumm" /><Label fx:id="resultPopSumm" /></HBox>
|
||||
<HBox spacing="4"><Label fx:id="resultCCSumm" wrapText="true"/></HBox>
|
||||
</VBox>
|
||||
</ScrollPane>
|
||||
@@ -198,7 +197,7 @@
|
||||
<cellValueFactory><PropertyValueFactory property="income"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn prefWidth="60" text="%market.system.upkeep">
|
||||
<cellValueFactory><PropertyValueFactory property="upkeep"/></cellValueFactory>
|
||||
<cellValueFactory><PropertyValueFactory property="currentUpkeep"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn prefWidth="80" text="%market.population">
|
||||
<cellFactory><TextCell><converter><CustomNumberStringConverter pattern="#,##0.##" /></converter></TextCell></cellFactory>
|
||||
@@ -221,7 +220,6 @@
|
||||
</TableView>
|
||||
<ScrollPane minHeight="50">
|
||||
<VBox spacing="4" padding="$summPadding">
|
||||
<HBox spacing="4"><Label text="%powerplay.label.populationSumm" /><Label fx:id="detailPopSumm" /></HBox>
|
||||
<HBox spacing="4"><Label fx:id="detailCCSumm" wrapText="true"/></HBox>
|
||||
</VBox>
|
||||
</ScrollPane>
|
||||
|
||||
@@ -10,4 +10,12 @@ public enum POWER_STATE {
|
||||
public boolean isExploited(){
|
||||
return this == EXPLOITED || this == BLOCKED;
|
||||
}
|
||||
|
||||
public boolean isExpansion(){
|
||||
return this == EXPANSION;
|
||||
}
|
||||
|
||||
public boolean isContested(){
|
||||
return this == CONTESTED;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user