public void FightAllTest() { List <int> fpList = new List <int>() { 8, 9, 14, 15, 16 }; var listOne = new List <PivotFighter>(); var listTwo = new List <PivotFighter>(); int fighter1Id = 5; int fighter2Id = 5; FightOptions options = new FightOptions() { JudgeLuck = 0.05, LuckAmount = 0.05 }; Data.Fighter f1 = DataHelpers.Entities.Fighters.First(f => f.FighterId == fighter1Id); FighterStats f1Stats = new FighterStats(f1); Data.Fighter f2 = DataHelpers.Entities.Fighters.First(f => f.FighterId == fighter2Id); FighterStats f2Stats = new FighterStats(f2); Fighter f1Fighter = new Fighter() { Stats = f1Stats }; Fighter f2Fighter = new Fighter() { Stats = f2Stats }; foreach (int i in fpList) { Data.FightPlan dfp = DataHelpers.Entities.FightPlans.First(fp => fp.PlanId == i); Model.FightPlan mFp = new FightPlan() { FightPlanText = dfp.PlanData }; string name = String.Format("{0}, {1}", f1.Name, dfp.PlanName); listOne.Add(new PivotFighter(f1Stats, mFp, name, TrainingStat.None)); name = String.Format("{0}, {1}", f2.Name, dfp.PlanName); listTwo.Add(new PivotFighter(f2Stats, mFp, name, TrainingStat.None)); } PivotFightSimulator simmer = new PivotFightSimulator(listOne, listTwo, 100, options); Stopwatch sw = new Stopwatch(); sw.Start(); simmer.FightAll(); Debug.Print("Done in " + sw.ElapsedMilliseconds); simmer.PrintAll(); }
private void SetOptions() { FightOptions optCopy = this.Options.Copy(); if (PropertiesWindow.EditProperties(optCopy)) { this.Options = optCopy; } }
public void SaveToDb() { if (_dbSaved != null && ParseText.Equals(_dbSaved)) { MessageBox.Show("Parse text appears to be the same"); return; } int fId1 = Shared.Locator().Fighter1.SelectedFighter.FighterId; int fId2 = Shared.Locator().Fighter2.SelectedFighter.FighterId; int pId1 = Shared.Locator().FightPlanF1.SelectedFightPlan.PlanId; int pId2 = Shared.Locator().FightPlanF2.SelectedFightPlan.PlanId; FightOptions options = Shared.Locator().Options.Options; _parseResult.SaveToDatabase(options, fId1, fId2, pId1, pId2, this.ParseText); _dbSaved = ParseText; }
public void FightRoundTest() { for (int i = 1; i <= 50; i++) { Fighter f = new Fighter() { Stats = FighterRoundStatsTests.GetFighterStats() }; f.Stats.Weight = 135; FighterFight fFight = new FighterFight(f, new FightPlan() { Default = new FighterRoundPlan(4, 8, 8) }); Fighter f2 = new Fighter() { Stats = FighterRoundStatsTests.GetFighterStats() }; FighterFight fFight2 = new FighterFight(f2, new FightPlan() { Default = new FighterRoundPlan(4, 8, 8) }); FightPlan defPlan = new FightPlan() { Default = new FighterRoundPlan(5, 9, 6) }; FightOptions options = new FightOptions() { WeightClass = WeightClass.Light }; FightTracker tracker = new FightTracker(f, f2, defPlan, defPlan, options); tracker.PlayFight(); } }
public static async Task <DiscordEmbed> RollAsync(Chr Author, Chr Target, FightOptions Option) { //Modifiers + Predefining. int Attribute = 0; bool Magic = false; int Dodge = Target.Dodge; switch (Option) { case FightOptions.Melee: Attribute += Author.Sleight; break; case FightOptions.Ranged: Attribute += Author.Marksman; break; case FightOptions.Magic: Attribute += Author.Magic; Magic = true; break; } //RNG Innit var AuthorRoll = Helpers.Tools.RNG.Next(12) + 1; var TargetRoll = Helpers.Tools.RNG.Next(12) + 1; //Roll Msg #1 string Roll = $"{Author.Name} rolls ({Option}) against {Target.Name}"; string RollInit = $"`({AuthorRoll} + {Attribute})` **vs** `({TargetRoll} + {Dodge})`"; //Switch Win/Loss var AuthorFull = AuthorRoll + Attribute; var TargetFull = TargetRoll + Dodge; string Situation = ""; int Visual = 0; int Damage = Author.Strenght + Helpers.Tools.RNG.Next(20) + 1; if (Magic == true) { Damage = Author.MagicEff + Helpers.Tools.RNG.Next(15) + 1; } if (Author.EffectPath != 0) { if (Author.EffectPath == EffectPath.boost) { Damage += Author.EffectAtribute; } if (Author.EffectPath == EffectPath.weaken) { Damage -= Author.EffectAtribute; } if (Damage < 0) { Damage = 0; } Author.EffectAtribute = 0; Author.EffectPath = 0; await ManageCharacter.UpdateAsync(Author); } if (AuthorFull == 0) { Situation = $"{Author.Name} didn't even get near {Target.Name}"; Visual += 10; Damage = 0; } else if (AuthorFull > TargetFull) { if (AuthorRoll == 12) { Damage += 5; } Situation = $"`{Author.Name}` **succesfully hitted** `{Target.Name}` **for** `{Damage}` **damage**"; Visual += 2; if (Magic == true) { if (Author.ENC < 10) { Situation = "You do not have enough stamina to use Magic Attacks."; Visual += 10; Damage = 0; } } } else if (AuthorFull == TargetFull) { Situation = $"{Author.Name} went on even grounds as {Target.Name}"; Visual += 10; Damage = 0; } else { Situation = $"{Author.Name} couldn't hit {Target.Name}"; Visual += 10; Damage = 0; } //Create Msg var Embed = new DiscordEmbedBuilder(); Embed = Embed.WithAuthor(Roll); Embed = Embed.WithDescription(RollInit + "\n\n" + Situation + "\n" + $"**{Target.Name}** has `{Target.HPC - Damage + "|" + Target.HPM} HP` left"); //CheckIfDamage if (Visual == 2) { Target.HPC -= Damage; if (Target.HPC < 1) { Target.HPC = 0; Embed = Embed.WithFooter($"{Target.Name} died."); } await ManageCharacter.UpdateAsync(Target); if (Magic == true) { Author.ENC -= 10; await ManageCharacter.UpdateAsync(Author); } } //End Return return(Embed); }
public async Task FightOneVSOne() { var db = context.Db; //User 1 erstellen var user_challenger = new Twitchuser() { Twitchuser_Id = "123", DisplayName = "Ash", Dt_Last_Userfight = null, Kz_Log_Enabled = false }; //Pokemon 1 erstellen var pokemon_zapdos = new SdPokemon() { SdPokemon_Id = 1, ATK = 50, Name = "Zapdos", HP = 999, Rarity = PokemonRarity.Legendary, Description = "Hehe Op", Type = PokemonType.Electric }; user_challenger.CatchedPokemon = new List <CatchedPokemon>() { new CatchedPokemon() { Pokemon_AmountCatched = 1, Pokemon_AmountOnFightingTeam = 1, SdPokemon = pokemon_zapdos, Twitchuser = user_challenger, CatchedPokemon_Id = 1 } }; db.Twitchuser.Add(user_challenger); await db.SaveChangesAsync(); //User 2 erstellen var user_defender = new Twitchuser() { Twitchuser_Id = "456", DisplayName = "Gary", Dt_Last_Userfight = null, Kz_Log_Enabled = false }; //Pokemon 2 erstellen var pokemon_raupy = new SdPokemon() { SdPokemon_Id = 2, ATK = 5, Name = "Raupy", HP = 100, Rarity = PokemonRarity.Common, Description = "Hehe Low", Type = PokemonType.Grass }; user_defender.CatchedPokemon = new List <CatchedPokemon>() { new CatchedPokemon() { Pokemon_AmountCatched = 1, Pokemon_AmountOnFightingTeam = 1, SdPokemon = pokemon_raupy, Twitchuser = user_defender, CatchedPokemon_Id = 2 } }; db.Twitchuser.Add(user_defender); await db.SaveChangesAsync(); //Kampf vorbereiten var tr_challenger = await userService.GetUser("123"); var tr_defender = await userService.GetUser("456"); var fight_WinnerCounter = 0; var fight_Counter = 100; for (int i = 0; i < fight_Counter; i++) { FightParticipant challenger = new FightParticipant() { User = tr_challenger, Pokemon = new List <TransferPokemon>() { tr_challenger.GetRandomPokemon() } }; FightParticipant defender = new FightParticipant() { User = tr_defender, Pokemon = new List <TransferPokemon>() { tr_defender.GetRandomPokemon() } }; challenger.Pokemon[0].HP = 100; defender.Pokemon[0].HP = 100; //Kampf ausführen var fight = new Fight(); var input = new FightOptions(challenger, defender, false); var result = fight.CalculateUnlimited(input); if (result.Winner.DisplayName == "Ash") { fight_WinnerCounter += 1; } } //Kampf auswerten Assert.AreEqual(fight_WinnerCounter, 100); }
public async Task FightRandomTeamVSTeam() { //Ausgangspunkt dieses Tests sind zwei Teams mit gleichen Pokemon. //Erwartungshaltung bei 100 Kämpfen wäre eine ausgeglichene Quote von etwa 50%. var db = context.Db; //User 1 erstellen var user_challenger = new Twitchuser() { Twitchuser_Id = "123", DisplayName = "Ash", Dt_Last_Userfight = null, Kz_Log_Enabled = false }; //Pokemon 1 erstellen var pokemon_raupy = new SdPokemon() { SdPokemon_Id = 1, ATK = 5, Name = "Raupy", HP = 100, Rarity = PokemonRarity.Common, Description = "Hehe Low", Type = PokemonType.Grass }; user_challenger.CatchedPokemon = new List <CatchedPokemon>() { new CatchedPokemon() { Pokemon_AmountCatched = 6, Pokemon_AmountOnFightingTeam = 1, SdPokemon = pokemon_raupy, Twitchuser = user_challenger, CatchedPokemon_Id = 1 } }; db.Twitchuser.Add(user_challenger); await db.SaveChangesAsync(); //User 2 erstellen var user_defender = new Twitchuser() { Twitchuser_Id = "456", DisplayName = "Gary", Dt_Last_Userfight = null, Kz_Log_Enabled = false }; user_defender.CatchedPokemon = new List <CatchedPokemon>() { new CatchedPokemon() { Pokemon_AmountCatched = 6, Pokemon_AmountOnFightingTeam = 1, SdPokemon = pokemon_raupy, Twitchuser = user_defender, CatchedPokemon_Id = 2 } }; db.Twitchuser.Add(user_defender); await db.SaveChangesAsync(); //Kampf vorbereiten var tr_challenger = await userService.GetUser("123"); var tr_defender = await userService.GetUser("456"); var fight_WinnerCounter = 0; var fight_Counter = 1000; for (int i = 0; i < fight_Counter; i++) { FightParticipant challenger = new FightParticipant() { User = tr_challenger, Pokemon = new List <TransferPokemon>() { tr_challenger.GetRandomPokemon() } }; FightParticipant defender = new FightParticipant() { User = tr_defender, Pokemon = new List <TransferPokemon>() { tr_defender.GetRandomPokemon() } }; challenger.Pokemon[0].HP = 100; defender.Pokemon[0].HP = 100; //Kampf ausführen var fight = new Fight(); var input = new FightOptions(challenger, defender, false); var result = fight.CalculateUnlimited(input); if (result.Winner.DisplayName == "Ash") { fight_WinnerCounter += 1; } } //Kampf auswerten Assert.IsTrue(fight_WinnerCounter > 450); Assert.IsTrue(fight_WinnerCounter < 550); }