Ejemplo n.º 1
0
        private bool DynamiteActionsAreValid(ArrayList dynamiteActions)
        {
            // if none, its valid
            if (dynamiteActions.Count == 0)
            {
                return(true);
            }

            for (int x = 0; x < dynamiteActions.Count; x++)
            {
                Actions.ActionRow actionRow = (Actions.ActionRow)dynamiteActions[x];

                // find another dynamite action in the list with
                // the same entity
                for (int y = x + 1; y < dynamiteActions.Count; y++)
                {
                    if (y == dynamiteActions.Count)
                    {
                        break;
                    }

                    Actions.ActionRow temp = (Actions.ActionRow)dynamiteActions[y];

                    if (temp.Entity == actionRow.Entity)
                    {
                        // check the links for both
                        if (actionRow.IsLinksNull())
                        {
                            MessageBox.Show(this.ParentForm, "Action " + actionRow.ID + " and Action " + temp.ID + " are dynamite actions with the same entity, but are not linked.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }

                        if (temp.IsLinksNull())
                        {
                            MessageBox.Show(this.ParentForm, "Action " + temp.ID + " and Action " + actionRow.ID + " are dynamite actions with the same entity, but are not linked.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }

                        // both have links, now verify they point to each other
                        string[] linksA = actionRow.Links.Split(new char[] { ' ' });

                        // look for temp ID
                        bool idFound = false;
                        for (int z = 0; z < linksA.Length; z++)
                        {
                            if (linksA[z] == temp.ID)
                            {
                                idFound = true;
                                break;
                            }
                        }

                        if (!idFound)
                        {
                            MessageBox.Show(this.ParentForm, "Action " + actionRow.ID + " and Action "
                                            + temp.ID + " are dynamite actions with the same entity, but are not linked.",
                                            "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }

                        string[] linksB = temp.Links.Split(new char[] { ' ' });

                        // look for actionRow ID
                        idFound = false;
                        for (int z = 0; z < linksB.Length; z++)
                        {
                            if (linksB[z] == actionRow.ID)
                            {
                                idFound = true;
                                break;
                            }
                        }

                        if (!idFound)
                        {
                            MessageBox.Show(this.ParentForm, "Action " + temp.ID + " and Action "
                                            + actionRow.ID + " are dynamite actions with the same entity, but are not linked.",
                                            "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }