private string GetPosChangeMsg(int pos, int bix) { // ----------------------------------------------- //CBatter bat = g.t[(int)abMng].bat[lineupCard.CurrentLineup[this.SelectedRow].bx]; CBatter bat = g.t[(int)abMng].bat[bix]; string msg; //var alert = new CAlert(); if (gameState != EGameState.PreGame && bat.where == 10) { CAlert.ShowOkAlert("", "Can't move DH to the field", "OK", this); msg = ""; } else if (bat.where == pos) { CAlert.ShowOkAlert("", "Fielder is already at position", "OK", this); msg = ""; } else { msg = "Move " + bat.bname + " to " + CGame.PosName[pos]; } return(msg); }
public void AssignGame(CGame g1) { // -------------------------------- g = g1; int i = g.t[g.ab].linup[g.t[g.ab].slot]; int j = g.t[g.fl].curp; b = g.t[g.ab].bat[i]; p = g.t[g.fl].pit[j]; }
public void UpdateCell(CGame gm1, int ab, CLineupCard lu1, NSIndexPath ixp) { // -------------------------------------------------- //int bx = gm1.bat[ab, ixp.Row+1].bx; if (ixp.Row > lu1.Available.Count - 1) { return; } int bx = lu1.Available[ixp.Row].bx; CBatter bat1 = gm1.t[ab].bat[bx]; lblName.Text = bat1.DisplayName; lblSkill.Text = bat1.DisplaySkill; }
public void UpdateCell(CGame gm1, int ab, CLineupCard lu1, NSIndexPath ixp) { // -------------------------------------------------- //int bx = gm1.bat[ab, ixp.Row+1].bx; int bx = lu1.CurrentLineup[ixp.Row].bx; CBatter bat1 = gm1.t[ab].bat[bx]; lblSlot.Text = bat1.DisplaySlot; lblName.Text = bat1.DisplayName; lblPos.Text = bat1.DisplayPos; lblBase.Text = bat1.DisplayBase; lblSkill.Text = bat1.DisplaySkill; }
public void RowSelected(int r, CBatter bat1) { // ------------------------------------------------------------------------ // This is intended to be called by LineUpCardSource object from that // class's RowSelected mothod... if (r < 0) { return; //S/n happen. } SelectedRow = r; SelectedBatter = bat1; switch (gameState) { case EGameState.PreGame: EnableControl(cmdPinchHit, false); EnableControl(cmdPinchRun, false); EnableControl(cmdReplace, true); EnableControl(cmdChangePos, bat1.where != 1); EnableControl(cmdMoveUp, true); EnableControl(cmdMoveDown, true); break; case EGameState.Offense: EnableControl(cmdPinchHit, bat1.DisplayBase == "ab"); EnableControl(cmdPinchRun, bat1.DisplayBase == "1st" || bat1.DisplayBase == "2nd" || bat1.DisplayBase == "3rd"); EnableControl(cmdReplace, false); EnableControl(cmdChangePos, false); EnableControl(cmdMoveUp, false); EnableControl(cmdMoveDown, false); break; case EGameState.Defense: bool isFielder = (bat1.where >= 1 && bat1.where <= 9 || bat1.where == 0); EnableControl(cmdReplace, isFielder); EnableControl(cmdChangePos, isFielder && bat1.where != 1); EnableControl(cmdMoveUp, false); EnableControl(cmdMoveDown, false); break; } }
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; // } }