Пример #1
0
        // PRIVATE METHODS

        private static double FightViewers(FightOutcome fo)
        {
            double viewers;


            Fighter f1 = fo.Fighter1();
            Fighter f2 = fo.Fighter2();


            //Country country = f1.Nationality;
            //Console.WriteLine(f1.Nationality + "'s buff is " + country.PopularityBuff);

            WeightClass w1 = (WeightClass)f1.Weight;

            //WeightCoefficient[w1.Weight]



            fo.Interested = MathUtils.Gauss(((f1.Performance["Elo"] + f2.Performance["Elo"]) / 2), 100) *
                            (f1.Nationality.PopularityBuff * f2.Nationality.PopularityBuff * w1.Popularity + f1.Belts + f2.Belts);



            //viewers = f1.Performance["Fans"] + f1.Performance["Followers"] + f1.Performance["Casuals"];
            //viewers += (f1.Performance["Fans"] + f2.Performance["Followers"] + f2.Performance["Casuals"]);


            viewers = fo.Interested + (PWin(fo)) * f1.Performance["Followers"] + (1 - PWin(fo) * f2.Performance["Followers"]) + (PWin(fo)) * f1.Performance["Fans"] + (1 - PWin(fo) * f2.Performance["Fans"]);


            return(viewers);
        }
Пример #2
0
        /// <summary>
        ///  WeightClass to string
        /// </summary>
        /// <param name="weight"></param>
        /// <returns></returns>
        public static string WeightClassToString(WeightClass weight)
        {
            String weightClass = String.Empty;

            switch (weight)
            {
            case WeightClass.One:
                weightClass = "0_54";
                break;

            case WeightClass.Two:
                weightClass = "55_64";
                break;

            case WeightClass.Three:
                weightClass = "65_74";
                break;

            case WeightClass.Four:
                weightClass = "75_84";
                break;

            case WeightClass.Five:
                weightClass = "85_94";
                break;

            case WeightClass.Six:
                weightClass = "95_plus";
                break;
            }
            return(weightClass);
        }
Пример #3
0
        public CheckableDataItem(Data.Fighter fighter) : this(fighter, fighter.Name, fighter.FighterId)
        {
            WeightClass weightClass = FighterStats.GetWeightClass(fighter.Weight, fighter.Conditioning);
            string      name        = Enum.GetName(typeof(WeightClass), weightClass);

            this.Name = String.Format("{0} ({1})", fighter.Name, name);
        }
Пример #4
0
        /// <summary>
        ///  WeightClass to string
        /// </summary>
        /// <param name="weight"></param>
        /// <returns></returns>
        public static string WeightClassToString(WeightClass weight)
        {
            String weightClass = String.Empty;

            switch (weight)
            {
                case WeightClass.One:
                    weightClass = "0_54";
                    break;
                case WeightClass.Two:
                    weightClass = "55_64";
                    break;
                case WeightClass.Three:
                    weightClass = "65_74";
                    break;
                case WeightClass.Four:
                    weightClass = "75_84";
                    break;
                case WeightClass.Five:
                    weightClass = "85_94";
                    break;
                case WeightClass.Six:
                    weightClass = "95_plus";
                    break;
            }
            return weightClass;
        }
Пример #5
0
        /// <summary>
        /// return upper weight for a division
        /// </summary>
        /// <param name="weightClass">weight class</param>
        /// <returns>upper weight</returns>
        public float GetDivisionWeightClass(WeightClass weightClass)
        {
            switch (weightClass)
            {
            case WeightClass.Strawweight: return(52.2f);

            case WeightClass.Flyweight: return(56.7f);

            case WeightClass.Bantamweight: return(61.2f);

            case WeightClass.Featherweight: return(65.8f);

            case WeightClass.Lightweight: return(70.3f);

            case WeightClass.Welterweight: return(77.1f);

            case WeightClass.Middleweight: return(83.9f);

            case WeightClass.LightHeavyweight: return(93.0f);

            case WeightClass.Heavyweight: return(120.2f);

            default: return(0f);
            }
        }
Пример #6
0
        public static int GetResolveValue(this AbstractActor actor)
        {
            WeightClass        weightClass     = actor.GetWeightClass();
            MoraleConstantsDef activeMoraleDef = actor.Combat.Constants.GetActiveMoraleDef(actor.Combat);

            // Special case for turrets as in related code (AttackDirector.ResolveSequenceMorale)
            if (actor.UnitType == UnitType.Turret)
            {
                return(activeMoraleDef.ChangeEnemyDestroyedLight);
            }

            switch (weightClass)
            {
            case WeightClass.LIGHT:
                return(activeMoraleDef.ChangeEnemyDestroyedLight);

            case WeightClass.MEDIUM:
                return(activeMoraleDef.ChangeEnemyDestroyedMedium);

            case WeightClass.HEAVY:
                return(activeMoraleDef.ChangeEnemyDestroyedHeavy);

            case WeightClass.ASSAULT:
                return(activeMoraleDef.ChangeEnemyDestroyedAssault);

            default:
                return(0);
            }
        }
Пример #7
0
 public AddWeightClassViewModel(int ageClassId)
 {
     _weightClass = new WeightClass()
     {
         AgeClassId = ageClassId
     };
 }
Пример #8
0
    public void KnockYou(Vector3 dirForce, WeightClass weight)
    {
        if (!buffs.powerActive(Power_Ups.Weeble))
        {
            if (!isKnocked)
            {
                knockForceDir = dirForce;
                knockTimer    = 0;
                isKnocked     = true;
                knockSlowDown = 1;

                playerAnimator.SetBool("KnockOver", true);
            }

            knockForceMultiplier = 1;

            switch (weight)
            {
            case WeightClass.Light:
                knockForceMultiplier = 5f;
                break;

            case WeightClass.Medium:
                knockForceMultiplier = 7.5f;
                break;

            case WeightClass.Heavy:
                knockForceMultiplier = 10f;
                break;
            }

            GetComponent <PlayerInteract>().DropObject();
        }
    }
Пример #9
0
        public static int GetAttackerJumpedAccuracyModifier(AbstractActor attacker)
        {
            if (attacker != null)
            {
                if (attacker.UnitType == UnitType.Mech)
                {
                    WeightClass weightClass = ((Mech)attacker).weightClass;

                    switch (weightClass)
                    {
                    case WeightClass.LIGHT:
                        return(DemandingJumps.Settings.ToHitSelfJumpedPenalties[0]);

                    case WeightClass.MEDIUM:
                        return(DemandingJumps.Settings.ToHitSelfJumpedPenalties[1]);

                    case WeightClass.HEAVY:
                        return(DemandingJumps.Settings.ToHitSelfJumpedPenalties[2]);

                    case WeightClass.ASSAULT:
                        return(DemandingJumps.Settings.ToHitSelfJumpedPenalties[3]);

                    default:
                        break;
                    }
                }
            }
            return(0);
        }
        public static int GetSustainableEvasion(this AbstractActor actor)
        {
            if (actor.UnitType == UnitType.Turret)
            {
                return(0);
            }

            WeightClass weightClass = actor.GetWeightClass();
            Pilot       p           = actor.GetPilot();

            int  sustainableEvasion      = 0;
            bool pilotHasEvasiveMovement = false;
            bool pilotIsMasterTactician  = false;

            using (List <Ability> .Enumerator enumerator = p.Abilities.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    if (enumerator.Current.Def.Description.Id == "AbilityDefP5")
                    {
                        pilotHasEvasiveMovement = true;
                        Logger.Info($"[Utilities_GetSustainableEvasion] Pilot {p.Name} has Evasive Movement");
                    }
                    if (enumerator.Current.Def.Description.Id == "AbilityDefT8A")
                    {
                        pilotIsMasterTactician = true;
                        Logger.Info($"[Utilities_GetSustainableEvasion] Pilot {p.Name} is Master Tactician");
                    }
                }
            }

            if (pilotHasEvasiveMovement)
            {
                if (weightClass == WeightClass.LIGHT)
                {
                    sustainableEvasion = SustainableEvasion.Settings.SustainableEvasionLight;
                }
                else if (weightClass == WeightClass.MEDIUM)
                {
                    sustainableEvasion = SustainableEvasion.Settings.SustainableEvasionMedium;
                }
                else if (weightClass == WeightClass.HEAVY)
                {
                    sustainableEvasion = SustainableEvasion.Settings.SustainableEvasionHeavy;
                }
                else if (weightClass == WeightClass.ASSAULT)
                {
                    sustainableEvasion = SustainableEvasion.Settings.SustainableEvasionAssault;
                }

                // Bonus for Scouts
                if (pilotIsMasterTactician)
                {
                    sustainableEvasion += SustainableEvasion.Settings.MasterTacticianSustainableBonus;
                }
            }
            return(sustainableEvasion);
        }
        public static void Postfix(Mech __instance)
        {
            if (!__instance.Combat.IsLoadingFromSave)
            {
                // to account for Master Tactician, need to check if initiative differs from weight based initiative
                WeightClass weightClass     = __instance.MechDef.Chassis.weightClass;
                int         i               = __instance.StatCollection.GetValue <int>("BaseInitiative");
                int         i_phaseModifier = 0;
                if (weightClass == WeightClass.LIGHT && i != __instance.Combat.Constants.Phase.PhaseLight)
                {
                    i_phaseModifier = i - __instance.Combat.Constants.Phase.PhaseLight;
                }
                else if (weightClass == WeightClass.MEDIUM && i != __instance.Combat.Constants.Phase.PhaseMedium)
                {
                    i_phaseModifier = i - __instance.Combat.Constants.Phase.PhaseMedium;
                }
                else if (weightClass == WeightClass.HEAVY && i != __instance.Combat.Constants.Phase.PhaseHeavy)
                {
                    i_phaseModifier = i - __instance.Combat.Constants.Phase.PhaseHeavy;
                }
                else if (weightClass == WeightClass.ASSAULT && i != __instance.Combat.Constants.Phase.PhaseAssault)
                {
                    i_phaseModifier = i - __instance.Combat.Constants.Phase.PhaseAssault;
                }

                float f_walkSpeed = __instance.MovementCaps.MaxWalkDistance;
                if (f_walkSpeed >= TheEngineInitiative.Settings.MechPhaseSpecialMinSpeed)
                {
                    __instance.Initiative = __instance.Combat.Constants.Phase.PhaseSpecial + i_phaseModifier;
                }
                else if (f_walkSpeed >= TheEngineInitiative.Settings.MechPhaseLightMinSpeed)
                {
                    __instance.Initiative = __instance.Combat.Constants.Phase.PhaseLight + i_phaseModifier;
                }
                else if (f_walkSpeed >= TheEngineInitiative.Settings.MechPhaseMediumMinSpeed)
                {
                    __instance.Initiative = __instance.Combat.Constants.Phase.PhaseMedium + i_phaseModifier;
                }
                else if (f_walkSpeed >= TheEngineInitiative.Settings.MechPhaseHeavyMinSpeed)
                {
                    __instance.Initiative = __instance.Combat.Constants.Phase.PhaseHeavy + i_phaseModifier;
                }
                else
                {
                    __instance.Initiative = __instance.Combat.Constants.Phase.PhaseAssault + i_phaseModifier;
                }

                // now wipe out the old BaseInitiative and add the new one.
                if (__instance.StatCollection.RemoveStatistic("BaseInitiative"))
                {
                    __instance.StatCollection.AddStatistic <int>("BaseInitiative", __instance.Initiative);
                }
            }
        }
Пример #12
0
        public void AdjustStartEndurance(WeightClass weightClass)
        {
            double mult = WeightLossEnduranceMultiplier(weightClass, this.Fighter.Stats.MinWeight);

            this.EndurancePoints          *= mult;
            this.StartFightEndurancePoints = this.EndurancePoints;
            this.EndurancePreRecover       = this.EndurancePoints;

            if (this.Fighter.Stats.MinWeight > 200)
            {
                this.FatigueLossPerRound = (this.Fighter.Stats.MinWeight - 200) / 10;
            }
        }
Пример #13
0
        public static WeightClass GetWeightClass(double minWeight)
        {
            WeightClass ret = WeightClass.Straw;

            foreach (var value in Enum.GetValues(typeof(WeightClass)).OfType <WeightClass>().OrderBy(r => (int)r))
            {
                if (minWeight <= (int)value)
                {
                    ret = value;
                    break;
                }
            }
            return(ret);
        }
Пример #14
0
        /// <summary>
        /// Gets the gender-filtered and weight-class filtered leaderboard of a segment. This method requires the currently
        /// authenticated  athlete to have a Strava premium account.
        /// </summary>
        /// <param name="segmentId">The Strava segment Id.</param>
        /// <param name="gender">The gender used to filter the leaderboard.</param>
        /// /// <param name="weight">The weight class used to filter the leaderboard.</param>
        /// <returns>The leaderboard filtered by gender and weight class.</returns>
        public Leaderboard GetSegmentLeaderboard(String segmentId, Gender gender, WeightClass weight)
        {
            String getUrl = String.Format("{0}/{1}/leaderboard?gender={2}&weight_class={3}&filter=weight_class&access_token={4}",
                                          Endpoints.Leaderboard,
                                          segmentId,
                                          gender.ToString().Substring(0, 1),
                                          UrlHelper.WeightClassToString(weight),
                                          Authentication.AccessToken
                                          );

            String json = WebRequest.SendGet(new Uri(getUrl));

            return(Unmarshaller <Leaderboard> .Unmarshal(json));
        }
        /// <summary>
        /// Pick a mech at random, from the given weight class
        /// </summary>
        /// <param name="weightClass"></param>
        /// <param name="mech"></param>
        /// <returns></returns>
        private bool SelectRandomMech(WeightClass weightClass, out MechDef mech)
        {
            List <MechDef> mechs;

            switch (weightClass)
            {
            case WeightClass.LIGHT: mechs = PossibleLight; break;

            case WeightClass.MEDIUM: mechs = PossibleMedium; break;

            case WeightClass.HEAVY: mechs = PossibleHeavy; break;

            default: mechs = PossibleAssault; break;
            }
            return(SelectRandomMech(mechs, out mech));
        }
Пример #16
0
 private static float GetTargetSizeModifier(WeightClass weightClass)
 {
     switch (weightClass)
     {
         case WeightClass.LIGHT:
             return MechStatisticsRules.Combat.ToHit.ToHitLight;
         case WeightClass.MEDIUM:
             return MechStatisticsRules.Combat.ToHit.ToHitMedium;
         case WeightClass.HEAVY:
             return MechStatisticsRules.Combat.ToHit.ToHitHeavy;
         case WeightClass.ASSAULT:
             return MechStatisticsRules.Combat.ToHit.ToHitAssault;
         default:
             return 0;
     }
 }
Пример #17
0
        public static double WeightLossEnduranceMultiplier(WeightClass weightClass, double minWeight)
        {
            if (weightClass == WeightClass.Heavy)
            {
                return(1);
            }

            if (minWeight <= (int)weightClass)
            {
                return(1);
            }

            double mult = (int)weightClass / minWeight;

            return(Math.Pow(mult, 2));
        }
Пример #18
0
        /// <summary>
        /// Gets the gender-filtered and weight-class filtered leaderboard of a segment. This method requires the currently
        /// authenticated  athlete to have a Strava premium account.
        /// </summary>
        /// <param name="segmentId">The Strava segment Id.</param>
        /// <param name="gender">The gender used to filter the leaderboard.</param>
        /// /// <param name="weight">The weight class used to filter the leaderboard.</param>
        /// <returns>The leaderboard filtered by gender and weight class.</returns>
        public Leaderboard GetSegmentLeaderboard(String segmentId, Gender gender, WeightClass weight)
        {
            String weightClass = String.Empty;

            switch (weight)
            {
            case WeightClass.One:
                weightClass = "0_54";
                break;

            case WeightClass.Two:
                weightClass = "55_64";
                break;

            case WeightClass.Three:
                weightClass = "65_74";
                break;

            case WeightClass.Four:
                weightClass = "75_84";
                break;

            case WeightClass.Five:
                weightClass = "85_94";
                break;

            case WeightClass.Six:
                weightClass = "95_plus";
                break;
            }

            String getUrl = String.Format("{0}/{1}/leaderboard?gender={2}&weight_class={3}&filter=weight_class&access_token={4}",
                                          Endpoints.Leaderboard,
                                          segmentId,
                                          gender.ToString().Substring(0, 1),
                                          weightClass,
                                          Authentication.AccessToken
                                          );

            String json = WebRequest.SendGet(new Uri(getUrl));

            return(Unmarshaller <Leaderboard> .Unmarshal(json));
        }
Пример #19
0
        // Set the game's MaxMeleeVerticalOffset to very high, then filter nodes at GetPathNodesForPoints
        public static void CheckMeleeVerticalOffset(List <PathNode> __result)
        {
            try {
                if (thisMeleeTarget == null || __result.IsNullOrEmpty())
                {
                    return;
                }
                //Verbo( "Checking {0} offsets", __result.Count );
                float       targetY = thisMeleeTarget.CurrentPosition.y, maxY = 0;
                WeightClass lowerClass = 0;
                for (int i = __result.Count - 1; i >= 0; i--)
                {
                    float attackerY = __result[i].Position.y;
                    if (attackerY > targetY)
                    {
                        lowerClass = thisMeleeTarget is Mech mech ? mech.weightClass : WeightClass.LIGHT;
                    }
                    else if (targetY > attackerY)
                    {
                        lowerClass = thisMeleeAttacker is Mech mech ? mech.weightClass : WeightClass.LIGHT;
                    }
                    else
                    {
                        continue;
                    }
                    switch (lowerClass)
                    {
                    case WeightClass.LIGHT: maxY = MaxMeleeVerticalOffsetByClass[0]; break;

                    case WeightClass.MEDIUM: maxY = MaxMeleeVerticalOffsetByClass[1]; break;

                    case WeightClass.HEAVY: maxY = MaxMeleeVerticalOffsetByClass[2]; break;

                    case WeightClass.ASSAULT: maxY = MaxMeleeVerticalOffsetByClass[3]; break;
                    }
                    //Verbo( "Offset {0}: class {1}, maxY {2}, diff {3}, attacker {4}, target {5}", i, lowerClass, maxY, attackerY - targetY, attackerY, targetY );
                    if (Math.Abs(attackerY - targetY) > maxY)
                    {
                        __result.RemoveAt(i);
                    }
                }
            }                 catch (Exception ex) { Error(ex); }
        }
Пример #20
0
        void Read()
        {
            List <byte> datapool = null;

            datapool = new List <byte>();
            while (!stop)
            {
                Thread.Sleep(20);
                try
                {
                    if (sm == null || !sm.DataAvailable)
                    {
                        continue;
                    }

                    var rbuf = new byte[2048];
                    var pos  = sm.Read(rbuf, readbuffoffset, rbuf.Length);
                    datapool.AddRange(rbuf.Take(pos));
                    //LogHelper.Log("sm.Read:读取到数据没有嘛" + pos);
                    while (datapool.Count > 0)
                    {
                        datastr = string.Empty;
                        var         headerbuf = datapool.Take(100).ToArray();
                        var         headerstr = Encoding.Unicode.GetString(headerbuf).Trim('\0');
                        var         json      = JsonHelper.ToObject(headerstr);
                        WeightClass cWeight   = JsonConvert.DeserializeObject <WeightClass>(headerstr);

                        var cmd = json["Cmd"];            //拿到获取重量的状态
                        //var weight = json["Weight"];//拿到重量
                        var reply = json["Reply"];        //拿到读取重量的状态
                        uiData.Weight   = cWeight.weight; //cWeight.cmd;
                        uiData.FitCmd   = cWeight.cmd.ToString();
                        uiData.FitReply = cWeight.reply.ToString();
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Log(ex);
                }
            }
        }
Пример #21
0
    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.GetComponent <PlayerCollision>() != null)
        {
            Vector3 dir = col.transform.position - transform.position;
            dir = dir.normalized;

            WeightClass kg = WeightClass.None;

            if (GetComponent <PlayerInteract>().GetHeldObject() != null)
            {
                kg = GetComponent <PlayerInteract>().GetHeldObject().GetComponent <ObjectData>().getWeight();
            }

            col.gameObject.GetComponent <PlayerCollision>().KnockYou(dir, kg);

            lerpRotation = Quaternion.LookRotation(dir, Vector3.up);

            Debug.Log("knock yo");
        }
    }
Пример #22
0
        /// <summary>
        /// gets division champion
        /// </summary>
        /// <param name="weightClass">weight class</param>
        /// <returns>champion name</returns>
        public string GetDivisionChampion(WeightClass weightClass)
        {
            switch (weightClass)
            {
            case WeightClass.Flyweight: return("Henry Cejudo");

            case WeightClass.Bantamweight: return("TJ Dillashaw");

            case WeightClass.Featherweight: return("Max BLESSED Holloway");

            case WeightClass.Lightweight: return("Khabib THE EAGLE Nurmagomedov");

            case WeightClass.Welterweight: return("Tyron THE CHOSEN ONE Woodley");

            case WeightClass.Middleweight: return("Robert THE REAPER Whittaker");

            case WeightClass.LightHeavyweight: return("Jon BONES Jones");

            case WeightClass.Heavyweight: return("Daniel DC Cormier");

            default: return("");
            }
        }
Пример #23
0
        public static WeightClass GetWeightClass(this AbstractActor actor)
        {
            WeightClass weightClass = WeightClass.LIGHT;

            if (actor.UnitType == UnitType.Turret)
            {
                weightClass = (actor as Turret).TurretDef.Chassis.weightClass;
            }
            else if (actor.UnitType == UnitType.Vehicle)
            {
                weightClass = (actor as Vehicle).VehicleDef.Chassis.weightClass;
            }
            else if (actor.UnitType == UnitType.Mech)
            {
                weightClass = (actor as Mech).MechDef.Chassis.weightClass;
            }
            else
            {
                // Throw error
                Logger.Debug($"[AbstractActorExtensions_GetWeightClass] ({actor.DisplayName}) is an unknown specialization of AbstractActor");
            }

            return(weightClass);
        }
Пример #24
0
        public override void SetInventorySlot(int index, Item item)
        {
            base.SetInventorySlot(index, item);

            int itemCount = 0;

            for (int i = 0; i < MaxInventorySize; i++)
            {
                if (GetInventorySlot(i) != null)
                {
                    itemCount++;
                }
            }
            weight = WeightClass.LIGHT;
            for (int i = 0; i < (int)WeightClass.COUNT; i++)
            {
                if (itemCount >= data.weightClassItemCount[i])
                {
                    weight = (WeightClass)i;
                }
            }

            OnInventoryChange?.Invoke();
        }
 public SingleTypefaceInfo(string path, DataFormat format, string family, FontRestrictions restrictions, WeightClass weight, WidthClass width, FontSelection selection, long offset)
 {
     this.Source       = path;
     this.SourceFormat = format;
     this.FamilyName   = family;
     this.Restrictions = restrictions;
     this.FontWeight   = weight;
     this.FontWidth    = width;
     this.Selections   = selection;
     this.OffsetInFile = offset;
     _thisRef          = new IFontInfo[] { this };
 }
Пример #26
0
 public double GetWeight(WeightClass weightClass)
 {
     return((int)weightClass > this.Weight ? this.Weight : (double)((int)weightClass));
 }
Пример #27
0
        /// <summary>
        /// Gets the gender-filtered and weight-class filtered leaderboard of a segment. This method requires the currently 
        /// authenticated  athlete to have a Strava premium account.
        /// </summary>
        /// <param name="segmentId">The Strava segment Id.</param>
        /// <param name="gender">The gender used to filter the leaderboard.</param>
        /// /// <param name="weight">The weight class used to filter the leaderboard.</param>
        /// <returns>The leaderboard filtered by gender and weight class.</returns>
        public Leaderboard GetSegmentLeaderboard(String segmentId, Gender gender, WeightClass weight)
        {
            String weightClass = String.Empty;

            switch (weight)
            {
                case WeightClass.One:
                    weightClass = "0_54";
                    break;
                case WeightClass.Two:
                    weightClass = "55_64";
                    break;
                case WeightClass.Three:
                    weightClass = "65_74";
                    break;
                case WeightClass.Four:
                    weightClass = "75_84";
                    break;
                case WeightClass.Five:
                    weightClass = "85_94";
                    break;
                case WeightClass.Six:
                    weightClass = "95_plus";
                    break;
            }

            String getUrl = String.Format("{0}/{1}/leaderboard?gender={2}&weight_class={3}&filter=weight_class&access_token={4}",
                Endpoints.Leaderboard,
                segmentId,
                gender.ToString().Substring(0, 1),
                weightClass,
                Authentication.AccessToken
                );

            String json = WebRequest.SendGet(new Uri(getUrl));

            return Unmarshaller<Leaderboard>.Unmarshal(json);
        }
Пример #28
0
 /// <summary>Division constructor</summary>
 /// <param name="weightClass">wieght class</param>
 public Division(WeightClass weightClass)
 {
     this._weightClass = weightClass;
 }
Пример #29
0
        /// <summary>
        /// Gets the gender-filtered and weight-class filtered leaderboard of a segment. This method requires the currently 
        /// authenticated  athlete to have a Strava premium account.
        /// </summary>
        /// <param name="segmentId">The Strava segment Id.</param>
        /// <param name="gender">The gender used to filter the leaderboard.</param>
        /// /// <param name="weight">The weight class used to filter the leaderboard.</param>
        /// <returns>The leaderboard filtered by gender and weight class.</returns>
        public Leaderboard GetSegmentLeaderboard(String segmentId, Gender gender, WeightClass weight)
        {
            String getUrl = String.Format("{0}/{1}/leaderboard?gender={2}&weight_class={3}&filter=weight_class&access_token={4}",
                Endpoints.Leaderboard,
                segmentId,
                gender.ToString().Substring(0, 1),
                UrlHelper.WeightClassToString(weight),
                Authentication.AccessToken
                );

            String json = WebRequest.SendGet(new Uri(getUrl));
            return Unmarshaller<Leaderboard>.Unmarshal(json);
        }
Пример #30
0
 internal FontSubfamily(StyleClass style, WeightClass weight, WidthClass width)
 {
     Style  = style;
     Weight = weight;
     Width  = width;
 }
Пример #31
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="weightClass">weightClass</param>
 public SuperDivision(WeightClass weightClass)
     : base(weightClass)
 {
 }
Пример #32
0
        /* Requirement #5 stated the following:
         *  Pet decisions shall be made using the following hierarchy (1 overrides 2, 2 overrides 3, etc.):
         *            1) Type
         *            2) Classification
         *            3) Weight
         *            4) Default Type/Classification/Weight on person object
         *
         * So order to satisfy this requirement, the "IsGood" method was adjusted to make decisions first based in a 4, 3, 2, 1 order.
         * First it will check the default behavior, then will evaluate the pet status based on weight overrides, then classification, and finally, type.
         */
        private static string IsGood(PersonModel person, PetModel pet)
        {
            //Defaulting the status to "bad"...assuming this person would not want a pet unless proven otherwise.
            string PetStatus = "bad";

            //Confirming if the weight of the animal matches the preferred weight class of the person.
            bool WeightMatch = false;

            if (person.PreferredPetWeightClass.ToLower() == WeightClass.GetClass(pet.Weight).ToLower())
            {
                WeightMatch = true;
            }

            //Confirming whether or not the preferred classification of the pet matches the person's preference.
            bool PreferredClassificationMatch = false;

            if (person.PreferredClassification == pet.Classification)
            {
                PreferredClassificationMatch = true;
            }

            //Confirming whether or not the preferred pet type matches the person's preferences.
            bool PreferredPetTypeMatch = false;

            if (person.PreferredType == pet.Type)
            {
                PreferredPetTypeMatch = true;
            }

            //Default Type/Classification/Weight decision made based on the person's preferences, similar to the original version of the code.
            //If one of the condition matches (weight, classification, or type), it can be considered a potential good pet.
            if (WeightMatch || PreferredClassificationMatch || PreferredPetTypeMatch)
            {
                PetStatus = "good";
            }

            //Checks to see if the person object (or derived class of it) has any overrides.
            //If any exist, it does 3 "for" loops through all the available overrides, checking for weight, then class, then type.
            if (person.GetOverrides() != null && person.GetOverrides().Count > 0)
            {
                foreach (PreferenceOverride ov in person.GetOverrides())
                {
                    if (ov.OverrideType == "weight")
                    {
                        if (WeightClass.GetClass(pet.Weight) == ov.OverrideType)
                        {
                            if (ov.Like)
                            {
                                PetStatus = "good";
                            }
                            else if (!ov.Like)
                            {
                                PetStatus = "bad";
                            }
                        }
                    }
                }

                foreach (PreferenceOverride ov in person.GetOverrides())
                {
                    if (ov.OverrideType == "classification")
                    {
                        if (pet.Classification == ov.Classification)
                        {
                            if (ov.Like)
                            {
                                PetStatus = "good";
                            }
                            else if (!ov.Like)
                            {
                                PetStatus = "bad";
                            }
                        }
                    }
                }

                foreach (PreferenceOverride ov in person.GetOverrides())
                {
                    if (ov.OverrideType == "type")
                    {
                        if (pet.Type == ov.PetType)
                        {
                            if (ov.Like)
                            {
                                PetStatus = "good";
                            }
                            else if (!ov.Like)
                            {
                                PetStatus = "bad";
                            }
                        }
                    }
                }
            }

            //Returns the pet status (i.e. "good" or "bad")
            return(PetStatus);
        }