From 581de4f58aede5ed93ee571688359d56109803a0 Mon Sep 17 00:00:00 2001 From: austin Date: Sat, 16 Oct 2021 00:06:49 -0400 Subject: [PATCH] work on macro simulation --- assets/Data/creatures.json | 19 + assets/Data/races.json | 8 + assets/Data/symbolism.json | 572 +++++++++++++++++- .../electrosphere/game/config/Config.java | 14 + .../game/server/character/Character.java | 45 +- .../character/CharacterDataStrings.java | 15 + .../server/character/CharacterGenerator.java | 26 - .../game/server/character/CharacterUtils.java | 38 ++ .../game/server/character/diety/Diety.java | 39 +- .../game/server/culture/religion/Story.java | 2 + .../culture/religion/StoryDataStrings.java | 30 + .../game/server/race/model/Race.java | 22 + .../game/server/race/model/RaceMap.java | 17 + .../game/server/symbolism/SymbolismMap.java | 14 - .../server/symbolism/{ => model}/Symbol.java | 2 +- .../server/symbolism/model/SymbolMap.java | 14 + .../{ => model}/SymbolismRelation.java | 2 +- .../game/server/world/MacroData.java | 144 +++++ .../game/state/MacroSimulation.java | 24 +- src/main/java/electrosphere/main/Globals.java | 2 + src/main/java/electrosphere/main/Main.java | 27 +- 21 files changed, 999 insertions(+), 77 deletions(-) create mode 100644 assets/Data/races.json create mode 100644 src/main/java/electrosphere/game/server/character/CharacterDataStrings.java delete mode 100644 src/main/java/electrosphere/game/server/character/CharacterGenerator.java create mode 100644 src/main/java/electrosphere/game/server/character/CharacterUtils.java create mode 100644 src/main/java/electrosphere/game/server/culture/religion/StoryDataStrings.java create mode 100644 src/main/java/electrosphere/game/server/race/model/Race.java create mode 100644 src/main/java/electrosphere/game/server/race/model/RaceMap.java delete mode 100644 src/main/java/electrosphere/game/server/symbolism/SymbolismMap.java rename src/main/java/electrosphere/game/server/symbolism/{ => model}/Symbol.java (85%) create mode 100644 src/main/java/electrosphere/game/server/symbolism/model/SymbolMap.java rename src/main/java/electrosphere/game/server/symbolism/{ => model}/SymbolismRelation.java (80%) create mode 100644 src/main/java/electrosphere/game/server/world/MacroData.java diff --git a/assets/Data/creatures.json b/assets/Data/creatures.json index f818d89f..d16c1f48 100644 --- a/assets/Data/creatures.json +++ b/assets/Data/creatures.json @@ -122,6 +122,12 @@ + + + + + + { "name" : "Goblin", "bodyParts" : [ @@ -234,6 +240,15 @@ "modelPath" : "Models/goblin1.fbx" }, + + + + + + + + + { "name" : "CUBE_MAN", @@ -276,5 +291,9 @@ + + + + ] } diff --git a/assets/Data/races.json b/assets/Data/races.json new file mode 100644 index 00000000..c3540e4d --- /dev/null +++ b/assets/Data/races.json @@ -0,0 +1,8 @@ +{ + "raceMap" : [ + { + "name" : "Human", + "associatedCreature" : "Human" + } + ] +} \ No newline at end of file diff --git a/assets/Data/symbolism.json b/assets/Data/symbolism.json index 1f6227f0..f5087047 100644 --- a/assets/Data/symbolism.json +++ b/assets/Data/symbolism.json @@ -1,7 +1,7 @@ { "symbolismMap" : [ { - "name" : "fire", + "name" : "wind", "relations" : [ { "name" : "water", @@ -10,21 +10,573 @@ ] }, { - "name" : "water", + "name" : "fire", "relations" : [ - { - "name" : "fire", - "strength" : -1 - } + + ] + }, + { + "name" : "earth", + "relations" : [ + + ] + }, + { + "name" : "ice", + "relations" : [ + ] }, { "name" : "water", "relations" : [ - { - "name" : "fire", - "strength" : -1 - } + + ] + }, + { + "name" : "lightning", + "relations" : [ + + ] + }, + { + "name" : "metal", + "relations" : [ + + ] + }, + { + "name" : "crystal", + "relations" : [ + + ] + }, + { + "name" : "storm", + "relations" : [ + + ] + }, + { + "name" : "lava", + "relations" : [ + + ] + }, + { + "name" : "gravity", + "relations" : [ + + ] + }, + { + "name" : "light", + "relations" : [ + + ] + }, + { + "name" : "dark", + "relations" : [ + + ] + }, + { + "name" : "arcane", + "relations" : [ + + ] + }, + { + "name" : "time", + "relations" : [ + + ] + }, + { + "name" : "sound", + "relations" : [ + + ] + }, + { + "name" : "poison", + "relations" : [ + + ] + }, + { + "name" : "mirror", + "relations" : [ + + ] + }, + { + "name" : "barrier", + "relations" : [ + + ] + }, + { + "name" : "void", + "relations" : [ + + ] + }, + { + "name" : "crescent", + "relations" : [ + + ] + }, + { + "name" : "life", + "relations" : [ + + ] + }, + { + "name" : "death", + "relations" : [ + + ] + }, + { + "name" : "nightmare", + "relations" : [ + + ] + }, + { + "name" : "dream", + "relations" : [ + + ] + }, + { + "name" : "sleep", + "relations" : [ + + ] + }, + { + "name" : "sky", + "relations" : [ + + ] + }, + { + "name" : "speed", + "relations" : [ + + ] + }, + { + "name" : "mind", + "relations" : [ + + ] + }, + { + "name" : "dawn", + "relations" : [ + + ] + }, + { + "name" : "dusk", + "relations" : [ + + ] + }, + { + "name" : "spring", + "relations" : [ + + ] + }, + { + "name" : "summer", + "relations" : [ + + ] + }, + { + "name" : "fall", + "relations" : [ + + ] + }, + { + "name" : "winter", + "relations" : [ + + ] + }, + { + "name" : "hunting", + "relations" : [ + + ] + }, + { + "name" : "sun", + "relations" : [ + + ] + }, + { + "name" : "moon", + "relations" : [ + + ] + }, + { + "name" : "sky", + "relations" : [ + + ] + }, + { + "name" : "earth", + "relations" : [ + + ] + }, + { + "name" : "cloud", + "relations" : [ + + ] + }, + { + "name" : "song", + "relations" : [ + + ] + }, + { + "name" : "harmony", + "relations" : [ + + ] + }, + { + "name" : "discord", + "relations" : [ + + ] + }, + { + "name" : "beginning", + "relations" : [ + + ] + }, + { + "name" : "end", + "relations" : [ + + ] + }, + { + "name" : "moral", + "relations" : [ + + ] + }, + { + "name" : "amoral", + "relations" : [ + + ] + }, + { + "name" : "storm", + "relations" : [ + + ] + }, + { + "name" : "flower", + "relations" : [ + + ] + }, + { + "name" : "shadow", + "relations" : [ + + ] + }, + { + "name" : "wealth", + "relations" : [ + + ] + }, + { + "name" : "poverty", + "relations" : [ + + ] + }, + { + "name" : "undeath", + "relations" : [ + + ] + }, + { + "name" : "afterlife", + "relations" : [ + + ] + }, + { + "name" : "logic", + "relations" : [ + + ] + }, + { + "name" : "writing", + "relations" : [ + + ] + }, + { + "name" : "violence", + "relations" : [ + + ] + }, + { + "name" : "warfare", + "relations" : [ + + ] + }, + { + "name" : "strategy", + "relations" : [ + + ] + }, + { + "name" : "trade", + "relations" : [ + + ] + }, + { + "name" : "law", + "relations" : [ + + ] + }, + { + "name" : "order", + "relations" : [ + + ] + }, + { + "name" : "justice", + "relations" : [ + + ] + }, + { + "name" : "marriage", + "relations" : [ + + ] + }, + { + "name" : "family", + "relations" : [ + + ] + }, + { + "name" : "sea", + "relations" : [ + + ] + }, + { + "name" : "harvest", + "relations" : [ + + ] + }, + { + "name" : "argiculture", + "relations" : [ + + ] + }, + { + "name" : "nature", + "relations" : [ + + ] + }, + { + "name" : "wisdom", + "relations" : [ + + ] + }, + { + "name" : "handicraft", + "relations" : [ + + ] + }, + { + "name" : "prophecy", + "relations" : [ + + ] + }, + { + "name" : "philosophy", + "relations" : [ + + ] + }, + { + "name" : "archery", + "relations" : [ + + ] + }, + { + "name" : "truth", + "relations" : [ + + ] + }, + { + "name" : "inspiration", + "relations" : [ + + ] + }, + { + "name" : "poety", + "relations" : [ + + ] + }, + { + "name" : "art", + "relations" : [ + + ] + }, + { + "name" : "medicine", + "relations" : [ + + ] + }, + { + "name" : "healing", + "relations" : [ + + ] + }, + { + "name" : "wilderness", + "relations" : [ + + ] + }, + { + "name" : "protection", + "relations" : [ + + ] + }, + { + "name" : "love", + "relations" : [ + + ] + }, + { + "name" : "invention", + "relations" : [ + + ] + }, + { + "name" : "volcanoes", + "relations" : [ + + ] + }, + { + "name" : "travel", + "relations" : [ + + ] + }, + { + "name" : "communication", + "relations" : [ + + ] + }, + { + "name" : "borders", + "relations" : [ + + ] + }, + { + "name" : "diplomacy", + "relations" : [ + + ] + }, + { + "name" : "theft", + "relations" : [ + + ] + }, + { + "name" : "game", + "relations" : [ + + ] + }, + { + "name" : "civilization", + "relations" : [ + + ] + }, + { + "name" : "structure", + "relations" : [ + + ] + }, + { + "name" : "festivity", + "relations" : [ + + ] + }, + { + "name" : "madness", + "relations" : [ + ] } ] diff --git a/src/main/java/electrosphere/game/config/Config.java b/src/main/java/electrosphere/game/config/Config.java index a13424e0..63a2be33 100644 --- a/src/main/java/electrosphere/game/config/Config.java +++ b/src/main/java/electrosphere/game/config/Config.java @@ -4,6 +4,8 @@ import electrosphere.game.config.creature.type.model.CreatureTypeMap; import electrosphere.game.config.foliage.type.model.FoliageTypeMap; import electrosphere.game.config.item.type.model.ItemTypeMap; import electrosphere.game.config.structure.type.model.StructureTypeMap; +import electrosphere.game.server.race.model.RaceMap; +import electrosphere.game.server.symbolism.model.SymbolMap; import electrosphere.util.FileLoadingUtils; /** @@ -16,6 +18,8 @@ public class Config { StructureTypeMap structureTypeMap; ItemTypeMap itemMap; FoliageTypeMap foliageMap; + SymbolMap symbolMap; + RaceMap raceMap; public static Config loadDefaultConfig(){ Config config = new Config(); @@ -23,6 +27,8 @@ public class Config { config.itemMap = FileLoadingUtils.loadObjectFromAssetPath("Data/items.json", ItemTypeMap.class); config.structureTypeMap = FileLoadingUtils.loadObjectFromAssetPath("Data/structures.json", StructureTypeMap.class); config.foliageMap = FileLoadingUtils.loadObjectFromAssetPath("Data/foliage.json", FoliageTypeMap.class); + config.symbolMap = FileLoadingUtils.loadObjectFromAssetPath("Data/symbolism.json", SymbolMap.class); + config.raceMap = FileLoadingUtils.loadObjectFromAssetPath("Data/races.json", RaceMap.class); return config; } @@ -42,4 +48,12 @@ public class Config { return foliageMap; } + public SymbolMap getSymbolMap() { + return symbolMap; + } + + public RaceMap getRaceMap() { + return raceMap; + } + } diff --git a/src/main/java/electrosphere/game/server/character/Character.java b/src/main/java/electrosphere/game/server/character/Character.java index ce995cff..5a889858 100644 --- a/src/main/java/electrosphere/game/server/character/Character.java +++ b/src/main/java/electrosphere/game/server/character/Character.java @@ -1,15 +1,44 @@ package electrosphere.game.server.character; import electrosphere.game.server.character.diety.Diety; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; public class Character { - boolean isDiety; - Diety diety; - boolean hasBasicPersonality; - BasicPersonality basicPersonality; - boolean hasAdvancedPersonality; - AdvancedPersonality advancedPersonality; - int discreteX; - int discreteY; + static int entity_id_iterator = 0; + + int id; + + HashMap data = new HashMap(); + + LinkedList dataKeys = new LinkedList(); + + + + public int getId() { + return id; + } + + public void setId(int id){ + this.id = id; + } + + public void putData(String key, Object o){ + data.put(key,o); + dataKeys.add(key); + } + + public List getDataKeys(){ + return dataKeys; + } + + public Object getData(String key){ + return data.get(key); + } + + public Character(){ + + } } diff --git a/src/main/java/electrosphere/game/server/character/CharacterDataStrings.java b/src/main/java/electrosphere/game/server/character/CharacterDataStrings.java new file mode 100644 index 00000000..54843631 --- /dev/null +++ b/src/main/java/electrosphere/game/server/character/CharacterDataStrings.java @@ -0,0 +1,15 @@ +package electrosphere.game.server.character; + +/** + * + * @author amaterasu + */ +public class CharacterDataStrings { + + public static final String POSITION_DISCRETE = "position"; + public static final String DIETY = "diety"; + public static final String PERSONALTIY_BASIC = "personalityBasic"; + public static final String PERSONALITY_ADVANCED = "personalityAdvanced"; + public static final String RACE = "race"; + +} diff --git a/src/main/java/electrosphere/game/server/character/CharacterGenerator.java b/src/main/java/electrosphere/game/server/character/CharacterGenerator.java deleted file mode 100644 index e9ad5526..00000000 --- a/src/main/java/electrosphere/game/server/character/CharacterGenerator.java +++ /dev/null @@ -1,26 +0,0 @@ -package electrosphere.game.server.character; - -import electrosphere.game.server.culture.Culture; -import electrosphere.game.server.character.Character; -import electrosphere.game.config.creature.type.CreatureType; - -public class CharacterGenerator { - - public static Character generateCharacter(CreatureType creature, Culture culture){ - Character character = new Character(); - - return character; - } - - public static void positionCharacter(Character c, int x, int y){ - c.discreteX = x; - c.discreteY = y; - } - - - public static Character generateDietyOfArchetype(){ - Character character = new Character(); - - return character; - } -} diff --git a/src/main/java/electrosphere/game/server/character/CharacterUtils.java b/src/main/java/electrosphere/game/server/character/CharacterUtils.java new file mode 100644 index 00000000..9a406baa --- /dev/null +++ b/src/main/java/electrosphere/game/server/character/CharacterUtils.java @@ -0,0 +1,38 @@ +package electrosphere.game.server.character; + +import electrosphere.game.server.character.Character; +import electrosphere.game.server.character.diety.Diety; +import electrosphere.game.server.race.model.Race; +import org.joml.Vector2i; + +/** + * + * @author amaterasu + */ +public class CharacterUtils { + + public static void addDiscretePosition(Character character, int posX, int posY){ + character.putData(CharacterDataStrings.POSITION_DISCRETE, new Vector2i(posX,posY)); + } + + public static Vector2i getDiscretePosition(Character character){ + return (Vector2i)character.getData(CharacterDataStrings.POSITION_DISCRETE); + } + + public static void addDiety(Character character, Diety diety){ + character.putData(CharacterDataStrings.DIETY, diety); + } + + public static Diety getDiety(Character character){ + return (Diety)character.getData(CharacterDataStrings.DIETY); + } + + public static void addRace(Character character, Race race){ + character.putData(CharacterDataStrings.RACE, race); + } + + public static Race getRace(Character character){ + return (Race)character.getData(CharacterDataStrings.RACE); + } + +} diff --git a/src/main/java/electrosphere/game/server/character/diety/Diety.java b/src/main/java/electrosphere/game/server/character/diety/Diety.java index d81292d8..9f08d0d5 100644 --- a/src/main/java/electrosphere/game/server/character/diety/Diety.java +++ b/src/main/java/electrosphere/game/server/character/diety/Diety.java @@ -1,6 +1,43 @@ package electrosphere.game.server.character.diety; +import electrosphere.game.server.symbolism.model.Symbol; +import electrosphere.game.server.symbolism.model.SymbolMap; +import electrosphere.main.Globals; +import java.util.LinkedList; +import java.util.List; +import java.util.Random; + public class Diety { - int godlyPower; + List symbols = new LinkedList(); + + //TODO: eventually add function where we can pass intial symbol to seed rest of diety off of + //this lets us create a "good" diety" and a "bad" diety to guarentee a more balanced pantheon + + public static Diety generateDiety(long seed){ + Random random = new Random(); + Diety rVal = new Diety(); + + //TODO: eventually use bucket based rng system where previous choices affect chances on future ones + //add symbols + SymbolMap symbolMap = Globals.gameConfigCurrent.getSymbolMap(); + int numSymbolTypes = symbolMap.getSymbolismMap().size(); + int numSymbolsToAdd = 3 + Math.abs(random.nextInt()) % 5; + for(int i = 0; i < numSymbolsToAdd; i++){ + Symbol potentialSymbol = symbolMap.getSymbolismMap().get(random.nextInt(numSymbolTypes)); + while(rVal.symbols.contains(potentialSymbol)){ + potentialSymbol = symbolMap.getSymbolismMap().get(random.nextInt(numSymbolTypes)); + } + rVal.symbols.add(potentialSymbol); + } + + return rVal; + } + + public List getSymbols() { + return symbols; + } + + + } diff --git a/src/main/java/electrosphere/game/server/culture/religion/Story.java b/src/main/java/electrosphere/game/server/culture/religion/Story.java index dab53bf7..3f9ab009 100644 --- a/src/main/java/electrosphere/game/server/culture/religion/Story.java +++ b/src/main/java/electrosphere/game/server/culture/religion/Story.java @@ -12,4 +12,6 @@ public class Story { } StoryType type; + + } diff --git a/src/main/java/electrosphere/game/server/culture/religion/StoryDataStrings.java b/src/main/java/electrosphere/game/server/culture/religion/StoryDataStrings.java new file mode 100644 index 00000000..4ede3f2d --- /dev/null +++ b/src/main/java/electrosphere/game/server/culture/religion/StoryDataStrings.java @@ -0,0 +1,30 @@ +package electrosphere.game.server.culture.religion; + +/** + * + * @author amaterasu + */ +public class StoryDataStrings { + /* + FABLE, //a story including animals/things that explains a moral + MYTH, //an explanation for some fact + PARABLE, //a story strictly starring humans that explains a moral + */ + public static final String STORY_TYPE = "storyType"; + public static final String STORY_TYPE_FABLE = "fable"; + public static final String STORY_TYPE_MYTH = "myth"; + public static final String STORY_TYPE_PARABLE = "parable"; + + + public static final String MYTH_GOAL = "mythGoal"; //what is the goal of the myth? + public static final String MYTH_GOAL_CREATE = "creationism"; //the goal is to tell of the creation of the world + + + public static final String MYTH_CREATE_MECHANISM = "creationismMechanism"; //what is the mechanism that the world is created by in the myth + public static final String CREATE_MECH_FROM_NOTHING = "fromNothing"; //there was nothing, and then the primary diety created the world + public static final String CREATE_MECH_START_TIME = "startTime"; //everything that existed at the start was frozen, and then time began + public static final String CREATE_MECH_DIVER = "diver"; //a primordial being dives into something and retrieves the world + public static final String CREATE_MECH_EMERGENCE = "emergence"; //primordial entities morph through stages until they're the current world + public static final String CREATE_MECH_DISMEMBERMENT = "dismemberment"; //some priomordial being is dismembered and the remains are the world + +} diff --git a/src/main/java/electrosphere/game/server/race/model/Race.java b/src/main/java/electrosphere/game/server/race/model/Race.java new file mode 100644 index 00000000..65c671c0 --- /dev/null +++ b/src/main/java/electrosphere/game/server/race/model/Race.java @@ -0,0 +1,22 @@ +package electrosphere.game.server.race.model; + +/** + * + * @author amaterasu + */ +public class Race { + + String name; + String associatedCreature; + + public String getName() { + return name; + } + + public String getAssociatedCreature() { + return associatedCreature; + } + + + +} diff --git a/src/main/java/electrosphere/game/server/race/model/RaceMap.java b/src/main/java/electrosphere/game/server/race/model/RaceMap.java new file mode 100644 index 00000000..ad615b74 --- /dev/null +++ b/src/main/java/electrosphere/game/server/race/model/RaceMap.java @@ -0,0 +1,17 @@ +package electrosphere.game.server.race.model; + +import java.util.List; + +/** + * + * @author amaterasu + */ +public class RaceMap { + + List raceMap; + + public List getSymbolismMap() { + return raceMap; + } + +} diff --git a/src/main/java/electrosphere/game/server/symbolism/SymbolismMap.java b/src/main/java/electrosphere/game/server/symbolism/SymbolismMap.java deleted file mode 100644 index 8ddfaad0..00000000 --- a/src/main/java/electrosphere/game/server/symbolism/SymbolismMap.java +++ /dev/null @@ -1,14 +0,0 @@ -package electrosphere.game.server.symbolism; - -import java.util.List; - -public class SymbolismMap { - - List symbolismMap; - - public List getSymbolismMap() { - return symbolismMap; - } - - -} diff --git a/src/main/java/electrosphere/game/server/symbolism/Symbol.java b/src/main/java/electrosphere/game/server/symbolism/model/Symbol.java similarity index 85% rename from src/main/java/electrosphere/game/server/symbolism/Symbol.java rename to src/main/java/electrosphere/game/server/symbolism/model/Symbol.java index 99edd4ec..ab6a98b3 100644 --- a/src/main/java/electrosphere/game/server/symbolism/Symbol.java +++ b/src/main/java/electrosphere/game/server/symbolism/model/Symbol.java @@ -1,4 +1,4 @@ -package electrosphere.game.server.symbolism; +package electrosphere.game.server.symbolism.model; import java.util.List; diff --git a/src/main/java/electrosphere/game/server/symbolism/model/SymbolMap.java b/src/main/java/electrosphere/game/server/symbolism/model/SymbolMap.java new file mode 100644 index 00000000..c23e4a79 --- /dev/null +++ b/src/main/java/electrosphere/game/server/symbolism/model/SymbolMap.java @@ -0,0 +1,14 @@ +package electrosphere.game.server.symbolism.model; + +import java.util.List; + +public class SymbolMap { + + List symbolismMap; + + public List getSymbolismMap() { + return symbolismMap; + } + + +} diff --git a/src/main/java/electrosphere/game/server/symbolism/SymbolismRelation.java b/src/main/java/electrosphere/game/server/symbolism/model/SymbolismRelation.java similarity index 80% rename from src/main/java/electrosphere/game/server/symbolism/SymbolismRelation.java rename to src/main/java/electrosphere/game/server/symbolism/model/SymbolismRelation.java index 42ac1175..a20789b0 100644 --- a/src/main/java/electrosphere/game/server/symbolism/SymbolismRelation.java +++ b/src/main/java/electrosphere/game/server/symbolism/model/SymbolismRelation.java @@ -1,4 +1,4 @@ -package electrosphere.game.server.symbolism; +package electrosphere.game.server.symbolism.model; public class SymbolismRelation { String name; diff --git a/src/main/java/electrosphere/game/server/world/MacroData.java b/src/main/java/electrosphere/game/server/world/MacroData.java new file mode 100644 index 00000000..57d20b7f --- /dev/null +++ b/src/main/java/electrosphere/game/server/world/MacroData.java @@ -0,0 +1,144 @@ +package electrosphere.game.server.world; + +import java.util.LinkedList; +import java.util.List; +import electrosphere.game.server.character.Character; +import electrosphere.game.server.character.CharacterDataStrings; +import electrosphere.game.server.character.CharacterUtils; +import electrosphere.game.server.character.diety.Diety; +import electrosphere.game.server.race.model.Race; +import electrosphere.game.server.race.model.RaceMap; +import electrosphere.game.server.symbolism.model.Symbol; +import electrosphere.main.Globals; +import java.util.Random; +import org.joml.Vector2i; + +/** + * + * @author amaterasu + */ +public class MacroData { + + List initialDieties = new LinkedList(); + List races = new LinkedList(); + List characters = new LinkedList(); + List aliveCharacters = new LinkedList(); + + + static Character generateInitialDiety(long seed){ + Character rVal = new Character(); + + + Diety diety = Diety.generateDiety(seed); + CharacterUtils.addDiety(rVal, diety); + + + return rVal; + } + + public static MacroData generateWorld(long seed){ + Random random = new Random(seed); + MacroData rVal = new MacroData(); + + //generate initial dieties + int numDieties = 3 + Math.abs(random.nextInt()) % 7; + for(int i = 0; i < numDieties; i++){ + Character diety = generateInitialDiety(random.nextLong()); + rVal.initialDieties.add(diety); + rVal.characters.add(diety); + } + + //generate initial races + if(Globals.gameConfigCurrent.getRaceMap().getSymbolismMap().size() < 3){ + for(Race race : Globals.gameConfigCurrent.getRaceMap().getSymbolismMap()){ + rVal.races.add(race); + } + } else { + RaceMap raceMap = Globals.gameConfigCurrent.getRaceMap(); + int numRacesToGenerate = 3 + random.nextInt(Math.min(raceMap.getSymbolismMap().size() - 3,7)); + for(int i = 0; i < numRacesToGenerate; i++){ + Race raceToAdd = raceMap.getSymbolismMap().get(random.nextInt(raceMap.getSymbolismMap().size())); + while(rVal.races.contains(raceToAdd)){ + raceToAdd = raceMap.getSymbolismMap().get(random.nextInt(raceMap.getSymbolismMap().size())); + } + rVal.races.add(raceToAdd); + } + } + + //spawn initial characters in each race + //find initial positions to place characters at per race + //generate initial characters + //place them + List occupiedStartingPositions = new LinkedList(); + for(Race race : rVal.races){ + boolean foundPlacementLocation = false; + while(!foundPlacementLocation){ + Vector2i start = new Vector2i(random.nextInt(Globals.serverTerrainManager.getWorldDiscreteSize()),random.nextInt(Globals.serverTerrainManager.getWorldDiscreteSize())); + //are we above sea level? + if(Globals.serverTerrainManager.getDiscreteValue(start.x, start.y) > 25){ //TODO: Set to actual sea level value + //is this position already occupied? + boolean match = false; + for(Vector2i known : occupiedStartingPositions){ + if(known.x == start.x && known.y == start.y){ + match = true; + break; + } + } + if(!match){ + //occupy position + occupiedStartingPositions.add(start); + foundPlacementLocation = true; + //make characters + int numCharactersToMake = 5 + random.nextInt(20); + for(int i = 0; i < numCharactersToMake; i++){ + Character character = new Character(); + CharacterUtils.addDiscretePosition(character, start.x, start.y); + CharacterUtils.addRace(character, race); + rVal.characters.add(character); + rVal.aliveCharacters.add(character); + } + } + } + } + } + + return rVal; + } + + public List getAliveCharacters(){ + return aliveCharacters; + } + + public void describeWorld(){ + System.out.println("Initial dieties"); + System.out.println("=========================="); + for(Character chara : initialDieties){ + System.out.println("Diety"); + Diety diety = CharacterUtils.getDiety(chara); + for(Symbol symbol : diety.getSymbols()){ + System.out.print(symbol.getName() + " "); + } + System.out.println("\n"); + } + System.out.println("=========================="); + System.out.println("\n\n"); + System.out.println("Initial races"); + System.out.println("=========================="); + for(Race race : races){ + System.out.println(race.getName()); + int numCharsOfRace = 0; + //n*m complexity - yikes! - as long as we're not making a million chars at start this should be _ok_ + for(Character chara : characters){ + if(chara.getDataKeys().contains(CharacterDataStrings.RACE)){ + if(CharacterUtils.getRace(chara).equals(race)){ + numCharsOfRace++; + } + } + } + System.out.println(numCharsOfRace + " initial characters"); + System.out.println("\n"); + } + System.out.println("=========================="); + } + +} diff --git a/src/main/java/electrosphere/game/state/MacroSimulation.java b/src/main/java/electrosphere/game/state/MacroSimulation.java index a1b0c10d..f639c3b5 100644 --- a/src/main/java/electrosphere/game/state/MacroSimulation.java +++ b/src/main/java/electrosphere/game/state/MacroSimulation.java @@ -8,6 +8,8 @@ import electrosphere.game.server.culture.Culture; import electrosphere.game.server.culture.religion.Religion; import electrosphere.game.server.structure.virtual.Structure; import electrosphere.game.server.town.Town; +import electrosphere.main.Globals; +import electrosphere.game.server.character.Character; import electrosphere.util.FileLoadingUtils; import electrosphere.util.Utilities; import java.util.LinkedList; @@ -15,16 +17,18 @@ import java.util.List; public class MacroSimulation { - List civilizationList = new LinkedList(); - List cultureList = new LinkedList(); - List religionList = new LinkedList(); - List creatureList = new LinkedList(); - List characterList = new LinkedList(); - List townList = new LinkedList(); - List structureList = new LinkedList(); +// List civilizationList = new LinkedList(); +// List cultureList = new LinkedList(); +// List religionList = new LinkedList(); +// List creatureList = new LinkedList(); +// List characterList = new LinkedList(); +// List townList = new LinkedList(); +// List structureList = new LinkedList(); + + boolean isReady = false; public MacroSimulation(){ - init(); + isReady = true; } void init(){ @@ -33,6 +37,8 @@ public class MacroSimulation { } public void simulate(){ - + for(Character character : Globals.macroData.getAliveCharacters()){ + //do something + } } } diff --git a/src/main/java/electrosphere/main/Globals.java b/src/main/java/electrosphere/main/Globals.java index 6b6587fb..2e8822ba 100644 --- a/src/main/java/electrosphere/main/Globals.java +++ b/src/main/java/electrosphere/main/Globals.java @@ -31,6 +31,7 @@ import electrosphere.game.state.MacroSimulation; import electrosphere.game.server.terrain.manager.ServerTerrainManager; import electrosphere.game.server.town.Town; import electrosphere.game.server.world.ServerWorldData; +import electrosphere.game.server.world.MacroData; import electrosphere.game.server.world.datacell.DataCellManager; import electrosphere.game.state.MicroSimulation; import electrosphere.menu.Menu; @@ -204,6 +205,7 @@ public class Globals { //macro simulation public static MacroSimulation macroSimulation; + public static MacroData macroData; //micro simulation public static MicroSimulation microSimulation; diff --git a/src/main/java/electrosphere/main/Main.java b/src/main/java/electrosphere/main/Main.java index 0cd96b05..66282072 100644 --- a/src/main/java/electrosphere/main/Main.java +++ b/src/main/java/electrosphere/main/Main.java @@ -16,6 +16,9 @@ import electrosphere.entity.types.attach.AttachUtils; import electrosphere.engine.LoadingThread; import electrosphere.game.client.ClientFunctions; import electrosphere.game.config.UserSettings; +import electrosphere.game.server.terrain.manager.ServerTerrainManager; +import electrosphere.game.server.world.MacroData; +import electrosphere.game.state.MacroSimulation; import electrosphere.game.state.MicroSimulation; import electrosphere.logger.LoggerInterface; import electrosphere.renderer.RenderingEngine; @@ -114,6 +117,19 @@ public class Main { //init global variables Globals.initGlobals(); + //world gen testing + //gen terrain + Globals.serverTerrainManager = new ServerTerrainManager(2000,50,100,0.0f,0); + Globals.serverTerrainManager.load(); + //gen world + MacroData world = MacroData.generateWorld(0); + world.describeWorld(); + boolean run = true; + Globals.macroSimulation = new MacroSimulation(); + while(run){ + Globals.macroSimulation.simulate(); + } + //debug: create terrain/world viewer // TerrainViewer.runViewer(); @@ -136,9 +152,6 @@ public class Main { /// Vector3f cameraRotationVector = new Vector3f(); - double posX = -1; - double posZ = 0; - //main loop while (running) { @@ -200,10 +213,10 @@ public class Main { // // P L A Y E R W O R L D P O S I T I O N U P D A T E // - if(Globals.playerCharacter != null && Globals.commonWorldData != null){ - newPlayerCharacterPosition = EntityUtils.getPosition(Globals.playerCharacter); - Globals.clientPlayerData.setWorldPosition(Globals.commonWorldData.convertRealToWorld(newPlayerCharacterPosition.x), Globals.commonWorldData.convertRealToWorld(newPlayerCharacterPosition.z)); - } +// if(Globals.playerCharacter != null && Globals.commonWorldData != null){ +// newPlayerCharacterPosition = EntityUtils.getPosition(Globals.playerCharacter); +// Globals.clientPlayerData.setWorldPosition(Globals.commonWorldData.convertRealToWorld(newPlayerCharacterPosition.x), Globals.commonWorldData.convertRealToWorld(newPlayerCharacterPosition.z)); +// } /// /// C L I E N T C E L L M A N A G E R