예제 #1
0
        public TeamForm(Team team)
        {
            this.team = team;

            ListViewItem item;
            InitializeComponent();

            // should use ListViewItems

            foreach (Batter btr in team.Hitters)
            {
                item = new ListViewItem();
                FillItem(item, btr);
                item.Tag = btr;
                batterListView.Items.Add(item);
            }

            foreach (Pitcher ptr in team.StartingPitchers)
            {
                item = new ListViewItem();
                FillItem(item, ptr);
                item.Tag = ptr;
                starterListView.Items.Add(item);
            }

            foreach (Pitcher ptr in team.BullPen)
            {
                item = new ListViewItem();
                FillItem(item, ptr);
                item.Tag = ptr;
                bullpenListView.Items.Add(item);
            }
        }
예제 #2
0
        public TeamLineupForm(Team tm, bool useGameMode)
        {
            InitializeComponent();

            team = tm;
            GameMode = useGameMode;

            LoadLists(tm);
        }
예제 #3
0
        public TeamLineupForm(Team tm)
        {
            InitializeComponent();

            team = tm;
            GameMode = false;

            LoadLists(tm);
        }
예제 #4
0
        public int AddTeam(Team team)
        {
            teams.Add(team);

            return teams.Count;
        }
예제 #5
0
 private void ShowTeam(Team team)
 {
     TeamForm frm = new TeamForm(team);
     frm.ShowDialog();
 }
예제 #6
0
        private void newTeamToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddTeamForm frm = new AddTeamForm();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                Team tm = new Team(frm.TeamName, 1, frm.TeamAbbrev);
                teams.Add(tm);
                bindingList.Add(tm);

            }
        }
예제 #7
0
        private void ShowTeamForm(Team team, bool modal)
        {
            TeamForm form = new TeamForm(team);

            if (modal == true)
            {
                form.ShowDialog();
            }
            else
            {
                form.Show();
            }
        }
예제 #8
0
        private void EditLineup(Team tm, bool homeTeam)
        {
            TeamLineupForm frm = new TeamLineupForm(tm, true);
            frm.GameMode = true;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                if (frm.PitcherModified == true)
                {
                    Label pitcherLabel = (homeTeam == true) ? lblHomepitcher : lblVispitcher;

                    pitcherLabel.Text = tm.CurrentPitcher.Name;

                    engine.SwapCurrentPitcher(homeTeam);
                }
            }
        }
예제 #9
0
        private void InitializeGameStats()
        {
            string result;
            battingTeam = visitingTeam;
            fieldingTeam = homeTeam;
            battingLocation = TeamLocation.Visitor;
            score.Reset();

            winningPitcher = null;
            losingPitcher = null;
            savePitcher = null;

            runnerOnFirst = null;
            runnerOnSecond = null;
            runnerOnThird = null;
            currentHitter = null;
            currentPitcher = null;

            outs = 0;
            RaiseLineScoreUpdateEvent(LineScoreUpdateType.Outs, -1, outs, battingLocation, "");
            inning = 1;
            RaiseLineScoreUpdateEvent(LineScoreUpdateType.Inning, inning, -1, battingLocation, "");
            RaiseInningChangeEvent(inning);
            teamAtBat = VISITING_TEAM;
            teamInField = HOME_TEAM;

            atBatIndex[VISITING_TEAM] = 0;
            atBatIndex[HOME_TEAM] = 0;
            runs[VISITING_TEAM] = 0;
            hits[VISITING_TEAM] = 0;
            errors[VISITING_TEAM] = 0;
            runs[HOME_TEAM] = 0;
            hits[HOME_TEAM] = 0;
            errors[HOME_TEAM] = 0;

            gameLog = new StringBuilder();
            result = string.Format("{0} {1}:\r\n\r\n", (teamAtBat == VISITING_TEAM) ? "TOP" : "BOTTOM",
                inning);
            gameLog.Append(result);

            for (int i = 0; i < 30; i++)
            {
                inningScores[HOME_TEAM, i] = inningScores[VISITING_TEAM, i] = -1;
            }
        }
예제 #10
0
        void SwapTeams()
        {
            int tmp;
            Team tmpTeam;

            tmp = teamAtBat;
            teamAtBat = teamInField;
            teamInField = tmp;

            tmpTeam = fieldingTeam;
            fieldingTeam = battingTeam;
            battingTeam = tmpTeam;

            battingLocation = battingLocation == TeamLocation.Home ? TeamLocation.Visitor : TeamLocation.Home;
        }
예제 #11
0
        private void SelectVisitingTeam()
        {
            Pitcher pitcher;
            Batter batter;

            visitingTeam = new Team();

            // for now create players in code and add to roster
            pitcher = new Pitcher(5, 7, ThrowingSide.Right, 600, PitcherType.Starter,
                "00000111222223334557", "Kevin Brown");
            visitingTeam.AddPitcher(pitcher);

            pitcher = new Pitcher(4, 7, ThrowingSide.Right, 430, PitcherType.Starter,
                "11000002222223333455", "Jose Lima");
            visitingTeam.AddPitcher(pitcher);

            pitcher = new Pitcher(4, 7, ThrowingSide.Left, 330, PitcherType.Starter,
                "11100000222223334555", "Odalis Perez");
            visitingTeam.AddPitcher(pitcher);

            pitcher = new Pitcher(3, 6, ThrowingSide.Right, 270, PitcherType.Starter,
                "11000002222222334459", "Darren Dreifort");
            visitingTeam.AddPitcher(pitcher);

            batter = new Batter(BattingSide.SwitchHitter, 9, Position.SecondBase, 2, Position.None, 0, 15,
                320, "11224444445555567789", "Jose Offerman");
            visitingTeam.AddBatter(batter);

            batter = new Batter(BattingSide.LeftHanded, 9, Position.LeftRight, 1, Position.FirstBase, 0, 15,
                280, "00022444444555557779", "John Vander Wal");
            visitingTeam.AddBatter(batter);

            batter = new Batter(BattingSide.LeftHanded, 10, Position.FirstBase, 1, Position.None, 0, 10,
                360, "22234444444455557799", "John Olerud");
            visitingTeam.AddBatter(batter);

            batter = new Batter(BattingSide.RightHanded, 10, Position.LeftRight, 2, Position.None, 0, 10,
                490, "00444444555555777999", "Kevin Pulsifer");
            visitingTeam.AddBatter(batter);

            batter = new Batter(BattingSide.RightHanded, 10, Position.CenterField, 4, Position.None, 0, 20,
                490, "00444444555555777999", "David Pulsifer");
            visitingTeam.AddBatter(batter);

            batter = new Batter(BattingSide.LeftHanded, 9, Position.LeftRight, 1, Position.None, 0, 20,
                340, "00044444445555556799", "J.D. Drew");
            visitingTeam.AddBatter(batter);

            batter = new Batter(BattingSide.RightHanded, 9, Position.ThirdBase, 2, Position.None, 0, 15,
                320, "02223445555555557799", "Chris Stynes");
            visitingTeam.AddBatter(batter);

            batter = new Batter(BattingSide.LeftHanded, 9, Position.Catcher, 0, Position.None, 0, 10,
                180, "02234444444555555779", "Scott Hatteberg");
            visitingTeam.AddBatter(batter);

            batter = new Batter(BattingSide.RightHanded, 7, Position.Shortstop, 3, Position.None, 0, 15,
                230, "00244445555555567999", "Jose Hernandez");
            visitingTeam.AddBatter(batter);

            visitingTeamSelected = true;
            visitingTeam.Name = "Brooklyn Dodgers";
            visitingTeam.Abbrev = "BRK";

            visitingTeam.SetLineUp();

            visitingLineupSelected = true;

            RaiseLineScoreUpdateEvent(LineScoreUpdateType.Name, -1, -1, TeamLocation.Visitor, visitingTeam.Abbrev);
        }
예제 #12
0
        private void SelectHomeTeam()
        {
            Pitcher pitcher;
            Batter batter;

            homeTeam = new Team();

            // for now create players in code and add to roster
            pitcher = new Pitcher(5, 7, ThrowingSide.Right, 550, PitcherType.Starter,
                "10000002222233333457", "Curt Schilling");
            homeTeam.AddPitcher(pitcher);

            pitcher = new Pitcher(4, 7, ThrowingSide.Right, 550, PitcherType.Starter,
                "11110000002222233335", "Derek Lowe");
            homeTeam.AddPitcher(pitcher);

            pitcher = new Pitcher(5, 6, ThrowingSide.Right, 440, PitcherType.Starter,
                "11100000222223333555", "Pedro Martinez");
            homeTeam.AddPitcher(pitcher);

            pitcher = new Pitcher(3, 6, ThrowingSide.Right, 250, PitcherType.Starter,
                "11110000222222334557", "Tim Wakefield");
            homeTeam.AddPitcher(pitcher);

            batter = new Batter(BattingSide.LeftHanded, 12, Position.CenterField, 0, Position.None, 0, 22,
                390, "00222344555555666679", "Jacoby Ellsbury");
            homeTeam.AddBatter(batter);

            batter = new Batter(BattingSide.RightHanded, 12, Position.Shortstop, 2, Position.None, 0, 17,
                590, "02223344555555677899", "Nomar Garciaparra");
            homeTeam.AddBatter(batter);

            batter = new Batter(BattingSide.LeftHanded, 14, Position.DesignatedHitter, 0, Position.None, 0, 10,
                540, "00223344444455557799", "David Ortiz");
            homeTeam.AddBatter(batter);

            batter = new Batter(BattingSide.RightHanded, 14, Position.LeftRight, 0, Position.None, 0, 10,
                610, "00233344444455557799", "Manny Ramirez");
            homeTeam.AddBatter(batter);

            batter = new Batter(BattingSide.RightHanded, 12, Position.FirstBase, 1, Position.None, 0, 15,
                270, "00223344444455555579", "Kevin Youkilis");
            homeTeam.AddBatter(batter);

            batter = new Batter(BattingSide.RightHanded, 11, Position.ThirdBase, 3, Position.None, 0, 12,
                230, "02233344455555555799", "Mike Lowell");
            homeTeam.AddBatter(batter);

            batter = new Batter(BattingSide.LeftHanded, 12, Position.LeftRight, 0, Position.None, 0, 12,
                340, "00023334444455557799", "Trot Nixon");
            homeTeam.AddBatter(batter);

            batter = new Batter(BattingSide.SwitchHitter, 12, Position.Catcher, 5, Position.None, 0, 15,
                360, "00223344445555566779", "Jason Varitek");
            homeTeam.AddBatter(batter);

            batter = new Batter(BattingSide.RightHanded, 11, Position.SecondBase, 3, Position.None, 0, 17,
                250, "02223344455555556779", "Dustin Pedroia");
            homeTeam.AddBatter(batter);

            homeTeamSelected = true;
            homeTeam.Name = "Boston Red Sox";
            homeTeam.Abbrev = "BOS";

            homeTeam.SetLineUp();

            homeLineupSelected = true;

            RaiseLineScoreUpdateEvent(LineScoreUpdateType.Name, -1, -1, TeamLocation.Home, homeTeam.Abbrev);
        }
예제 #13
0
        private List<Team> GetTeams2(int leagueId, League lge)
        {
            DataTable table;
            List<Team> teamList = new List<Team>();

            table = DbUtils.GetDataTable(string.Format("select * from teams where league_id = {0}", leagueId));
            foreach (DataRow row in table.Rows)
            {
                Team team = new Team(row, lge);
                teamList.Add(team);
            }

            return teamList;
        }
예제 #14
0
        private void LoadLists(Team tm)
        {
            foreach (Batter btr in tm.Hitters)
            {
                AddToBatterList(btr);
            }

            int slotNum = 1;

            foreach (BattingOrderSlot slot in tm.BattingOrder)
            {
                ListViewItem lvi;

                lvi = new ListViewItem(slotNum.ToString());

                if (slot == null)
                {
                    lvi.SubItems.Add("[empty]");
                    lvi.SubItems.Add("");

                    lineupListView.Items.Add(lvi);
                }
                else
                {
                    lvi.SubItems.Add(slot.Hitter.Name);
                    lvi.SubItems.Add(EnumHelpers.PositionToString(slot.FieldingPosition));
                    lvi.Tag = slot.Hitter;

                    lineupListView.Items.Add(lvi);
                    RemoveFromBatterList(slot.Hitter);
                }
                slotNum++;

            }

            foreach (Pitcher ptr in tm.StartingPitchers)
            {
                if (GameMode == true && team.CurrentPitcher.ID == ptr.ID)
                {
                    pitcherTextbox.Tag = ptr;
                    pitcherTextbox.Text = ptr.Name;
                }
                else
                {
                    ListViewItem lvi = new ListViewItem(ptr.Name);
                    lvi.Tag = ptr;
                    startersListView.Items.Add(lvi);
                }
            }

            foreach (Pitcher ptr in tm.BullPen)
            {
                if (GameMode == true && team.CurrentPitcher.ID == ptr.ID)
                {
                    pitcherTextbox.Tag = ptr;
                    pitcherTextbox.Text = ptr.Name;
                }
                else
                {
                    ListViewItem lvi = new ListViewItem(ptr.Name);
                    lvi.Tag = ptr;
                    lvi.SubItems.Add(ptr.PitcherRole.ToString());
                    bullpenListView.Items.Add(lvi);
                }
            }

            return;
        }