// private static int BattleRatingExp(int petLevel, int petHP, int petType, int enemytype, int enemylevel) // { // var advantage = 0; // var disadvantage = 0; // // var mypet = petType; // // //Logging.Write("Pet Type : " + mypet); // int rating; // //Logging.Write("target type " + enemytype); // if (mypet == DumbChoiceTakeMoreDMG(enemytype)) disadvantage = -2; // // if (mypet == DumbChoiceDealLessDMG(enemytype)) disadvantage = disadvantage - 1; //rating -1; // if (mypet == SmartChoiceTakeLessDMG(enemytype)) advantage = 1; // // if (mypet == SmartChoiceDealMoreDMG(enemytype)) advantage = advantage + 2; // // /*****************************************/ // // var s = "1 + 1 * 3"; // // Calculate(s); // int total; // // //pet 1 // // var HPformula = "petHP * HPFactor"; // s = HPformula; // var hpFactor = PetBattleEasy.HpFactor.ToString(); // s = s.Replace("petHP", petHP.ToString()).Replace("HPFactor", hpFactor); // // var hPresult = Calculate(s); // total = Int32.Parse(hPresult.ToString()); // // s = "advantage * 50 * AdFactor"; // var adFactor = PetBattleEasy.AdFactor.ToString(); // s = s.Replace("advantage", advantage.ToString()).Replace("AdFactor", adFactor); // // var adresult = Calculate(s); // total = total + Int32.Parse(adresult.ToString()); // // s = "disadvantage * 50 * DisFactor"; // var disFactor = PetBattleEasy.DisFactor.ToString(); // s = s.Replace("disadvantage", disadvantage.ToString()).Replace("DisFactor", disFactor); // // var disresult = Calculate(s); // total = total + Int32.Parse(disresult.ToString()); // // s = "(petLevel - enemylevel) * 4 * LevelFactor"; // s = // s.Replace("petLevel", petLevel.ToString()) // .Replace("enemylevel", enemylevel.ToString()) // .Replace("LevelFactor", "0"); // // var levelresult = Calculate(s); // total = total + Int32.Parse(levelresult.ToString()); // // rating = total; // // if (petHP < 30) rating = rating - 10000; // if (petHP < 15) rating = rating - 40000; // if (petHP < 5) rating = rating - 50000; // // return rating; // } /* * private static int Calculate(string s) * { * var ce = new CE.CalcEngine(); * var x = ce.Parse(s); * * var value = x.Evaluate(); * return Int32.Parse(value.ToString(), CultureInfo.InvariantCulture); * } */ public static void CheckingPetForCell() { var listall = new Tournamet().NeedPets; foreach (var i in listall) { var pet = GetPetFromEntryID(i); if (pet.IsValid) { Logging.Write(pet.Name + " есть."); } if (!pet.IsValid) { Logging.Write(i + " отсутсвует в списке петов."); } } }
public static void SetPetForEncounter() { var id = 0; if (ObjectManager.Target != null) { id = ObjectManager.Target.Entry; } var objectType = new Tournamet(); var name = "Npc" + id; var methodInfo = objectType.GetType().GetField(name); if (methodInfo != null) { Logging.Write(Color.MediumSpringGreen, "Найдены петы для ID:{0} ", id); List <int> list = methodInfo.GetValue(objectType) as List <int>; var inx = 1; foreach (var str in from object str in (IEnumerable)list where str != null select str) { var originalid = (int)str; Logging.Write(str.ToString()); var pet = GetPetFromEntryID(originalid); if (pet.IsValid) { BattlePet.PetJournal.SetPetToSlot(inx, pet.PetID); } if (!pet.IsValid && objectType.PetsForChange.ContainsKey(originalid)) { Logging.Write("Есть замена"); var newid = objectType.PetsForChange.FirstOrDefault(key => key.Key == originalid).Value; Logging.Write(newid.ToString()); var newpet = GetPetFromEntryID(newid); Logging.Write(newpet.Name); if (newpet.IsValid) { BattlePet.PetJournal.SetPetToSlot(inx, newpet.PetID); } } inx++; } } }