Пример #1
0
 public void CheckPotion(Healing potion)
 {
     if (potion.ID == 8)
     {
         RaiseMessage("You feel woozy from drinking this.");
         List <int> listNumbers = new List <int>();
         int        number      = 0;
         int        shuffle     = -50 + (Strength + Endurance + Speed + Intelligence + Sight);
         for (int i = 5; i != 0; i--)
         {
             do
             {
                 number = RandomNumberGen.NumberBetween(1, 5);
             } while (listNumbers.Contains(number));
             listNumbers.Add(number);
             if (shuffle <= 0)
             {
                 shuffle = 0;
             }
             int random = RandomNumberGen.NumberBetween(0, shuffle);
             if (random >= 100)
             {
                 random = 100;
             }
             else if (random <= 0)
             {
                 random = 1;
             }
             if (number == 5)
             {
                 Strength = random + 10;
             }
             else if (number == 4)
             {
                 Endurance = random + 10;
             }
             else if (number == 3)
             {
                 Speed = random + 10;
             }
             else if (number == 2)
             {
                 Sight = random + 10;
             }
             else if (number == 1)
             {
                 Intelligence = random + 10;
             }
             shuffle = shuffle - random;
         }
     }
     //
     if (potion.ID == 9)
     {
         RaiseMessage("This should protect way better than those rags.");
         AC = 10;
     }
 }
Пример #2
0
        public void Rest()
        {
            if (World.LocationByID(World.Location_ID_Camp) == CurrentLocation)
            {
                HP = MaxHP;
                if (Stamina <= 100 + ((int)Speed / 4))
                {
                    Stamina = 100 + ((int)Speed / 5);
                }
            }
            else
            {
                if (MaxHP <= (HP + (int)(MaxHP * .12)))
                {
                    HP = MaxHP;
                }
                else
                {
                    HP = HP + (int)(MaxHP * .12);
                }
                if ((Stamina + 40) >= 100)
                {
                    Stamina = 100;
                }
                else
                {
                    Stamina += 40;
                }
            }


            RaiseMessage("You had a rest and regain health and replenshed stamina");
            if (CurrentMonster != null)
            {
                if (CurrentMonster.HP >= 0)
                {
                    double crit           = CurrentMonster.MaxDmg * 1.5;
                    int    damageToPlayer = RandomNumberGen.NumberBetween(10, (int)crit);
                    RaiseMessage("The " + CurrentMonster.Name + " did " + damageToPlayer + " points of damage.");
                    HP -= damageToPlayer;
                    if (HP <= 0)
                    {
                        RaiseMessage("The " + CurrentMonster.Name + " killed you.");
                        Gold = Gold - (int)(0.05 * Gold);
                        MoveHome();
                    }
                }
            }
        }
Пример #3
0
        internal Monster NewInstanceOfMonster()
        {
            Monster NewMonster = new Monster(ID, Name, MaxDmg, RewardEXP, Gold, HP, MaxHP, Stamina, Ac, Sight, Weakness);

            foreach (LootItem lootItem in LootTable.Where(LootItem => RandomNumberGen.NumberBetween(1, 100) <= LootItem.DropPercentage))
            {
                NewMonster.lootItems.Add(new Inventory(lootItem.Details, 1));
            }
            if (NewMonster.lootItems.Count == 0)
            {
                foreach (LootItem lootItem in LootTable.Where(x => x.IsDefaultItem))
                {
                    NewMonster.lootItems.Add(new Inventory(lootItem.Details, 1));
                }
            }
            return(NewMonster);
        }
Пример #4
0
        private void LetTheMonsterAttack()
        {
            int monsterhit = RandomNumberGen.NumberBetween(0, CurrentMonster.Sight + level);

            if (monsterhit >= (int)(Speed / 5))
            {
                int damagetoPlayer = (RandomNumberGen.NumberBetween((int)(CurrentMonster.MaxDmg / 4), CurrentMonster.MaxDmg) - AC);
                RaiseMessage("The " + CurrentMonster.Name + " did " + damagetoPlayer + " of damage.");
                HP -= damagetoPlayer;
                if (IsDead)
                {
                    RaiseMessage("You have fainted from the " + CurrentMonster.Name + " attack.");
                    MoveHome();
                    Gold = Gold - (int)(0.05 * Gold);
                }
            }
            else
            {
                RaiseMessage("The " + CurrentMonster.Name + " missed.");
            }
        }
Пример #5
0
        public Monster NewInstanceOfMonsterLivingHere()
        {
            if (!HasAmonster)
            {
                return(null);
            }

            // If this location only has a monster appear some of the times,
            // check if a monster should appear this time.
            if (MonsterAppearanceChance > 0)
            {
                // Gets a random number between 1 and 100.
                // If the number is less than, or equal to, the MonsterAppearanceChance, create a monster
                bool monsterAppeared = RandomNumberGen.NumberBetween(1, 100) <= MonsterAppearanceChance;

                // If no monster appeared, return null (no monster this time)
                if (!monsterAppeared)
                {
                    return(null);
                }
            }

            int totalPercentages = _monsterAtLocation.Values.Sum();
            int randomNumber     = RandomNumberGen.NumberBetween(1, totalPercentages);
            int runningTotal     = 0;

            foreach (KeyValuePair <int, int> monsterKeyValuePair in _monsterAtLocation)
            {
                runningTotal += monsterKeyValuePair.Value;

                if (randomNumber <= runningTotal)
                {
                    return(World.MonsterByID(monsterKeyValuePair.Key).NewInstanceOfMonster());
                }
            }
            return(World.MonsterByID(_monsterAtLocation.Keys.Last()).NewInstanceOfMonster());
        }
Пример #6
0
        public void UseWeapon(Weapon weapon)
        {
            RaiseMessage(CurrentMonster.Name);
            int damageToMonster = RandomNumberGen.NumberBetween(weapon.MinDmg, weapon.MaxDmg);
            int dice            = RandomNumberGen.NumberBetween(1, 20);
            int dice2           = dice + (int)(Sight / 10);

            if (dice == 20)
            {
                CurrentMonster.HP -= damageToMonster * 2;
                RaiseMessage("Critial Hit!");
                RaiseMessage("You hit the " + CurrentMonster.Name + " for " + (damageToMonster * 2) + ".");
            }
            else if (dice2 >= CurrentMonster.Ac && dice != 0)
            {
                if (weapon.DmgType == CurrentMonster.Weakness)
                {
                    if (weapon.DmgType == "strike")
                    {
                        CurrentMonster.HP -= (damageToMonster + (int)(Strength / 2));
                        RaiseMessage("You hit the " + CurrentMonster.Name + " for " + (damageToMonster + (int)(Strength / 5)) + ".");
                    }
                    else if (weapon.DmgType == "magic")
                    {
                        CurrentMonster.HP -= (damageToMonster + (int)(Intelligence / 4));
                        RaiseMessage("You hit the " + CurrentMonster.Name + " for " + (damageToMonster + (int)(Intelligence / 4)) + ".");
                    }
                    else if (weapon.DmgType == "pericing")
                    {
                        CurrentMonster.HP -= (damageToMonster + (int)(Speed / 4));
                        RaiseMessage("You hit the " + CurrentMonster.Name + " for " + (damageToMonster + (int)(Speed / 4)) + ".");
                    }
                    else if (weapon.DmgType == "blunt")
                    {
                        CurrentMonster.HP -= (damageToMonster + (int)(Endurance / 4));
                        RaiseMessage("You hit the " + CurrentMonster.Name + " for " + (damageToMonster + (int)(Endurance / 4)) + ".");
                    }
                }
                else if (weapon.DmgType == "crit")
                {
                    CurrentMonster.HP -= (int)(damageToMonster * 1.5);
                    RaiseMessage("You hit the " + CurrentMonster.Name + " for " + (int)(damageToMonster * 1.5) + ".");
                }
                else
                {
                    CurrentMonster.HP -= (damageToMonster);
                    RaiseMessage("You hit the " + CurrentMonster.Name + " for " + damageToMonster + ".");
                }
            }
            else
            {
                RaiseMessage("You missed the " + CurrentMonster.Name);
            }
            if (CurrentMonster.IsDead)
            {
                LootTheCurrentMonster();
                MoveTo(CurrentLocation);
            }
            else
            {
                LetTheMonsterAttack();
            }
        }