예제 #1
0
        public void TestCheckIfGil_Failure()
        {
            Chest chest = new Chest(50, 5, 50, 50, 100, false);

            Assert.IsFalse(chest.CheckIfGil(75));
        }
예제 #2
0
        /// <summary>
        /// The purpose of this method is to display to chest information for the future
        /// based on our current location in the RNG
        /// </summary>
        /// <param name="displayRNG">RNG numbers to use</param>
        /// <param name="start">index where our first matching heal is</param>
        /// <param name="rowsToRender">How many rows to display</param>
        private void displayRNGHelper(IRNG displayRNG, int start, int rowsToRender)
        {
            //Clear datagridview
            dataGridView1.Rows.Clear();

            // Chest/Item 1:
            Chest chest1 = new Chest(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text);

            // Chest/Item 2:
            Chest chest2 = new Chest(textBox10.Text, textBox9.Text, textBox8.Text, textBox7.Text, textBox6.Text);

            // Use these variables to check for first instance of chest and contents
            bool chestSpawn1    = false;
            bool chestFound1    = false;
            int  chestFoundPos1 = 0;
            int  chestItemPos1  = 0;

            bool chestSpawn2    = false;
            bool chestFound2    = false;
            int  chestFoundPos2 = 0;
            int  chestItemPos2  = 0;

            // Use these variables to check for first punch combo
            bool comboFound = false;
            int  comboPos   = 0;

            uint firstRNGVal  = displayRNG.genrand();
            uint secondRNGVal = displayRNG.genrand();

            // We want to preserve the character index, since this loop is just for display:
            int indexStatic = _group.GetIndex();

            _group.ResetIndex();

            int end = start + rowsToRender;

            for (int index = start; index < end; index++)
            {
                // Index starting at 0
                int loopIndex = index - start;

                // Get the heal value once:
                int currentHeal = _group.GetHealValue(firstRNGVal);
                int nextHeal    = _group.PeekHealValue(secondRNGVal);

                // Put the next expected heal in the text box
                if (index == start + _healVals.Count - 1)
                {
                    tbLastHeal.Text = nextHeal.ToString();
                }

                // Advance the RNG before starting the loop in case we want to skip an entry
                uint firstRNGVal_temp  = firstRNGVal;
                uint secondRNGVal_temp = secondRNGVal;
                firstRNGVal  = secondRNGVal;
                secondRNGVal = displayRNG.genrand();

                // Skip the entry if it's too long ago
                if (loopIndex < _healVals.Count - HistoryToDisplay)
                {
                    continue;
                }

                //Start actually displaying
                dataGridView1.Rows.Add();

                // Color consumed RNG green
                if (index < start + _healVals.Count)
                {
                    dataGridView1.Rows[dataGridView1.Rows.Count - 1].DefaultCellStyle.BackColor = Color.LightGreen;
                }
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[0].Value = index;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[1].Value = currentHeal;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[2].Value = randToPercent(firstRNGVal_temp);

                // Check if the chests are in a position offset by a fixed amount
                if (chest1.CheckSpawn(firstRNGVal_temp))
                {
                    handleChestSpawn(chest1, loopIndex, 3, ref chestFoundPos1, ref chestSpawn1);
                }

                if (chest2.CheckSpawn(firstRNGVal_temp))
                {
                    handleChestSpawn(chest2, loopIndex, 4, ref chestFoundPos2, ref chestSpawn2);
                }

                // This is a big conditional to see what is in both chests.
                // There may be a better way, but this was fast to write and doesn't call the RNG.
                // Calculate the contents of the chest. First, gil:
                if (chest1.CheckIfGil(firstRNGVal_temp))
                {
                    handleGilReward(chest1, secondRNGVal_temp, 3);
                }
                // Otherwise, what item is it, and where is the first desired item
                else
                {
                    handleItemReward(chest1, secondRNGVal_temp, loopIndex, 3, checkBox1, ref chestItemPos1, ref chestFound1);
                }

                if (chest2.CheckIfGil(firstRNGVal_temp))
                {
                    handleGilReward(chest2, secondRNGVal_temp, 4);
                }
                // Otherwise, what item is it, and where is the first desired item
                else
                {
                    handleItemReward(chest2, secondRNGVal_temp, loopIndex, 4, checkBox2, ref chestItemPos2, ref chestFound2);
                }

                // Check for combo during string of punches

                int comboCheck = loopIndex - _healVals.Count - 5 + 1;

                if (comboCheck % 10 == 0 && comboCheck >= 0)
                {
                    if (!comboFound && Combo.IsSucessful(firstRNGVal_temp))
                    {
                        comboFound = true;
                        comboPos   = comboCheck / 10;
                    }
                }
            }

            tbAppear1.Text = chestFoundPos1.ToString();
            tbItem1.Text   = chestItemPos1.ToString();

            tbAppear2.Text = chestFoundPos2.ToString();
            tbItem2.Text   = chestItemPos2.ToString();

            tbCombo.Text = comboFound ? comboPos.ToString() : "SAFE";

            tbLastHeal.Focus();
            tbLastHeal.SelectAll();

            _group.SetIndex(indexStatic);
        }
예제 #3
0
        public void TestCheckIfGil_Success()
        {
            Chest chest = new Chest(50, 5, 50, 50, 100, false);

            Assert.IsTrue(chest.CheckIfGil(25));
        }