Ejemplo n.º 1
0
        public static HashSet <CutBase> TestDamageForDataFight(Data.Fight fight, double threshold)
        {
            HashSet <CutBase> ret = new HashSet <Model.CutBase>();

            fight.SetCuts();
            FighterStats stats1 = new FighterStats(fight.Fighter1);
            FighterStats stats2 = new FighterStats(fight.Fighter2);

            foreach (Data.Round round in fight.Rounds)
            {
                if (RoundMatchesExpectations(round, stats1, stats2, true, threshold))
                {
                    foreach (var c in GetCutsForDataRound(round.First))
                    {
                        if (!ret.Contains(c))
                        {
                            ret.Add(c);
                        }
                    }
                    foreach (var c in GetCutsForDataRound(round.Second))
                    {
                        if (!ret.Contains(c))
                        {
                            ret.Add(c);
                        }
                    }
                }
            }
            return(ret);
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        public Fight(Data.Fight fight)
        {
            this.Fighter1Score = fight.Fighter1Score;
            this.Fighter2Score = fight.Fighter2Score;
            this.Fighter1      = new Model.FighterStats(fight.Fighter1);
            this.Fighter2      = new Model.FighterStats(fight.Fighter2);
            FightOutcome outcome = FightOutcome.Draw;

            if (fight.Fighter1Win == true)
            {
                outcome = FightOutcome.Win;
            }
            else if (fight.Fighter1Win == false)
            {
                outcome = FightOutcome.Loss;
            }
            SetJudgeScores();
            this.Result = new FightResult()
            {
                Outcome    = outcome,
                Rounds     = fight.NumberOfRounds,
                ResultType = (FightResultType)fight.ResultType,
                TkoCut     = fight.TkoCut
            };
            this.RoundResults = new List <Model.Round>();

            foreach (Data.Round r in fight.Rounds)
            {
                Round rr = new Model.Round(r)
                {
                    Fight = this
                };
                rr.Fighter1Round.SetPercentages(fight.Fighter1.Conditioning * 10);
                rr.Fighter2Round.SetPercentages(fight.Fighter2.Conditioning * 10);
                this.RoundResults.Add(rr);
            }
        }