public Creature(string message) { string[] buildSplit = message.Split(delim); AccountName = buildSplit[0]; CharacterName = buildSplit[1]; CharacterAlignment = Alignment.GetAlignment(uint.Parse(buildSplit[2])); CharacterRace = Race.GetRace(uint.Parse(buildSplit[3])); Gender = int.Parse(buildSplit[4]); Background = Background.GetBackground(uint.Parse(buildSplit[5])); string[] classSplit = buildSplit[6].Split(listDelim); Classes = new Dictionary<CharacterClass, uint>(); foreach(string cl in classSplit) { if(String.IsNullOrWhiteSpace(cl)) { continue; } string[] clSp = cl.Split(keyDelim); CharacterClass toAdd = CharacterClass.GetClass(uint.Parse(clSp[0])); uint level = uint.Parse(clSp[1]); Classes.Add(toAdd, level); } string[] subClassSplit = buildSplit[7].Split(listDelim); SubClasses = new Dictionary<CharacterClass, CharacterClass>(); foreach (string sub in subClassSplit) { if (String.IsNullOrWhiteSpace(sub)) { continue; } string[] subSp = sub.Split(keyDelim); CharacterClass baseClass = CharacterClass.GetClass(uint.Parse(subSp[0])); if (!String.IsNullOrWhiteSpace(subSp[1])) { CharacterClass subClass = CharacterClass.GetClass(uint.Parse(subSp[1])); SubClasses.Add(baseClass, subClass); } else { SubClasses.Add(baseClass, null); } } string[] saveSplit = buildSplit[8].Split(listDelim); ProficientSaves = new List<uint>(); foreach (string save in saveSplit) { if(String.IsNullOrWhiteSpace(save)) { continue; } ProficientSaves.Add(uint.Parse(save)); } string[] cantripSplit = buildSplit[9].Split(listDelim); Cantrips = new List<Spell>(); foreach(string cantrip in cantripSplit) { if(String.IsNullOrWhiteSpace(cantrip)) { continue; } Cantrips.Add(Spell.GetSpell(uint.Parse(cantrip))); } string[] spellSplit = buildSplit[10].Split(listDelim); SpellsKnown = new List<Spell>(); foreach(string spell in spellSplit) { if(String.IsNullOrWhiteSpace(spell)) { continue; } SpellsKnown.Add(Spell.GetSpell(uint.Parse(spell))); } ExperiencePoints = uint.Parse(buildSplit[11]); Level = uint.Parse(buildSplit[12]); Strength = int.Parse(buildSplit[13]); Dexterity = int.Parse(buildSplit[14]); Constitution = int.Parse(buildSplit[15]); Intelligence = int.Parse(buildSplit[16]); Wisdom = int.Parse(buildSplit[17]); Charisma = int.Parse(buildSplit[18]); ProficiencyBonus = uint.Parse(buildSplit[19]); string[] skillSplit = buildSplit[20].Split(listDelim); Skills = new List<Skill>(); foreach(string skill in skillSplit) { if(String.IsNullOrWhiteSpace(skill)) { continue; } Skills.Add(Skill.GetSkill(uint.Parse(skill))); } string[] powerSplit = buildSplit[21].Split(listDelim); Powers = new List<Power>(); foreach(string power in powerSplit) { if(String.IsNullOrWhiteSpace(power)) { continue; } Powers.Add(Power.GetPower(uint.Parse(power))); } InspirationPoints = uint.Parse(buildSplit[22]); HairStyle = uint.Parse(buildSplit[23]); HairColor = uint.Parse(buildSplit[24]); SkinColor = uint.Parse(buildSplit[25]); Map = buildSplit[26]; LocationX = int.Parse(buildSplit[27]); LocationY = int.Parse(buildSplit[28]); LocationZ = int.Parse(buildSplit[29]); LocationFacing = (Direction)Enum.Parse(typeof(Direction), buildSplit[30]); string[] equipSplit = buildSplit[31].Split(listDelim); Equipment = new Dictionary<int, InventoryItem>(); foreach(string equip in equipSplit) { if(String.IsNullOrWhiteSpace(equip)) { continue; } string[] itemSplit = equip.Split(keyDelim); InventoryItem it = new InventoryItem(itemSplit[1]); if (it.Valid) { Equipment.Add(int.Parse(itemSplit[0]), it); } } string[] invSplit = buildSplit[32].Split(listDelim); Inventory = new List<InventoryItem>(); foreach(string item in invSplit) { if(String.IsNullOrWhiteSpace(item)) { continue; } InventoryItem it = new InventoryItem(item); if (it.Valid) { Inventory.Add(it); } } IsGM = bool.Parse(buildSplit[33]); IsCreatureValid = true; }
public static void Load() { string file = System.IO.Directory.GetCurrentDirectory() + "\\DataArrays\\BaseItems.txt"; FileStream strLib = File.Open(file, FileMode.Open); using (StreamReader read = new StreamReader(strLib, Encoding.UTF7)) { while (read.Peek() >= 0) { InventoryItem toAdd = new InventoryItem(read.ReadLine()); if(toAdd.Valid) { _library.Add(toAdd.Identifier, toAdd); } } } }
public Character(string message) { string[] split = message.Split(delim); if (split.Length < 36) return; AccountName = split[0]; CharacterName = split[1]; uint.TryParse(split[2], out CharacterRace); int.TryParse(split[3], out Sex); uint.TryParse(split[4], out CharacterVirtue); uint.TryParse(split[5], out CharacterVice); uint.TryParse(split[6], out MoralsCare); uint.TryParse(split[7], out MoralsFairness); uint.TryParse(split[8], out MoralsLoyalty); uint.TryParse(split[9], out MoralsAuthority); uint.TryParse(split[10], out MoralsTradition); uint.TryParse(split[11], out CharacterProfession); uint.TryParse(split[12], out CharacterTalent); uint.TryParse(split[13], out CharacterHobby); string[] abilDict = split[14].Split(dictDelim); Abilities = new Dictionary<uint, int>(); foreach(string keyVal in abilDict) { if (String.IsNullOrWhiteSpace(keyVal)) continue; string[] kv = keyVal.Split(keyDelim); uint key; int value; uint.TryParse(kv[0], out key); int.TryParse(kv[1], out value); Abilities.Add(key, value); } string[] skillDict = split[15].Split(dictDelim); Skills = new Dictionary<uint, int>(); foreach (string keyVal in skillDict) { if (String.IsNullOrWhiteSpace(keyVal)) continue; string[] kv = keyVal.Split(keyDelim); uint key; int value; uint.TryParse(kv[0], out key); int.TryParse(kv[1], out value); Skills.Add(key, value); } uint.TryParse(split[16], out CurrentActionPoints); uint.TryParse(split[17], out MaxActionPoints); uint.TryParse(split[18], out DecayedActionPoints); uint.TryParse(split[19], out DestroyedActionPoints); uint.TryParse(split[20], out CurrentWillpowerPoints); uint.TryParse(split[21], out MaxWillpowerPoints); uint.TryParse(split[22], out DecayedWillpowerPoints); uint.TryParse(split[23], out DestroyedWillpowerPoints); uint.TryParse(split[24], out CurrentStun); uint.TryParse(split[25], out MaxStun); uint.TryParse(split[26], out DecayedStun); uint.TryParse(split[27], out DestroyedStun); uint.TryParse(split[28], out CurrentStructure); uint.TryParse(split[29], out MaxStructure); uint.TryParse(split[30], out DecayedStructure); uint.TryParse(split[31], out DestroyedStructure); uint.TryParse(split[32], out CurrentVital); uint.TryParse(split[33], out MaxVital); uint.TryParse(split[34], out DecayedVital); uint.TryParse(split[35], out DestroyedVital); uint.TryParse(split[36], out HairStyle); uint.TryParse(split[37], out HairColor); uint.TryParse(split[38], out SkinColor); int.TryParse(split[39], out LocationX); int.TryParse(split[40], out LocationY); int.TryParse(split[41], out LocationZ); Direction.TryParse(split[42], out LocationFacing); Map = split[43]; string[] invDict = split[44].Split(dictDelim); Equipment = new Dictionary<int, InventoryItem>(); Inventory = new List<InventoryItem>(); foreach (string keyVal in invDict) { if (String.IsNullOrWhiteSpace(keyVal)) continue; InventoryItem it = new InventoryItem(keyVal); if (it.EquipKey > 0) Equipment.Add(it.EquipKey, it); else Inventory.Add(it); } bool.TryParse(split[45], out IsDM); }