Esempio n. 1
0
 public void CastAtHigherLevel(byte slot)
 {
     if (chosenSpell.GetLevel() > slot)
     {
         MessageBox.Show("Spell slot " + slot + " is too weak to process this spell.");
     }
     else
     {
         if (chosenSpell.GetLevel() == 0)
         {
             MessageBox.Show("Cantrips can not be cast with higher level slots.");
         }
         else
         {
             if (c.SpendSlot(slot))
             {
                 log.Write("To Hit: " + DiceThrower.RollToHit(c.GetModifier(c.GetSpellMod()) + c.GetProfiencyBonus()));
                 log.Write("You cast " + chosenSpell.GetName());
                 log.InputSpace();
             }
             else
             {
                 MessageBox.Show("No level " + slot + " slot available");
             }
         }
     }
 }
Esempio n. 2
0
 private void btnCast_Click(object sender, RoutedEventArgs e)
 {
     if (chosenSpell == null)
     {
         MessageBox.Show("No spell selected.");
     }
     else
     {
         if (chosenSpell.GetLevel() == 0)
         {
             log.Write("To hit: " + DiceThrower.RollToHit(c.GetModifier(c.GetSpellMod()) + c.GetProfiencyBonus()));
             log.Write("You cast " + chosenSpell.GetName());
             log.InputSpace();
         }
         else
         {
             if (c.SpendSlot(chosenSpell.GetLevel()))
             {
                 log.Write("To hit: " + DiceThrower.RollToHit(c.GetModifier(c.GetSpellMod()) + c.GetProfiencyBonus()));
                 log.Write("You cast " + chosenSpell.GetName());
                 log.InputSpace();
             }
             else
             {
                 MessageBox.Show("No level " + chosenSpell.GetLevel() + " slot available");
             }
         }
     }
 }
Esempio n. 3
0
        private void PerformSavingThrow(string stat, bool advantage, bool disadvantage)
        {
            string[] throws = c.GetSavingThrows();
            int      mod    = 0;

            mod += c.GetModifier(stat);

            if (throws[0] == stat || throws[1] == stat)
            {
                mod += c.GetProfiencyBonus();
            }

            if (advantage || disadvantage)
            {
                if (advantage)
                {
                    log.Write(stat + " SAVE: " + DiceThrower.ThrowDieAdvantage(20, mod, true));
                }
                else
                {
                    log.Write(stat + " SAVE: " + DiceThrower.ThrowDieAdvantage(20, mod, false));
                }
            }
            else
            {
                log.Write(stat + " SAVE: " + DiceThrower.ThrowDie(20, mod));
            }
        }
Esempio n. 4
0
        private void menuDeath_Click(object sender, RoutedEventArgs e)
        {
            if (DiceThrower.ThrowDieNumb(20, 0) >= 10)
            {
                log.Write("Death saving throw: Life");
                lifeThrow++;

                if (lifeThrow == 3)
                {
                    MessageBox.Show("Stablised!");
                    lifeThrow  = 0;
                    deathThrow = 0;
                }
            }
            else
            {
                log.Write("Death saving throw: Death");
                deathThrow++;

                if (deathThrow == 3)
                {
                    MessageBox.Show("Farewell.");
                    deathThrow = 0;
                    lifeThrow  = 0;
                }
            }
            UpdateDeath();
        }
        private void btnAttack_Click(object sender, RoutedEventArgs e)
        {
            bool secondDice = false;

            bonus = 0;

            try
            {
                amount1 = Convert.ToInt32(tbDiceAmount.Text);

                if (tbDiceAmount2.Text != "" && tbDiceAmount2.Text != "0")
                {
                    amount2    = Convert.ToInt32(tbDiceAmount2.Text);
                    secondDice = true;
                }

                sides1 = (int)cbDiceSides.SelectedItem;

                if (secondDice)
                {
                    sides2 = (int)cbDiceSides2.SelectedItem;
                }

                toHit = Convert.ToInt32(tbToHit.Text);

                if (tbBonus.Text != "")
                {
                    bonus = Convert.ToInt32(tbBonus.Text);
                }

                log.Write("Bonus: " + bonus);

                if (secondDice)
                {
                    if ((int)cbDiceSides2.SelectedItem != 0)
                    {
                        log.Write("2nd Damage: " + DiceThrower.RollDamage(amount2, sides2, 0));
                    }
                }


                if (amount1 == 0)
                {
                    log.Write("Damage: Please use the first die!");
                }
                else
                {
                    log.Write("1st Damage: " + DiceThrower.RollDamage(amount1, sides1, 0));
                }

                log.Write("To Hit: " + DiceThrower.RollToHit(toHit));
            }
            catch (Exception error)
            {
                MessageBox.Show("Invalid Input: " + error.ToString());
            }

            log.InputSpace();
        }
        public void Roll(string skillName, int mod)
        {
            int  bonus = 0;
            bool adv   = rbAdvantage.IsChecked.Value;
            bool dis   = rbDisadvantage.IsChecked.Value;

            if (tbBonus.Text != "")
            {
                try
                {
                    bonus = Convert.ToInt32(tbBonus.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("Invalid bonus.");
                }
            }

            mod += bonus;

            if (skillName == "Stealth")
            {
                if (stealthDis)
                {
                    if (!adv)
                    {
                        dis = true;
                    }
                    adv = false;
                }
            }

            if (adv)
            {
                p.log.Write(skillName + ": " + DiceThrower.ThrowDieAdvantage(20, mod, true));
            }
            else if (dis)
            {
                p.log.Write(skillName + ": " + DiceThrower.ThrowDieAdvantage(20, mod, false));
            }
            else
            {
                p.log.Write(skillName + ": " + DiceThrower.ThrowDie(20, mod));
            }

            this.Close();
        }
Esempio n. 7
0
        private void btnHitDie_Click(object sender, RoutedEventArgs e)
        {
            int hitDice;

            hitDice = db.GetHitDiceByClass(c.GetClass());
            int result = DiceThrower.ThrowDieNumb(hitDice, c.GetModifier("CON"));

            log.Write("Hit Die: " + result);

            if ((c.GetCurrentHealth() + result) > c.GetMaxHealth())
            {
                c.SetCurrentHealth(c.GetMaxHealth());
            }
            else
            {
                c.SetCurrentHealth(c.GetCurrentHealth() + result);
            }
            UpdateHealth();
        }
Esempio n. 8
0
        public void Attack()
        {
            string amount = string.Empty;
            string sides  = string.Empty;

            string amount2 = string.Empty;
            string sides2  = string.Empty;

            int amountNumb = 0;
            int sidesNumb  = 0;

            int amountNumb2 = 0;
            int sidesNumb2  = 0;

            string damage = w.GetDamage();

            bool pastDice   = false;
            bool secondDice = false;

            if (damage == "1")
            {
                play.log.Write("Damage: " + damage + " " + w.GetBaseDamageType());
                play.log.Write("To hit: " + DiceThrower.RollToHit(toHit));
                play.log.InputSpace();
            }
            else
            {
                for (int i = 0; i < damage.Length; i++)
                {
                    if (!pastDice)
                    {
                        if (damage[i] != 'd')
                        {
                            amount += damage[i];
                        }
                        else
                        {
                            pastDice = true;
                        }
                    }
                    else
                    {
                        sides += damage[i];
                    }
                }

                pastDice = false;

                damage = w.GetDamage2();

                if (damage != "0" && damage != string.Empty && damage != null)
                {
                    secondDice = true;

                    for (int i = 0; i < damage.Length; i++)
                    {
                        if (!pastDice)
                        {
                            if (damage[i] != 'd')
                            {
                                amount2 += damage[i];
                            }
                            else
                            {
                                pastDice = true;
                            }
                        }
                        else
                        {
                            sides2 += damage[i];
                        }
                    }
                }

                try
                {
                    amountNumb = Convert.ToInt32(amount);
                    sidesNumb  = Convert.ToInt32(sides);

                    if (secondDice)
                    {
                        amountNumb2 = Convert.ToInt32(amount2);
                        sidesNumb2  = Convert.ToInt32(sides2);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Invalid damage conversion.");
                }

                string toHitMessage = DiceThrower.RollToHit(toHit);
                int    criticalDice = 20 + toHit;

                // Critical hits
                if (toHitMessage == ("Critical " + criticalDice))
                {
                    amountNumb++;
                }

                if (w.GetBonusDamage() != 0)
                {
                    play.log.Write("Bonus: " + w.GetBonusDamage() + " " + w.GetBonusDamageType());
                }

                if (secondDice)
                {
                    play.log.Write("+ " + (DiceThrower.RollDamage(amountNumb2, sidesNumb2, 0)) + " " + w.GetBaseDamage2());
                }

                play.log.Write("Damage: " + (DiceThrower.RollDamage(amountNumb, sidesNumb, c.GetModifier(mod))) + " " + w.GetBaseDamageType());
                play.log.Write("To hit: " + toHitMessage);
                play.log.InputSpace();
            }
        }
Esempio n. 9
0
        private void btnInitiative_Click(object sender, RoutedEventArgs e)
        {
            List <int> results = new List <int>();

            log.Write("Initiative Result: " + DiceThrower.ThrowDie(20, c.GetModifier("DEX")));
        }