public ObservableCollection <Entity> LoadEntities() { FileInfo entitiesFile = new FileInfo(Path.Combine(App.ApplicationPath, "persistence", "entities.json")); if (!entitiesFile.Exists) { return(null); } ObservableCollection <Entity> entityViewModels = new(); EntityLists entities = JsonConvert.DeserializeObject <EntityLists>(File.ReadAllText(entitiesFile.FullName)); if (entities != null) { foreach (Server server in entities.ServerList) { DirectoryInfo serverDir = new DirectoryInfo(Path.Combine(App.ServerPath, server.Name)); if (!serverDir.Exists) { ErrorLogger.Append( new Exception("Could not find server " + server.Name + " that was listed in entities.json . Removing it...")); continue; } if (!entityViewModels.Contains(server)) { entityViewModels.Add(server); } } foreach (Network network in entities.NetworkList) { DirectoryInfo serverDir = new DirectoryInfo(Path.Combine(App.ServerPath, network.Name)); if (!serverDir.Exists) { ErrorLogger.Append( new Exception("Could not find network " + network.Name + " that was listed in entities.json . Removing it...")); continue; } entityViewModels.Add(network); } } return(entityViewModels); }
public void StoreEntities() { EntityLists entities = new EntityLists(); foreach (EntityViewModel viewModel in ServerManager.Instance.Entities) { switch (viewModel.Entity) { case Server server: entities.ServerList.Add(server); break; case Network network: entities.NetworkList.Add(network); break; } } #if DEBUG string json = JsonConvert.SerializeObject(entities, Formatting.Indented); #else string json = JsonConvert.SerializeObject(entities, Formatting.None); #endif DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(App.ApplicationPath, "persistence")); if (!directoryInfo.Exists) { directoryInfo.Create(); } FileInfo entitiesFile = new FileInfo(Path.Combine(App.ApplicationPath, "persistence", "entities.json")); lock (writeLock) { using (FileStream fs = entitiesFile.Create()) using (StreamWriter sw = new StreamWriter(fs)) { sw.WriteLine(json); } } }
/// <summary> /// Constructor. /// </summary> public HomesCollection() { //_homesList = new List<Home>(); _homesList = new List <Home>(EntityLists.GetTreeListOfHomes()); collectionMonitor = new CollectionMonitor(); }
void Awake() { entityManager = GetComponent <EntityLists>(); }
public bool OnCast(Character caster, string args) { // There is no power level to this spell. Only one demon may be controlled, and if the caster has // any pets the spell will flail. The demon will be very powerful, this it's why it is a skill 17 spell. // First gather a list of unnamed demons. if (caster.Pets != null && caster.Pets.Count > 0 && (caster is PC) && (caster as PC).ImpLevel < Globals.eImpLevel.DEVJR) { caster.WriteToDisplay("Summoning a demon requires your full concentration."); return(false); } List <EntityLists.Entity> availableDemons = new List <EntityLists.Entity>(); foreach (EntityLists.Entity entity in EntityLists.DEMONS) { if (!EntityLists.NAMED_DEMONS.Contains(entity)) { availableDemons.Add(entity); } } NPC demon = NPC.LoadNPC(Item.ID_SUMMONEDMOB, caster.FacetID, caster.LandID, caster.MapID, caster.X, caster.Y, caster.Z, -1); EntityLists.Entity chosenDemon = availableDemons[Rules.Dice.Next(availableDemons.Count)]; EntityBuilder builder = new EntityBuilder(); demon.Level = caster.Level + Rules.RollD(3, 4); demon.entity = chosenDemon; List <Character.ClassType> allowedProfessions = new List <Character.ClassType> { Character.ClassType.Fighter, Character.ClassType.Ravager, //Character.ClassType.Sorcerer, //Character.ClassType.Thaumaturge, Character.ClassType.Thief, Character.ClassType.Wizard, }; demon.BaseProfession = allowedProfessions[Rules.Dice.Next(0, allowedProfessions.Count - 1)]; builder.SetOnTheFlyVariables(demon); EntityBuilder.SetVisualKey(demon.entity, demon); builder.SetName(demon, demon.BaseProfession.ToString().ToLower()); builder.SetDescriptions("summoned", demon, caster.Map.ZPlanes[caster.Z], demon.BaseProfession.ToString().ToLower()); EntityBuilder.SetGender(demon, caster.Map.ZPlanes[caster.Z]); EntityBuilder.SetVisualKey(demon.entity, demon); if (demon.IsSpellUser) { NPC.CreateGenericSpellList(demon); GameSpell.FillSpellLists(demon); } if (EntityLists.IsHumanOrHumanoid(demon)) { demon.wearing.Clear(); List <int> armorToWear = Autonomy.ItemBuilding.ArmorSets.ArmorSet.ArmorSetDictionary[Autonomy.ItemBuilding.ArmorSets.ArmorSet.FULL_STEEL].GetArmorList(demon); foreach (int id in armorToWear) { Item armor = Item.CopyItemFromDictionary(id); armor.special += " " + Item.EXTRAPLANAR; demon.WearItem(armor); } } if (EntityLists.IsHumanOrHumanoid(demon) || EntityLists.ANIMALS_WIELDING_WEAPONS.Contains(demon.entity)) { List <int> weaponsList = Autonomy.ItemBuilding.LootManager.GetBasicWeaponsFromArmory(demon, true); if (weaponsList.Count > 0) { demon.EquipRightHand(Item.CopyItemFromDictionary(weaponsList[Rules.Dice.Next(weaponsList.Count - 1)])); } weaponsList = Autonomy.ItemBuilding.LootManager.GetBasicWeaponsFromArmory(demon, false); if (weaponsList.Count > 0) { demon.EquipLeftHand(Item.CopyItemFromDictionary(weaponsList[Rules.Dice.Next(weaponsList.Count - 1)])); } if (demon.RightHand != null) { demon.RightHand.special += " " + Item.EXTRAPLANAR; } if (demon.LeftHand != null) { demon.LeftHand.special += " " + Item.EXTRAPLANAR; } } demon.castMode = NPC.CastMode.Limited; demon.Hits = demon.HitsFull; demon.Mana = demon.ManaFull; demon.Stamina = demon.StaminaFull; demon.Alignment = Globals.eAlignment.ChaoticEvil; demon.race = "Hell"; //demon.aiType = NPC.AIType.EmptySlot; demon.Age = 0; demon.special = "despawn"; int fiveMinutes = Utils.TimeSpanToRounds(new TimeSpan(0, 5, 0)); // 5 minutes plus 1 minute per magic skill level demon.RoundsRemaining = fiveMinutes + Skills.GetSkillLevel(caster.magic) * Utils.TimeSpanToRounds(new TimeSpan(0, 1, 0)); demon.species = Globals.eSpecies.Demon; // this may need to be changed for AI to work properly demon.Alignment = caster.Alignment; demon.canCommand = true; demon.IsMobile = true; demon.IsSummoned = true; demon.IsUndead = EntityLists.UNDEAD.Contains(demon.entity); demon.FollowID = caster.UniqueID; demon.PetOwner = caster; caster.Pets.Add(demon); if (demon.CurrentCell != caster.CurrentCell) { demon.CurrentCell = caster.CurrentCell; } demon.EmitSound(demon.idleSound); demon.AddToWorld(); return(true); }
public ObservableCollection <EntityViewModel> LoadEntities() { ObservableCollection <EntityViewModel> entityViewModels = new ObservableCollection <EntityViewModel>(); // Legacy stuff to support older Fork versions FileInfo serversFile = new FileInfo(Path.Combine(App.ApplicationPath, "persistence", "servers.xml")); if (serversFile.Exists) { List <Server> servers = DeSerializeObject <List <Server> >(serversFile.FullName); if (servers != null) { foreach (Server server in servers) { entityViewModels.Add(new ServerViewModel(server)); } } try { serversFile.Delete(); } catch (Exception e) { Console.WriteLine("Error while deleting servers.xml"); ErrorLogger.Append(e); } } FileInfo entitiesFile = new FileInfo(Path.Combine(App.ApplicationPath, "persistence", "entities.json")); if (!entitiesFile.Exists) { return(entityViewModels); } EntityLists entities = JsonConvert.DeserializeObject <EntityLists>(File.ReadAllText(entitiesFile.FullName)); if (entities != null) { foreach (Server server in entities.ServerList) { DirectoryInfo serverDir = new DirectoryInfo(Path.Combine(App.ServerPath, server.Name)); if (!serverDir.Exists) { ErrorLogger.Append( new Exception("Could not find server " + server.Name + " that was listed in entities.json . Removing it...")); continue; } ServerViewModel serverViewModel = new ServerViewModel(server); if (!entityViewModels.Contains(serverViewModel)) { entityViewModels.Add(serverViewModel); } } foreach (Network network in entities.NetworkList) { DirectoryInfo serverDir = new DirectoryInfo(Path.Combine(App.ServerPath, network.Name)); if (!serverDir.Exists) { ErrorLogger.Append( new Exception("Could not find network " + network.Name + " that was listed in entities.json . Removing it...")); continue; } entityViewModels.Add(new NetworkViewModel(network)); } } //Overwrite json if any changes appeared while deserializing (Unset value set etc.) StoreEntities(entityViewModels); return(entityViewModels); }
public static HomesCollection GetHomesCollectionObject() { return(new HomesCollection(EntityLists.GetTreeListOfHomes())); }
public static bool BuildNewEntities(out int spawnZonesCount) { spawnZonesCount = 0; foreach (Facet facet in World.Facets) { foreach (Land land in facet.Lands) { foreach (Map map in land.Maps) { foreach (ZPlane zPlane in map.ZPlanes.Values) { try { if (zPlane.zAutonomy != null && zPlane.zAutonomy.entities != null && zPlane.zAutonomy.entities.Length > 0) { // name(class|class2),name,name,name(class|class|class) string[] critters = zPlane.zAutonomy.entities.Split(",".ToCharArray()); List <Tuple <string, EntityLists.Entity, string> > creatureDescProfessionTuples = new List <Tuple <string, EntityLists.Entity, string> >(); #region Create list of Tuples with EntityLists.Entity and profession or profession synonym string. foreach (string s in critters) { EntityLists.Entity cr = EntityLists.Entity.Alligator; string desc = ""; // adjective(s) for descriptive, and other purposes if (s.StartsWith("[")) { desc = s.Substring(s.IndexOf("[") + 1, s.IndexOf("]") - s.IndexOf("[") - 1); } string critterType = ""; if (s.Contains("(")) // various professions { if (s.StartsWith("[")) { critterType = s.Substring(s.IndexOf("]") + 1, s.IndexOf("(") - s.IndexOf("]") - 1); } else { critterType = s.Substring(0, s.IndexOf("(")); } if (!Enum.TryParse(critterType, true, out cr)) { Utils.Log("Error parsing CreatureLists.Creature (" + critterType + ") from zPlane: " + zPlane.ToString(), Utils.LogType.SystemWarning); continue; } string[] classesList = s.Substring(s.IndexOf("(") + 1, s.IndexOf(")") - s.IndexOf("(") - 1).Split("|".ToCharArray()); foreach (string cl in classesList) { Tuple <string, EntityLists.Entity, string> tuple = Tuple.Create(desc, cr, cl); if (!creatureDescProfessionTuples.Contains(tuple)) { creatureDescProfessionTuples.Add(tuple); } } } else { if (s.StartsWith("[")) { critterType = s.Substring(s.IndexOf("]") + 1, s.Length - s.IndexOf("]") - 1); } else { critterType = s; } if (!Enum.TryParse(critterType, true, out cr)) { Utils.Log("Error parsing CreatureLists.Creature ( " + critterType + " ) from zPlane: " + zPlane.ToString(), Utils.LogType.SystemWarning); continue; } Tuple <string, EntityLists.Entity, string> tuple = Tuple.Create(desc, cr, "Fighter"); if (!creatureDescProfessionTuples.Contains(tuple)) { creatureDescProfessionTuples.Add(tuple); } } } #endregion NPC npc = null; List <int> NPCIDList = new List <int>(); List <int> WaterDwellingNPCIDList = new List <int>(); Dictionary <int, Tuple <int, int> > SpawnGroupAmounts = new Dictionary <int, Tuple <int, int> >(); Dictionary <int, Tuple <int, int> > WaterSpawnGroupAmounts = new Dictionary <int, Tuple <int, int> >(); foreach (Tuple <string, EntityLists.Entity, string> tuple in creatureDescProfessionTuples) { npc = null; #region Check if an entity/profession, in the same level range, has already been built. If so, choose it for the SpawnZone. foreach (Tuple <EntityLists.Entity, string, int> createdNPC in AutoCreatedNPCDictionary.Keys) { // if an Entity/profession pair has already been created, check level and use if within range. if (createdNPC.Item1 == tuple.Item2 && createdNPC.Item2 == tuple.Item3 && AutoCreatedNPCDictionary[createdNPC].shortDesc.Contains(tuple.Item1)) { if (AutoCreatedNPCDictionary[createdNPC].Level >= zPlane.zAutonomy.minimumSuggestedLevel && AutoCreatedNPCDictionary[createdNPC].Level <= zPlane.zAutonomy.maximumSuggestedLevel) { npc = AutoCreatedNPCDictionary[createdNPC].CloneNPC(); break; } } } #endregion if (npc == null) { if (EntityLists.IsMerchant(tuple.Item2)) { npc = new Merchant(); if (EntityLists.TRAINER_SPELLS.Contains(tuple.Item2)) { (npc as Merchant).trainerType = Merchant.TrainerType.Spell; } else if (EntityLists.TRAINER_ANIMAL.Contains(tuple.Item2)) { (npc as Merchant).trainerType = Merchant.TrainerType.Animal; } if (EntityLists.MENTOR.Contains(tuple.Item2)) { (npc as Merchant).interactiveType = Merchant.InteractiveType.Mentor; } if (!EntityLists.MOBILE.Contains(tuple.Item2)) { npc.IsMobile = false; } } else { npc = new NPC(); } EntityBuilder builder = new EntityBuilder(); if (!builder.BuildEntity(tuple.Item1, tuple.Item2, npc, zPlane, tuple.Item3)) { // Log an issue with building a new entity, move on to next. Utils.Log("Failed to build entity: " + tuple.Item1.ToString() + ", " + tuple.Item2.ToString() + " ZPlane: " + zPlane.ToString(), Utils.LogType.SystemWarning); continue; } else { // Built a new entity (NPC), add it to the dictionary. AutoCreatedNPCDictionary.Add(Tuple.Create(tuple.Item2, tuple.Item3, npc.npcID), npc); } } if (npc != null) { if (!NPCIDList.Contains(npc.npcID)) { if (!npc.IsWaterDweller) { NPCIDList.Add(npc.npcID); } else { WaterDwellingNPCIDList.Add(npc.npcID); } // Currently limiting social groups of spell warming professions to humans only. // Let's say other humanoid casters don't work well together as there is too much of a power struggle. // Maybe in the future there will be exceptions to this rule. if (EntityLists.SOCIAL.Contains(tuple.Item2) && ((npc.IsSpellWarmingProfession && EntityLists.HUMAN.Contains(tuple.Item2)) || !npc.IsSpellWarmingProfession) && !SpawnGroupAmounts.ContainsKey(npc.npcID)) { int low = 2; int high = 4; // Animals typically have more members in a group. if (EntityLists.ANIMAL.Contains(tuple.Item2)) { high += Rules.Dice.Next(0, Rules.RollD(1, 2)); } // Humanoids and humans have a chance to be alone. if (EntityLists.IsHumanOrHumanoid(npc) && Rules.RollD(1, 100) < 15) { low = 1; high = 2; } if (!npc.IsWaterDweller) { SpawnGroupAmounts.Add(npc.npcID, Tuple.Create(low, high)); } else { WaterSpawnGroupAmounts.Add(npc.npcID, Tuple.Create(low, high)); } } } else { Utils.Log("NPC ID already exists in SpawnZone NPCIDList in BuildNewEntities(). NPC: " + npc.GetLogString() + " ZPlane: " + zPlane.ToString(), Utils.LogType.SystemWarning); } } } if (NPCIDList.Count > 0) { SpawnZone szl = new SpawnZone(facet, NPCIDList[0], NPCIDList, SpawnGroupAmounts, land.LandID, map.MapID, zPlane.zCord, false); facet.Add(szl); if (!SpawnZone.Spawns.ContainsKey(szl.ZoneID)) { SpawnZone.Spawns.Add(szl.ZoneID, szl); } spawnZonesCount++; } else if (WaterDwellingNPCIDList.Count > 0) { SpawnZone szl = new SpawnZone(facet, WaterDwellingNPCIDList[0], NPCIDList, SpawnGroupAmounts, land.LandID, map.MapID, zPlane.zCord, true); facet.Add(szl); if (!SpawnZone.Spawns.ContainsKey(szl.ZoneID)) { SpawnZone.Spawns.Add(szl.ZoneID, szl); } spawnZonesCount++; } } if (zPlane.zAutonomy != null && zPlane.zAutonomy.uniqueEntities.Count > 0) { EntityBuilder builder = new EntityBuilder(); foreach (ZUniqueEntity zUnique in zPlane.zAutonomy.uniqueEntities) { NPC npc; if (EntityLists.IsMerchant(zUnique.entity)) { npc = new Merchant(); if (EntityLists.TRAINER_SPELLS.Contains(zUnique.entity)) { (npc as Merchant).trainerType = Merchant.TrainerType.Spell; } else if (EntityLists.TRAINER_ANIMAL.Contains(zUnique.entity)) { (npc as Merchant).trainerType = Merchant.TrainerType.Animal; } if (EntityLists.MENTOR.Contains(zUnique.entity)) { (npc as Merchant).interactiveType = Merchant.InteractiveType.Mentor; } if (!EntityLists.MOBILE.Contains(zUnique.entity)) { npc.IsMobile = false; } } else { npc = new NPC(); } npc.lairCritter = zUnique.hasLair; npc.lairCells = zUnique.lairCells; if (!builder.BuildEntity(zUnique.description, zUnique.entity, npc, zPlane, zUnique.profession)) { // Log an issue with building a new unique entity, move on to next. Utils.Log("Failed to build unique entity: " + zUnique.description + ", " + zUnique.entity + " ZPlane: " + zPlane.ToString(), Utils.LogType.SystemWarning); continue; } else { // Built a new unique entity (NPC), add it to the dictionary. AutoCreatedNPCDictionary.Add(Tuple.Create(zUnique.entity, zUnique.profession, npc.npcID), npc); } // add spawn zone SpawnZone szl = new SpawnZone(facet, zUnique, npc, land.LandID, map.MapID, zPlane.zCord, npc.IsWaterDweller); facet.Add(szl); if (!SpawnZone.Spawns.ContainsKey(szl.ZoneID)) { SpawnZone.Spawns.Add(szl.ZoneID, szl); } spawnZonesCount++; } } } catch (Exception e) { Utils.Log("EntityCreationManager.BuildNewEntities issue with map:" + map.Name + " zPlane:" + zPlane.name + ". Check autonomous tags and info.", Utils.LogType.ExceptionDetail); Utils.LogException(e); } } } } } return(true); }
public static PeopleCollection <Person> GetPeopleCollectionObject() { return(new PeopleCollection <Person>(EntityLists.GetListOfPeople())); }
public static RealEstateCosCollection GetRECosCollectionObject() { return(new RealEstateCosCollection(EntityLists.GetTreeListOfRECompanies())); }
public void OneBigTest() { { #region LogicBrokerTests // GetPerson(PersonID) { var expectedPerson = new Person() { FirstName = "John", LastName = "Smith", Email = "*****@*****.**", Phone = "1112223333" }; int personID = 1; Person actualPerson = LogicBroker.GetPerson(personID); bool areEqual = expectedPerson.Equals(actualPerson); Assert.IsTrue(areEqual); } // GetPerson(firstname, lastname) { string firstName = "John"; string lastName = "Smith"; var expectedPerson = new Person() { FirstName = firstName, LastName = lastName, Email = "*****@*****.**", Phone = "1112223333" }; Person actualPerson = LogicBroker.GetPerson(firstName, lastName); bool areEqual = expectedPerson.Equals(actualPerson); Assert.IsTrue(areEqual); } // GetHome(homeID) { var address = "23 Oak St."; var zip = "955551111"; var expectedHome = new Home() { Address = address, City = "Johnsonville", State = "CA", Zip = zip }; int homeID = 1; Home actualHome = LogicBroker.GetHome(homeID); bool areEqual = expectedHome.Equals(actualHome); Assert.IsTrue(areEqual); } // GetHome(address, zip) { var address = "23 Oak St."; var zip = "955551111"; var expectedHome = new Home() { Address = address, City = "Johnsonville", State = "CA", Zip = zip }; Home actualHome = LogicBroker.GetHome(address, zip); bool areEqual = expectedHome.Equals(actualHome); Assert.IsTrue(areEqual); } // GetHomeSale(saleID) // SOLD { int homesaleID = 6; var expectedHomeSale = new HomeSale() { SaleID = homesaleID, HomeID = 3, SoldDate = new DateTime(2014, 06, 13), AgentID = 1, SaleAmount = 550_000m, BuyerID = 5, MarketDate = new DateTime(2014, 06, 01), CompanyID = 4 }; var actualHomeSale = LogicBroker.GetHomeSale(homesaleID); bool areEqual = expectedHomeSale.Equals(actualHomeSale); if (!areEqual) { var items = new List <HomeSale>() { expectedHomeSale, actualHomeSale }; PrintObjects(items); } Assert.IsTrue(areEqual); } // GetHomeSale(marketDate, saleAmount) // SOLD { int homesaleID = 6; var marketDate = new DateTime(2015, 03, 01); var saleAmount = 335_000m; var expectedHomeSale = new HomeSale() { SaleID = homesaleID, HomeID = 1, SoldDate = new DateTime(2010, 03, 15), AgentID = 1, SaleAmount = saleAmount, BuyerID = 1, MarketDate = marketDate, CompanyID = 2 }; var actualHomeSale = LogicBroker.GetHomeSale(marketDate, saleAmount); bool areEqual = expectedHomeSale.Equals(actualHomeSale); if (!areEqual) { var items = new List <HomeSale>() { expectedHomeSale, actualHomeSale }; PrintObjects(items); } Assert.IsTrue(areEqual); } // GetHomeSale(saleID) // FOR SALE { var saleID = 1; var expectedHomeForSale = new HomeSale() { SaleID = saleID, HomeID = 3, SoldDate = null, AgentID = 4, SaleAmount = 700_000m, MarketDate = new DateTime(2016, 08, 15), CompanyID = 1 }; var actualHomeForSale = LogicBroker.GetHomeSale(saleID); bool areEqual = expectedHomeForSale.Equals(actualHomeForSale); if (!areEqual) { var items = new List <HomeSale>() { expectedHomeForSale, actualHomeForSale }; PrintObjects(items); } Assert.IsTrue(areEqual); } // GetReCompany(companyID) { int companyID = 3; var expectedRECo = new RealEstateCompany() { CompanyID = companyID, CompanyName = "Rapid Real Estate", Phone = "6662221111" }; var actualRECo = LogicBroker.GetReCompany(companyID); bool areEqual = expectedRECo.Equals(actualRECo); if (!areEqual) { var items = new List <RealEstateCompany>() { expectedRECo, actualRECo }; PrintObjects(items); } Assert.IsTrue(areEqual); } // GetReCompany(companyName) { int companyID = 3; var companyName = "Rapid Real Estate"; var expectedRECo = new RealEstateCompany() { CompanyID = companyID, CompanyName = companyName, Phone = "6662221111" }; var actualRECo = LogicBroker.GetReCompany(companyName); bool areEqual = expectedRECo.Equals(actualRECo); if (!areEqual) { var items = new List <RealEstateCompany>() { expectedRECo, actualRECo }; PrintObjects(items); } Assert.IsTrue(areEqual); } // GetAgent(AgentID) { var agentID = 4; var expectedAgent = new Agent() { AgentID = agentID, CompanyID = 1, CommissionPercent = 0.03m }; var actualAgent = LogicBroker.GetAgent(agentID); bool areEqual = expectedAgent.Equals(actualAgent); if (!areEqual) { var items = new List <Agent>() { expectedAgent, actualAgent }; PrintObjects(items); } Assert.IsTrue(areEqual); } // GetBuyer(BuyerID) { var buyerID = 7; var expectedBuyer = new Buyer() { BuyerID = buyerID, CreditRating = 780 }; var actualBuyer = LogicBroker.GetBuyer(buyerID); bool areEqual = expectedBuyer.Equals(actualBuyer); if (!areEqual) { var items = new List <Buyer>() { expectedBuyer, actualBuyer }; PrintObjects(items); } Assert.IsTrue(areEqual); } // GetOwner(OwnerID) { var ownerID = 7; var expectedOwner = new Owner() { OwnerID = ownerID, PreferredLender = "Unique Mortgaging" }; var actualOwner = LogicBroker.GetOwner(ownerID); bool areEqual = expectedOwner.Equals(actualOwner); if (!areEqual) { var items = new List <Owner>() { expectedOwner, actualOwner }; PrintObjects(items); } Assert.IsTrue(areEqual); } // UpdateExistingItem<Person>(person) { var updatePersonFirstName = "p1FirstName"; var updatePersonLastName = "p2LastName"; var addUpdateRemovePerson = new Person { FirstName = updatePersonFirstName, LastName = updatePersonLastName, Phone = "123456789", Email = "*****@*****.**" }; var expectedStoreResult = true; var actualStoreResult = LogicBroker.StoreItem <Person>(addUpdateRemovePerson); PrintObject <Person>(addUpdateRemovePerson, "Update Existing Item addUpdateRemovePerson."); PrintObject <bool>(actualStoreResult, "Return value from StoreItem()."); if (!actualStoreResult) { Console.WriteLine(addUpdateRemovePerson.ToString()); } Assert.AreEqual(expectedStoreResult, actualStoreResult); var personToUpdate = LogicBroker.GetPerson(updatePersonFirstName, updatePersonLastName); PrintObject <Person>(personToUpdate, "Returned Person from GetPerson(firstname, lastname)."); var expectedUpdateResult = true; var updatePerson = new Person() { PersonID = personToUpdate.PersonID, FirstName = personToUpdate.FirstName, LastName = personToUpdate.LastName, Phone = "0000000000", Email = "*****@*****.**" }; var actualUpdateResult = LogicBroker.UpdateExistingItem <Person>(updatePerson); PrintObject <bool>(actualUpdateResult, "Return value from UpdateExistingItem()."); if (actualUpdateResult) { Person resultPerson = LogicBroker.GetPerson(addUpdateRemovePerson.FirstName, addUpdateRemovePerson.LastName); Console.WriteLine(resultPerson.ToString()); } Assert.AreEqual(expectedUpdateResult, actualUpdateResult); var expectedRemoveResult = true; var actualRemoveResult = LogicBroker.RemoveEntity <Person>(updatePerson); PrintObject <bool>(actualRemoveResult, "Return value from RemoveEntity<Person>()."); if (!actualRemoveResult) { Console.WriteLine("RemoveEntity<Person>(addUpdateRemovePerson) failed."); Console.WriteLine(addUpdateRemovePerson.ToString()); } Assert.AreEqual(expectedRemoveResult, actualRemoveResult); } } #endregion LogicBrokerTests #region InitializeCollections DbPeopleCollection = new PeopleCollection <Person>(EntityLists.GetListOfPeople()); Assert.IsTrue(DbPeopleCollection.Count == 10); DbHomesCollection = new HomesCollection(EntityLists.GetTreeListOfHomes()); Assert.IsTrue(DbHomesCollection.Count == 5); DbHomesalesCollection = new HomeSalesCollection(EntityLists.GetListOfHomeSales()); Assert.IsTrue(DbHomesalesCollection.Count == 8); DbRECosCollection = new RealEstateCosCollection(EntityLists.GetTreeListOfRECompanies()); Assert.IsTrue(DbRECosCollection.Count == 4); #endregion InitializeCollections #region PeopleCollectionTests { // COUNT var expectedCount = 10; var actualCount = DbPeopleCollection.Count; Assert.AreEqual(expectedCount, actualCount); // ADD var personPerson = new Person() { FirstName = "Owen", LastName = "Owner", Phone = "123456789", Email = "*****@*****.**" }; var personAddedCount = DbPeopleCollection.Add(personPerson); PrintObject <Person>(personPerson, $"Attempted to add Person to PersonCollection. Result: { personAddedCount }."); Assert.IsTrue(personAddedCount == 1); // Add plain Person // GET (PersonID by F+L Names) int addedPersonID = 0; addedPersonID = DbPeopleCollection.GetPersonIDbyName(personPerson.FirstName, personPerson.LastName); PrintObject <int>(addedPersonID, "Returned PersonID from GetPersonIDbyName(Owen, Owner)."); Assert.IsTrue(addedPersonID > 10); // GET (Person by Person) Person addedPerson = null; addedPerson = DbPeopleCollection.Get(addedPersonID); PrintObject <Person>(addedPerson, "Returned Person from Get(addedPersonID)."); Assert.IsTrue(addedPerson != null); // UPDATE (Person's Phone) addedPerson.Phone = "3254678451"; var addedPersonUpdated = DbPeopleCollection.UpdatePerson(addedPerson); PrintObject <Person>(addedPerson, $"UpdatePerson(addedPerson) result: { addedPersonUpdated }."); Assert.IsTrue(addedPersonUpdated == 1); // UPDATE (Person as an Owner) var existingUpdatePerson = DbPeopleCollection.Get(addedPersonID); var owner = new Owner() { OwnerID = addedPerson.PersonID, PreferredLender = "Lender Test" }; existingUpdatePerson.Owner = owner; var ownerPersonUpdated = DbPeopleCollection.UpdatePerson(existingUpdatePerson); PrintObject <Person>(existingUpdatePerson, $"UpdatePerson(addedPerson) with Owner result: { ownerPersonUpdated }."); Assert.IsTrue(ownerPersonUpdated > 0); // REMOVE var updatePersonWithOwner = DbPeopleCollection.Get(addedPersonID); var personRemoved = DbPeopleCollection.Remove(updatePersonWithOwner); PrintObject <Person>(updatePersonWithOwner, $"Removing person from collection result: { personRemoved }."); Assert.IsTrue(personRemoved); // Remove Person with Owner FK // CLEAR DbPeopleCollection.Clear(); expectedCount = 0; actualCount = DbPeopleCollection.Count; // REINIT DbPeopleCollection = new PeopleCollection <Person>(EntityLists.GetListOfPeople()); Assert.IsTrue(DbPeopleCollection.Count == 10); } #endregion #region HomesCollectionTests { var newHome = new Home() { Address = "4412 153rd Ave SE", City = "Bellevue", State = "WA", Zip = "980060000" }; // GET HOME BY ADDRESS AND ZIP // var homeByAddress = DbHomesCollection.GetHome(anAddress, aZipCode); // GET HOME BY ID var homeID = 1; var homeByID = DbHomesCollection.Retreive(homeID); var expectedHome = new Home() { HomeID = 1, Address = "23 Oak St.", City = "Johnsonville", State = "CA", Zip = "955551111", OwnerID = 1 }; var expectedResult = true; var actualResult = expectedHome.Equals(homeByID); PrintObject <Home>(homeByID, "Get Home by ID Result."); PrintObject <bool>(actualResult, "Get Home by id actual result:"); Assert.AreEqual(expectedResult, actualResult); // UPDATE HOME newHome.OwnerID = 3; var actualUpdateResult = DbHomesCollection.Update(newHome); var expectedUpdateResult = 1; PrintObject <int>(actualUpdateResult, "Update Home actual update result:"); Assert.AreEqual(expectedUpdateResult, actualUpdateResult); // REMOVE HOME var expectedRemoveResult = true; var actualRemoveResult = DbHomesCollection.Remove(newHome.HomeID); PrintObject <bool>(actualRemoveResult, "Remove Home actual result:"); Assert.AreEqual(expectedRemoveResult, actualRemoveResult); // CLEAR //DbHomesCollection.Clear(); //expectedCount = 0; //actualCount = DbHomesCollection.Count; //Assert.AreEqual(expectedCount, actualCount); // REINIT DbHomesCollection = new HomesCollection(EntityLists.GetTreeListOfHomes()); var expectedCount = 5; var actualCount = DbHomesCollection.Count; PrintObject <int>(actualCount, "Actual Count of reinitialized Homes collection."); Assert.AreEqual(expectedCount, actualCount); } #endregion #region HomeSalesCollectionTests { // GET BY ID var existingSaleID = 1; var getHomesale = DbHomesalesCollection.Retreive(existingSaleID); PrintObject <HomeSale>(getHomesale, "Retreived Homesale with SaleID=1: "); var marketDate = new DateTime(2016, 08, 15); var expectedHomesale = new HomeSale() { SaleID = 6, HomeID = 3, AgentID = 4, SaleAmount = 700000m, MarketDate = new DateTime(2016, 08, 15), CompanyID = 1 }; var expectedResult = true; var actualResult = expectedHomesale.Equals(getHomesale); Assert.AreEqual(expectedResult, actualResult); // GET BY ITEM? // TODO: Implement if necessary // UPDATE E.G. SELLHOME var preNewHomesale = DbHomesalesCollection.Retreive(1); // so it can be put back into DB at end of tests PrintObject <HomeSale>(preNewHomesale, "PreNewHomesale instance, SaleID=1: "); var newHomeSale = new HomeSale() { SaleID = 1, HomeID = 3, AgentID = 4, SaleAmount = 766666m, MarketDate = new DateTime(2016, 08, 15), CompanyID = 1, SoldDate = new DateTime(2020, 08, 15), BuyerID = 1 }; var actualUpdateResult = DbHomesalesCollection.Update(newHomeSale); PrintObject <HomeSale>(newHomeSale, "NewHomeSale instance sent to Update method: "); PrintObject <int>(actualUpdateResult, "UPDATE Home as sold result: "); var expectedUpdateResult = 1; Assert.AreEqual(expectedUpdateResult, actualUpdateResult); // REMOVE var actualRemoveResult = DbHomesalesCollection.Remove(newHomeSale); PrintObject <HomeSale>(newHomeSale, "Item sent to Remove() method: "); var expectedRemoveResult = true; Assert.AreEqual(expectedRemoveResult, actualRemoveResult); // GET UPDATE REMOVEFROMMARKET (put homesale back, then remove from market) var expectedPostRemoveFromMarketCount = DbHomesalesCollection.Count; var resetHomesale = new HomeSale() { SaleID = 6, HomeID = 3, AgentID = 4, SaleAmount = 700000m, MarketDate = new DateTime(2016, 08, 15), CompanyID = 1 }; var reAddHomeForSaleToCollectionResult = DbHomesalesCollection.Add(resetHomesale); PrintObject <HomeSale>(resetHomesale, "ResetHomesale, SaleID=6, sent to Add method: "); var expectedReAddHomeForSaleToCollectionResult = 1; Assert.AreEqual(expectedReAddHomeForSaleToCollectionResult, reAddHomeForSaleToCollectionResult); var expectedPostRemoveFromMarketResult = true; var actualPostRemoveFromMarketResult = DbHomesalesCollection.Remove(resetHomesale); PrintObject <HomeSale>(resetHomesale, "ResetHomesale, SaleID=6, sent to Remove method: "); var actualPostRemoveFromMarketCount = DbHomesalesCollection.Count; Assert.AreEqual(expectedPostRemoveFromMarketResult, actualPostRemoveFromMarketResult); Assert.AreEqual(expectedPostRemoveFromMarketCount, actualPostRemoveFromMarketCount); // CLEAR // TODO: Implement Clear method if necessary. } #endregion #region RealEstateCompaniesTests { // RETREIVE var recoToRetreiveID = 3; var retreivedRECo = DbRECosCollection.Retrieve(recoToRetreiveID); var expectedRECo = new RealEstateCompany() { CompanyID = 3, CompanyName = "Rapid Real Estate", Phone = "6662221111", }; var expectedAgentsCount = 1; var expectedHomesalesCount = 2; PrintObject <RealEstateCompany>(retreivedRECo, "Expecting Rapid Real Estate. RECo retreived from Collection: "); var actualRetreivedRECoAgentsCount = retreivedRECo.Agents.Count; var actualRetreivedRECoHomesalesCount = retreivedRECo.HomeSales.Count; PrintObject <int>(actualRetreivedRECoAgentsCount, "Expected: 1; Actual AGENTS in retreived RECo instance: "); PrintObject <int>(actualRetreivedRECoHomesalesCount, "Expected: 2; Actual HOMESALES in retreived RECo instance: "); Assert.AreEqual(expectedAgentsCount, retreivedRECo.Agents.Count); Assert.AreEqual(expectedHomesalesCount, retreivedRECo.HomeSales.Count); var expectedRECoRetreiveResult = true; var actualRECoRetreiveResult = expectedRECo.Equals(retreivedRECo); PrintObject <bool>(actualRECoRetreiveResult, "Expected .Equals(): True; Actual comparison result: "); Assert.AreEqual(expectedRECoRetreiveResult, actualRECoRetreiveResult); // ADD var expectedPreCount = DbRECosCollection.Count; var recoToAdd = new RealEstateCompany() { CompanyName = "TestCompany", Phone = "2061234567" }; var expectedAddResult = 1; var actualAddResult = DbRECosCollection.Add(recoToAdd); Assert.AreEqual(expectedAddResult, actualAddResult); // SEARCH and store var recoToRemove = DbRECosCollection.Where(re => re.CompanyName == recoToAdd.CompanyName).FirstOrDefault(); if (recoToRemove == null) { Assert.Fail($"Unable to recover added RECo: { recoToAdd }"); } // Remove var expectedRemoveResult = true; var recoRemovalPreCount = DbRECosCollection.Count; var expectedPostCount = recoRemovalPreCount - 1; var actualRemoveResult = DbRECosCollection.Remove(recoToRemove.CompanyID); // this exercizes BOTH remove methods var actualPostCount = DbRECosCollection.Count; Assert.AreEqual(expectedPostCount, actualPostCount); Assert.AreEqual(expectedRemoveResult, actualRemoveResult); } #endregion } } }
public void processFile(string Filename) { //string[] Headers = "r_object_id||object_name/Correspondence Reference Number||Subject||Corr_Category||eif_project_ref||eif_type_of_doc||From_Code||eif_from||To_Code||eif_to||ecs_lc_state||eif_originator||folder_name||File Path||Rendition/Attachments||Rendition object ID||Confidential-YES/NO||Permissions/Confidentiality ||Relationship/Link||Created Date||Contract Number||Creator Name".Split("||"); StreamReader sr = new StreamReader(Filename); TempFileName = Filename; sw = new StreamWriter(TempFileName.Replace(".txt", "_result.txt"), true); Tasks = new List <Task>(); string[] Headers = sr.ReadLine().Split("||"); int RecordCount = 1; int counter = 0; string objectID = ""; while (!sr.EndOfStream) { try { string RowData = sr.ReadLine(); string[] Fields = RowData.Split("||"); CorrModel corrModel = new CorrModel(); List <Attachment> attachments = new List <Attachment>(); List <Corrdetail> corrdetails = new List <Corrdetail>(); for (int i = 0; i < Headers.Length; i++) { try { if (Headers[i].Trim() == "object_name/Correspondence Reference Number") { if (corrtype == 2) { corrModel.SendersReferencenumber = Fields[i]; corrModel.Referencenumber = "E0000-ERL-JBS-CL-XXXXX"; } else { //corrModel.SendersReferencenumber = ""; corrModel.Referencenumber = Fields[i]; } } if (Headers[i].Trim() == "r_object_id") { objectID = Fields[i].Trim(); } if (Headers[i].Trim() == "Subject") { corrModel.Subject = Fields[i]; } if (Headers[i].Trim() == "Corr_Category") { corrModel.RidCorrCategory = corrtype; // incoming correspondence } if (Headers[i].Trim() == "eif_type_of_doc") { //CL-1 //CC-2 //CM-3 if (Fields[i].Trim().Contains("CL-")) { corrModel.RidDocumenttype = 1; } else if (Fields[i].Trim().Contains("CC-")) { corrModel.RidDocumenttype = 2; } else if (Fields[i].Trim().Contains("CM-")) { corrModel.RidDocumenttype = 3; } else { //ignore this record continue; } } if (Headers[i].Trim() == "From_Code") { corrModel.SenderRidEntityList = EntityLists.Where(x => x.EntityCode == Fields[i]).First().RidEntityList; } if (Headers[i].Trim() == "To_Code") { corrModel.RecipientRidEntityList = EntityLists.Where(x => x.EntityCode == Fields[i]).First().RidEntityList; } if (Headers[i].Trim() == "ecs_lc_state") { corrModel.Status = "MIGRATED"; } if (Headers[i].Trim() == "Created Date") { corrModel.CorrespondenceDate = DateTime.Parse(Fields[i]); } if (Headers[i].Trim() == "Confidential-YES/NO") { if (Fields[i].Trim().Contains("Y")) { string[] users = Fields[i + 1].Split(","); foreach (var item in users) { try { Usermaster usermaster = Usermasters.Where(x => (x.Username) == item.Replace(" ", "")).FirstOrDefault(); if (usermaster != null) { corrdetails.Add(new Corrdetail() { Duedate = null, Include = "Y", Isactive = "Y", Ismandatory = "N", RidCommunicationtype = 1, RidCommunicationDetail = null, SignatureRequired = "N", RidWorkflowstep = (corrtype == 2 ? 2 : 4), RidUsermaster = usermaster.RidUsermaster }); } else if (item.Contains("DCC")) { corrdetails.Add(new Corrdetail() { Duedate = null, Include = "Y", Isactive = "Y", Ismandatory = "N", RidCommunicationtype = 1, RidCommunicationDetail = null, SignatureRequired = "N", RidWorkflowstep = (corrtype == 2 ? 2 : 4), RidUsermaster = Usermasters.Where(x => (x.Username) == "svc.cmsadmintest").FirstOrDefault().RidUsermaster }); } } catch (Exception) { Console.WriteLine("Error at Record Index(" + RecordCount + ") at Column Index while finding Condidential user in Userlist:" + item); throw; } } } else { } } if (Headers[i].Trim() == "Contract Number") { string[] temparr = Fields[i].Split("-"); Decimal tempContract = Contracts.Where(x => x.Contractcode == temparr[0].Trim()).First().RidContract; corrModel.RidContractlist = Convert.ToDecimal(tempContract); } if (Headers[i].Trim() == "Creator Name") { //corrModel.RidUsermaster = 81; Usermaster usermaster = Usermasters.Where(x => (x.Username) == Fields[i].Trim()).FirstOrDefault(); if (usermaster != null) { corrModel.RidUsermaster = usermaster.RidUsermaster; } else { corrModel.RidUsermaster = Usermasters.Where(x => (x.Username) == "svc.cmsadmintest").FirstOrDefault().RidUsermaster; } corrdetails.Add(new Corrdetail() { Duedate = null, Include = "Y", Isactive = "Y", Ismandatory = "N", RidCommunicationtype = 1, RidCommunicationDetail = null, SignatureRequired = "N", RidWorkflowstep = 1, RidUsermaster = corrModel.RidUsermaster }); } if (Headers[i].Trim() == "r_object_id") { objectID = Fields[i].Trim(); if (Fields[i].Trim().Length > 0) { attachments.Add(new Attachment() { ObjectID = Fields[i], Isactive = "Y" }); } } if (Headers[i].Trim() == "Rendition object ID") { if (Fields[i].Trim().Length > 0) { attachments.Add(new Attachment() { ObjectID = Fields[i], Isactive = "Y" }); } } } catch (Exception) { string logMessage = "Error at Record Index(" + RecordCount + ") at Column Index" + i; Console.WriteLine(logMessage); DataRow dataRowError = ObjectWithCorrID.NewRow(); dataRowError.SetField("RowId", RecordCount); dataRowError.SetField("ObjectId", Fields[0]); //dataRowError.SetField("RidCorr", typeof(decimal)); // dataRowError.SetField("CreateCorrJSONMessage", typeof(string)); //dataRowError.SetField("AttachmentIDs", typeof(string)); //dataRowError.SetField("CorrDetailIDs", typeof(string)); dataRowError.SetField("ErrorMessage", logMessage); ObjectWithCorrID.Rows.Add(dataRowError); RecordCount++; throw; } } corrModel.Isactive = "Y"; corrModel.Isconfidential = "N"; corrModel.Isreplyrequired = "N"; corrModel.ApprovalsRequired = "N"; if (corrtype == 2) { corrModel.RidCommunicationType = 2; } else { corrModel.RidCommunicationType = 1; } corrModel.RidGroupType = 1; corrModel.RelationRidCorr = new int[0]; Task temp = null; try { temp = Task.Run(() => MigrateRecord(RecordCount++, Fields[0], corrModel, attachments, corrdetails, corrtype)); Tasks.Add(temp); counter++; } catch (Exception ex) { Console.WriteLine(ex.Message); } try { if (counter == 5) { Task.WaitAll(Tasks.ToArray()); Tasks.Clear(); counter = 0; foreach (DataRow e in ObjectWithCorrID.Rows) { try { sw.WriteLine(e[0] + "||" + e[1] + "||" + e[2] + "||" + e[3] + "||" + e[4] + "||" + e[5] + "||" + e[6]); sw.Flush(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } ObjectWithCorrID.Rows.Clear(); } } catch (Exception ex) { Console.WriteLine(ex.Message); Tasks.Clear(); counter = 0; foreach (DataRow e in ObjectWithCorrID.Rows) { try { sw.WriteLine(e[0] + "||" + e[1] + "||" + e[2] + "||" + e[3] + "||" + e[4] + "||" + e[5] + "||" + e[6]); sw.Flush(); } catch (Exception ex2) { Console.WriteLine(ex2.Message); } } ObjectWithCorrID.Rows.Clear(); } finally { } } catch (Exception) { Console.WriteLine(objectID + ": Skipping record"); } } sr.Close(); sw.Close(); }
public bool OnCast(Character caster, string args) { #region Determine number of pets. Return false if at or above MAX_PETS. if (!caster.IsImmortal) { int petCount = 0; foreach (NPC pet in caster.Pets) { if (pet.QuestList.Count == 0) { petCount++; } } if (petCount >= GameSpell.MAX_PETS) { caster.WriteToDisplay("You do not possess the mental fortitude to summon an ally."); return(false); } } #endregion args = args.Replace(ReferenceSpell.Command, ""); args = args.Trim(); string[] sArgs = args.Split(" ".ToCharArray()); #region Determine Power int magicSkillLevel = Skills.GetSkillLevel(caster.magic); int power = magicSkillLevel; if (sArgs.Length > 0) { try { power = Convert.ToInt32(sArgs[0]); if (power > magicSkillLevel && !caster.IsImmortal) { power = magicSkillLevel; } } catch (Exception) { power = magicSkillLevel; } } if (power < 1) { power = caster.Level; } #endregion Entity entity = Entity.Fighter; Enum.TryParse(caster.BaseProfession.ToString(), true, out entity); EntityBuilder builder = new EntityBuilder(); string profession = entity.ToString().ToLower(); if (!EntityLists.IsHuman(caster) || Rules.RollD(1, 100) < 50) { string entityLowerCase = caster.entity.ToString().ToLower(); if (entityLowerCase.StartsWith("drow")) { entity = Entity.Drow; // Drow.Master summons drow thieves, Drow.Matriarch summons drow priestesses unless uncomment below lines //List<string> availableProfessions = new List<string>() {"anathema", "cleric", "ravager", "rogue", "sorcerer" }; //profession = availableProfessions[Rules.Dice.Next(0, availableProfessions.Count - 1)]; } else if (EntityLists.ELVES.Contains(caster.entity)) { List <Entity> allyEntities = new List <Entity>() { Entity.Grey_Elf, Entity.High_Elf, Entity.Wood_Elf }; } else { List <Entity> allyEntities = new List <Entity>() { Entity.Gnome, Entity.Goblin, Entity.Kobold, Entity.Orc, Entity.Tengu, }; entity = allyEntities[Rules.Dice.Next(0, allyEntities.Count - 1)]; } //profession = EntityBuilder.THIEF_SYNONYMS[Rules.Dice.Next(0, EntityBuilder.THIEF_SYNONYMS.Length - 1)]; } NPC ally = builder.BuildEntity("allied", entity, caster.Map.ZPlanes[caster.Z], profession); // Set level. ally.Level = Math.Max(caster.Level, magicSkillLevel) + Rules.Dice.Next(-1, 1); // magic skill should be set to higher skill if using impcast if (ally.Level <= 0) { ally.Level = 1; } builder.SetOnTheFlyVariables(ally); ally.Alignment = caster.Alignment; builder.SetName(ally, profession); builder.SetDescriptions("allied", ally, caster.Map.ZPlanes[caster.Z], ally.BaseProfession.ToString().ToLower()); EntityBuilder.SetGender(ally, caster.Map.ZPlanes[caster.Z]); EntityBuilder.SetVisualKey(ally.entity, ally); if (ally.spellDictionary.Count > 0) { ally.magic = Skills.GetSkillForLevel(ally.Level + Rules.Dice.Next(-1, 1)); } GameSpell.FillSpellLists(ally); if (EntityLists.IsHumanOrHumanoid(ally)) { List <int> armorToWear; if (power <= 13) { armorToWear = Autonomy.ItemBuilding.ArmorSets.ArmorSet.ArmorSetDictionary[Autonomy.ItemBuilding.ArmorSets.ArmorSet.FULL_STUDDED_LEATHER].GetArmorList(ally); } else if (power < 16) { armorToWear = Autonomy.ItemBuilding.ArmorSets.ArmorSet.ArmorSetDictionary[Autonomy.ItemBuilding.ArmorSets.ArmorSet.FULL_CHAINMAIL].GetArmorList(ally); } else { armorToWear = Autonomy.ItemBuilding.ArmorSets.ArmorSet.ArmorSetDictionary[Autonomy.ItemBuilding.ArmorSets.ArmorSet.FULL_BANDED_MAIL].GetArmorList(ally); } foreach (int id in armorToWear) { Item armor = Item.CopyItemFromDictionary(id); // It's basic armor sets only. Label them as ethereal. (They will go back with the phantasm to their home plane. Given items drop.) armor.special += " " + Item.EXTRAPLANAR; ally.WearItem(armor); } } if (EntityLists.IsHumanOrHumanoid(ally) || EntityLists.ANIMALS_WIELDING_WEAPONS.Contains(ally.entity)) { List <int> weaponsList = Autonomy.ItemBuilding.LootManager.GetBasicWeaponsFromArmory(ally, true); if (weaponsList.Count > 0) { ally.EquipRightHand(Item.CopyItemFromDictionary(weaponsList[Rules.Dice.Next(weaponsList.Count - 1)])); } weaponsList = Autonomy.ItemBuilding.LootManager.GetBasicWeaponsFromArmory(ally, false); if (weaponsList.Count > 0) { ally.EquipLeftHand(Item.CopyItemFromDictionary(weaponsList[Rules.Dice.Next(weaponsList.Count - 1)])); } if (ally.RightHand != null) { ally.RightHand.special += " " + Item.EXTRAPLANAR; } if (ally.LeftHand != null) { ally.LeftHand.special += " " + Item.EXTRAPLANAR; } } ally.Hits = ally.HitsFull; ally.Mana = ally.ManaFull; ally.Stamina = ally.StaminaFull; ally.Age = GameWorld.World.AgeCycles[Rules.Dice.Next(0, GameWorld.World.AgeCycles.Count - 1)]; ally.special = "despawn summonthief"; int oneMinute = Utils.TimeSpanToRounds(new TimeSpan(0, 1, 0)); // 10 minutes + 2 minutes for every skill level past 3 ally.RoundsRemaining = (oneMinute * 5) + ((power - ReferenceSpell.RequiredLevel) * oneMinute); //ally.species = Globals.eSpecies.Magical; // this may need to be changed for AI to work properly ally.canCommand = true; ally.IsMobile = true; ally.IsSummoned = true; ally.IsUndead = false; ally.FollowID = caster.UniqueID; ally.PetOwner = caster; caster.Pets.Add(ally); if (ally.CurrentCell != caster.CurrentCell) { ally.CurrentCell = caster.CurrentCell; } ReferenceSpell.SendGenericCastMessage(caster, null, true); ally.EmitSound(ally.idleSound); caster.WriteToDisplay((ally.longDesc.StartsWith("evil") ? "An " : "A ") + ally.longDesc + " answers your call for assistance."); caster.SendToAllInSight(caster.GetNameForActionResult() + " summons an ally."); if (caster is NPC) { ally.MostHated = (caster as NPC).MostHated; } ally.AddToWorld(); return(true); }