Beispiel #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;
              }
        }
 private String playerTab(Player p)
 {
     int length = p.toString().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;
 }
Beispiel #3
0
        public void SubPlayer(Player player, int battingPosition , FieldingPosition position)
        {
            Player replaced = currentOrder[battingPosition];

            player.HittingPositionNow = battingPosition;
            player.FieldingPositionNow = position;
            currentFielders[(int)position - 1] = player;
            currentOrder[(int)battingPosition - 1] = player;
        }
Beispiel #4
0
 public void StartPlayer(Player player,int battingPosition, FieldingPosition position)
 {
     player.HittingPositionNow = battingPosition;
     player.FieldingPositionNow = position;
     currentFielders[(int)position] = player;
     currentOrder[(int)battingPosition - 1] = player;
 }