public void LoadVanilla(int endDate) { var files = ModManager.instance.GetFileKeys("history\\characters"); foreach (var file in files) { Script s = ScriptLoader.instance.LoadKey(file); foreach (var rootChild in s.Root.Children) { var scope = rootChild as ScriptScope; CharacterParser chr = new CharacterParser(scope); chr.ID = Convert.ToInt32(scope.Name); chr.ChrName = scope.GetString("name"); if (chr.ID == 144999) { } if (chr.CalculateAgeFromScope(endDate)) { if (chr.YearOfDeath >= SimulationManager.instance.Year) { AliveCharacters.Add(chr); } Characters.Add(chr); CharacterMap[chr.ID] = chr; } } } foreach (var characterParser in Characters) { characterParser.FixupFromScope(endDate); } }
public ExtensionParser(char marker, string substitution, Parser innerParser) { ExtensionMarker = new CharacterParser (marker); ReferenceParser = new ReferenceParser (); InnerParser = innerParser; Substitution = substitution; }
public void Parsing_character_dto_to_character_entity(string name, string planet) { // Arrange var episodes = new List <string>() { "New Hope", "Empire", "Jedi" }; var friends = new List <string>() { "Leia", "Han Solo", "Joda" }; StarWarsCharacterDto characterDto = new StarWarsCharacterDto { Id = Guid.NewGuid(), Name = name, Planet = planet, Episodes = episodes, Friends = friends }; CharacterParser parser = new CharacterParser(); // Act var characterEntity = parser.CharacterDtoToEntity(characterDto); // Assert Assert.Equal(characterDto.Id, characterEntity.Id); Assert.Equal(characterDto.Name, characterEntity.Name); Assert.Equal(characterDto.Planet, characterEntity.Planet); Assert.Equal(characterDto.Episodes, characterEntity.Episodes.Select(x => x.EpisodeName)); Assert.Equal(characterDto.Friends, characterEntity.Friends.Select(x => x.FriendName)); }
public void FindAdjacent(List <ProvinceParser> provinces, int c, CharacterParser head) { List <ProvinceParser> choices = new List <ProvinceParser>(); foreach (var provinceParser in provinces) { foreach (var parser in provinceParser.Adjacent) { var t = parser.Title; if (!provinces.Contains(parser) && (head == null || (head == t.Holder || (head.PrimaryTitle.Rank == 2 && parser.Title.TopmostTitle == head.PrimaryTitle.TopmostTitle)) && (parser.Title.Liege == null || parser.Title.Rank == 2))) { choices.Add(parser); } } } for (int i = 0; i < c; i++) { if (choices.Count > 0) { int cc = Rand.Next(choices.Count); provinces.Add(choices[cc]); choices.RemoveAt(cc); } } }
public CharacterParser CreateNewCharacter(String culture, String religion, bool bFemale) { if (!bInit) { Init(); } // var scope = new ScriptScope(); // scope.Name = CharacterParser.IDMax.ToString(); // scope.SetChild(CharactersScript.Root); var chr = new CharacterParser(); // chr.SetProperty("dynasty", Rand.Next(1235)+1); // chr.SetProperty("culture", new ScriptReference("norse")); // chr.SetProperty("religion", new ScriptReference("pagan")); // chr.DeleteProperty("name"); Characters.Add(chr); chr.YearOfBirth = 769 - Rand.Next(60); chr.Dynasty = DynastyManager.instance.GetDynasty(CultureManager.instance.CultureMap[culture]); chr.religion = religion; chr.isFemale = bFemale; chr.culture = culture; chr.YearOfDeath = 769 + Rand.Next(30); this.CharactersScript.Root.SetChild(chr.Scope); AddedSinceLastPrune.Add(chr); CharacterMap[chr.ID] = chr; chr.SetupExistingDynasty(); chr.UpdateCultural(); return(chr); }
public CharacterParser CreateNewCharacter(Dynasty dynasty, bool bFemale, int dateOfBirth, string religion, String culture) { if (!bInit) { Init(); } var chr = new CharacterParser(); Characters.Add(chr); AliveCharacters.Add(chr); chr.YearOfBirth = dateOfBirth; if (dynasty == null) { dynasty = DynastyManager.instance.GetDynasty(CultureManager.instance.CultureMap[culture]); } chr.Dynasty = dynasty; chr.religion = religion; chr.isFemale = bFemale; chr.culture = culture; chr.YearOfDeath = SimulationManager.instance.Year + 1000; AddedSinceLastPrune.Add(chr); CharacterMap[chr.ID] = chr; chr.SetupExistingDynasty(); chr.UpdateCultural(); return(chr); }
public void FindAdjacentSameRealm(List <ProvinceParser> provinces, int c, CharacterParser head) { List <ProvinceParser> choices = new List <ProvinceParser>(); foreach (var provinceParser in provinces) { foreach (var parser in provinceParser.Adjacent) { if (!parser.land) { continue; } if (parser.title == null) { continue; } var t = parser.Title; if (!provinces.Contains(parser) && (head == parser.Title.Holder || parser.Title.Holder == null || (parser.Title.Liege != null && head == parser.TotalLeader))) { choices.Add(parser); } } } for (int i = 0; i < c; i++) { if (choices.Count > 0) { int cc = Rand.Next(choices.Count); provinces.Add(choices[cc]); choices.RemoveAt(cc); } } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies.Get("SAMembers"); string username; if (cookie == null) { //Response.Redirect("~/NotLoggedIn.aspx"); } else { username = CheckLoggedIn.Check(cookie.Value); } if (IsPostBack) { if (CharUpload.HasFile) { String InputFileName = CharUpload.FileName; if (InputFileName != "CharacterProfiler.lua") { LabelStatus.Text = "Sorry, you need to upload the CharacterProfiler.lua file"; } else { HttpPostedFile InputFile = CharUpload.PostedFile; Stream theStream = InputFile.InputStream; // Call the CharacterParser class to read and parse out the Proudmoore // chars in the file. Once done, save the object to the Cache. CharacterParser myChars = new CharacterParser(); List <WoWCharacter> proudmooreChars = new List <WoWCharacter>(); proudmooreChars = myChars.DoParse(theStream); Cache.Insert("uploadedChars", proudmooreChars); // Count how many characters are in the file - reject if there arent any int CharCount = 0; foreach (WoWCharacter TempChar in proudmooreChars) { CharCount++; } if (CharCount > 0) { Response.Redirect("SelectChars.aspx"); } else { LabelStatus.Text = "Sorry - that file doesn't have any characters from Proudmoore in it"; } } } else { LabelStatus.Text = "Sorry - you need to select a file to upload"; } } }
public void TryGetToken_ReturnsFailureResult_WhenStringStreamIsNull() { var parser = new CharacterParser(_primitiveParser); var result = parser.TryGetToken(null, out _); Assert.IsInstanceOf <FailureParseResult>(result); }
public String getNick(CharacterParser chr) { if (!init) { Init(); } return(nicks[Rand.Next(nicks.Count)]); }
public void ZeroAsRawInputYieldsZero() { var rawEntry = " _ " + "| |" + "|_|"; Assert.That(CharacterParser.ToCharacter(rawEntry), Is.EqualTo('0')); }
void Start() { dialogueParser = GameObject.Find("DialogueParser").GetComponent <DialogueParser>(); characterParser = GameObject.Find("CharacterParser").GetComponent <CharacterParser>(); answerBox = GameObject.Find("Answer").GetComponent <Text>(); panels = GetComponentsInChildren <DialogueOptionPanel>(); characterNameBox = GameObject.Find("CharacterName").GetComponent <Text>(); characterNameBox.text = characterParser.characterName; }
public void TryGetToken_ReturnsSuccessResult_WhenInputIsClassRange() { _primitiveParser.TryParseCharacterRange(Arg.Any <IStringStream>()).Returns(_classRangeParserSuccess); var parser = new CharacterParser(_primitiveParser); var result = parser.TryGetToken(_stream, out _); Assert.IsTrue(result.IsSuccess); _primitiveParser.Received(1).TryParseCharacterRange(Arg.Any <IStringStream>()); _primitiveParser.Received(0).TryParseCharacter(Arg.Any <IStringStream>()); }
public TitleParser CreateKingScriptScope(ProvinceParser capital, CharacterParser chr) { var rand = Rand.Get(); Color col = Color.FromArgb(255, rand.Next(200) + 55, rand.Next(200) + 55, rand.Next(200) + 55); ScriptScope scope = new ScriptScope(); scope.Parent = LandedTitlesScript.Root; { String place = chr.Culture.dna.GetPlaceName(); String text = place; place = StarNames.SafeName(place); if (TitleManager.instance.TitleMap.ContainsKey("k_" + place)) { return(CreateKingScriptScope(capital, chr.culture)); } LanguageManager.instance.Add(place, text); scope.Name = "k_" + place; LanguageManager.instance.Add(scope.Name, text); } //scope.Kids.Add(new ScriptCommand() { Name = "rebel", Value = false }); scope.Add(new ScriptCommand() { Name = "color", Value = col }); scope.Add(new ScriptCommand() { Name = "color2", Value = col }); scope.Add(new ScriptCommand() { Name = "capital", Value = capital.id }); TitleParser title = new TitleParser(scope); AddTitle(title); // now place the counties into it... if (title.capital != 0) { title.CapitalProvince = MapManager.instance.ProvinceIDMap[title.capital]; } return(title); }
public CharacterParser AddCharacterForTitle(TitleParser title, bool adult = false) { CharacterParser chr = CharacterManager.instance.GetNewCharacter(); chr.GiveTitle(title); if (title.Rank > 0) { characters.Add(chr); } return(chr); }
public CharacterParser AddCharacterForTitle(TitleParser title, String culture, String religion) { CharacterParser chr = CharacterManager.instance.CreateNewCharacter(culture, religion, Rand.Next(8) == 0); chr.GiveTitle(title); if (title.Rank > 0) { characters.Add(chr); } return(chr); }
private void CreateCasusBelli(string casusBelli, CharacterParser actor, CharacterParser recipient, TitleParser title, int yearStart) { var scope = new ScriptScope("casus_belli"); scope.Add(new ScriptCommand("actor", actor.ID, scope)); scope.Add(new ScriptCommand("recipient", recipient.ID, scope)); scope.Add(new ScriptCommand("casus_belli", casusBelli, scope)); scope.Add(new ScriptCommand("landed_title", title, scope)); scope.Add(new ScriptCommand("date", yearStart.ToString() + ".1.1", scope)); warScript.Root.Add(scope); }
public int Next(StringSplitter splitter) { var nextChar = splitter.Stream.Next(); if (nextChar == '"') { var normal = new CharacterParser(); splitter.CharacterGrabber = normal; return(normal.Next(splitter)); } return(nextChar); }
public TextLiteral(CharacterParser containingCharacter, Parser <char> container) : base( new EscapedLiteral(containingCharacter.Character).ToParser() .XOr( Parse.CharExcept( $"{containingCharacter.Character}{Slash}") .Or(EscapedCharacter) .Many() .Text() ).Contained(container, container) .Token() .Select(x => new LiteralExpression(x)) ) { }
public CharacterParser GetNewCharacter(bool adult = false) { if (!bInit) { Init(); } var chr = new CharacterParser(); Characters.Add(chr); AliveCharacters.Add(chr); AddedSinceLastPrune.Add(chr); CharacterMap[chr.ID] = chr; return(chr); }
public void Save() { foreach (var religionParser in AllReligions) { if (religionParser.ReligiousHeadTitle != null) { CharacterParser chr = CharacterManager.instance.GetNewCharacter(); chr.GiveTitle(religionParser.ReligiousHeadTitle); chr.religion = religionParser.Name; } } script.Save(); }
public CharacterParser CreateNewHistoricCharacter(Dynasty dynasty, bool bFemale, string religion, String culture, int dateOfBirth, int dateOfDeath = -1, bool adult = true) { if (!bInit) { Init(); } // var scope = new ScriptScope(); // scope.Name = CharacterParser.IDMax.ToString(); // scope.SetChild(CharactersScript.Root); var chr = new CharacterParser(); // chr.SetProperty("dynasty", Rand.Next(1235)+1); // chr.SetProperty("culture", new ScriptReference("norse")); // chr.SetProperty("religion", new ScriptReference("pagan")); // chr.DeleteProperty("name"); Characters.Add(chr); chr.YearOfBirth = dateOfBirth; chr.isFemale = bFemale; chr.culture = culture; chr.religion = religion; if (dateOfDeath != -1) { chr.YearOfDeath = dateOfDeath; } else { chr.YearOfDeath = dateOfBirth + Rand.Next(40); if (Rand.Next(4) == 0) { chr.YearOfDeath = dateOfBirth + Rand.Next(80); } if (adult) { chr.YearOfDeath = dateOfBirth + 16 + Rand.Next(80 - 16); } } this.CharactersScript.Root.SetChild(chr.Scope); AddedSinceLastPrune.Add(chr); CharacterMap[chr.ID] = chr; chr.Dynasty = dynasty; chr.SetupExistingDynasty(); chr.UpdateCultural(); // CharacterManager.instance.SetAllDates(chr.YearOfBirth, chr.YearOfDeath, chr.Scope); return(chr); }
public void GetResponse_ReturnsSuccessTrue_OnSuccess() { // Arrange dynamic json = JObject.Parse(TestJson.Get("character-success")); var sut = new CharacterParser(); // Act Response <Character> result = sut.GetResponse <Character>(json); // Assert Assert.AreEqual(true, result.Success); Assert.AreEqual("200", result.Code); Assert.AreEqual("Success.", result.Status); Assert.IsNotNull(result.Data); }
public void GetResponse_ReturnsSuccessFalse_OnApiError() { // Arrange dynamic json = JObject.Parse(TestJson.Get("api-error")); var sut = new CharacterParser(); // Act Response <Character> result = sut.GetResponse <Character>(json); // Assert Assert.AreEqual(false, result.Success); Assert.AreEqual("409", result.Code); Assert.AreEqual("Limit greater than 100.", result.Status); Assert.IsNull(result.Data); }
public void GetResponse_ReturnsSuccessFalse_OnAuthError() { // Arrange dynamic json = JObject.Parse(TestJson.Get("auth-error")); var sut = new CharacterParser(); // Act Response <Character> result = sut.GetResponse <Character>(json); // Assert Assert.AreEqual(false, result.Success); Assert.AreEqual("InvalidCredentials", result.Code); Assert.AreEqual("The passed API key is invalid.", result.Status); Assert.IsNull(result.Data); }
static void Main(string[] args) { try { var myDocuments = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string savegamePath = Path.Combine(myDocuments, "my games","Skyrim","Saves"); if (args.Length > 0) { savegamePath = args[0]; } string outputFilePath = "mySkyrimCharacters.xml"; if (args.Length > 1) { outputFilePath = args[1]; } Console.WriteLine("Reading savegames..."); SkyrimSavegameReader savegameReader = new SkyrimSavegameReader(); IEnumerable<SkyrimSavegame> savegames = savegameReader.Read(new DirectoryInfo(savegamePath)); Console.WriteLine("Parsing characters..."); CharacterParser characterParser = new CharacterParser(); CharacterList characterList = characterParser.ParseCharacters(savegames.ToArray()); Console.WriteLine("Exporting to XML..."); XmlCharacterSerializer xmlSerializer = new XmlCharacterSerializer(); xmlSerializer.Write(characterList, outputFilePath); Console.WriteLine("Exporting to CSV..."); CsvCharacterSerializer csvSerializer = new CsvCharacterSerializer(); csvSerializer.Write(characterList, outputFilePath.Replace(".xml", ".csv")); Console.WriteLine("FINISHED"); //Console.ReadLine(); } catch(Exception ex) { Console.WriteLine("Error: " + ex.Message); } }
public CharacterParser CreateNewHistoricCharacter(Dynasty dynasty, bool bFemale, string religion, String culture, int dateOfBirth, int dateOfDeath = -1, bool adult = true) { if (!bInit) { Init(); } var chr = new CharacterParser(); Characters.Add(chr); AliveCharacters.Add(chr); chr.YearOfBirth = dateOfBirth; chr.isFemale = bFemale; chr.culture = culture; chr.religion = religion; if (dateOfDeath != -1) { chr.YearOfDeath = dateOfDeath; } else { chr.YearOfDeath = dateOfBirth + 150 + Rand.Next(40); if (Rand.Next(4) == 0) { chr.YearOfDeath = dateOfBirth + 150 + Rand.Next(80); } if (adult) { chr.YearOfDeath = dateOfBirth + 150 + 16 + Rand.Next(80 - 16); } } this.CharactersScript.Root.SetChild(chr.Scope); AddedSinceLastPrune.Add(chr); CharacterMap[chr.ID] = chr; chr.Dynasty = dynasty; chr.SetupExistingDynasty(); chr.UpdateCultural(); return(chr); }
public void Init() { // ModularFunctionalityManager.instance.Save(); DynastyManager.instance.Init(); CharacterManager.instance.Init(); CulturalDnaManager.instance.Init(); CultureManager.instance.Init(); EventManager.instance.Load(); DecisionManager.instance.Load(); TraitManager.instance.Init(); SpriteManager.instance.Init(); foreach (var titleParser in TitleManager.instance.Titles) { titleParser.DoCapital(); } ReligionManager.instance.Init(); CharacterParser chr = CharacterManager.instance.GetNewCharacter(); characters.Add(chr); Random rand = new Random(); for (int n = 0; n < 1; n++) { ScriptScope s = new ScriptScope(); string name = chr.Culture.dna.GetPlaceName(); s.Name = StarNames.SafeName(name); LanguageManager.instance.Add(s.Name, name); //872 vanilla MapManager.instance.ProvinceIDMap[872].RenameForCulture(chr.Culture); var tit = MapManager.instance.ProvinceIDMap[872].CreateTitle(); // if (chr.Culture.dna.horde) // tit.Scope.Do("historical_nomad = yes"); chr.GiveTitle(tit); MapManager.instance.ProvinceIDMap[872].CreateProvinceDetails(chr.Culture); } }
public CharacterParser GetNewCharacter(bool adult = false) { if (!bInit) { Init(); } // var scope = new ScriptScope(); // scope.Name = CharacterParser.IDMax.ToString(); // scope.SetChild(CharactersScript.Root); var chr = new CharacterParser(); // chr.SetProperty("dynasty", Rand.Next(1235)+1); // chr.SetProperty("culture", new ScriptReference("norse")); // chr.SetProperty("religion", new ScriptReference("pagan")); // chr.DeleteProperty("name"); Characters.Add(chr); this.CharactersScript.Root.SetChild(chr.Scope); AddedSinceLastPrune.Add(chr); CharacterMap[chr.ID] = chr; return(chr); }
public void Parsing_character_entity_to_character_dto(string name, string planet) { // Arrange var episodes = new List <EpisodeEntity>(); var friends = new List <FriendEntity>(); episodes.Add(new EpisodeEntity(Guid.NewGuid(), "New Hope")); episodes.Add(new EpisodeEntity(Guid.NewGuid(), "Empire")); friends.Add(new FriendEntity(Guid.NewGuid(), "R2D2")); friends.Add(new FriendEntity(Guid.NewGuid(), "HanSolo")); var characterEntity = new StarWarsCharacterEntity(Guid.NewGuid(), name, episodes, friends, planet); CharacterParser parser = new CharacterParser(); // Act var characterDto = parser.CharacterEntityToDto(characterEntity); // Assert Assert.Equal(characterEntity.Id, characterDto.Id); Assert.Equal(characterEntity.Name, characterDto.Name); Assert.Equal(characterEntity.Planet, characterDto.Planet); Assert.Equal(characterEntity.Episodes.Select(x => x.EpisodeName), characterDto.Episodes); Assert.Equal(characterEntity.Friends.Select(x => x.FriendName), characterDto.Friends); }
public void Setup() { theParser = new CharacterParser(); }
public CharacterParser FindPreviousOwner(CharacterParser prevOwner, List <CharacterParser> prevOwners, int year) { List <CharacterParser> choices = new List <CharacterParser>(); List <CharacterParser> choicesDyn = new List <CharacterParser>(); if (prevOwner == null) { return(null); } CultureParser cul = prevOwner.Culture; for (int index = 0; index < Characters.Count; index++) { var characterParser = Characters[index]; if (characterParser.isFemale) { continue; } if (prevOwners.Contains(characterParser)) { continue; } if (year <= characterParser.YearOfBirth) { continue; } if (year >= characterParser.YearOfDeath) { continue; } if (characterParser.Culture != cul) { continue; } if (characterParser.Father == null) { continue; } if (prevOwner != null) { if (prevOwner == characterParser) { continue; } } if (prevOwner.Dynasty != characterParser.Dynasty) { choices.Add(characterParser); } else { choicesDyn.Add(characterParser); } } if (Rand.Next(6) != 0 && choicesDyn.Count > 0) { return(choicesDyn[Rand.Next(choicesDyn.Count)]); } if (choices.Count > 0) { return(choices[Rand.Next(choices.Count)]); } return(null); }
public void RemoveCharacter(CharacterParser characterParser) { Characters.Remove(characterParser); CharacterMap.Remove(characterParser.ID); CharactersScript.Root.Remove(characterParser.Scope); }