governments
All checks were successful
studiorailgun/trpg/pipeline/head This commit looks good

This commit is contained in:
austin 2025-01-05 19:03:54 -05:00
parent 5f5aace1e2
commit ab38723bf7
8 changed files with 188 additions and 1 deletions

View File

@ -1,5 +1,5 @@
{ {
"name" : "continent", "name" : "town(human)",
"childrenMandatory" : [ "childrenMandatory" : [
], ],

View File

@ -20,6 +20,11 @@ public class CreatureDef {
*/ */
String plural; String plural;
/**
* Tracks whether this creature is a civilization builder or not
*/
Boolean civBuilder;
public String getName() { public String getName() {
return name; return name;
@ -45,6 +50,14 @@ public class CreatureDef {
this.plural = plural; this.plural = plural;
} }
public Boolean getCivBuilder() {
return civBuilder;
}
public void setCivBuilder(Boolean civBuilder) {
this.civBuilder = civBuilder;
}
} }

View File

@ -1,7 +1,10 @@
package org.studiorailgun.sim.config.creature; package org.studiorailgun.sim.config.creature;
import java.io.File; import java.io.File;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.studiorailgun.FileUtils; import org.studiorailgun.FileUtils;
@ -21,6 +24,11 @@ public class CreatureDefManager {
*/ */
Map<String,CreatureDef> definitions = new HashMap<String,CreatureDef>(); Map<String,CreatureDef> definitions = new HashMap<String,CreatureDef>();
/**
* The list of creatures that build civilizations
*/
List<CreatureDef> civBuilders = new LinkedList<CreatureDef>();
/** /**
* Loads the location def manager * Loads the location def manager
* @return The location def manager * @return The location def manager
@ -54,5 +62,14 @@ public class CreatureDefManager {
return definitions.get(name); return definitions.get(name);
} }
/**
* Gets the collection of all creature definitions
* @return The collection of all creature definitions
*/
public Collection<CreatureDef> getDefinitions(){
return definitions.values();
}
} }

View File

@ -0,0 +1,109 @@
package org.studiorailgun.sim.org;
import java.util.LinkedList;
import java.util.List;
import org.studiorailgun.sim.space.Region;
/**
* A government
*/
public class Government {
/**
* The list of territories under the leadership of this unit of government
*/
List<Region> territories = new LinkedList<Region>();
/**
* Subdivisions of this government
*/
List<Government> subdivision = new LinkedList<Government>();
/**
* The type of government
*/
String type;
/**
* The name of the government
*/
String name;
/**
* Constructor
* @param type The type of government
* @param name The name of the government
*/
public Government(String type, String name){
this.type = type;
this.name = name;
}
public List<Region> getTerritories() {
return territories;
}
public void setTerritories(List<Region> territories) {
this.territories = territories;
}
/**
* Adds a region to the territories controlled by this government
* @param region The region
*/
public void addTerritory(Region region){
this.territories.add(region);
}
/**
* Removes a region from the territories controlled by this government
* @param region The region
*/
public void removeTerritory(Region region){
this.territories.remove(region);
}
public List<Government> getSubdivision() {
return subdivision;
}
public void setSubdivision(List<Government> subdivision) {
this.subdivision = subdivision;
}
/**
* Adds a subdivision to this government
* @param subdivision The subdivision
*/
public void addSubdivision(Government subdivision){
this.subdivision.add(subdivision);
}
/**
* Removes a subdivision from this government
* @param subdivision The subdivision
*/
public void removeSubdivision(Government subdivision){
this.subdivision.remove(subdivision);
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.studiorailgun.sim.character.Character; import org.studiorailgun.sim.character.Character;
import org.studiorailgun.sim.org.Government;
/** /**
* Top level spatial container * Top level spatial container
@ -22,6 +23,11 @@ public class World {
*/ */
List<Character> characters = new LinkedList<Character>(); List<Character> characters = new LinkedList<Character>();
/**
* The list of governments
*/
List<Government> governments = new LinkedList<Government>();
/** /**
* Map of location id -> location * Map of location id -> location
*/ */
@ -76,6 +82,24 @@ public class World {
return this.idLocationMap.get(id); return this.idLocationMap.get(id);
} }
public List<Government> getGovernments() {
return governments;
}
public void setGovernments(List<Government> governments) {
this.governments = governments;
}
/**
* Adds a government
* @param gov The government
*/
public void addGovernment(Government gov){
this.governments.add(gov);
}
} }

View File

@ -18,6 +18,12 @@ public class RegionGenerator {
Region rVal = new Region(); Region rVal = new Region();
RegionDefinitionFile def = Globals.config.getRegionDefinitionManager().getDefinition(type); RegionDefinitionFile def = Globals.config.getRegionDefinitionManager().getDefinition(type);
//generate all mandatory child region types
for(String childType : def.getChildrenMandatory()){
Region child = RegionGenerator.generate(childType);
rVal.addChild(child);
}
return rVal; return rVal;
} }

View File

@ -8,6 +8,8 @@ import org.studiorailgun.sim.space.util.LocationResolver;
import org.studiorailgun.Globals; import org.studiorailgun.Globals;
import org.studiorailgun.sim.character.Character; import org.studiorailgun.sim.character.Character;
import org.studiorailgun.sim.character.gen.CharacterGenerator; import org.studiorailgun.sim.character.gen.CharacterGenerator;
import org.studiorailgun.sim.config.creature.CreatureDef;
import org.studiorailgun.sim.org.Government;
/** /**
* Generates a world * Generates a world
@ -25,6 +27,9 @@ public class WorldGenerator {
//generate the regions //generate the regions
rVal.setRegion(TownGenerator.generateTown()); rVal.setRegion(TownGenerator.generateTown());
//generate the govs
WorldGenerator.generateGovernments(rVal);
//generate the characters //generate the characters
WorldGenerator.generateCharacters(rVal); WorldGenerator.generateCharacters(rVal);
@ -47,4 +52,17 @@ public class WorldGenerator {
newChar.move(placementDest); newChar.move(placementDest);
} }
/**
* Populates the world with governments
* @param world The world
*/
private static void generateGovernments(World world){
for(CreatureDef creatureDef : Globals.config.getCreatureDefManager().getDefinitions()){
if(creatureDef.getCivBuilder()){
Government creatureGov = new Government("kingdom", "Kingdom of the " + creatureDef.getName());
world.addGovernment(creatureGov);
}
}
}
} }