Exemplo n.º 1
0
        /*
         * Should work...
         * When the user right-clicks somewhere in the check box list.
         */
        private void chkBoxChummer_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                // confirm we are selecting a chummer
                if (chkBoxChummer.SelectedItem == null)
                {
                    MessageBox.Show("Please select a chummer before right-clicking");
                }

                frmInitRoller frmHits = new frmInitRoller
                {
                    Dice = characters[chkBoxChummer.SelectedIndex].InitPasses
                };
                frmHits.ShowDialog(this);

                if (frmHits.DialogResult != DialogResult.OK)
                {
                    return;   // we decided not to actually change the initiative
                }
                characters[chkBoxChummer.SelectedIndex].InitRoll = frmHits.Result;

                chkBoxChummer.Items[chkBoxChummer.SelectedIndex] = characters[chkBoxChummer.SelectedIndex];
            }
        }
        /// <summary>
        /// Add's the token to the initiative chain
        /// </summary>
        /// <param name="character"></param>
        /// <param name="autoInit"></param>
        public void AddToken(Character character, bool autoInit)
        {
            if (character.InitRoll == Int32.MinValue)
            {
                frmInitRoller frmHits = new frmInitRoller();
                frmHits.Dice = character.InitPasses;
                frmHits.ShowDialog(this);

                if (frmHits.DialogResult != DialogResult.OK)
                {
                    MessageBox.Show("ERROR"); // TODO edward show error
                    return;
                }

                character.InitRoll = frmHits.Result + character.InitialInit;
            }
            else
            {
                autoInit = true;
            }
            if (staticBattleMode)
            {
                character.StaticInit = character.InitRoll;
            }
            //If you join a fight in a later Initiativeround, your Initiative is reduced by turn times 10
            character.InitRoll += round > 1 ? (round - 1) * -10 : 0;
            _characters.Add(new Tuple <Character, bool>(character, autoInit));
            var lindex = chkBoxChummer.Items.Add(character);

            chkBoxChummer.SetItemChecked(lindex, autoInit);
        }
Exemplo n.º 3
0
        /*
         * Reset button pressed
         */
        private void btnReset_Click(object sender, EventArgs e)
        {
            // for every checked character, we re-roll init
            for (int i = 0; i < characters.Count; i++)
            {
                if (chkBoxChummer.CheckedIndices.Contains(i))
                {
                    Character objLoopCharacter = characters[i];
                    int       intInitRoll      = 0;
                    for (int j = 0; j < objLoopCharacter.InitPasses; j++)
                    {
                        do
                        {
                            _intModuloTemp = _objRandom.Next();
                        }while (_intModuloTemp >= int.MaxValue - 1); // Modulo bias removal for 1d6
                        intInitRoll += 1 + _intModuloTemp % 6;
                    }
                    objLoopCharacter.InitRoll = intInitRoll + objLoopCharacter.InitialInit;
                }
            }

            // query for new initiatives
            for (int j = 0; j < characters.Count; j++)
            {
                if (chkBoxChummer.GetItemCheckState(j) == CheckState.Unchecked)
                {
                    Character     objLoopCharacter = characters[j];
                    frmInitRoller frmHits          = new frmInitRoller
                    {
                        Text        = "Initiative: " + objLoopCharacter.Name,
                        Description = "initiative result",
                        Dice        = objLoopCharacter.InitPasses
                    };
                    frmHits.ShowDialog(this);

                    if (frmHits.DialogResult != DialogResult.OK)
                    {
                        return;   // we decided not to actually change the initiative
                    }
                    objLoopCharacter.InitRoll = frmHits.Result + objLoopCharacter.InitialInit;
                }
            }

            ResetListBoxChummers();
            _finishedCombatTurn = false;
            index                   = 0;
            round                   = 1;
            lblRound.Text           = "Round 1";
            totalChummersWithNoInit = 0;
        }
        /// <summary>
        /// Adds changeDice Dices to the InitPasses and changes the actual InitRoll accordingly
        /// </summary>
        /// <param name="changeDice"></param>
        private void ApplyInitiativePassesChange(int changeDice)
        {
            // check if we have selected a chummer in the list
            if (chkBoxChummer.SelectedItem == null)
            {
                MessageBox.Show("Please select a Chummer");
                return;
            }
            // pull the simple character out
            int selectedIndex = chkBoxChummer.SelectedIndex;

            if (changeDice > 0 && _characters[selectedIndex].Item1.InitPasses + changeDice > 5)
            {
                MessageBox.Show("No more than five initiative dice allowed");
                return;
            }
            if (changeDice < 0 && _characters[selectedIndex].Item1.InitPasses + changeDice < 0)
            {
                MessageBox.Show("Not less than zero initiative dice allowed");
                return;
            }
            _characters[selectedIndex].Item1.InitPasses += changeDice;
            int initChange;

            if (chkBoxChummer.GetItemCheckState(selectedIndex) == CheckState.Unchecked)
            {
                frmInitRoller frmHits = new frmInitRoller();
                frmHits.Text        = "Initiave change: " + _characters[selectedIndex].Item1.Name;
                frmHits.Description = "dice result";
                frmHits.Dice        = Math.Abs(changeDice);
                frmHits.ShowDialog(this);
                if (frmHits.DialogResult != DialogResult.OK)
                {
                    return;
                }
                initChange = changeDice > 0 ? frmHits.Result : -frmHits.Result;
            }
            else
            {
                var random = new Random();
                initChange = changeDice > 0
                    ? random.Next(1 * changeDice, 6 * changeDice)
                    : random.Next(6 * changeDice, 1 * changeDice); // if change is negative, min value is multiplied times 6
            }
            ApplyInitChange(initChange);
            if (staticBattleMode)
            {
                _characters[selectedIndex].Item1.StaticInit += initChange;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Add's the token to the initiative chain
        /// </summary>
        /// <param name="character"></param>
        public void AddToken(Character character)
        {
            if (character.InitRoll == Int32.MinValue)
            {
                frmInitRoller frmHits = new frmInitRoller();
                frmHits.Dice = character.InitPasses;
                frmHits.ShowDialog(this);

                if (frmHits.DialogResult != DialogResult.OK)
                {
                    MessageBox.Show("ERROR");   // TODO edward show error
                    return;
                }

                character.InitRoll = frmHits.Result + character.InitialInit;
            }

            characters.Add(character);
            chkBoxChummer.Items.Add(character);
        }
        /// <summary>
        /// Add's the token to the initiative chain
        /// </summary>
        /// <param name="character"></param>
        public void AddToken(Character character)
        {
            if (character.InitRoll == Int32.MinValue)
            {
                frmInitRoller frmHits = new frmInitRoller();
                frmHits.Dice = character.InitPasses;
                frmHits.ShowDialog(this);

                if (frmHits.DialogResult != DialogResult.OK)
                {
                    MessageBox.Show("ERROR");   // TODO edward show error
                    return;
                }

                character.InitRoll = frmHits.Result + character.InitialInit;
            }

            this.characters.Add(character);
            this.chkBoxChummer.Items.Add(character);
        }
Exemplo n.º 7
0
        /*
         * Reset button pressed
         */
        private void btnReset_Click(object sender, EventArgs e)
        {
            // for every checked character, we re-roll init
            Random random = MersenneTwister.SfmtRandom.Create();

            for (int i = 0; i < characters.Count; i++)
            {
                if (chkBoxChummer.CheckedIndices.Contains(i))
                {
                    characters[i].InitRoll = random.Next(characters[i].InitPasses, characters[i].InitPasses * 6) + characters[i].InitialInit;
                }
            }

            // query for new initiatives
            for (int j = 0; j < characters.Count; j++)
            {
                if (chkBoxChummer.GetItemCheckState(j) == CheckState.Unchecked)
                {
                    frmInitRoller frmHits = new frmInitRoller();
                    frmHits.Text        = "Initiative: " + characters[j].Name;
                    frmHits.Description = "initiative result";
                    frmHits.Dice        = characters[j].InitPasses;
                    frmHits.ShowDialog(this);

                    if (frmHits.DialogResult != DialogResult.OK)
                    {
                        return;   // we decided not to actually change the initiative
                    }
                    characters[j].InitRoll = frmHits.Result + characters[j].InitialInit;
                }
            }

            ResetListBoxChummers();
            _finishedCombatTurn = false;
            index                   = 0;
            round                   = 1;
            lblRound.Text           = "Round 1";
            totalChummersWithNoInit = 0;
        }
        private bool QueryUserInitiatives()
        {
            for (int j = 0; j < _characters.Count; j++)
            {
                if (chkBoxChummer.GetItemCheckState(j) == CheckState.Unchecked)
                {
                    frmInitRoller frmHits = new frmInitRoller
                    {
                        Text        = "Initiative: " + _characters[j].Item1.Name,
                        Description = "initiative result",
                        Dice        = _characters[j].Item1.InitPasses
                    };
                    frmHits.ShowDialog(this);

                    if (frmHits.DialogResult != DialogResult.OK)
                    {
                        return(true);
                    }
                    _characters[j].Item1.InitRoll = frmHits.Result + _characters[j].Item1.InitialInit;
                }
            }
            return(false);
        }
        /*
         * Should work...
         * When the user right-clicks somewhere in the check box list.
         */
        private void chkBoxChummer_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                // confirm we are selecting a chummer
                if (this.chkBoxChummer.SelectedItem == null)
                    MessageBox.Show("Please select a chummer before right-clicking");

                frmInitRoller frmHits = new frmInitRoller();
                frmHits.Dice = this.characters[this.chkBoxChummer.SelectedIndex].InitPasses;
                frmHits.ShowDialog(this);

                if (frmHits.DialogResult != DialogResult.OK)
                    return;   // we decided not to actually change the initiative

                this.characters[this.chkBoxChummer.SelectedIndex].InitRoll = frmHits.Result;

                this.chkBoxChummer.Items[this.chkBoxChummer.SelectedIndex] = this.characters[this.chkBoxChummer.SelectedIndex];
            }
        }
Exemplo n.º 10
0
        /*
         * Reset button pressed
         */
        private void btnReset_Click(object sender, EventArgs e)
        {
            // for every checked character, we re-roll init
            Random random = new Random();
            for (int i = 0; i < this.characters.Count; i++)
            {
                if (this.chkBoxChummer.CheckedIndices.Contains(i))
                    this.characters[i].InitRoll = random.Next(this.characters[i].InitPasses, this.characters[i].InitPasses * 6) + this.characters[i].InitialInit;
            }

            // query for new initiatives
            for (int j = 0; j < this.characters.Count; j++)
            {
                if (this.chkBoxChummer.GetItemCheckState(j) == CheckState.Unchecked)
                {
                    frmInitRoller frmHits = new frmInitRoller();
                    frmHits.Text = "Initiative: " + this.characters[j].Name;
                    frmHits.Description = "initiative result";
                    frmHits.Dice = this.characters[j].InitPasses;
                    frmHits.ShowDialog(this);

                    if (frmHits.DialogResult != DialogResult.OK)
                        return;   // we decided not to actually change the initiative
                    this.characters[j].InitRoll = frmHits.Result + this.characters[j].InitialInit;
                }
            }

            this.ResetListBoxChummers();
            this.finishedCombatTurn = false;
            this.index = 0;
            this.round = 1;
            this.lblRound.Text = "Round 1";
            this.totalChummersWithNoInit = 0;
        }
 /// <summary>
 /// Adds changeDice Dices to the InitPasses and changes the actual InitRoll accordingly
 /// </summary>
 /// <param name="changeDice"></param>
 private void ApplyInitiativePassesChange(int changeDice)
 {
     // check if we have selected a chummer in the list
     if (chkBoxChummer.SelectedItem == null)
     {
         MessageBox.Show("Please select a Chummer");
         return;
     }
     // pull the simple character out
     int selectedIndex = chkBoxChummer.SelectedIndex;
     if (changeDice > 0 && _characters[selectedIndex].Item1.InitPasses + changeDice > 5)
     {
         MessageBox.Show("No more than five initiative dice allowed");
         return;
     }
     if (changeDice < 0 && _characters[selectedIndex].Item1.InitPasses + changeDice < 0)
     {
         MessageBox.Show("Not less than zero initiative dice allowed");
         return;
     }
     _characters[selectedIndex].Item1.InitPasses += changeDice;
     int initChange;
     if (chkBoxChummer.GetItemCheckState(selectedIndex) == CheckState.Unchecked)
     {
         frmInitRoller frmHits = new frmInitRoller();
         frmHits.Text = "Initiave change: " + _characters[selectedIndex].Item1.Name;
         frmHits.Description = "dice result";
         frmHits.Dice = Math.Abs(changeDice);
         frmHits.ShowDialog(this);
         if (frmHits.DialogResult != DialogResult.OK)
         {
             return;
         }
         initChange = changeDice > 0 ? frmHits.Result : -frmHits.Result;
     }
     else
     {
         var random = new Random();
         initChange = changeDice > 0
             ? random.Next(1*changeDice, 6*changeDice)
             : random.Next(6*changeDice, 1*changeDice); // if change is negative, min value is multiplied times 6
     }
     ApplyInitChange(initChange);
     if (staticBattleMode)
     {
         _characters[selectedIndex].Item1.StaticInit += initChange;
     }
 }
        /// <summary>
        /// Add's the token to the initiative chain
        /// </summary>
        /// <param name="character"></param>
        /// <param name="autoInit"></param>
        public void AddToken(Character character, bool autoInit)
        {
            if (character.InitRoll == Int32.MinValue)
            {
                frmInitRoller frmHits = new frmInitRoller();
                frmHits.Dice = character.InitPasses;
                frmHits.ShowDialog(this);

                if (frmHits.DialogResult != DialogResult.OK)
                {
                    MessageBox.Show("ERROR"); // TODO edward show error
                    return;
                }

                character.InitRoll = frmHits.Result + character.InitialInit;

            }
            else
            {
                autoInit = true;
            }
            if (staticBattleMode)
            {
                character.StaticInit = character.InitRoll;
            }
            //If you join a fight in a later Initiativeround, your Initiative is reduced by turn times 10
            character.InitRoll += round > 1 ? (round - 1)*-10 : 0;
            _characters.Add(new Tuple<Character, bool>(character, autoInit));
            var lindex = chkBoxChummer.Items.Add(character);
            chkBoxChummer.SetItemChecked(lindex, autoInit);
        }
        private bool QueryUserInitiatives()
        {
            for (int j = 0; j < _characters.Count; j++)
            {
                if (chkBoxChummer.GetItemCheckState(j) == CheckState.Unchecked)
                {
                    frmInitRoller frmHits = new frmInitRoller
                    {
                        Text = "Initiative: " + _characters[j].Item1.Name,
                        Description = "initiative result",
                        Dice = _characters[j].Item1.InitPasses
                    };
                    frmHits.ShowDialog(this);

                    if (frmHits.DialogResult != DialogResult.OK)
                        return true;
                    _characters[j].Item1.InitRoll = frmHits.Result + _characters[j].Item1.InitialInit;
                }
            }
            return false;
        }