private bool AlreadySelected( Pet pet) { for( int i=0; i<3; i++) { string petId = _selectedpets[i].pet.PetId; if (!string.IsNullOrEmpty(petId) && petId == pet.PetId) { return true; } } return false; }
public Pet( Pet pet) { // TODO: make this thing normal _petLua = pet._petLua; Level = pet.Level; PetId = pet.PetId; SpeciesID = pet.SpeciesID; CreatureID = pet.CreatureID; _health = pet.Health; _maxHealth = pet.MaxHealth; _attack = pet.Attack; _speed = pet.Speed; IsWild = pet.IsWild; CanBattle = pet.CanBattle; _rarity = pet.Rarity; _isFav = pet.IsFav; PROTECTEDfromreleasing = pet.PROTECTEDfromreleasing; Name = pet.Name; _statsAreLoaded = pet._statsAreLoaded; }
private List<Pet> LoadFromJournal() { List<Pet> ownedPets = new List<Pet>(); int partsize = 10; int PetsOwned = _petLua.GetNumPets(); if (PetsOwned == 0) { Logger.Write("0 pets in journal."); return ownedPets; } int remaining = (PetsOwned - 1) % partsize; int maxportions = ((PetsOwned - 1) / partsize) + 1; string[] AllCollectedPetFullData; //string additionlreporttext = ""; for (uint k = 0; k < maxportions; k++) { List<string> List1 = null; for (uint t = 0; t < 1; t++) { int currentportionsize = ((k == maxportions - 1) ? remaining : partsize - 1); List1 = _petLua.GetPetInfoByIndex(partsize, k, currentportionsize); if (List1 == null) { continue; } break; } if (List1 == null) continue; AllCollectedPetFullData = List1.ToArray(); for (int i = 0; i < AllCollectedPetFullData.Count(); i++) { if (AllCollectedPetFullData[i] == "----------") { Pet pd = new Pet(_petLua); pd.PROTECTEDfromreleasing = true; for (int j = 1; j < 25; j++) { if (i + j >= AllCollectedPetFullData.Count()) break; if (AllCollectedPetFullData[i + j] == "----------") break; if (j == 1) { pd.PetId = AllCollectedPetFullData[i + j]; } if (j == 2) pd.SpeciesID = AllCollectedPetFullData[i + j].ToInt32(); if (j == 5) pd.Level = AllCollectedPetFullData[i + j].ToInt32(); if (j == 6) pd.IsFav = AllCollectedPetFullData[i + j].ToBoolean(); if (j == 8) pd.Name = AllCollectedPetFullData[i + j]; if (j == 11) pd.CreatureID = AllCollectedPetFullData[i + j].ToInt32(); if (j == 12) if ((AllCollectedPetFullData[i + j].IndexOf("Áèòâû ïèòîìöåâ") >= 0) || (AllCollectedPetFullData[i + j].IndexOf("battles") >= 0)) pd.PROTECTEDfromreleasing = false; if (j == 12) if (AllCollectedPetFullData[i + j].IndexOf("UI-GOLDICON") >= 0) pd.PROTECTEDfromreleasing = true; if (j == 12) if (AllCollectedPetFullData[i + j].IndexOf("UI-SILVERICON") >= 0) pd.PROTECTEDfromreleasing = true; if (j == 12) if (AllCollectedPetFullData[i + j].IndexOf("MONEYFRAME") >= 0) pd.PROTECTEDfromreleasing = true; if (j == 12) if ((AllCollectedPetFullData[i + j].IndexOf("Ïðîôåññèÿ") >= 0) || (AllCollectedPetFullData[i + j].IndexOf("rofess") >= 0)) pd.PROTECTEDfromreleasing = true; if (j == 12) if ((AllCollectedPetFullData[i + j].IndexOf("Äîñòèæåíèå") >= 0) || (AllCollectedPetFullData[i + j].IndexOf("chiev") >= 0)) pd.PROTECTEDfromreleasing = true; if (j == 12) if ((AllCollectedPetFullData[i + j].IndexOf("ÿéöî") >= 0) || (AllCollectedPetFullData[i + j].IndexOf("egg") >= 0)) pd.PROTECTEDfromreleasing = true; if (j == 14) pd.IsWild = AllCollectedPetFullData[i + j].ToBoolean(); if (j == 15) pd.CanBattle = AllCollectedPetFullData[i + j].ToBoolean(); } ownedPets.Add(pd); } }; } return ownedPets; }
public void PopulatePetJournal() { Logger.Write("Populating pet journal..."); using (StyxWoW.Memory.AcquireFrame()) { try { _petLua.SetFilterAllCollectedPets(); _ownedPetsList = LoadFromJournal(); Logger.Write("Owned pets journal count: " + _ownedPetsList.Count); // TODO: leave sort order as is? //_ownedPetsList.Sort(delegate(Pet p1, Pet p2) { return p1.Name.CompareTo(p2.Name); }); _ownedPetsList.Sort(delegate(Pet p1, Pet p2) { return p1.Level-p2.Level; }); _favouritePetsList = new List<Pet>(); foreach (Pet pet in _ownedPetsList) // TODO: Select ToList { if (pet.IsFav) { Pet pf = new Pet(pet); _favouritePetsList.Add(pf); } } Logger.Write("Favourite pets journal count: " + _favouritePetsList.Count); if (_pluginProperties.Mode != eMode.Capture) // TODO: what's wrong with capture { WritePetsByLevel(); } } catch { Logger.Write("Journal init query fail!!! "); try { int PetCount = _petLua.GetNumPets(); int PetsOwned = _petLua.GetNumPetsOwned(); Logger.Write("Query too large?? " + PetsOwned + "," + PetCount); } catch { Logger.Write("simple C_PetJournal.GetNumPets function failed. Try in WoW: \n/run local numPets, numOwned = C_PetJournal.GetNumPets(false); print('Journal: pet count:' .. tostring(numOwned) .. ' total:' .. tostring(numPets));"); } } } }
private List <Pet> LoadFromJournal() { List <Pet> ownedPets = new List <Pet>(); int partsize = 10; int PetsOwned = _petLua.GetNumPets(); if (PetsOwned == 0) { Logger.Write("0 pets in journal."); return(ownedPets); } int remaining = (PetsOwned - 1) % partsize; int maxportions = ((PetsOwned - 1) / partsize) + 1; string[] AllCollectedPetFullData; //string additionlreporttext = ""; for (uint k = 0; k < maxportions; k++) { List <string> List1 = null; for (uint t = 0; t < 1; t++) { int currentportionsize = ((k == maxportions - 1) ? remaining : partsize - 1); List1 = _petLua.GetPetInfoByIndex(partsize, k, currentportionsize); if (List1 == null) { continue; } break; } if (List1 == null) { continue; } AllCollectedPetFullData = List1.ToArray(); for (int i = 0; i < AllCollectedPetFullData.Count(); i++) { if (AllCollectedPetFullData[i] == "----------") { Pet pd = new Pet(_petLua); pd.PROTECTEDfromreleasing = true; for (int j = 1; j < 25; j++) { if (i + j >= AllCollectedPetFullData.Count()) { break; } if (AllCollectedPetFullData[i + j] == "----------") { break; } if (j == 1) { pd.PetId = AllCollectedPetFullData[i + j]; } if (j == 2) { pd.SpeciesID = AllCollectedPetFullData[i + j].ToInt32(); } if (j == 5) { pd.Level = AllCollectedPetFullData[i + j].ToInt32(); } if (j == 6) { pd.IsFav = AllCollectedPetFullData[i + j].ToBoolean(); } if (j == 8) { pd.Name = AllCollectedPetFullData[i + j]; } if (j == 11) { pd.CreatureID = AllCollectedPetFullData[i + j].ToInt32(); } if (j == 12) { if ((AllCollectedPetFullData[i + j].IndexOf("Áèòâû ïèòîìöåâ") >= 0) || (AllCollectedPetFullData[i + j].IndexOf("battles") >= 0)) { pd.PROTECTEDfromreleasing = false; } } if (j == 12) { if (AllCollectedPetFullData[i + j].IndexOf("UI-GOLDICON") >= 0) { pd.PROTECTEDfromreleasing = true; } } if (j == 12) { if (AllCollectedPetFullData[i + j].IndexOf("UI-SILVERICON") >= 0) { pd.PROTECTEDfromreleasing = true; } } if (j == 12) { if (AllCollectedPetFullData[i + j].IndexOf("MONEYFRAME") >= 0) { pd.PROTECTEDfromreleasing = true; } } if (j == 12) { if ((AllCollectedPetFullData[i + j].IndexOf("Ïðîôåññèÿ") >= 0) || (AllCollectedPetFullData[i + j].IndexOf("rofess") >= 0)) { pd.PROTECTEDfromreleasing = true; } } if (j == 12) { if ((AllCollectedPetFullData[i + j].IndexOf("Äîñòèæåíèå") >= 0) || (AllCollectedPetFullData[i + j].IndexOf("chiev") >= 0)) { pd.PROTECTEDfromreleasing = true; } } if (j == 12) { if ((AllCollectedPetFullData[i + j].IndexOf("ÿéöî") >= 0) || (AllCollectedPetFullData[i + j].IndexOf("egg") >= 0)) { pd.PROTECTEDfromreleasing = true; } } if (j == 14) { pd.IsWild = AllCollectedPetFullData[i + j].ToBoolean(); } if (j == 15) { pd.CanBattle = AllCollectedPetFullData[i + j].ToBoolean(); } } ownedPets.Add(pd); } } ; } return(ownedPets); }
private Pet SelectPetForSlot(int slot, int Level) // 0-2 { eMode mode = _pluginProperties.Mode; bool isRinger = (slot == 1 && mode == eMode.Ringerx2) || (slot == 2 && (mode == eMode.Ringer || mode == eMode.Ringerx2)); int minLevel = Level; if (slot == 1) { minLevel += mode == eMode.Ringerx2 ? PluginSettings.ModeInfo.Pet3_Diff : PluginSettings.ModeInfo.Pet2_Diff; //Logger.WriteDebug("Slot " + (slot + 1) + ": Added Pet2_Diff" + (eMode.Ringerx2 ? PluginSettings.ModeInfo.Pet3_Diff : PluginSettings.ModeInfo.Pet2_Diff) + ", result =" + minLevel); } else if (slot == 2) { minLevel += PluginSettings.ModeInfo.Pet3_Diff; //Logger.WriteDebug("Slot " + (slot + 1) + ": Added Pet3_Diff" + PluginSettings.ModeInfo.Pet3_Diff + ", result =" + minLevel); } minLevel = ValidLevel(minLevel); //Logger.WriteDebug("Slot " + (slot + 1) + ": Applied ValidLevel, result =" + minLevel); int maxLevel = _pluginProperties.MaxLevel; if (maxLevel < minLevel) { maxLevel = minLevel; } if (mode == eMode.Capture) { maxLevel = 25; } Pet pet = SelectPet(slot, minLevel, maxLevel, isRinger, true); if (pet != null) { return(pet); } // try some corrections, like: if (isRinger && maxLevel < 25) { Logger.WriteDebug("Slot " + (slot + 1) + ": Trying to increase the level for the Ringer"); maxLevel = 25; pet = SelectPet(slot, minLevel, maxLevel, isRinger, true); if (pet != null) { return(pet); } } if (minLevel > PluginSettings.Instance.MinLevel) { Logger.WriteDebug("Slot " + (slot + 1) + ": Trying to consider lower level pets, ignoring mode diff"); for (int i = minLevel; i >= PluginSettings.Instance.MinLevel; i--) // going down { pet = SelectPet(slot, i, i, isRinger, true); if (pet != null) { return(pet); } } } Pet candidate = null; Logger.WriteDebug("Slot " + (slot + 1) + ": Checking non-healthy pets, ignoring health"); pet = SelectPet(slot, minLevel, maxLevel, isRinger, false); if (pet != null) { if (pet.Health > 0) { return(pet); } candidate = pet; } // candidate not found or has 0 health, checking lower-level if (minLevel > PluginSettings.Instance.MinLevel) { Logger.WriteDebug("Slot " + (slot + 1) + ": Checking lower level non-healthy pets"); for (int i = minLevel; i >= PluginSettings.Instance.MinLevel; i--) // going down { pet = SelectPet(slot, i, i, isRinger, false); if (pet != null) { if (candidate == null || pet.Health > candidate.Health) { candidate = pet; } } } } if (candidate != null) { Logger.WriteDebug("Slot " + (slot + 1) + ": Using non-healthy with highest health"); return(candidate); } Logger.Write("Slot " + (slot + 1) + ": Failed to obtain any pets"); return(null); }
private Pet SelectPet(int slot, int minPetLevel, int maxPetLevel, bool isRingerSelection, bool healthyNeeded) { List <Pet> petsList = _petJournal.OwnedPetsList; if (isRingerSelection && PluginSettings.Instance.UseFavouriteRingers && _petJournal.FavouritePetsList != null) { Wd("Fav Ringers"); petsList = _petJournal.FavouritePetsList; } else if (!isRingerSelection && PluginSettings.Instance.UseFavouritePetsOnly && _petJournal.FavouritePetsList != null) { Wd("Fav all"); petsList = _petJournal.FavouritePetsList; } Logger.WriteDebug(string.Format("Slot " + (slot + 1) + ": Asked to select [{0}-{1}], ringer={2}, healthy={3}", minPetLevel, maxPetLevel, isRingerSelection, healthyNeeded)); //find the lowest available pet which matches the criteria Pet candidate = null; //for (int level = minPetLevel; level <= maxPetLevel; level++) - we have sorted by level { foreach (Pet availablePet in petsList) { if (availablePet.Level > maxPetLevel) { Wd("Max level " + maxPetLevel + " reached. Exit."); return(candidate); } Wd("Checking " + availablePet.Name + ", level=" + availablePet.Level + (availablePet.IsRare ? ", Blue" : "")); if (availablePet.Level < minPetLevel) { Wd("too low"); continue; } if (AlreadySelected(availablePet)) { Wd("already selected"); continue; } //already selected if (!availablePet.IsEquipable) { Wd("not eqipable"); continue; } // not equippable if (availablePet.IsWild && !_pluginProperties.UseWildPets && (!isRingerSelection)) { Wd("wild"); continue; } // is wild if (!availablePet.CanBattle) { Wd("Can't battle"); continue; } // can't battle if (_blacklistForSelection.Contains(availablePet.PetId)) { Wd("Blacklisted"); continue; } // black listed if (minPetLevel <= availablePet.Level && availablePet.Level <= maxPetLevel) { if (healthyNeeded && availablePet.HealthPercentage < _pluginProperties.MinPetHealth && !isRingerSelection) { Wd("health levelled"); continue; } // health too low if (healthyNeeded && availablePet.HealthPercentage < _pluginProperties.MinRingerPetHealth && isRingerSelection) { Wd("Health Ringer"); continue; } // health too low if (_pluginProperties.OnlyBluePets && !availablePet.IsRare && (!isRingerSelection)) { Wd("not blue"); continue; } // not rare if (availablePet.Name == "Elekk Plushie") { Wd("Elekk Plushie"); continue; } if (availablePet.IsSummonable() || availablePet.Health == 0) { Wd("selected"); if (healthyNeeded) { return(availablePet); } else if (candidate == null || (candidate.HealthPercentage < availablePet.HealthPercentage)) { Wd("candidate replaced"); candidate = availablePet; } } else { Logger.Write("Slot " + (slot + 1) + ": Can't Summon pet " + availablePet.ToString() + "... blacklisting it."); _blacklistForSelection.Add(availablePet.PetId); } } else { Wd(string.Format("level {0} not in [{1}-{2}]", availablePet.Level, minPetLevel, maxPetLevel)); } } } return(candidate); }