Permalink
Browse files

+ post-collapse needs pop img upd

+ pollution orb should fill up faster
+ planet <-> civ bidirectional link now unidirectional
+ pointless confirm pre adv text display
+ "the 2 billion enslaved x are enslaved"
+ seccessisson should transfer tech and weapon tech level!
+ not enough lifeforms, too many civs too early
+ adv actions require confirm even if no text
+ make colonisation a bit more frequent and ensure it has no weird prerequisites that stop it most of the time
+ were drawing numbers on the master version of government icons
+ positioning of arriving agents is wrong
+ govt change requires pop img update
  • Loading branch information...
1 parent 6b805e2 commit 71d4511b52e15acb6d6cf0b2fedfbba3e645a8f9 @Zarkonnen committed Mar 14, 2012
@@ -51,7 +51,7 @@ public void setLocation(Planet location) {
if (this.location != null) {
boolean passedMe = false;
for (Agent ag : sg.agents) {
- if (ag == this) { passedMe = true; }
+ if (ag == this) { passedMe = true; continue; }
if (ag.location == this.location && passedMe) {
add(move(ag.sprite, ag.sprite.x - 36, ag.sprite.y));
}
@@ -81,7 +81,7 @@ public void setLocation(Planet location) {
}
boolean passedMe = false;
for (Agent ag : sg.agents) {
- if (ag == this) { passedMe = true; }
+ if (ag == this) { passedMe = true; continue; }
if (ag.location == this.location && passedMe) {
add(move(ag.sprite, ag.sprite.x + 36, ag.sprite.y));
}
@@ -353,10 +353,7 @@ public void behave(Agent a, SpaceGen sg) {
if (p.getOwner() != null) {
p.getOwner().relations.put(la.artefact.creator, Diplomacy.Outcome.WAR);
la.artefact.creator.relations.put(p.getOwner(), Diplomacy.Outcome.WAR);
- p.getOwner().colonies.remove(p);
}
- la.artefact.creator.colonies.clear();
- la.artefact.creator.colonies.add(p);
p.setOwner(la.artefact.creator);
boolean inserted = false;
for (Population pop : p.inhabitants) {
@@ -394,17 +391,17 @@ public void behave(Agent a, SpaceGen sg) {
major = true;
p.strata.remove(stratum);
a.resources++;
- sg.pick(a.originator.colonies).addArtefact(la.artefact);
+ sg.pick(a.originator.getColonies()).addArtefact(la.artefact);
stratNum--;
}
}
}
- //if (major) {
+ if (rep.length() > 0) {
sg.l(rep.toString());
confirm();
- /*return;
- }*/
+ return;
+ }
return;
}
@@ -535,7 +532,7 @@ public void behave(Agent a, SpaceGen sg) {
// Steal U
if (enemy != null) {
- for (Planet p : enemy.colonies) {
+ for (Planet p : enemy.getColonies()) {
if (!p.artefacts.isEmpty()) {
Artefact art = p.artefacts.get(0);
sg.l("The " + a.originator.name + " send " + a.name + " on a mission to steal the " + art.type.getName() + " on " + p.name + ".");
@@ -95,7 +95,7 @@ public Artefact create2(Civ actor, SpaceGen sg) {
case 4:
case 5:
ArrayList<Artefact> arts = new ArrayList<Artefact>();
- for (Planet p : actor.colonies) {
+ for (Planet p : actor.getColonies()) {
arts.addAll(p.artefacts);
}
if (!arts.isEmpty()) {
@@ -51,10 +51,9 @@
rep.append("A slave revolt on ").append(col.name).append(" falters from fear of torture pits of the ").append(actor.name).append(".");
return;
}
- int resTaken = actor.getResources() / actor.colonies.size();
- int milTaken = actor.getMilitary() / actor.colonies.size();
- Civ newCiv = new Civ(sg.year, rebels.get(0).type, col, Government.REPUBLIC, resTaken, sg.historicalCivNames);
- actor.colonies.remove(col);
+ int resTaken = actor.getResources() / actor.getColonies().size();
+ int milTaken = actor.getMilitary() / actor.getColonies().size();
+ Civ newCiv = new Civ(sg.year, rebels.get(0).type, col, Government.REPUBLIC, resTaken, sg);
actor.setResources(actor.getResources() - resTaken);
actor.setMilitary(actor.getMilitary() - milTaken);
newCiv.setMilitary(milTaken);
@@ -68,7 +67,7 @@
}
sg.civs.add(newCiv);
sg.historicalCivNames.add(newCiv.name);
- for (Planet p : newCiv.colonies) { for (Population pop : p.inhabitants) { pop.addUpdateImgs(); } }
+ for (Planet p : newCiv.getColonies()) { for (Population pop : p.inhabitants) { pop.addUpdateImgs(); } }
animate();
rep.append("Slaves on ").append(col.name).append(" revolt, killing their oppressors and declaring the Free ").append(newCiv.name).append(".");
return;
@@ -79,13 +78,13 @@
THEFT() {
@Override public void i(Civ actor, SpaceGen sg, StringBuilder rep) {
ArrayList<Artefact> cands = new ArrayList<Artefact>();
- for (Planet p : actor.colonies) {
+ for (Planet p : actor.getColonies()) {
cands.addAll(p.artefacts);
}
if (cands.isEmpty()) { return; }
Artefact a = sg.pick(cands);
Planet p = null;
- for (Planet p2 : actor.colonies) { if (p2.artefacts.contains(a)) { p = p2; } }
+ for (Planet p2 : actor.getColonies()) { if (p2.artefacts.contains(a)) { p = p2; } }
Planet newP = sg.pick(sg.planets);
//p.artefacts.remove(a);
// qqDPS
@@ -104,8 +103,7 @@
actor.fullMembers.clear();
actor.fullMembers.add(rulers);
actor.setGovt(Government.DICTATORSHIP, sg.historicalCivNames);
- sg.historicalCivNames.add(actor.name);
- for (Planet p : actor.colonies) { for (Population pop : p.inhabitants) { pop.addUpdateImgs(); } }
+ for (Planet p : actor.getColonies()) { for (Population pop : p.inhabitants) { pop.addUpdateImgs(); } }
animate();
rep.append("A military putsch turns the ").append(oldName).append(" into the ").append(actor.name).append(".");
}
@@ -114,8 +112,7 @@
@Override public void i(Civ actor, SpaceGen sg, StringBuilder rep) {
String oldName = actor.name;
actor.setGovt(Government.THEOCRACY, sg.historicalCivNames);
- sg.historicalCivNames.add(actor.name);
- for (Planet p : actor.colonies) { for (Population pop : p.inhabitants) { pop.addUpdateImgs(); } }
+ for (Planet p : actor.getColonies()) { for (Population pop : p.inhabitants) { pop.addUpdateImgs(); } }
animate();
rep.append("Religious fanatics sieze power in the ").append(oldName).append(" and declare the ").append(actor.name).append(".");
}
@@ -134,10 +131,13 @@
if (actor.fullMembers.size() > 1) {
rep.append(" With the knowledge of faster-than-light travel lost, each planet in the empire has to fend for itself.");
}
- for (Planet c : new ArrayList<Planet>(actor.colonies)) {
+ for (Planet c : new ArrayList<Planet>(actor.getColonies())) {
c.darkAge(sg.year);
+ for (Population pop : c.inhabitants) {
+ pop.addUpdateImgs();
+ }
}
- actor.colonies.clear();
+ animate();
}
}
},
@@ -165,18 +165,19 @@
CIVIL_WAR() {
@Override public void i(Civ actor, SpaceGen sg, StringBuilder rep) {
ArrayList<Planet> bigPlanets = new ArrayList<Planet>();
- for (Planet c : actor.colonies) {
+ for (Planet c : actor.getColonies()) {
if (c.population() > 2) { bigPlanets.add(c); }
}
if (bigPlanets.size() > 1) {
Collections.shuffle(bigPlanets, sg.r);
- Civ newCiv = new Civ(sg.year, null, bigPlanets.get(0), sg.pick(Government.values()), actor.getResources() / 2, sg.historicalCivNames);
+ Civ newCiv = new Civ(sg.year, null, bigPlanets.get(0), sg.pick(Government.values()), actor.getResources() / 2, sg);
newCiv.fullMembers.clear();
newCiv.setMilitary(actor.getMilitary() / 2);
+ newCiv.setTechLevel(actor.getTechLevel());
+ newCiv.setWeapLevel(actor.getWeapLevel());
actor.setMilitary(actor.getMilitary() - newCiv.getMilitary());
actor.setResources(actor.getResources() - newCiv.getResources());
for (int i = 1; i < bigPlanets.size() / 2; i++) {
- newCiv.colonies.add(bigPlanets.get(i));
bigPlanets.get(i).setOwner(newCiv);
for (Population pop : bigPlanets.get(i).inhabitants) {
if (!newCiv.fullMembers.contains(pop.type)) {
@@ -189,20 +190,18 @@
newCiv.fullMembers.add(pop.type);
}
}
- for (Planet c : new ArrayList<Planet>(actor.colonies)) {
+ for (Planet c : new ArrayList<Planet>(actor.getColonies())) {
if (bigPlanets.contains(c)) { continue; }
if (sg.coin()) {
- newCiv.colonies.add(c);
c.setOwner(newCiv);
}
}
- actor.colonies.removeAll(newCiv.colonies);
newCiv.setGovt(newCiv.getGovt(), sg.historicalCivNames);
newCiv.relations.put(actor, Diplomacy.Outcome.WAR);
actor.relations.put(newCiv, Diplomacy.Outcome.WAR);
sg.civs.add(newCiv);
sg.historicalCivNames.add(newCiv.name);
- for (Planet p : newCiv.colonies) { for (Population pop : p.inhabitants) { pop.addUpdateImgs(); } }
+ for (Planet p : newCiv.getColonies()) { for (Population pop : p.inhabitants) { pop.addUpdateImgs(); } }
animate();
rep.append("The ").append(newCiv.name).append(" secedes from the ").append(actor.name).append(", leading to a civil war!");
}
@@ -259,7 +258,7 @@
SentientType st = sg.pick(actor.fullMembers);
String color = sg.pick(Names.COLORS);
String name = color + st.base.pSuffix;
- Planet p = sg.pick(actor.colonies);
+ Planet p = sg.pick(actor.getColonies());
rep.append("The pirate ").append(name).append(" establishes ").append(sg.coin() ? "himself" : "herself").append(" on ").append(p.name).append(".");
Agent ag = new Agent(AgentType.PIRATE, sg.year, name, sg);
ag.color = color;
@@ -273,7 +272,7 @@
},
ROGUE_AI() {
@Override public void i(Civ actor, SpaceGen sg, StringBuilder rep) {
- Planet p = sg.pick(actor.colonies);
+ Planet p = sg.pick(actor.getColonies());
String pref = sg.pick(new String[] { "Experiment ", "System ", "Mind ", "Simulation " });
Agent ag = new Agent(AgentType.ROGUE_AI, sg.year, pref + sg.r.nextInt(500), sg);
ag.setLocation(p);
@@ -29,7 +29,6 @@
public class Civ {
ArrayList<SentientType> fullMembers = new ArrayList<SentientType>();
private Government govt;
- ArrayList<Planet> colonies = new ArrayList<Planet>();
HashMap<Civ, Diplomacy.Outcome> relations = new HashMap<Civ, Diplomacy.Outcome>();
int number = 0;
@@ -44,6 +43,15 @@
int birthYear;
int nextBreakthrough = 6;
int decrepitude = 0;
+ private final SpaceGen sg;
+
+ public ArrayList<Planet> getColonies() {
+ ArrayList<Planet> cols = new ArrayList<Planet>();
+ for (Planet p : sg.planets) {
+ if (p.getOwner() == this) { cols.add(p); }
+ }
+ return cols;
+ }
public int getResources() {
return resources;
@@ -136,7 +144,7 @@ public Planet closestColony(Planet p) {
}
}
if (c == null) {
- return colonies.get(0);
+ return getColonies().get(0);
} else {
return c;
}
@@ -148,7 +156,7 @@ public Planet closestColony(Planet p) {
ArrayList<Planet> ir = new ArrayList<Planet>();
for (Planet p : sg.planets) {
int closestR = 100000;
- for (Planet c : colonies) {
+ for (Planet c : getColonies()) {
int dist = (p.x - c.x) * (p.x - c.x) + (p.y - c.y) * (p.y - c.y);
closestR = Math.min(dist, closestR);
}
@@ -160,7 +168,7 @@ public Planet closestColony(Planet p) {
}
public boolean has(ArtefactType at) {
- for (Planet c : colonies) {
+ for (Planet c : getColonies()) {
for (Artefact a : c.artefacts) {
if (a.type == at) { return true; }
}
@@ -169,7 +177,7 @@ public boolean has(ArtefactType at) {
}
Artefact use(ArtefactType at) {
- for (Planet c : colonies) {
+ for (Planet c : getColonies()) {
for (Artefact a : c.artefacts) {
if (a.type == at) {
c.artefacts.remove(a);
@@ -185,28 +193,28 @@ Artefact use(ArtefactType at) {
return relations.get(c);
}
- public Civ(int year, SentientType st, Planet home, Government govt, int resources, ArrayList<String> historicals) {
+ public Civ(int year, SentientType st, Planet home, Government govt, int resources, SpaceGen sg) {
this.govt = govt;
+ this.sg = sg;
if (st != null) {
this.fullMembers.add(st);
}
- this.colonies.add(home);
setResources(resources);
this.birthYear = year;
- updateName(historicals);
+ updateName(sg.historicalCivNames);
home.setOwner(this);
setTechLevel(1);
}
public int population() {
int sum = 0;
- for (Planet col : colonies) { sum += col.population(); }
+ for (Planet col : getColonies()) { sum += col.population(); }
return sum;
}
public ArrayList<Planet> fullColonies() {
ArrayList<Planet> fcs = new ArrayList<Planet>();
- for (Planet col : colonies) {
+ for (Planet col : getColonies()) {
if (col.population() > 0) { fcs.add(col); }
}
return fcs;
@@ -215,7 +223,7 @@ public int population() {
public Planet largestColony() {
int sz = -1;
Planet largest = null;
- for (Planet col : colonies) {
+ for (Planet col : getColonies()) {
if (col.population() > sz) { largest = col; sz = col.population(); }
}
return largest;
@@ -254,6 +262,7 @@ final void updateName(ArrayList<String> historicals) {
name = n;
break;
}
+ historicals.add(name);
}
public String fullDesc(SpaceGen sg) {
@@ -299,15 +308,15 @@ public String fullDesc(SpaceGen sg) {
}
sb.append(" ").append(getGovt().title).append(" of ");
- if (colonies.size() == 1) {
- sb.append("a single planet, ").append(colonies.get(0).name);
+ if (getColonies().size() == 1) {
+ sb.append("a single planet, ").append(getColonies().get(0).name);
} else {
- sb.append(colonies.size()).append(" planets");
+ sb.append(getColonies().size()).append(" planets");
}
sb.append(", with ").append(population()).append(" billion inhabitants.\n");
sb.append("Major populations:\n");
HashMap<SentientType, Integer> pops = new HashMap<SentientType, Integer>();
- for (Planet c : colonies) { for (Population pop : c.inhabitants) {
+ for (Planet c : getColonies()) { for (Population pop : c.inhabitants) {
if (!pops.containsKey(pop.type)) {
pops.put(pop.type, pop.getSize());
} else {
@@ -323,7 +332,7 @@ public String fullDesc(SpaceGen sg) {
sb.append(e.getValue()).append(" billion enslaved ").append(e.getKey().getName()).append(".\n");
}
HashSet<Device> devices = new HashSet<Device>();
- for (Planet c : colonies) { for (Artefact a : c.artefacts) {
+ for (Planet c : getColonies()) { for (Artefact a : c.artefacts) {
if (a.type instanceof Device) {
devices.add((Device) a.type);
}
Oops, something went wrong.

0 comments on commit 71d4511

Please sign in to comment.