work on describing things
All checks were successful
studiorailgun/trpg/pipeline/head This commit looks good
All checks were successful
studiorailgun/trpg/pipeline/head This commit looks good
This commit is contained in:
parent
03a82bbc67
commit
01559b9283
@ -1,10 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name" : "continent",
|
"name" : "continent",
|
||||||
"childrenMandatory" : [
|
"childrenMandatory" : [
|
||||||
|
"plains"
|
||||||
],
|
],
|
||||||
"childrenOptional" : [
|
"childrenOptional" : [
|
||||||
"plains"
|
|
||||||
],
|
],
|
||||||
"dependencies" : [
|
"dependencies" : [
|
||||||
"./data/sim/region/wilderness/wilderness.json",
|
"./data/sim/region/wilderness/wilderness.json",
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
package org.studiorailgun.sim.character.gen;
|
package org.studiorailgun.sim.character.gen;
|
||||||
|
|
||||||
import org.studiorailgun.sim.character.Character;
|
import org.studiorailgun.sim.character.Character;
|
||||||
|
import org.studiorailgun.sim.character.emotion.EmotionData;
|
||||||
|
import org.studiorailgun.sim.character.needs.NeedsHierarchy;
|
||||||
|
import org.studiorailgun.sim.character.vis.CharacterAppearance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a character
|
* Generates a character
|
||||||
@ -13,8 +16,46 @@ public class CharacterGenerator {
|
|||||||
*/
|
*/
|
||||||
public static Character generateCharacter(){
|
public static Character generateCharacter(){
|
||||||
Character rVal = new Character();
|
Character rVal = new Character();
|
||||||
|
|
||||||
|
CharacterGenerator.generateAppearance(rVal);
|
||||||
|
CharacterGenerator.generateEmotions(rVal);
|
||||||
|
CharacterGenerator.generateNeedsHierarchy(rVal);
|
||||||
|
|
||||||
rVal.setLocationId(Character.LOCATION_UNASSIGNED);
|
rVal.setLocationId(Character.LOCATION_UNASSIGNED);
|
||||||
|
|
||||||
|
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates the appearance data for the character
|
||||||
|
* @param character The character
|
||||||
|
*/
|
||||||
|
private static void generateAppearance(Character character){
|
||||||
|
CharacterAppearance appearance = new CharacterAppearance();
|
||||||
|
appearance.setParent(character);
|
||||||
|
|
||||||
|
appearance.setRace("human");
|
||||||
|
|
||||||
|
character.setAppearance(appearance);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates the emotion data for the character
|
||||||
|
* @param character The character
|
||||||
|
*/
|
||||||
|
private static void generateEmotions(Character character){
|
||||||
|
EmotionData emotions = new EmotionData();
|
||||||
|
character.setEmotions(emotions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates the needs data for the character
|
||||||
|
* @param character The character
|
||||||
|
*/
|
||||||
|
private static void generateNeedsHierarchy(Character character){
|
||||||
|
NeedsHierarchy needs = new NeedsHierarchy();
|
||||||
|
character.setNeeds(needs);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package org.studiorailgun.sim.character.vis;
|
package org.studiorailgun.sim.character.vis;
|
||||||
|
|
||||||
|
import org.studiorailgun.sim.character.Character;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container for the appearance of a character
|
* Container for the appearance of a character
|
||||||
*/
|
*/
|
||||||
@ -25,6 +27,11 @@ public class CharacterAppearance {
|
|||||||
*/
|
*/
|
||||||
String race;
|
String race;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The parent character
|
||||||
|
*/
|
||||||
|
Character parent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the height of the character
|
* Gets the height of the character
|
||||||
* @return The height of the character
|
* @return The height of the character
|
||||||
@ -81,4 +88,14 @@ public class CharacterAppearance {
|
|||||||
this.race = race;
|
this.race = race;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Character getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParent(Character parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.studiorailgun.sim.character.Character;
|
import org.studiorailgun.sim.character.Character;
|
||||||
import org.studiorailgun.sim.item.Item;
|
import org.studiorailgun.sim.item.Item;
|
||||||
|
import org.studiorailgun.sim.writing.GroupDescriber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An area contains characters, items, etc.
|
* An area contains characters, items, etc.
|
||||||
@ -38,9 +39,13 @@ public class Location {
|
|||||||
*/
|
*/
|
||||||
public void describe(){
|
public void describe(){
|
||||||
System.out.println("You are in a " + this.type);
|
System.out.println("You are in a " + this.type);
|
||||||
System.out.println("There are " + chars.size() + " people in the " + this.type);
|
if(chars.size() > 1){
|
||||||
|
GroupDescriber.summarize(chars);
|
||||||
|
}
|
||||||
|
if(items.size() > 0){
|
||||||
System.out.println("There are " + items.size() + " items in the " + this.type);
|
System.out.println("There are " + items.size() + " items in the " + this.type);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|||||||
@ -19,10 +19,15 @@ public class RegionGenerator {
|
|||||||
RegionDefinitionFile def = Globals.config.getRegionDefinitionManager().getDefinition(type);
|
RegionDefinitionFile def = Globals.config.getRegionDefinitionManager().getDefinition(type);
|
||||||
|
|
||||||
//generate all mandatory child region types
|
//generate all mandatory child region types
|
||||||
|
if(def.getChildrenMandatory() != null){
|
||||||
for(String childType : def.getChildrenMandatory()){
|
for(String childType : def.getChildrenMandatory()){
|
||||||
Region child = RegionGenerator.generate(childType);
|
Region child = RegionGenerator.generate(childType);
|
||||||
rVal.addChild(child);
|
rVal.addChild(child);
|
||||||
}
|
}
|
||||||
|
} else if(def.getDiscoverables() != null){
|
||||||
|
String locType = def.getDiscoverables().get(0);
|
||||||
|
rVal.addLocation(LocationGenerator.generate(locType));
|
||||||
|
}
|
||||||
|
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,7 @@ public class WorldGenerator {
|
|||||||
Globals.world = rVal;
|
Globals.world = rVal;
|
||||||
|
|
||||||
//generate the regions
|
//generate the regions
|
||||||
rVal.setRegion(TownGenerator.generateTown());
|
rVal.setRegion(RegionGenerator.generate("continent"));
|
||||||
|
|
||||||
//generate the govs
|
//generate the govs
|
||||||
WorldGenerator.generateGovernments(rVal);
|
WorldGenerator.generateGovernments(rVal);
|
||||||
@ -58,7 +58,7 @@ public class WorldGenerator {
|
|||||||
*/
|
*/
|
||||||
private static void generateGovernments(World world){
|
private static void generateGovernments(World world){
|
||||||
for(CreatureDef creatureDef : Globals.config.getCreatureDefManager().getDefinitions()){
|
for(CreatureDef creatureDef : Globals.config.getCreatureDefManager().getDefinitions()){
|
||||||
if(creatureDef.getCivBuilder()){
|
if(creatureDef.getCivBuilder() != null && creatureDef.getCivBuilder()){
|
||||||
Government creatureGov = new Government("kingdom", "Kingdom of the " + creatureDef.getName());
|
Government creatureGov = new Government("kingdom", "Kingdom of the " + creatureDef.getName());
|
||||||
world.addGovernment(creatureGov);
|
world.addGovernment(creatureGov);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,53 @@
|
|||||||
|
package org.studiorailgun.sim.writing;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.studiorailgun.Globals;
|
||||||
|
import org.studiorailgun.sim.character.Character;
|
||||||
|
import org.studiorailgun.sim.config.creature.CreatureDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes a group of characters
|
||||||
|
*/
|
||||||
|
public class GroupDescriber {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes a group of characters
|
||||||
|
* @param characters The characters
|
||||||
|
*/
|
||||||
|
public static void summarize(List<Character> characters){
|
||||||
|
Map<String,Integer> raceCountMap = new HashMap<String,Integer>();
|
||||||
|
for(Character currentChar : characters){
|
||||||
|
String race = currentChar.getAppearance().getRace();
|
||||||
|
if(raceCountMap.containsKey(race)){
|
||||||
|
raceCountMap.put(race, raceCountMap.get(race) + 1);
|
||||||
|
} else {
|
||||||
|
raceCountMap.put(race, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(Entry<String,Integer> entry : raceCountMap.entrySet()){
|
||||||
|
String race = entry.getKey();
|
||||||
|
int count = entry.getValue();
|
||||||
|
CreatureDef creatureType = Globals.config.getCreatureDefManager().getDefinition(race);
|
||||||
|
if(count > 1){
|
||||||
|
String message = "There are " + NumberWordizer.convert(count) + " " + creatureType.getPlural() + ".";
|
||||||
|
System.out.println(message);
|
||||||
|
} else {
|
||||||
|
String message = "There is one " + creatureType.getSingular() + ".";
|
||||||
|
System.out.println(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes a group of characters
|
||||||
|
* @param characters The group of characters
|
||||||
|
*/
|
||||||
|
public static void describe(List<Character> characters){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,91 @@
|
|||||||
|
package org.studiorailgun.sim.writing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a number to words
|
||||||
|
*/
|
||||||
|
public class NumberWordizer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a number to a string of words
|
||||||
|
* @param num The number
|
||||||
|
* @return The string of words
|
||||||
|
*/
|
||||||
|
public static String convert(int num){
|
||||||
|
if(num == 0){
|
||||||
|
return "zero";
|
||||||
|
}
|
||||||
|
if(num < 10){
|
||||||
|
switch(num){
|
||||||
|
case 1: {
|
||||||
|
return "one";
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
return "two";
|
||||||
|
}
|
||||||
|
case 3: {
|
||||||
|
return "three";
|
||||||
|
}
|
||||||
|
case 4: {
|
||||||
|
return "four";
|
||||||
|
}
|
||||||
|
case 5: {
|
||||||
|
return "five";
|
||||||
|
}
|
||||||
|
case 6: {
|
||||||
|
return "six";
|
||||||
|
}
|
||||||
|
case 7: {
|
||||||
|
return "seven";
|
||||||
|
}
|
||||||
|
case 8: {
|
||||||
|
return "eight";
|
||||||
|
}
|
||||||
|
case 9: {
|
||||||
|
return "nine";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error("Unsupported number " + num);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the tens place word
|
||||||
|
* @param num The number
|
||||||
|
* @return The tens place word
|
||||||
|
*/
|
||||||
|
public static String getTensPlace(int num){
|
||||||
|
int divResult = num / 10;
|
||||||
|
switch(divResult){
|
||||||
|
case 2: {
|
||||||
|
return "twenty";
|
||||||
|
}
|
||||||
|
case 3: {
|
||||||
|
return "thirty";
|
||||||
|
}
|
||||||
|
case 4: {
|
||||||
|
return "fourty";
|
||||||
|
}
|
||||||
|
case 5: {
|
||||||
|
return "fifty";
|
||||||
|
}
|
||||||
|
case 6: {
|
||||||
|
return "sixty";
|
||||||
|
}
|
||||||
|
case 7: {
|
||||||
|
return "seventy";
|
||||||
|
}
|
||||||
|
case 8: {
|
||||||
|
return "eighty";
|
||||||
|
}
|
||||||
|
case 9: {
|
||||||
|
return "ninety";
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
case 0:
|
||||||
|
default: {
|
||||||
|
throw new Error("Unhandled value!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user