Skip to content

Commit

Permalink
Add Javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Mackenzie1678 committed Nov 15, 2020
1 parent 1addf9f commit 642f626
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/org/qme/world/World.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package org.qme.world;

import org.qme.main.QApplication;
import org.qme.world.gen.SettlementGen;
import org.qme.world.gen.WorldGenNeo;
import org.qme.world.gen.WorldGenRandom;
import org.qme.world.gen.WorldGenSquigglyBlob;

/**
* Represents a 2D array of tiles
* @author adamhutchings
* @author S-Mackenzie1678
* @since pre0
*/
public class World {
Expand Down Expand Up @@ -56,6 +58,7 @@ public World(QApplication a, int x, int y) {
}
}

SettlementGen.settlementGive(this);
}

}
21 changes: 12 additions & 9 deletions src/org/qme/world/gen/SettlementGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@
import org.qme.world.TileType;
import org.qme.world.World;

/**
* Generates settlement
* CURSED!
* @author santiago
* @since pre5
*/
public class SettlementGen {
private int settlementProbabilityModifier(Tile tile) {
private static int settlementProbabilityModifier(Tile tile) {
if(tile.getType() == TileType.OCEAN) {
return 10000;
}
Expand All @@ -35,29 +41,26 @@ private int settlementProbabilityModifier(Tile tile) {
return 2100000000;
}

public World settlementGive(World world) {
World s = world;
public static void settlementGive(World world) {
ArrayList<PoliticalEntity> civs = world.tiles[0][0].application.game.civilizations;
for(int w = 0; w < world.tiles[0].length; w++) {
for(int w = 0; w < civs.size(); w++) {
while(civs.get(w).capital == null) {
for(int i = 0; i < world.xDimension; i++) {
for(int j = 0; j < world.yDimension; j++) {
Random rand = new Random();
if(rand.nextInt(17) == 0) {
if(rand.nextInt(settlementProbabilityModifier(world.tiles[i][j])) == 0) {
Settlement newCity = new Settlement(s.tiles[i][j].application, s.tiles[i][j], civs.get(w));
s.tiles[i][j].structure = newCity;
Settlement newCity = new Settlement(world.tiles[i][j].application, world.tiles[i][j], civs.get(w));
world.tiles[i][j].structure = newCity;
civs.get(w).capital = newCity;
civs.get(w).superior = null;
civs.get(w).territory.add(0, s.tiles[i][j]);
civs.get(w).territory.add(0, world.tiles[i][j]);
civs.get(w).ownedCities.add(0, newCity);
}
}
}
}
}
}

return s;
}
}

0 comments on commit 642f626

Please sign in to comment.