/*public void initApiary(){ * Image[] images = GameObject.Find("Canvas").GetComponentsInChildren<Image>(); * Debug.Log(images[16].name); * apiaryWindow = images[16].gameObject; * }*/ //this is ugly as but the logic all chacks out public void initVars() { breedTimer = 0; breed = apiaryWindow.GetComponentInChildren <Breeding>(); Button[] temp = apiaryWindow.GetComponentsInChildren <Button>(); breedText = temp[temp.Length - 2].GetComponentInChildren <Text>(); RawImage[] tiles = apiaryWindow.GetComponentsInChildren <RawImage>(); int offset = bees.Count; beeSlotOne = tiles[offset + 1]; beeSlotTwo = tiles[offset + 3]; resultOne = tiles[offset + 4]; resultOneButton = resultOne.GetComponentInChildren <Button>(); resultOneButton.onClick.AddListener(delegate { AudioManager.audioManager.playSound("button"); }); resultTwo = tiles[offset + 5]; resultTwoButton = resultTwo.GetComponentInChildren <Button>(); resultTwoButton.onClick.AddListener(delegate { AudioManager.audioManager.playSound("button"); }); resultThree = tiles[offset + 6]; resultThreeButton = resultThree.GetComponentInChildren <Button>(); resultThreeButton.onClick.AddListener(delegate { AudioManager.audioManager.playSound("button"); }); honeyResultText = tiles[tiles.Length - 1]; Image[] gm = apiaryWindow.GetComponentsInChildren <Image>(); toolTip = gm[gm.Length - 1].gameObject; apiaryDoneText = GameObject.Find("Canvas").GetComponentInChildren <Button>().GetComponentInChildren <Text>(); beeTruth = new Dictionary <string, bool>(); }
public async Task <IActionResult> Edit(int id, [Bind("Id,DogRace,DogName,BirthDate")] Breeding breeding) { if (id != breeding.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(breeding); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BreedingExists(breeding.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(breeding)); }
static void Main(string[] args) { World world = new World(); Aging aging = new Aging(); Breeding breeding = new Breeding(); world.Laws.Add(aging); world.Laws.Add(breeding); Plant firstPlant = new Plant(); firstPlant.Position = new Vector3(0.0f, 0.0f, 0.0f); firstPlant.Age = 0; firstPlant.MaxAge = 101; firstPlant.MaxBreedingNumber = 2; firstPlant.BreedingAge = 50; firstPlant.BreedingPeriod = 50; firstPlant.ChildSpreadingRadius = 5.0f; world.Objects.Add(firstPlant); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); world.Start(); stopwatch.Stop(); System.Console.WriteLine(stopwatch.ElapsedMilliseconds); }
// // GET: /Birth/Delete/5 public ActionResult Delete(Int32 id) { Birth birth = db.Births.FirstOrDefault(m => m.id == id); if (birth == null) { return(HttpNotFound()); } int userID = (int)Membership.GetUser().ProviderUserKey; Breeding breeding = db.Breedings.Find(birth.breed_id); if (breeding == null) { return(HttpNotFound()); } breeding.Animal = db.Animals.Find(breeding.father_id); if ((!User.IsInRole("admin")) && breeding.Animal.UserProfile.UserId != userID) { return(HttpNotFound()); } BirthViewModel bvm = new BirthViewModel(); bvm.birth = birth; bvm.offspring_tag = birth.Animal.tag; bvm.father_tag = db.Animals.Find(db.Breedings.Find(birth.breed_id).father_id).tag; bvm.mother_tag = db.Animals.Find(db.Breedings.Find(birth.breed_id).mother_id).tag; return(View(bvm)); }
public ActionResult Edit(Breeding breeding) { int userID = (int)Membership.GetUser().ProviderUserKey; if (ModelState.IsValid) { db.Entry(breeding).State = EntityState.Modified; try { db.SaveChanges(); } catch { return(RedirectToAction("Error", "Home")); } return(RedirectToAction("Index")); } BreedingViewModel bvm = new BreedingViewModel(); bvm.breeding = breeding; bvm.father_name = db.Animals.Find(breeding.father_id).name; bvm.mother_name = db.Animals.Find(breeding.mother_id).name; bvm.father_tag = db.Animals.Find(breeding.father_id).tag; bvm.mother_tag = db.Animals.Find(breeding.mother_id).tag; return(View(bvm)); }
public ActionResult updateLitter(Breeding breeding) { if (ModelState.IsValid) { if (breeding.alive > breeding.born) { BreedingViewModel bv = new BreedingViewModel(); bv.breeding = breeding; ModelState.AddModelError("", "The number of animals alive in this litter must be less than the number born."); return(View(bv)); } db.Entry(breeding).State = EntityState.Modified; try { db.SaveChanges(); } catch { return(RedirectToAction("Error", "Home")); } return(RedirectToAction("Index", new { id = breeding.id })); } BreedingViewModel bvm = new BreedingViewModel(); bvm.breeding = breeding; return(View(bvm)); }
void Start() { breeding = GameObject.FindWithTag("Breeding").GetComponent <Breeding> (); chromo1 = new List <Chromosome> (); chromo2 = new List <Chromosome> (); for (int i = 0; i < chromoCount; i++) { Chromosome newChromosome = new Chromosome(); for (int j = 0; j < genes.Count; j++) { newChromosome.AddToGeneList(genes [j]); } chromo1.Add(newChromosome); } for (int i = 0; i < chromoCount; i++) { Chromosome newChromosome = new Chromosome(); for (int j = 0; j < genes.Count; j++) { newChromosome.AddToGeneList(genes [j]); } chromo2.Add(newChromosome); } animal.SetChromosomes(chromo1, chromo2); }
public TIndividual Run(XFitnessFunction <TChromosome> fitnessFunction) { int generation = 0; var reproductionGroup = new List <TIndividual>(); var currentPopulationsChromosomes = PopulationInitializer.Initialize(); IReadOnlyList <TIndividual> currentPopulation = currentPopulationsChromosomes.Select( chromosome => IndividualFactory.CreateIndividual(chromosome, fitnessFunction) ).ToList(); var bestSolution = currentPopulation[0]; foreach (var individual in currentPopulation) { if (individual.Fitness > bestSolution.Fitness) { bestSolution = individual; } } while (ContinueCondition.ShouldContinue(currentPopulation, generation)) { var pairs = Breeding.Select(currentPopulation); reproductionGroup.Clear(); foreach (var Compound in pairs.Select(pair => Crossover.Crossover(pair))) { reproductionGroup.AddRange( Compound .Select(chromosome => Mutation.Mutate(chromosome)) .Select(mutant => IndividualFactory.CreateIndividual(mutant, fitnessFunction))); } foreach (var individual in reproductionGroup) { if (individual.Fitness > bestSolution.Fitness) { bestSolution = individual; } } currentPopulation = Strategy.NextGeneration( currentPopulation, reproductionGroup ); generation++; } return(bestSolution); }
public async Task <IActionResult> Create([Bind("Id,DogRace,DogName,BirthDate")] Breeding breeding) { if (ModelState.IsValid) { _context.Add(breeding); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(breeding)); }
public static async Task ReplyWithLegalizedSetAsync(this ISocketMessageChannel channel, ITrainerInfo sav, ShowdownSet set) { if (set.Species <= 0) { await channel.SendMessageAsync("Oops! I wasn't able to interpret your message! If you intended to convert something, please double check what you're pasting!").ConfigureAwait(false); return; } try { var template = AutoLegalityWrapper.GetTemplate(set); var pkm = sav.GetLegal(template, out var result); if (pkm is PK8 && pkm.Nickname.ToLower() == "egg" && Breeding.CanHatchAsEgg(pkm.Species)) { TradeExtensions <PK8> .EggTrade(pkm); } else if (pkm is PB8 && pkm.Nickname.ToLower() == "egg" && Breeding.CanHatchAsEgg(pkm.Species)) { TradeExtensions <PB8> .EggTrade(pkm); } var la = new LegalityAnalysis(pkm); var spec = GameInfo.Strings.Species[template.Species]; if (!la.Valid) { var reason = result == "Timeout" ? $"That {spec} set took too long to generate." : $"I wasn't able to create a {spec} from that set."; var imsg = $"Oops! {reason}"; if (result == "Failed") { imsg += $"\n{AutoLegalityWrapper.GetLegalizationHint(template, sav, pkm)}"; } await channel.SendMessageAsync(imsg).ConfigureAwait(false); return; } var msg = $"Here's your ({result}) legalized PKM for {spec} ({la.EncounterOriginal.Name})!"; await channel.SendPKMAsync(pkm, msg + $"\n{ReusableActions.GetFormattedShowdownText(pkm)}").ConfigureAwait(false); } catch (Exception ex) { LogUtil.LogSafe(ex, nameof(AutoLegalityExtensionsDiscord)); var msg = $"Oops! An unexpected problem happened with this Showdown Set:\n```{string.Join("\n", set.GetSetLines())}```"; await channel.SendMessageAsync(msg).ConfigureAwait(false); } }
public static EggSource6[] Validate(int generation, int species, int form, GameVersion version, ReadOnlySpan <int> moves, out bool valid) { var count = moves.IndexOf(0); if (count == 0) { valid = false; // empty moveset return(Array.Empty <EggSource6>()); } if (count == -1) { count = moves.Length; } var learn = GameData.GetLearnsets(version); var table = GameData.GetPersonal(version); var index = table.GetFormIndex(species, form); var learnset = learn[index]; var egg = MoveEgg.GetEggMoves(generation, species, form, version); var actual = new EggSource6[count]; Span <byte> possible = stackalloc byte[count]; var value = new BreedInfo <EggSource6>(actual, possible, learnset, moves, level); if (species is (int)Species.Pichu && moves[count - 1] is (int)Move.VoltTackle) { actual[--count] = VoltTackle; } if (count == 0) { valid = VerifyBaseMoves(value); } else { bool inherit = Breeding.GetCanInheritMoves(species); MarkMovesForOrigin(value, egg, count, inherit); valid = RecurseMovesForOrigin(value, count - 1); } if (!valid) { CleanResult(actual, possible); } return(value.Actual); }
public static int[] GetEggMoves(PersonalInfo pi, int species, int form, GameVersion version, int generation) { if (species > GetMaxSpeciesOrigin(generation, version)) { return(Array.Empty <int>()); } if (pi.Genderless && !FixedGenderFromBiGender.Contains(species)) { return(Array.Empty <int>()); } if (!Breeding.CanGameGenerateEggs(version)) { return(Array.Empty <int>()); } return(GetEggMoves(generation, species, form, version)); }
public static IEnumerable <EncounterEgg> GenerateEggs(PKM pk, EvoCriteria[] chain, bool all = false) { int species = pk.Species; if (!Breeding.CanHatchAsEgg(species)) { yield break; } var canBeEgg = all || GetCanBeEgg(pk); if (!canBeEgg) { yield break; } // Gen2 was before split-breed species existed; try to ensure that the egg we try and match to can actually originate in the game. // Species must be < 251 // Form must be 0 (Unown cannot breed). var baseID = chain[^ 1];
public ActionResult DeleteConfirmed(Int32 id) { Breeding breeding = db.Breedings.Find(id); var births = db.Births.Include(a => a.Animal.UserProfile).Where(b => b.breed_id == id); db.Breedings.Remove(breeding); foreach (Birth bi in births) { db.Births.Remove(bi); } try { db.SaveChanges(); } catch { return(RedirectToAction("Error", "Home")); } return(RedirectToAction("Index")); }
// // GET: /Birth/ public ActionResult Index(Int32 id) { List <BirthViewModel> bvmList = new List <BirthViewModel>(); int userID = (int)Membership.GetUser().ProviderUserKey; var births = db.Births.Include(a => a.Animal.UserProfile).Where(b => b.breed_id == id); Breeding breeding = db.Breedings.Find(id); if (breeding == null) { return(HttpNotFound()); } breeding.Animal = db.Animals.Find(breeding.father_id); if ((!User.IsInRole("admin")) && breeding.Animal.UserProfile.UserId != userID) { return(HttpNotFound()); } foreach (Birth birth in births) { BirthViewModel bvm = new BirthViewModel(); bvm.birth = birth; bvm.offspring_tag = birth.Animal.tag; bvm.father_tag = db.Animals.Find(db.Breedings.Find(id).father_id).tag; bvm.mother_tag = db.Animals.Find(db.Breedings.Find(id).mother_id).tag; bvmList.Add(bvm); } BirthViewModel bvmFinal = new BirthViewModel(); bvmFinal.born = breeding.born == null ? -1 : (int)breeding.born; bvmFinal.alive = breeding.alive == null ? -1 : (int)breeding.alive; bvmFinal.parity = breeding.parity == null ? -1 : (int)breeding.parity; bvmFinal.ien = bvmList; bvmFinal.birth = new Birth(); bvmFinal.birth.breed_id = id; bvmFinal.father_tag = db.Animals.Find(db.Breedings.Find(id).father_id).tag; bvmFinal.mother_tag = db.Animals.Find(db.Breedings.Find(id).mother_id).tag; return(View(bvmFinal)); }
// // GET: /Breeding/Details/5 public ActionResult Details(Int32 id) { Breeding breeding = db.Breedings.Find(id); int userID = (int)Membership.GetUser().ProviderUserKey; if (breeding == null) { return(HttpNotFound()); } breeding.Animal = db.Animals.Find(breeding.father_id); if ((!User.IsInRole("admin")) && breeding.Animal.UserProfile.UserId != userID) { return(HttpNotFound()); } BreedingViewModel be = new BreedingViewModel(); be.breeding = breeding; be.father_name = db.Animals.Find(breeding.father_id).name; be.mother_name = db.Animals.Find(breeding.mother_id).name; be.father_tag = db.Animals.Find(breeding.father_id).tag; be.mother_tag = db.Animals.Find(breeding.mother_id).tag; return(View(be)); }
// // GET: /Birth/Create public ActionResult Create(Int32 id) { BirthViewModel bvm = new BirthViewModel(); int userID = (int)Membership.GetUser().ProviderUserKey; var births = db.Animals.Include(a => a.UserProfile).Where(m => m.owner == userID && m.isChild == true); bvm.birth = new Birth(); bvm.birth.breed_id = id; bvm.offspring = new List <System.Web.Mvc.SelectListItem>(); bvm.offspring.Add(new System.Web.Mvc.SelectListItem { Text = "Select Offspring", Value = "" + -1 }); Breeding breeding = db.Breedings.Find(id); if (breeding == null) { return(HttpNotFound()); } breeding.Animal = db.Animals.Find(breeding.father_id); if ((!User.IsInRole("admin")) && breeding.Animal.UserProfile.UserId != userID) { return(HttpNotFound()); } foreach (Animal birth in births) { if (db.Births.Where(m => m.child_id == birth.id).Count() < 1) { bvm.offspring.Add(new System.Web.Mvc.SelectListItem { Text = birth.tag, Value = "" + birth.id }); } } @ViewBag.offspringDrop = bvm.offspring; return(View("Create", bvm)); }
public static EggSource2[] Validate(int species, GameVersion version, ReadOnlySpan <int> moves, out bool valid) { var count = moves.IndexOf(0); if (count == 0) { valid = false; // empty moveset return(Array.Empty <EggSource2>()); } if (count == -1) { count = moves.Length; } var learn = GameData.GetLearnsets(version); var table = GameData.GetPersonal(version); var learnset = learn[species]; var pi = table[species]; var egg = (version == GameVersion.C ? Legal.EggMovesC : Legal.EggMovesGS)[species].Moves; var actual = new EggSource2[count]; Span <byte> possible = stackalloc byte[count]; var value = new BreedInfo <EggSource2>(actual, possible, learnset, moves, level); { bool inherit = Breeding.GetCanInheritMoves(species); MarkMovesForOrigin(value, egg, count, inherit, pi, version); valid = RecurseMovesForOrigin(value, count - 1); } if (!valid) { CleanResult(actual, possible); } return(actual); }
public async Task TradeAsync([Summary("Trade Code")] int code, [Summary("Showdown Set")][Remainder] string content) { content = ReusableActions.StripCodeBlock(content); var set = new ShowdownSet(content); var template = AutoLegalityWrapper.GetTemplate(set); if (set.InvalidLines.Count != 0) { var msg = $"Unable to parse Showdown Set:\n{string.Join("\n", set.InvalidLines)}"; await ReplyAsync(msg).ConfigureAwait(false); return; } try { var sav = AutoLegalityWrapper.GetTrainerInfo <T>(); var pkm = sav.GetLegal(template, out var result); if (pkm.Species == 132) { TradeExtensions <T> .DittoTrade(pkm); } if (pkm.Nickname.ToLower() == "egg" && Breeding.CanHatchAsEgg(pkm.Species)) { TradeExtensions <T> .EggTrade(pkm); } var la = new LegalityAnalysis(pkm); var spec = GameInfo.Strings.Species[template.Species]; pkm = EntityConverter.ConvertToType(pkm, typeof(T), out _) ?? pkm; bool memes = Info.Hub.Config.Trade.Memes && await TradeAdditionsModule <T> .TrollAsync(Context, pkm is not T || !la.Valid, pkm).ConfigureAwait(false); if (memes) { return; } if (pkm is not T pk || !la.Valid) { var reason = result == "Timeout" ? $"That {spec} set took too long to generate." : $"I wasn't able to create a {spec} from that set."; var imsg = $"Oops! {reason}"; if (result == "Failed") { imsg += $"\n{AutoLegalityWrapper.GetLegalizationHint(template, sav, pkm)}"; } await ReplyAsync(imsg).ConfigureAwait(false); return; } pk.ResetPartyStats(); var sig = Context.User.GetFavor(); await AddTradeToQueueAsync(code, Context.User.Username, pk, sig, Context.User).ConfigureAwait(false); } catch (Exception ex) { LogUtil.LogSafe(ex, nameof(TradeModule <T>)); var msg = $"Oops! An unexpected problem happened with this Showdown Set:\n```{string.Join("\n", set.GetSetLines())}```"; await ReplyAsync(msg).ConfigureAwait(false); } }
void Awake() { uiManager = GameObject.FindGameObjectWithTag("UIManager").GetComponent <UIManager>(); creatureTending = gameObject.GetComponent <Tend>(); creatureBreeding = gameObject.GetComponent <Breeding>(); }
void Awake() { aging = GetComponent<Age>(); breeding = GetComponent<Breeding>(); mortal = GetComponent<Mortal>(); }
private void UpdateList() { switch (currentStage) { case 0: // Stables topBarText.text = "Boid Stables"; forwardButtonText.text = "Begin Breeding"; if (full.Count == 0) { gameObject.GetComponentInChildren <BoidList.BoidList>().Init(BoidManager.GetCurrentBoids()); full = new List <BoidListItem>(gameObject.GetComponentsInChildren <BoidListItem>()); } foreach (BoidListItem item in full) { item.gameObject.SetActive(true); Toggle toggle = item.GetComponentInChildren <Toggle>(); toggle.interactable = false; toggle.isOn = false; } break; case 1: // Select Boids to Save topBarText.text = "Select Boids to Save"; forwardButtonText.text = "Next"; foreach (BoidListItem item in full) { item.gameObject.SetActive(true); item.GetComponentInChildren <Toggle>().interactable = true; } save = null; break; case 2: // Select Boids to Breed topBarText.text = "Select Boids to Breed"; forwardButtonText.text = "Breed"; if (save == null) { save = new List <BoidListItem>(); foreach (var item in full) { if (item.GetComponentInChildren <Toggle>().isOn) { save.Add(item); item.gameObject.SetActive(false); } } } else { foreach (BoidListItem item in full) { if (!save.Contains(item)) { item.gameObject.SetActive(false); } } } break; case 3: // Repopulate List List <BoidAttributes> breed = new List <BoidAttributes>(); int toReplace = 0; foreach (BoidListItem item in full) { if (item.gameObject.activeSelf) { if (item.GetComponentInChildren <Toggle>().isOn) { breed.Add(item.attributes); } else { BoidManager.RemoveBoid(item.attributes); DestroyImmediate(item); toReplace++; } } } // Generate new boids and add them to flock. List <BoidAttributes> newBoids = Breeding.BreedPlayerBoids(breed, toReplace); BoidManager.AddBoids(newBoids); // Reset the Breeding Screen at the Stables full.Clear(); save = null; currentStage = 0; UpdateList(); break; } }
public void Mate(Breeding partner) { Destroy(gameObject); }
/// <summary> /// Creates <see cref="PKM"/> from the showdownsets and checks compatibility with the savefile. /// </summary> /// <remarks>REMEMBER: Many moves was removed in the 8th gen, so some showdownsets will eventually be incompatible with your savefile.</remarks> public void CreatePkM() { if (SAV == null) { Console.WriteLine("No savefile loaded yet."); return; } if (showdownSets.Count == 0) { Console.WriteLine("No showdown set loaded."); return; } foreach (ShowdownSet set in showdownSets) { PKM pkm = SAV.BlankPKM; string speciesname = SpeciesName.GetSpeciesName(set.Species, 2); Console.WriteLine("Creating " + speciesname); if (Breeding.CanHatchAsEgg(set.Species)) { EncounterEgg egg = new EncounterEgg(set.Species, set.Form, set.Level, SAV.Generation, game); pkm = egg.ConvertToPKM(SAV); } else { pkm.Species = set.Species; pkm.Form = set.Form; pkm.SetGender(pkm.GetSaneGender()); IEncounterable[] encs = EncounterMovesetGenerator.GenerateEncounter(pkm, SAV.Generation).ToArray(); if (encs.Length == 0) { // use debut generation for Pokemon that available but not catchable in current generation e.g. Meltan encs = EncounterMovesetGenerator.GenerateEncounter(pkm, pkm.DebutGeneration).ToArray(); } foreach (IEncounterable enc in encs) { PKM pk = enc.ConvertToPKM(SAV); // not all Pokemon in database are legal in all games if (new LegalityAnalysis(pk, SAV.Personal).Valid) { pkm = PKMConverter.ConvertToType(pk, SAV.PKMType, out _); if ((pk.Generation != SAV.Generation || pk.GO || pk.GO_HOME || pk.LGPE) && pkm is IBattleVersion b) { b.BattleVersion = (int)game; } break; } } } pkm.Language = SAV.Language; pkm.ApplySetDetails(set); LegalityAnalysis la = new LegalityAnalysis(pkm, SAV.Personal); string report = la.Report(); if (report == "Legal!") { ENTITIES.Add(pkm); IsValid.Add(true); } else { // setting blank pkm if invalid for better indexing ENTITIES.Add(SAV.BlankPKM); IsValid.Add(false); Console.WriteLine("Warning: " + speciesname + " is invalid!"); Console.WriteLine(report); Console.WriteLine("Ignoring " + speciesname); } } }
public static IEnumerable <EncounterEgg> GenerateEggs(PKM pk, EvoCriteria[] chain, int generation, bool all = false) { System.Diagnostics.Debug.Assert(generation >= 3); // if generating Gen2 eggs, use the other generator. int currentSpecies = pk.Species; if (!Breeding.CanHatchAsEgg(currentSpecies)) { yield break; } var currentForm = pk.Form; if (!Breeding.CanHatchAsEgg(currentSpecies, currentForm, generation)) { yield break; // can't originate from eggs } // version is a true indicator for all generation 3-5 origins var ver = (GameVersion)pk.Version; if (!Breeding.CanGameGenerateEggs(ver)) { yield break; } var lvl = EggStateLegality.GetEggLevel(generation); int max = GetMaxSpeciesOrigin(generation); var(species, form) = GetBaseSpecies(chain, 0); if ((uint)species <= max) { // NOTE: THE SPLIT-BREED SECTION OF CODE SHOULD BE EXACTLY THE SAME AS THE BELOW SECTION if (FormInfo.IsBattleOnlyForm(species, form, generation)) { form = FormInfo.GetOutOfBattleForm(species, form, generation); } if (Breeding.CanHatchAsEgg(species, form, ver)) { yield return(new EncounterEgg(species, form, lvl, generation, ver)); if (generation > 5 && (pk.WasTradedEgg || all) && HasOtherGamePair(ver)) { yield return(new EncounterEgg(species, form, lvl, generation, GetOtherTradePair(ver))); } } } if (!Breeding.GetSplitBreedGeneration(generation).Contains(currentSpecies)) { yield break; // no other possible species } var otherSplit = species; (species, form) = GetBaseSpecies(chain, 1); if ((uint)species == otherSplit) { yield break; } if (species <= max) { // NOTE: THIS SECTION OF CODE SHOULD BE EXACTLY THE SAME AS THE ABOVE SECTION if (FormInfo.IsBattleOnlyForm(species, form, generation)) { form = FormInfo.GetOutOfBattleForm(species, form, generation); } if (Breeding.CanHatchAsEgg(species, form, ver)) { yield return(new EncounterEgg(species, form, lvl, generation, ver)); if (generation > 5 && (pk.WasTradedEgg || all) && HasOtherGamePair(ver)) { yield return(new EncounterEgg(species, form, lvl, generation, GetOtherTradePair(ver))); } } } }
// Helper functions for commands public static bool AddToWaitingList(string setstring, string display, string username, ulong mUserId, bool sub, out string msg) { if (!TwitchBot <T> .Info.GetCanQueue()) { msg = "Sorry, I am not currently accepting queue requests!"; return(false); } var set = ShowdownUtil.ConvertToShowdown(setstring); if (set == null) { msg = $"Skipping trade, @{username}: Empty nickname provided for the species."; return(false); } var template = AutoLegalityWrapper.GetTemplate(set); if (template.Species < 1) { msg = $"Skipping trade, @{username}: Please read what you are supposed to type as the command argument."; return(false); } if (set.InvalidLines.Count != 0) { msg = $"Skipping trade, @{username}: Unable to parse Showdown Set:\n{string.Join("\n", set.InvalidLines)}"; return(false); } try { var sav = AutoLegalityWrapper.GetTrainerInfo <T>(); PKM pkm = sav.GetLegal(template, out var result); var nickname = pkm.Nickname.ToLower(); if (nickname == "egg" && Breeding.CanHatchAsEgg(pkm.Species)) { TradeExtensions <T> .EggTrade(pkm); } if (pkm.Species == 132 && (nickname.Contains("atk") || nickname.Contains("spa") || nickname.Contains("spe") || nickname.Contains("6iv"))) { TradeExtensions <T> .DittoTrade(pkm); } if (!pkm.CanBeTraded()) { msg = $"Skipping trade, @{username}: Provided Pokémon content is blocked from trading!"; return(false); } if (pkm is T pk) { var valid = new LegalityAnalysis(pkm).Valid; if (valid) { var tq = new TwitchQueue <T>(pk, new PokeTradeTrainerInfo(display, mUserId), username, sub); TwitchBot <T> .QueuePool.RemoveAll(z => z.UserName == username); // remove old requests if any TwitchBot <T> .QueuePool.Add(tq); msg = $"@{username} - added to the waiting list. Please whisper your trade code to me! Your request from the waiting list will be removed if you are too slow!"; return(true); } } var reason = result == "Timeout" ? "Set took too long to generate." : "Unable to legalize the Pokémon."; msg = $"Skipping trade, @{username}: {reason}"; } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) #pragma warning restore CA1031 // Do not catch general exception types { LogUtil.LogSafe(ex, nameof(TwitchCommandsHelper <T>)); msg = $"Skipping trade, @{username}: An unexpected problem occurred."; } return(false); }
public ActionResult Create(Breeding breeding) { BreedingViewModel bvm = new BreedingViewModel(); int userID = (int)Membership.GetUser().ProviderUserKey; bvm.maleList = db.Animals.Include(a => a.UserProfile).Where(m => m.owner == userID && m.isChild == false && m.sex == true); bvm.femaleList = db.Animals.Include(a => a.UserProfile).Where(m => m.owner == userID && m.isChild == false && m.sex == false); List <SelectListItem> mlist = new List <SelectListItem>(); List <SelectListItem> flist = new List <SelectListItem>(); if (ModelState.IsValid && breeding.father_id != 0 && breeding.mother_id != 0) { if (breeding.actual_birthing_date != null && breeding.date != null) { if (((DateTime)breeding.actual_birthing_date).CompareTo(((DateTime)breeding.date)) < 0) { ModelState.AddModelError("", "Birthing date cannot be after breeding date."); mlist = new List <SelectListItem>(); flist = new List <SelectListItem>(); mlist.Add(new SelectListItem { Text = "Select Sire", Value = "0" }); flist.Add(new SelectListItem { Text = "Select Dam", Value = "0" }); for (int i = 1; i <= bvm.maleList.Count(); i++) { mlist.Add(new SelectListItem { Text = bvm.maleList.ElementAt(i - 1).tag, Value = "" + i }); } for (int i = 1; i <= bvm.femaleList.Count(); i++) { flist.Add(new SelectListItem { Text = bvm.femaleList.ElementAt(i - 1).tag, Value = "" + i }); } @ViewBag.flist = flist; @ViewBag.mlist = mlist; return(View(bvm)); } } breeding.Animal = db.Animals.Find(bvm.maleList.ElementAt(breeding.father_id - 1).id); breeding.Animal1 = db.Animals.Find(bvm.femaleList.ElementAt(breeding.mother_id - 1).id); breeding.father_id = breeding.Animal.id; breeding.mother_id = breeding.Animal1.id; db.Breedings.Add(breeding); try { db.SaveChanges(); } catch { return(RedirectToAction("Error", "Home")); } return(RedirectToAction("Index")); } mlist.Add(new SelectListItem { Text = "Select Sire", Value = "0" }); flist.Add(new SelectListItem { Text = "Select Dam", Value = "0" }); for (int i = 1; i <= bvm.maleList.Count(); i++) { mlist.Add(new SelectListItem { Text = bvm.maleList.ElementAt(i - 1).tag, Value = "" + i }); } for (int i = 1; i <= bvm.femaleList.Count(); i++) { flist.Add(new SelectListItem { Text = bvm.femaleList.ElementAt(i - 1).tag, Value = "" + i }); } @ViewBag.flist = flist; @ViewBag.mlist = mlist; ModelState.AddModelError("", "Both a male and female must be selected."); return(View(bvm)); }
private void Start() { instance = this; }
public EGA SetupBreeding(Breeding b, double g) { breeding = b; this.g = g; return(this); }
void Awake() { breeding = GetComponent<Breeding>(); jumping = GetComponent<Jumping>(); moving = GetComponent<Moving>(); }