コード例 #1
0
        public void addDPercentTable(DPercentTable add)
        {
            int dupCount = 0;

            foreach (DPercentTable table in tables)
            {
                if (table.Name == add.Name)
                {
                    dupCount++;
                }
            }
            if (dupCount > 0)
            {
                add.Name += " " + (dupCount + 1).ToString();
            }
            tables.Add(add);
            UpdateTableList();
            tableList.SelectedItem  = add.Name;
            button1.Enabled         = true;
            button2.Enabled         = true;
            npcAttackButton.Enabled = true;

            BattleIO auto = new BattleIO();

            auto.AutoSaveDPercentList(tables, Program.activeSettings);
        }
コード例 #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (selectedTable != null)
     {
         DialogResult result = MessageBox.Show("Remove " + selectedTable.Name + "?", "Delete Table", MessageBoxButtons.YesNo);
         if (result == DialogResult.Yes)
         {
             int nextIndex = tables.IndexOf(selectedTable) - 1;
             if (nextIndex < 0)
             {
                 nextIndex = 0;
             }
             tables.Remove(selectedTable);
             selectedTable = new DPercentTable();
             UpdateTableList();
             UpdateResultsTable();
             if (nextIndex < tables.Count)
             {
                 tableList.SelectedItem = tables.ElementAt(nextIndex).Name;
             }
             BattleIO auto = new BattleIO();
             auto.AutoSaveDPercentList(tables, Program.activeSettings);
         }
     }
     if (tables.Count <= 0)
     {
         button1.Enabled         = false;
         button2.Enabled         = false;
         npcAttackButton.Enabled = false;
     }
 }
コード例 #3
0
 public void EditMode(DPercentTable editTable, int index)
 {
     editMode = true;
     for (int i = 0; i < editTable.startValues.Count; i++)
     {
         DPercentLine newLine = new DPercentLine();
         newLine.sendingForm = this;
         if (i == 0)
         {
             newLine.SetMin();
         }
         else
         {
             newLine.SetMinToValue(editTable.startValues.ElementAt(i));
         }
         if (i < editTable.results.Count)
         {
             newLine.addEffect(editTable.results.ElementAt(i));
         }
         newLine.SetMinToValue(editTable.startValues.ElementAt(i));
         if (i < editTable.startValues.Count - 1)
         {
             newLine.SetMaxToValue(editTable.startValues.ElementAt(i + 1) - 1);
         }
         else
         {
             newLine.SetMaxToValue(editTable.MaxVal);
         }
         tableIndex = index;
         lines.Add(newLine);
         RedrawLines();
     }
 }
コード例 #4
0
        private void tableList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tableList.SelectedIndex < tables.Count && tableList.SelectedIndex >= 0)
            {
                SelectedTableIndex = tableList.SelectedIndex;

                selectedTable = tables.ElementAt(SelectedTableIndex);
                UpdateResultsTable();
            }
        }
コード例 #5
0
        public void UpdateDPercentTable(DPercentTable updatedTable, int tableIndex)
        {
            int dupCount = 0;

            foreach (DPercentTable table in tables)
            {
                if (table.Name == updatedTable.Name)
                {
                    dupCount++;
                }
            }
            if (dupCount > 0)
            {
                updatedTable.Name += " " + (dupCount + 1).ToString();
            }
            tables.RemoveAt(tableIndex);
            tables.Insert(tableIndex, updatedTable);
            UpdateTableList();
            tableList.SelectedItem = updatedTable.Name;
        }
コード例 #6
0
        private void BuildTable()
        {
            DPercentTable output = new DPercentTable();
            string        name   = "";

            if (nameBox.Text == "")
            {
                name = "New Table";
            }
            else
            {
                name = nameBox.Text;
            }

            if (lines.Count <= 0)
            {
                MessageBox.Show("This table has no lines. Please add lines and make this table happy.", "Oops");
                return;
            }



            output.Name = name;
            List <int[]> gaps = new List <int[]>();

            for (int i = 0; i < lines.Count - 1; i++)
            {
                int min = lines.ElementAt(i).GetMin();
                int max = lines.ElementAt(i).GetMax();
                if (min < 0 || max < 0)
                {
                    MessageBox.Show("One or more lines have invalid values. Please enter values for all fields.", "Oops!");
                    return;
                }
                string results;
                if (lines.ElementAt(i).GetEffect() == "")
                {
                    results = "No effect";
                }
                else
                {
                    results = lines.ElementAt(i).GetEffect();
                }
                if (lines.ElementAt(i).GetMax() < lines.ElementAt(i + 1).GetMin() - 1)
                {
                    int low  = lines.ElementAt(i).GetMax() + 1;
                    int high = lines.ElementAt(i + 1).GetMin() - 1;
                    gaps.Add(new int[] { low, high });
                }
                output.AddResult(results, min);
            }
            output.AddResult(lines.Last().GetEffect(), lines.Last().GetMin());
            output.MaxVal = lines.Last().GetMax();
            if (gaps.Count > 0)
            {
                RaiseGapMessage(gaps);
            }
            else
            {
                if (editMode)
                {
                    sendingForm.UpdateDPercentTable(output, tableIndex);
                }
                else
                {
                    sendingForm.addDPercentTable(output);
                }
                this.Close();
            }
        }