コード例 #1
0
ファイル: frmAddToken.cs プロジェクト: squall255/chummer5a
        /// <summary>
        /// passes the character back to the dashboard init user control
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            Random objRandom = MersenneTwister.SfmtRandom.Create();

            if (_character != null)
            {
                _character.InitRoll    = chkAutoRollInit.Checked ? objRandom.Next((int)nudInit.Value, ((int)nudInit.Value) * 6) + ((int)nudInitStart.Value) : Int32.MinValue;
                _character.InitialInit = (int)nudInitStart.Value;
                _character.Delayed     = false;
                _character.InitPasses  = (int)nudInit.Value;
                _character.Name        = txtName.Text;
            }
            else
            {
                _character = new Character()
                {
                    Name        = txtName.Text,
                    InitPasses  = (int)nudInit.Value,
                    InitRoll    = chkAutoRollInit.Checked ? objRandom.Next((int)nudInit.Value, ((int)nudInit.Value) * 6) + ((int)nudInitStart.Value) : Int32.MinValue,
                    Delayed     = false,
                    InitialInit = (int)nudInitStart.Value
                }
            };
            parentControl.AddToken(_character);
            Close();
        }
    }
コード例 #2
0
        /// <summary>
        /// passes the character back to the dashboard init user control
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            Random objRandom = MersenneTwister.SfmtRandom.Create();

            if (_character != null)
            {
                _character.InitialInit = (int)nudInitStart.Value;
                _character.Delayed     = false;
                _character.InitPasses  = (int)nudInit.Value;
                if (chkAutoRollInit.Checked)
                {
                    int intInitRoll = 0;
                    for (int j = 0; j < _character.InitPasses; j++)
                    {
                        do
                        {
                            _intModuloTemp = _objRandom.Next();
                        }while (_intModuloTemp >= int.MaxValue - 1); // Modulo bias removal for 1d6
                        intInitRoll += 1 + _intModuloTemp % 6;
                    }
                    _character.InitRoll = intInitRoll + _character.InitialInit;
                }
                else
                {
                    _character.InitRoll = int.MinValue;
                }
                _character.Name = txtName.Text;
            }
            else
            {
                _character = new Character()
                {
                    Name        = txtName.Text,
                    InitPasses  = (int)nudInit.Value,
                    InitRoll    = int.MinValue,
                    Delayed     = false,
                    InitialInit = (int)nudInitStart.Value
                };
                if (chkAutoRollInit.Checked)
                {
                    int intInitRoll = 0;
                    for (int j = 0; j < _character.InitPasses; j++)
                    {
                        do
                        {
                            _intModuloTemp = _objRandom.Next();
                        }while (_intModuloTemp >= int.MaxValue - 1); // Modulo bias removal for 1d6
                        intInitRoll += 1 + _intModuloTemp % 6;
                    }
                    _character.InitRoll = intInitRoll + _character.InitialInit;
                }
            }
            parentControl.AddToken(_character);
            Close();
        }
コード例 #3
0
ファイル: AddToken.cs プロジェクト: Stexinator/chummer5a
        /// <summary>
        /// passes the character back to the dashboard init user control
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btnOK_Click(object sender, EventArgs e)
        {
            if (_character != null)
            {
                _character.Name = await txtName.DoThreadSafeFuncAsync(x => x.Text);

                _character.InitPasses = await nudInit.DoThreadSafeFuncAsync(x => x.ValueAsInt);

                _character.Delayed     = false;
                _character.InitialInit = await nudInitStart.DoThreadSafeFuncAsync(x => x.ValueAsInt);
            }
            else
            {
                _character = new Character
                {
                    Name        = await txtName.DoThreadSafeFuncAsync(x => x.Text),
                    InitPasses  = await nudInit.DoThreadSafeFuncAsync(x => x.ValueAsInt),
                    Delayed     = false,
                    InitialInit = await nudInitStart.DoThreadSafeFuncAsync(x => x.ValueAsInt)
                };
            }
            if (await chkAutoRollInit.DoThreadSafeFuncAsync(x => x.Checked))
            {
                int intInitPasses = _character.InitPasses;
                int intInitRoll   = intInitPasses;
                for (int j = 0; j < intInitPasses; ++j)
                {
                    intInitRoll += await GlobalSettings.RandomGenerator.NextD6ModuloBiasRemovedAsync();
                }
                _character.InitRoll = intInitRoll + _character.InitialInit;
            }
            else
            {
                _character.InitRoll = int.MinValue;
            }

            _blnCharacterAdded = true;
            await parentControl.AddToken(_character);

            await this.DoThreadSafeAsync(x => x.Close());
        }
コード例 #4
0
        /// <summary>
        /// passes the character back to the dashboard init user control
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btnOK_Click(object sender, EventArgs e)
        {
            if (_character != null)
            {
                _character.Name        = txtName.Text;
                _character.InitPasses  = (int)nudInit.Value;
                _character.Delayed     = false;
                _character.InitialInit = (int)nudInitStart.Value;
            }
            else
            {
                _character = new Character
                {
                    Name        = txtName.Text,
                    InitPasses  = (int)nudInit.Value,
                    Delayed     = false,
                    InitialInit = (int)nudInitStart.Value
                };
            }
            if (chkAutoRollInit.Checked)
            {
                int intInitPasses = _character.InitPasses;
                int intInitRoll   = intInitPasses;
                for (int j = 0; j < intInitPasses; ++j)
                {
                    intInitRoll += await GlobalSettings.RandomGenerator.NextD6ModuloBiasRemovedAsync();
                }
                _character.InitRoll = intInitRoll + _character.InitialInit;
            }
            else
            {
                _character.InitRoll = int.MinValue;
            }

            _blnCharacterAdded = true;
            await parentControl.AddToken(_character);

            Close();
        }