private int PositionCompare(string x, string y) { if (mFormulas == null) { InitFormulas(); } string formula = GetFormula(x); if (formula != "") { List <string> playerPartsX = InputParser.ParsePlayerLine(x); try { List <string> playerPartsY = InputParser.ParsePlayerLine(y); string xExpr = GetExpression(formula, playerPartsX); string yExpr = GetExpression(formula, playerPartsY); double xResult = (double)this.Table.Compute(xExpr, ""); double yResult = (double)this.Table.Compute(yExpr, ""); return(yResult.CompareTo(xResult)); } catch (Exception) { throw new Exception("Error comparing position: " + playerPartsX[0] + "\nCheck formula for position."); } } return(0); }
/// <summary> /// Updates the GUI with the player 'line' passed. /// </summary> public void SetPlayerData(string playerLine) { List <string> playerParts = InputParser.ParsePlayerLine(playerLine); for (int i = 0; i < playerParts.Count; i++) { SetControlValue(mKeyParts[i], playerParts[i]); } }
private void getPlayerBytesToolStripMenuItem_Click(object sender, EventArgs e) { StringBuilder builder = new StringBuilder(); List <string> attributes = null; MessageBox.Show( "This process will get the players specified by position,fname,lname.\r\n" + "You will be prompted for for the data, it must like be in the following example:\r\n" + " QB,Steve,Young\r\n" + " QB,Joe,Montana\r\n" + "In the example above thie feature will search through all players named 'Steve Young' and 'Joe Montana' playing QB and\r\n" + "retrieve their data." , "Info"); string dataToApply = MessageForm.GetString("Paste data below", ""); byte[] playerBytes = null; if (dataToApply != null) { string[] lines = dataToApply.Replace("\r\n", "\n").Split(new Char[] { '\n' }); foreach (string line in lines) { if (line.StartsWith("#") || line.Length < 3) { // skip comments } else { attributes = InputParser.ParsePlayerLine(line); if (attributes != null && attributes.Count > 2) { playerBytes = Tool.GetPlayerBytes(attributes[0], attributes[1], attributes[2]); if (playerBytes != null) { for (int i = 0; i < playerBytes.Length; i++) { builder.Append(playerBytes[i].ToString("X2")); builder.Append(" "); } builder.Append("\r\n"); } else { builder.Append("# notFound> "); builder.Append(line); builder.Append("\r\n"); } } } } mResultsTextBox.Text = builder.ToString(); } }
private void DoubleClicked() { string line = InputParser.GetLine(mTextBox.SelectionStart, mTextBox.Text); if (!String.IsNullOrEmpty(line) && line.StartsWith("Coach", StringComparison.InvariantCultureIgnoreCase)) { EditCoach(); } else if (!String.IsNullOrEmpty(line) && InputParser.ParsePlayerLine(line).Count > 2) { EditPlayer(); } }
/// <summary> /// Will add warnings if there is an issue with the player. /// </summary> /// <param name="line">The player line</param> public string ValidatePlayer(string line) { List <string> playerParts = InputParser.ParsePlayerLine(line); PlayerValidationResult res = new PlayerValidationResult(Get(playerParts, "Position"), Get(playerParts, "fname"), Get(playerParts, "lname")); ValidateBodyType(playerParts, res); ValidateWeight(playerParts, res); if (res.Invalid) { res.Height = Get(playerParts, "Height"); res.BodyType = Get(playerParts, "BodyType"); res.Weight = Get(playerParts, "Weight"); return(String.Format("{0},{1},{2},{3},{4},{5}\n", res.Position, res.FirstName, res.LastName, res.BodyType, res.Height, res.Weight)); } return(""); }
/// <summary> /// just a reminder of how to parse player parts. /// </summary> public static List <string> GetPlayerParts(string playerLine) { return(InputParser.ParsePlayerLine(playerLine)); }