Example #1
0
        public Data.Fight SaveToDatabase(FightOptions options, int fighter1Id, int fighter2Id, int plan1Id, int plan2Id, string parseText)
        {
            {
                WeebulEntities entities = Data.DataHelpers.Entities;
                entities.Fights.Load();
                FightOption o = entities.FightOptions.Create();
                o.CutMultiplier  = options.CutFactor;
                o.Luck           = options.LuckAmount;
                o.NumberOfRounds = options.TotalRounds;
                o.WeightClass    = (int)options.WeightClass;
                o = entities.FightOptions.Add(o);
                int        upd = entities.SaveChanges();
                Data.Fight f   = entities.Fights.Create();
                f.Fighter1Id     = fighter1Id;
                f.Fighter2Id     = fighter2Id;
                f.Fighter1PlanId = plan1Id;
                f.Fighter2PlanId = plan2Id;

                f.Fighter1Score = this.Fighter1Score;
                f.Fighter2Score = this.Fighter2Score;

                f.NumberOfRounds = this.Result.Rounds;
                f.OptionsId      = o.OptionsId;

                bool?fighter1Win = null;

                if (this.Result.Outcome == FightOutcome.Win)
                {
                    fighter1Win = true;
                }
                else if (this.Result.Outcome == FightOutcome.Loss)
                {
                    fighter1Win = false;
                }
                f.Fighter1Win = fighter1Win;
                f.IsParsed    = true;
                f.ResultType  = (int)this.Result.ResultType;

                f            = entities.Fights.Add(f);
                f.Date       = DateTime.Now;
                f.ParseText  = parseText;
                f.TkoCut     = this.Result.TkoCut;
                f.CutLevelF1 = this.RoundResults.Last().Fighter1Round.CutLevel;
                f.CutLevelF2 = this.RoundResults.Last().Fighter2Round.CutLevel;
                entities.SaveChanges();
                foreach (Round rr in this.RoundResults)
                {
                    rr.CreateToDatabase(f.FightId);
                }
                entities.SaveChanges();
                return(f);
            }
        }
Example #2
0
        public void MakeAdjustments(FighterFight other, FightOptions options)
        {
            FightingStyle style = this.RoundStats.Plan.Style;

            this.RoundStats.AdjustStyle(style, other.RoundStats);
            this.RoundStats.AdjustHeight(other.RoundStats);
            AdjustFatigueEndurancePreRound();
            this.RoundStats.AdjustCuts(this.Cuts);
            this.RoundStats.AdjustEndurance(this.EndurancePoints);

            if (options.LuckAmount > 0)
            {
                this.RoundStats.SetLuckFactor(options.LuckAmount);
            }
            else
            {
                this.RoundStats.LuckFactor = 1;
            }

            this.RoundStats.FixAdjustments();
            this.RoundStats.SetCutPercent(other.RoundStats);
        }
 public PivotFightSimulator(List <PivotFighter> groupOne, List <PivotFighter> groupTwo, int numberOfSims, FightOptions options)
 {
     this.PivotGroup1      = groupOne;
     this.PivotGroup2      = groupTwo;
     this.Options          = options;
     this.NumberOfSimsEach = numberOfSims;
     SetNumbers();
 }
Example #4
0
        public void SetRoundResult(FightOptions options)
        {
            if (Fighter1Round.IsTowel)
            {
                IsEndOfBout = true;
                ResultType  = FightResultType.TKO;
                Fighter1Win = false;
                return;
            }
            if (Fighter2Round.IsTowel)
            {
                IsEndOfBout = true;
                ResultType  = FightResultType.TKO;
                Fighter1Win = true;
                return;
            }
            if (Fighter1Round.IsDisqualified)
            {
                IsEndOfBout = true;
                ResultType  = FightResultType.DQ;
                Fighter1Win = false;
                return;
            }
            if (Fighter2Round.IsDisqualified)
            {
                IsEndOfBout = true;
                ResultType  = FightResultType.DQ;
                Fighter1Win = true;
                return;
            }

            if (Fighter1Round.DamageDealt.StunValue > 2.5 && Fighter1Round.DamageDealt.StunValue > Fighter2Round.DamageDealt.StunValue)
            {
                IsEndOfBout = true;
                Fighter1Win = true;
                ResultType  = FightResultType.Knockout;
                return;
            }
            if (Fighter2Round.DamageDealt.StunValue > 2.5)
            {
                IsEndOfBout = true;
                Fighter1Win = false;
                ResultType  = FightResultType.Knockout;
                return;
            }
            ScoreRound(options.JudgeLuck, options.Judges);

            if (Fighter1Round.IsTKOedByEndurance || Fighter1Round.IsTKOedByCut)
            {
                IsEndOfBout = true;
                Fighter1Win = false;
                ResultType  = FightResultType.TKO;
                return;
            }
            if (Fighter2Round.IsTKOedByEndurance || Fighter2Round.IsTKOedByCut)
            {
                IsEndOfBout = true;
                Fighter1Win = true;
                ResultType  = FightResultType.TKO;
                return;
            }
            IsEndOfBout = false;
            ResultType  = FightResultType.Decision;
        }
Example #5
0
 public FightTracker(FighterFight fighter1, FighterFight fighter2, FightOptions options)
 {
     this.Fighter1 = fighter1;
     this.Fighter2 = fighter2;
     this.Options  = options;
 }
Example #6
0
 public FightTracker(Fighter fighter1, Fighter fighter2, FightPlan fighter1Plan, FightPlan fighter2Plan, FightOptions options) : this()
 {
     this.Fighter1 = new FighterFight(fighter1, fighter1Plan);
     this.Fighter2 = new FighterFight(fighter2, fighter2Plan);
     this.Options  = options;
 }
Example #7
0
        public static FightResultSet PlayMultiple_ResultSet(int numberOfTimes, FighterFight f1, FighterFight f2, FightOptions options)
        {
            List <Fight> fights = PlayMultiple(numberOfTimes, f1.Fighter, f2.Fighter, f1.FightPlan, f2.FightPlan, options);

            return(new FightResultSet(fights.Select(f => f.Result)));
        }
Example #8
0
        public static List <Fight> PlayMultiple(int numberOfTimes, Fighter f1, Fighter f2, FightPlan fp1, FightPlan fp2, FightOptions options)
        {
            int perEach = numberOfTimes / 20;
            var results = new ConcurrentBag <List <Fight> >();

            Parallel.For(0, 20, (i) =>
            {
                FightTracker tracker = new FightTracker(f1, f2, fp1.Copy(), fp2.Copy(), options);
                List <Fight> resTemp = tracker.PlayFights(perEach);
                results.Add(resTemp);
            });
            List <Fight> ret = results.SelectMany(fr => fr).ToList();

            if (ret.Count < numberOfTimes)
            {
                int          numSim  = ret.Count - numberOfTimes;
                FightTracker tracker = new FightTracker(f1, f2, fp1.Copy(), fp2.Copy(), options);
                var          v       = tracker.PlayFights(numSim);
                foreach (var res in v)
                {
                    ret.Add(res);
                }
            }
            return(ret);
        }