private CTeamRecord selectedTeam;    //Need just 1 of these.


        public PickTeamsController(IntPtr handle) : base(handle)
        {
            // ---------------------------------------------------------
            //leagueList = new List<string> { "NL2014", "AL2014", "NL2015", "AL2015" };
            //leagueList = GFileAccess.GetLeagueList ();
            yearList = GFileAccess.GetYearList();
        }
Beispiel #2
0
        public override void ViewDidLoad()
        {
            // ----------------------------------
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            cmdDoIt.TouchUpInside += delegate(object sender, EventArgs e) {
                // -------------------------------------------------
                try {
                    switch (operation.type)
                    {
                    case 'h':
                        lineupCard.ReplacePlayer(operation.x, operation.y);
                        lineupCard.SetLineupCard();
                        dgvLineupCard.ReloadData();
                        dgvLineupCard.Source = new CLineupCardSource((int)abMng, this);
                        CAlert.ShowOkAlert("Lineup change", "Change made!", "OK", this);
                        break;

                    case 'r':
                        lineupCard.ReplacePlayer(operation.x, operation.y);
                        lineupCard.SetLineupCard();
                        dgvLineupCard.ReloadData();
                        dgvLineupCard.Source = new CLineupCardSource((int)abMng, this);
                        CAlert.ShowOkAlert("Lineup change", "Change made!", "OK", this);
                        break;

                    case 's':
                        // Some validation...
                        CBatter bx = g.t[(int)abMng].bat[operation.x];
                        CBatter by = g.t[(int)abMng].bat[operation.y];
                        if (gameState != EGameState.PreGame && bx.where == 10)
                        {
                            CAlert.ShowOkAlert("Lineup change", "Replacing DH is not supported. (You can pinch hit.)", "Got it", this);
                        }
                        //else if (bx.where == 1 && by.px == 0) {
                        //   CAlert.ShowOkAlert("Lineup change", "Replacing pitcher with position player is not supported.", "Got it", this);
                        //}
                        else
                        {
                            lineupCard.ReplacePlayer(operation.x, operation.y);
                            // If new player is a p-type, he goes in as p. Else as old player's pos.... [subst.1]
                            lineupCard.AssignPos(operation.y, by.px == 1 ? 1 : operation.p);
                            lineupCard.SetLineupCard();
                            dgvLineupCard.ReloadData();
                            dgvLineupCard.Source = new CLineupCardSource((int)abMng, this);
                            CAlert.ShowOkAlert("Lineup change", "Change made!", "OK", this);
                        }
                        break;

                    case 'p':
                        // Some validation...
                        if (gameState != EGameState.PreGame && g.t[(int)abMng].bat[operation.x].where == 10)
                        {
                            CAlert.ShowOkAlert("Lineup change", "Moving DH to the field is not supported.", "Got it", this);
                        }
                        else if (g.t[(int)abMng].bat[operation.x].where == 1)
                        {
                            CAlert.ShowOkAlert("Lineup change", "Playing a pitcher at a position is not supported.", "Got it", this);
                        }
                        else
                        {
                            lineupCard.AssignPos(operation.x, operation.p);
                            lineupCard.SetLineupCard();
                            dgvLineupCard.ReloadData();
                            dgvLineupCard.Source = new CLineupCardSource((int)abMng, this);
                            CAlert.ShowOkAlert("Lineup change", "Change made!", "OK", this);
                        }
                        break;
                    }
                }
                catch (Exception ex) {
                    // AssignPos will throw exception if it detects you are putting a
                    // non-pitcher in as pitcher. (Based on his .px property being 0.)
                    // I guess restricting the available list to pitchers would be
                    // cleaner... future change.
                    // So do nothing here.
                    CAlert.ShowOkAlert("Lineup change", ex.Message, "Got it", this);
                }

                lblAction.Text = "";
                EnableControl(cmdDoIt, false);
            };


            // Read text from disk regarding instructions plus expanation
            // of fielding ratings.
            // -------------------------------------------------------------------
            using (StreamReader f = GFileAccess.GetOtherFileReader("Strings/Instructions1.txt")) {
                lblInstructions.Text = f.ReadToEnd();
            }
            using (StreamReader f = GFileAccess.GetOtherFileReader("Strings/Fielding1.txt")) {
                lblInstructions.Text += "\r\n" + f.ReadToEnd();
            }


            SetupCard();

            string msg = g.t[(int)abMng].nick;

            switch (gameState)
            {
            case EGameState.Offense: msg += " At Bat"; break;

            case EGameState.Defense: msg += " In Field"; break;

            case EGameState.PreGame: msg += " Pre-game"; break;
            }
            lblGameState.Text = msg;



//         cmdSac.Image = CSApp.Properties.Resources.GreyLight;
//         cmdSteal.Image = CSApp.Properties.Resources.GreyLight;
//         cmdIP.Image = CSApp.Properties.Resources.GreyLight;
//
//         switch (g.specialPlay) {
//            case SPECIAL_PLAY.Bunt:
//               cmdSac.Image = CSApp.Properties.Resources.CyanLight;
//               break;
//            case SPECIAL_PLAY.Steal:
//               cmdSteal.Image = CSApp.Properties.Resources.CyanLight;
//               break;
//            case SPECIAL_PLAY.IP:
//               cmdIP.Image = CSApp.Properties.Resources.CyanLight;
//               break;
//         }
        }