private void ScrambleSeeds(TomeOfChaos tome, Herbal herbal) { var shuffled = SeedAdjectives .OrderBy(d => tome.LearnableRndNext()).ToList(); foreach (var key in herbal.PlantByID.Keys) { herbal.PlantByID[key].SeedAdjective = shuffled[0]; shuffled.RemoveAt(0); } }
public TomeOfChaos Tome_FromNew(string topSeed) { var tome = new TomeOfChaos(topSeed); AbstractGenerator topRNG; AbstractGenerator mapRNG; // Any time the sequence of .Next() calls to an RNG changes, // the same seed will no longer produce the same world. tome.Generators["Top"] = topRNG = new NR3Generator(tome.TopSeedInt); tome.Generators["MapTop"] = mapRNG = new NR3Generator(topRNG.Next()); tome.Generators["Learnable"] = new NR3Generator(topRNG.Next()); tome.MapGenerators[MapEnum.TackerFarm] = new NR3Generator(mapRNG.Next()); tome.MapGenerators[MapEnum.TownBarricade] = new NR3Generator(mapRNG.Next()); return(tome); }
public TomeOfChaos Tome_FromYaml(IParser parser) { parser.Consume <MappingStart>(); (string k, string v) = parser.GetKVP(); if (k != "TopSeed") { throw new Exception($"Expected 'TopSeed', got '{k}'."); } var topSeed = v; var mapGenerators = new Dictionary <MapEnum, AbstractGenerator>(); var generators = new Dictionary <string, AbstractGenerator>(); string label = parser.GetScalar(); if (label != "Generators") { throw new Exception($"Expected 'Generators', got '{label}'."); } parser.Consume <MappingStart>(); while (!parser.TryConsume <MappingEnd>(out _)) { (k, v) = parser.GetKVP(); generators[k] = RngFromBase64(v); } label = parser.GetScalar(); if (label != "MapGenerators") { throw new Exception($"Expected 'MapGenerators', got '{label}'."); } parser.Consume <MappingStart>(); while (!parser.TryConsume <MappingEnd>(out _)) { (k, v) = parser.GetKVP(); MapEnum key = Enum.Parse <MapEnum>(k); mapGenerators[key] = RngFromBase64(v); } parser.Consume <MappingEnd>(); var tome = new TomeOfChaos(topSeed, generators, mapGenerators); return(tome); }
public IBook Compendium_FromYaml(IParser parser) { parser.Consume <MappingStart>(); uint nextID = uint.Parse(parser.GetKVP_string("NextID")); IDGenerator idGen = new IDGenerator(nextID); TomeOfChaos tome = null; Herbal herbal = null; SocialRegister register = null; Dramaticon drama = null; Atlas atlas = null; while (parser.TryConsume <Scalar>(out var next)) { switch (next.Value) { case "TomeOfChaos": tome = Tome_FromYaml(parser); break; case "Herbal": herbal = Herbal_FromYaml(parser); break; case "SocialRegister": register = Register_FromYaml(parser, BeingCreator); break; case "Dramaticon": drama = Dramaticon_FromYaml(parser); break; case "Atlas": atlas = Atlas_FromYaml(parser); break; default: throw new NotImplementedException($"Cannot yet parse a [{next.Value}] for Compendium."); } } var compendium = new Compendium(idGen, BeingCreator, tome, herbal, register, drama, atlas); parser.Consume <MappingEnd>(); return(compendium); }
public void TopSeed_is_recorded() { TomeOfChaos tome = new TomeOfChaos("SampleTopSeed"); Assert.That(tome.TopSeed, Is.EqualTo("SampleTopSeed")); }
public void Scramble(TomeOfChaos tome, Herbal herbal) { ScrambleSeeds(tome, herbal); ScrambleFruit(tome, herbal); }