private bool IsActionValid(Actions.ActionRow actionRow) { bool isValid = true; StringBuilder msg = new StringBuilder(); string id = ""; string allyAction = ""; string axisAction = ""; string ent = ""; string linked = ""; string classNum = ""; if (!actionRow.IsIDNull()) { id = Convert.ToString(actionRow["ID"]); } if (!actionRow.IsAllyActionNull()) { allyAction = Convert.ToString(actionRow["AllyAction"]); } if (!actionRow.IsAxisActionNull()) { axisAction = Convert.ToString(actionRow["AxisAction"]); } if (!actionRow.IsEntityNull()) { ent = Convert.ToString(actionRow["Entity"]); if (ent == "1023") ent = ""; // default if (ent == "-1") ent = ""; // shouldn't be -1 } if (!actionRow.IsLinksNull()) { linked = Convert.ToString(actionRow["Links"]); } if (!actionRow.IsClassNull()) { classNum = Convert.ToString(actionRow["Class"]); } if ((allyAction == "-1" || allyAction == "") && (axisAction == "-1" || axisAction == "")) { msg.Append("Action " + id + " has no valid ally or axis actions.\r\n"); isValid = false; } if (ent == "") { if (_entityActions.ContainsKey(allyAction)) { msg.Append("Action " + id + " is an " + _entityActions[allyAction] + " action with no entity.\r\n"); isValid = false; } if (_entityActions.ContainsKey(axisAction)) { msg.Append("Action " + id + " is an " + _entityActions[axisAction] + " action with no entity.\r\n"); isValid = false; } } if (_campActions.ContainsKey(allyAction)) { if (linked.Trim() == "") { msg.Append("Action " + id + " is an ally " + _campActions[allyAction] + " with no links.\r\n"); isValid = false; } else { // check the links string[] links = linked.Split(new char[] { ' ' }); for (int x = 0; x < links.Length; x++) { int ndx = Convert.ToInt32(links[x]); // check to see if the action exists!!! if (ndx > _actions.Action.Count - 1) { msg.Append("Action " + id + " has link to an action that doesn't exist [" + ndx + "]"); isValid = false; } else { Actions.ActionRow linkedAction = _actions.Action[ndx]; // we don't allow sorting, so this is ok if (linkedAction.IsAllyActionNull() || linkedAction.AllyAction != "3") { msg.Append("Action " + id + " is an ally " + _campActions[allyAction] + " with an invalid link to Action " + links[x] + " (either no ally action or an ally action that is not an Aim action)\r\n"); isValid = false; } } } } } if (_campActions.ContainsKey(axisAction)) { if (linked.Trim() == "") { msg.Append("Action " + id + " is an axis " + _campActions[axisAction] + " with no links.\r\n"); isValid = false; } else { // check the links string[] links = linked.Split(new char[] { ' ' }); for (int x = 0; x < links.Length; x++) { int ndx = Convert.ToInt32(links[x]); // the axis action should be 3 Actions.ActionRow linkedAction = _actions.Action[ndx]; // we don't allow sorting, so this is ok if (linkedAction.IsAxisActionNull() || linkedAction.AxisAction != "3") { msg.Append("Action " + id + " is an axis " + _campActions[axisAction] + " with an invalid link to Action " + links[x] + " (either no axis action or an axis action that is not an Aim action)\r\n"); isValid = false; } } } } if (!isValid) { MessageBox.Show(this.ParentForm, msg.ToString(), "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error); } return isValid; }
public void FromActionRow(Actions.ActionRow actionRow) { if (!actionRow.IsAllyActionNull()) AllyAction = Convert.ToInt32(actionRow.AllyAction); if (!actionRow.IsAxisActionNull()) AxisAction = Convert.ToInt32(actionRow.AxisAction); if (!actionRow.IsRadiusNull()) Radius = Convert.ToInt32(actionRow.Radius); if (!actionRow.IsGoalNull()) Goal = Convert.ToInt32(actionRow.Goal); if (!actionRow.IsGroupNull()) Group = Convert.ToInt32(actionRow.Group); if (!actionRow.IsClassNull()) Class = Convert.ToInt32(actionRow.Class); if (!actionRow.IsCloseNodeNull()) CloseNode = Convert.ToInt32(actionRow.CloseNode); if (!actionRow.IsLinksNull()) Links = actionRow.Links; if (!actionRow.IsProneNull()) Prone = Convert.ToInt32(actionRow.Prone); if (!actionRow.IsActiveNull()) Active = Convert.ToInt32(actionRow.Active); if (!actionRow.IsEntityNull()) Entity = Convert.ToInt32(actionRow.Entity); }