Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions src/rotp/model/colony/Colony.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,16 @@ public String printString() {

public int displayPopulation() { return population < 1 ? (int) Math.ceil(population) : (int) population; }
public float population() { return population; }
public void setPopulation(float pop) { population = pop; }
public void adjustPopulation(float pop) { population += pop; }
public int setPopulation(float pop) {
float currentMaxPop = planet().currentSize();
float lost = pop - currentMaxPop;
if (lost > 0) {
population = currentMaxPop;
return (int) lost;
}
population = max(0.0f, pop);
return 0;
}
public int rebels() { return rebels; }
public void rebels(int i) { rebels = i; }
public int deltaPopulation() { return (int) population - (int) previousPopulation - (int) inTransport(); }
Expand Down Expand Up @@ -957,8 +965,12 @@ public void scheduleTransportsToSystem(StarSystem dest, int pop) {
empire.setVisibleShips();
}
public void acceptTransport(Transport t) {
setPopulation(min(planet.currentSize(), (population() + t.size())));
log("Accepting ", str(t.size()), " transports at: ", starSystem().name(), ". New pop:", fmt(population(), 2));
int lostPop = setPopulation(population() + t.size());
if (lostPop > 0 && t.empire().isPlayerControlled()) {
// TODO: Alert to user...
}
log("Accepting ", str(t.size() - lostPop), " transports at: ", starSystem().name(), ". New pop:", fmt(population(), 2),
"(lost ", str(lostPop), ")");
t.size(0);
}
public float maxTransportsToReceive() {
Expand Down Expand Up @@ -1150,7 +1162,10 @@ private void capturedByTransport(Transport tr) {
}
}

setPopulation(min(planet.currentSize(),tr.size()));
int lostPop = setPopulation(tr.size());
if (lostPop > 0 && tr.empire().isPlayerControlled()) {
// TODO: Excess transports lost -- ought to be an alert?
}
tr.size(0);
shipyard().capturedBy(tr.empire());
industry().capturedBy(tr.empire());
Expand Down