//adds a number of creatures based on the count given. //Rat 3 would make 3 rats, roll their initiative and assign their place. private void AddCount_Click(object sender, EventArgs e) { if (InitiativeTextBox.Text != "") { string[] contents = InitiativeTextBox.Text.Split(' '); InitiativeTextBox.Text = ""; try { Dice roller = new Dice(); for (int count = 0; count < Convert.ToInt32(contents[1]); count++) { InitiativeManager.AddRollPlace(InitiativeListBox, contents[0] + Convert.ToString(count + 1), roller.Roll(6, 2)); } undoRedoTracker = InitiativeManager.UpdateUndoBox(InitiativeListBox, undoInitiativeListBox, undoRedoTracker); PlayerTurnLabel.Text = InitiativeManager.UpdatePlayerTurnLabel(InitiativeListBox); } catch (IndexOutOfRangeException) { } catch (FormatException) { } } }
//adds the result to the list and orders them by that. //Rat 3 would mean I rolled a total of 3 and it orders them by the roll result. private void AddRoll_Click(object sender, EventArgs e) { if (InitiativeTextBox.Text != "") { string[] contents = InitiativeTextBox.Text.Split(' '); InitiativeTextBox.Text = ""; try { if (contents.Length == 1) { InitiativeManager.AddRollPlace(InitiativeListBox, contents[0]); } else { InitiativeManager.AddRollPlace(InitiativeListBox, contents[0], Convert.ToInt32(contents[1])); } undoRedoTracker = InitiativeManager.UpdateUndoBox(InitiativeListBox, undoInitiativeListBox, undoRedoTracker); PlayerTurnLabel.Text = InitiativeManager.UpdatePlayerTurnLabel(InitiativeListBox); } catch (IndexOutOfRangeException) { } catch (FormatException) { } } }
//Steps to the very next item in the list. private void Step_Click(object sender, EventArgs e) { string tmpStep = InitiativeListBox.Items[0].ToString(); InitiativeListBox.Items.RemoveAt(0); InitiativeListBox.Items.Insert(InitiativeListBox.Items.Count, tmpStep); PlayerTurnLabel.Text = InitiativeManager.UpdatePlayerTurnLabel(InitiativeListBox); undoRedoTracker = InitiativeManager.UpdateUndoBox(InitiativeListBox, undoInitiativeListBox, undoRedoTracker); }
private void Redo_Click(object sender, EventArgs e) { if (undoRedoTracker < undoInitiativeListBox.Count) { undoRedoTracker++; InitiativeListBox.Items.Clear(); InitiativeListBox.Items.AddRange(undoInitiativeListBox[undoRedoTracker - 1].Items); PlayerTurnLabel.Text = InitiativeManager.UpdatePlayerTurnLabel(InitiativeListBox); } }
//Finds the next turn of someone that isn't downed. private void Next_Click(object sender, EventArgs e) { do { string tmpNext = InitiativeListBox.Items[0].ToString(); InitiativeListBox.Items.RemoveAt(0); InitiativeListBox.Items.Insert(InitiativeListBox.Items.Count, tmpNext); }while (InitiativeListBox.Items[0].ToString().EndsWith(InitiativeManager.DOWN)); PlayerTurnLabel.Text = InitiativeManager.UpdatePlayerTurnLabel(InitiativeListBox); undoRedoTracker = InitiativeManager.UpdateUndoBox(InitiativeListBox, undoInitiativeListBox, undoRedoTracker); }
//Moves the current item to another place in the list. //If it were the Rat's turn and I put 3 in movelist, it would move rat to index 3. private void MoveList_Click(object sender, EventArgs e) { if (InitiativeTextBox.Text != "") { string[] contents = InitiativeTextBox.Text.Split(' '); InitiativeTextBox.Text = ""; try { if (Convert.ToInt32(contents[1]) > InitiativeListBox.Items.Count) { contents[1] = Convert.ToString(InitiativeListBox.Items.Count); } for (int index = 0; index < InitiativeListBox.Items.Count; index++) { if (!InitiativeListBox.Items[index].ToString().Contains(InitiativeManager.TOP_OF_ROUND)) { InitiativeListNode tmp = new InitiativeListNode(InitiativeListBox.Items[index].ToString()); if (tmp.Name.Contains(contents[0])) { string tmpStr = InitiativeListBox.Items[index].ToString(); InitiativeListBox.Items.Insert(Convert.ToInt32(contents[1]), tmpStr); InitiativeListBox.Items.RemoveAt(index); } } } undoRedoTracker = InitiativeManager.UpdateUndoBox(InitiativeListBox, undoInitiativeListBox, undoRedoTracker); PlayerTurnLabel.Text = InitiativeManager.UpdatePlayerTurnLabel(InitiativeListBox); InitiativeManager.UpdatePositions(InitiativeListBox); } catch (IndexOutOfRangeException) { } catch (FormatException) { } } }