Exemple #1
0
        public void TestInMemoryConfigurationFile()
        {
            const int EXPECTED_NUM_LINES            = 12;
            string    directory                     = ConfigurationManager.GetConfigurationValue("TEST_ROAD_TEAM_DIRECTORY_2");//Lou Piniella
            string    coachInfoFilePath             = TextUtilities.FormFilePathName(directory, "Coach", ".dat");
            InMemoryConfigurationFile coachInfoFile = ConfigurationManager.GetInMemoryConfigFile(coachInfoFilePath);

            Assert.NotNull(coachInfoFile);
            Assert.IsTrue(EXPECTED_NUM_LINES == coachInfoFile.Count);
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:StatusQuoBaseball.Base.CoachingStats"/> class.
 /// </summary>
 /// <param name="managerialTendencies">Managerial tendencies.</param>
 public CoachingStats(InMemoryConfigurationFile managerialTendencies)
 {
     this.rating = Convert.ToInt32(Convert.ToDouble(managerialTendencies["winPct"]) * 100);
     this.rating = Convert.ToInt32(rating * Convert.ToDouble(ConfigurationManager.GetConfigurationValue("PROFESSIONAL_COACH_RATING_MODIFIER")));
     if (this.rating > 100)
     {
         this.rating = 100;
     }
     this.prestige = Convert.ToInt32(Convert.ToDouble(managerialTendencies["accolades"]) * Convert.ToDouble(ConfigurationManager.GetConfigurationValue("PROFESSIONAL_COACH_PRESTIGE_MODIFIER")));
     if (this.prestige > 100)
     {
         this.prestige = 100;
     }
     this.steal2ndBase    = Convert.ToInt32(Convert.ToDouble(managerialTendencies["steal2nd"]));
     this.steal2ndBase    = this.steal2ndBase < 1 ? this.steal2ndBase = 1 : this.steal2ndBase = 0;
     this.steal3rdBase    = Convert.ToInt32(Convert.ToDouble(managerialTendencies["steal3rd"]));
     this.steal3rdBase    = this.steal3rdBase < 1 ? this.steal3rdBase = 1 : this.steal3rdBase = 0;
     this.sacrificeBunt   = Convert.ToInt32(Convert.ToDouble(managerialTendencies["sacBunt"]));
     this.sacrificeBunt   = this.sacrificeBunt < 1 ? this.sacrificeBunt = 1 : this.sacrificeBunt = 0;
     this.intentionalWalk = Convert.ToInt32(Convert.ToDouble(managerialTendencies["IBB"]));
     this.intentionalWalk = this.intentionalWalk < 1 ? this.intentionalWalk = 1 : this.intentionalWalk = 0;
 }
Exemple #3
0
        public void TestLoadCoachFromFile()
        {
            //Load Coach/manager from baseballreference.com
            Coach ret = null;
            InMemoryConfigurationFile coachInfoFile = null;
            string coachInfoFilePath = TextUtilities.FormFilePathName(ConfigurationManager.GetConfigurationValue("TEST_ROAD_TEAM_DIRECTORY_2"), "Coach", ".dat");

            if (File.Exists(coachInfoFilePath))
            {
                try
                {
                    coachInfoFile = ConfigurationManager.GetInMemoryConfigFile(coachInfoFilePath);

                    //Player-relevant fields
                    string   lName    = coachInfoFile["lastName"].ToString();
                    string   fName    = coachInfoFile["firstName"].ToString();
                    string   position = coachInfoFile["position"].ToString();
                    Height   height   = new Height(coachInfoFile["height"].ToString());
                    Weight   weight   = new Weight(Convert.ToInt32(coachInfoFile["weight"]));
                    Birthday bDay     = new Birthday(coachInfoFile["birthday"].ToString());

                    ret = new Coach(Guid.NewGuid().ToString(), lName, fName, "", position, Race.Unknown, Handedness.Unknown, Handedness.Unknown, height, weight, bDay);

                    //Managerial Tendencies form Coaching Stats
                    CoachingStats cStats = new CoachingStats(coachInfoFile);
                    if (cStats != null)
                    {
                        ret.CoachingStats = cStats;
                    }

                    Assert.IsTrue(ret.FullName.Equals("Lou Piniella"));
                    Assert.IsTrue(ret.CoachingStats.Rating == 91);//52 * 1.75
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Loads the coach from file.
        /// </summary>
        /// <returns>Coach</returns>
        /// <param name="directory">string</param>
        private static Coach LoadCoachFromFile(string directory)
        {
            Coach ret = null;
            InMemoryConfigurationFile coachInfoFile = null;
            string coachInfoFilePath = TextUtilities.FormFilePathName(directory, "Coach", ".dat");

            if (File.Exists(coachInfoFilePath))
            {
                try
                {
                    coachInfoFile = ConfigurationManager.GetInMemoryConfigFile(coachInfoFilePath);

                    //Player-relevant fields
                    string   lName    = coachInfoFile["lastName"].ToString();
                    string   fName    = coachInfoFile["firstName"].ToString();
                    string   position = coachInfoFile["position"].ToString();
                    Height   height   = new Height(coachInfoFile["height"].ToString());
                    Weight   weight   = new Weight(Convert.ToInt32(coachInfoFile["weight"]));
                    Birthday bDay     = new Birthday(coachInfoFile["birthday"].ToString());

                    ret = new Coach(Guid.NewGuid().ToString(), lName, fName, "", position, Race.Unknown, Handedness.Unknown, Handedness.Unknown, height, weight, bDay);

                    //Managerial Tendencies form Coaching Stats
                    CoachingStats cStats = new CoachingStats(coachInfoFile);
                    if (cStats != null)
                    {
                        ret.CoachingStats = cStats;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            return(ret);
        }