Esempio n. 1
0
 public FighterRoundPlan GetPlan(FightRoundVariables variables)
 {
     if (WeblScript != null)
     {
         return(EvaluatePlan(variables));
     }
     return(Default);
 }
Esempio n. 2
0
        public Round FightRound()
        {
            FightRoundVariables var1 = FightRoundVariables.GetVariables(this.Round, this.Fight.Fighter1Score - this.Fight.Fighter2Score, this.Fighter1, this.Fighter2);

            this.Fighter1.SetStartRoundStatsAndGetPlan(var1);
            FightRoundVariables var2 = FightRoundVariables.GetVariables(this.Round, this.Fight.Fighter2Score - this.Fight.Fighter1Score, this.Fighter2, this.Fighter1);

            this.Fighter2.SetStartRoundStatsAndGetPlan(var2);
            Round ret = new Round()
            {
                RoundNumber = this.Round, Fight = this.Fight
            };

            if (this.Fighter1.RoundStats.Plan.IsTowel || this.Fighter2.RoundStats.Plan.IsTowel)
            {
                ret.SetTowel(!this.Fighter1.RoundStats.Plan.IsTowel);
            }
            else
            {
                SimRound(ret);
                ret.SetRoundResult(this.Options);
            }

            if (ret.IsEndOfBout)
            {
                this.IsOver = true;
                this.Fight.Result.Outcome    = ret.Fighter1Win ? FightOutcome.Win : FightOutcome.Loss;
                this.Fight.Result.ResultType = ret.ResultType;
                this.Fight.Result.Rounds     = this.Round;
            }
            else
            {
                if (ret.Fighter1Score > ret.Fighter2Score)
                {
                    this.Fighter1.RoundsWon++;
                }
                else if (ret.Fighter2Score > ret.Fighter1Score)
                {
                    this.Fighter2.RoundsWon++;
                }
                this.Fighter1.Knockdowns += ret.Fighter1Round.StunsCaused / 2;
                this.Fighter1.Stuns      += ret.Fighter1Round.StunsCaused;
                this.Fighter2.Stuns      += ret.Fighter2Round.StunsCaused;
                this.Fighter2.Knockdowns += ret.Fighter2Round.StunsCaused / 2;
                this.Fight.Fighter1Score += ret.Fighter1Score;
                this.Fight.Fighter2Score += ret.Fighter2Score;
                this.Fighter1.RecoverEndurance();
                ret.Fighter1Round.EndurancePostRecover = this.Fighter1.EndurancePoints;
                this.Fighter2.RecoverEndurance();
                ret.Fighter2Round.EndurancePostRecover = this.Fighter2.EndurancePoints;
            }
            return(ret);
        }
Esempio n. 3
0
        public void SetStartRoundStatsAndGetPlan(FightRoundVariables variables)
        {
            this.RoundStats.AdjustedStats             = this.RoundStats.OriginalStats.Copy();
            this.RoundStats.LuckFactor                = 1;
            this.RoundStats.DamageAdjustment          = 1;
            this.RoundStats.AdditionalFatigue         = FatigueLossPerRound;
            this.RoundStats.AdditionalEnduranceDamage = 0;
            // this.RoundStats.StunDefense = this.RoundStats.OriginalStats.Chin + this.RoundStats.OriginalStats.Agility - 10;
            FighterRoundPlan plan = this.FightPlan.GetPlan(variables);

            this.PlanLineHits.Add(plan.HitLineNumber);
            this.RoundStats.Plan            = plan;
            this.RoundStats.AdjustedTactics = plan.Copy();
        }
Esempio n. 4
0
        private FighterRoundPlan EvaluatePlan(FightRoundVariables frv)
        {
            if (WeblScript == null)
            {
                WeblScript = new WeblScript();
            }
            ScriptVariables  variables = frv.ToScriptVariables();
            ParseResult      res       = WeblScript.ParseAndEvaluate(this.FightPlanText, variables);
            FighterRoundPlan roundPlan = FighterRoundPlan.Parse(res.Text);

            if (res.Cheat)
            {
                roundPlan.Dirty = true;
            }
            roundPlan.HitLineNumber = res.LineNumber;
            return(roundPlan);
        }
        public static FightRoundVariables GetVariables(int round, int score, FighterFight fighter, FighterFight other)
        {
            FightRoundVariables ret = new FightRoundVariables()
            {
                Round            = round,
                Score            = score,
                EndurancePercent = fighter.EndurancePercent,
                MyStuns          = fighter.Stuns,
                MyKnockdowns     = fighter.Knockdowns,
                MyCuts           = fighter.Cuts.Sum(s => (int)s.Level),
                HisCuts          = other.Cuts.Sum(s => (int)s.Level),
                HisStuns         = other.Stuns,
                HisKnockdowns    = other.Knockdowns,
                RoundsWon        = fighter.RoundsWon,
                RoundsLost       = other.RoundsWon,
                Endurance        = Convert.ToInt32(fighter.EndurancePoints),
                Warnings         = fighter.Warnings,
                CanTowel         = fighter.CanTowel()
            };

            double otherEndurancePre = (round == 1 || other.EndurancePreRecover == 0) ? other.EndurancePoints : other.EndurancePreRecover;
            double otherEndurance    = otherEndurancePre / (other.RoundStats.AdjustedStats.Conditioning * 10);

            if (otherEndurance < 1d / 3)
            {
                ret.Opponent = OpponentStrength.Exhausted;
            }
            else if (otherEndurance <= 2d / 3)
            {
                ret.Opponent = OpponentStrength.Tired;
            }
            else
            {
                ret.Opponent = OpponentStrength.Strong;
            };
            return(ret);
        }