Example #1
0
        public Team PopulateTeam(Team.TeamType cType)
        {
            //read roster from JSON file and populate team objects with players
              try
              {
              Team iTeam = new Team();
              iTeam.TypeOfTeam = cType;
              StreamReader Reader = new StreamReader("c:\\temp\\" + cType.ToString() + ".json");
              string json = Reader.ReadToEnd();
              List<String> PlayersList = JsonConvert.DeserializeObject<List<String>>(json);
              iTeam.TeamPlayers = new List<Player>();

              FieldingPosition fp = FieldingPosition.Pitcher;
              foreach (String PlayerName in PlayersList)
              {

                  Player Pl = new Player();
                  Pl.Name = PlayerName.ToString();
                  Pl.FieldingPositionNow = fp;
                  iTeam.TeamPlayers.Add(Pl);
                  fp++;
              }
              return iTeam;
              }
              catch (Exception e)
              {
              Console.WriteLine(e.Message);
              return null;
              }
        }
        public void initializeGame(String HomeTeamName, String AwayTeamName)
        {
            TodayGame = new Game();

               HomeTeam =  TodayGame.PopulateTeam(Team.TeamType.Home);
               HomeTeam.Name = HomeTeamName;
               AwayTeam = TodayGame.PopulateTeam(Team.TeamType.Away);
               AwayTeam.Name = AwayTeamName;

               //assign teams to the game reference pointers
               TodayGame.HomeTeam = HomeTeam;
               TodayGame.AwayTeam = AwayTeam;

               TodayGame.CurrentInning = new Inning();
               TodayGame.CurrentInning.InningNumber = 1.0;
               TodayGame.CurrentInning.HalfInning = Team.TeamType.Home;
        }
Example #3
0
        public void updateMultisimStats(Game game)
        {
            iterations++;
            home = game.HomeTeam;
            away = game.AwayTeam;
            homeOrder = game.homeOrder;
            awayOrder = game.awayOrder;

            homeRuns += game.hRuns;
            homeAVGRuns = homeRuns/iterations;
            awayRuns += game.aRuns;
            awayAVGRuns = awayRuns/iterations;

            if (game.hRuns > game.aRuns)
            homeWins++;
            else
            awayWins++;

            homeAVGWins = homeWins/iterations;
            awayAVGWins = awayWins/iterations;

            updateHomeStats();
            updateAwayStats();
        }
Example #4
0
 private String teamTab(Team t)
 {
     int length = t.Name.Length;
     int tabsNeeded;
     String tabs = "";
     if (length <= 15)
     tabsNeeded = 3;
     else if (length <= 25)
     tabsNeeded = 2;
     else
     tabsNeeded = 1;
     for (int i = 0; i < tabsNeeded; i++)
     tabs += "\t";
     return tabs;
 }