Esempio n. 1
0
 public ContainerButton(Button button, Medicine medicine)
 {
     Button = button;
     Move = null;
     Monster = null;
     Medicine = medicine;
     Capture = null;
     BoxedMonster = null;
 }
Esempio n. 2
0
 public ContainerButton(Button button, Capture capture)
 {
     Button = button;
     Move = null;
     Monster = null;
     Medicine = null;
     Capture = capture;
     BoxedMonster = null;
 }
Esempio n. 3
0
 public ContainerButton(Button button, BoxedMonster boxedMonster)
 {
     Button = button;
     Move = null;
     Monster = null;
     Medicine = null;
     Capture = null;
     BoxedMonster = boxedMonster;
 }
Esempio n. 4
0
 public Stats ApplyModifiers(Monster monster)
 {
     var stats = monster.Stats;
     monster.RestorePreviousStats();
     CheckMinimum(monster.Stats, monster.PreviousStats);
     stats.Attack = Convert.ToInt32(stats.Attack * AttackMod);
     stats.Defense = Convert.ToInt32(stats.Defense * DefenseMod);
     stats.SpecialAttack = Convert.ToInt32(stats.SpecialAttack * SpecialAttackMod);
     stats.SpecialDefense = Convert.ToInt32(stats.SpecialDefense * SpecialDefenseMod);
     stats.Speed = Convert.ToInt32(stats.Speed * SpeedMod);
     //Actually set the right stats to PreviousStats
     return stats;
 }
Esempio n. 5
0
        public static void DrawBattle(SpriteBatch batch, Monster user, Monster opponent)
        {
            Rectangle userMonsterPos = new Rectangle(
                ContentLoader.GrassyBackground.Width - (ContentLoader.GrassyBackground.Width),
                ContentLoader.GrassyBackground.Height - user.BackSprite.Height,
                user.BackSprite.Width,
                user.BackSprite.Height);
            Rectangle opponentMonsterPos = new Rectangle(
                ContentLoader.GrassyBackground.Width - (int)(opponent.FrontSprite.Width * 2),
                ContentLoader.GrassyBackground.Height - (int)(opponent.FrontSprite.Height * 2),
                opponent.FrontSprite.Width,
                opponent.FrontSprite.Height);

            userpos = userMonsterPos;
            opponentpos = opponentMonsterPos;

            batch.Draw(user.BackSprite, new Vector2(userMonsterPos.X, userMonsterPos.Y));
            batch.Draw(opponent.FrontSprite, new Vector2(opponentMonsterPos.X, opponentMonsterPos.Y));
            DrawStatus(batch, user, opponent);
        }
Esempio n. 6
0
        public void Use(Monster monster, Character player)
        {
            if (Cures != Cure.None) {
                if (Cures == Cure.All) {
                    monster.Ailment = Ailment.Normal;
                }
                if (monster.Ailment == (Ailment)Cures) {
                    monster.Ailment = Ailment.Normal;
                }
            }
            if (inflict != Cure.None) {
                monster.Ailment = (Ailment)inflict;
            }
            if ((monster.Stats.Health + HealAmount) >= monster.MaxHealth) {
                monster.Stats.Health = monster.MaxHealth;
            }
            else if (monster.Stats.Health != monster.MaxHealth)
                monster.Stats.Health += HealAmount;
            else {
                Amount++;
            }
            Amount--;

            if (Amount < 1) {
                player.Inventory.Medicine.Remove(Id);
            }
        }
Esempio n. 7
0
        public void ReceiveExp(Monster opponent)
        {
            double a = opponent.IsWild ? 1 : 1.5f;
            double l = opponent.Level;
            double y = Level >= l ? 1 : 1.2f;

            var expGain = (a * l * y);
            // / 3

            experience += Convert.ToInt32(expGain);
            CheckLevelUp();
            //TODO: Add a experience calculation which will return level based on the amount of experience it has
        }
Esempio n. 8
0
        public static void DrawMonsterInfo(SpriteBatch batch, Monster m, Vector2 startPos = default(Vector2), bool knownMonsters = false)
        {
            Texture2D background = ContentLoader.MonsterViewer;
            var nameSize = ContentLoader.Arial.MeasureString(m.Ability.Name);
            Rectangle backgroundRectangle = new Rectangle((int)startPos.X, (int)startPos.Y, background.Width, background.Height);
            var frontPos = new Vector2(backgroundRectangle.X + 10, backgroundRectangle.Y + 24);
            var namePos = new Vector2(frontPos.X, backgroundRectangle.Y + 6);
            var descriptionPos = new Vector2(frontPos.X + 110, backgroundRectangle.Y + 28);
            var statsPos = new Vector2(frontPos.X, backgroundRectangle.Y + 130);
            var abilityNamePos = new Vector2(backgroundRectangle.X + 230, statsPos.Y);
            var abilityDescriptionPos = new Vector2(abilityNamePos.X, abilityNamePos.Y + 17);

            batch.Draw(background, backgroundRectangle, Color.White);
            batch.Draw(m.FrontSprite, frontPos, Color.White);
            batch.DrawString(ContentLoader.Arial, SplitString(m.Description, new Rectangle(0, 0, 112, 24)), descriptionPos, Color.Black);
            if (knownMonsters) {
                batch.DrawString(ContentLoader.Arial, m.Name, namePos, Color.Black);
                batch.DrawString(ContentLoader.Arial, m.Stats.PintBaseStats(), statsPos, Color.Black);
                if (m.PossibleAbilities.Count == 1) {
                    batch.DrawString(ContentLoader.Arial, $"{m.Ability.Name}", abilityNamePos, Color.Black);
                    batch.DrawString(ContentLoader.Arial, m.Ability.Description, abilityDescriptionPos, Color.Black);
                }
                else {
                    batch.DrawString(ContentLoader.Arial, $"{ m.PossibleAbilities[0].Name}", abilityNamePos, Color.Black);
                    batch.DrawString(ContentLoader.Arial, $"{ m.PossibleAbilities[0].Description}", abilityDescriptionPos, Color.Black);

                    var pos = new Vector2(abilityNamePos.X, abilityNamePos.Y + nameSize.Y + descriptionPos.Y);

                    batch.DrawString(ContentLoader.Arial, $"{ m.PossibleAbilities[1].Name}", pos, Color.Black);
                    batch.DrawString(ContentLoader.Arial, $"{ m.PossibleAbilities[1].Description}", new Vector2(pos.X, pos.Y + 17), Color.Black);
                }
            }
            else {
                batch.DrawString(ContentLoader.Arial, $"{m.Name} - Lv. {m.Level}", namePos, Color.Black);
                batch.DrawString(ContentLoader.Arial, m.Stats.PrintStats(m.MaxHealth), statsPos, Color.Black);
                batch.DrawString(ContentLoader.Arial, $"{m.Ability.Name}", abilityNamePos, Color.Black);
                batch.DrawString(ContentLoader.Arial, m.Ability.Description, abilityDescriptionPos, Color.Black);
            }
        }
Esempio n. 9
0
        public static void DrawStatus(SpriteBatch batch, Monster user, Monster opponent)
        {
            var font = ContentLoader.Arial;
            float prevFullExp = user.Level * user.Level * 5;
            float fullExp = ((user.Level + 1) * (user.Level + 1) * 5);
            float difference = fullExp - prevFullExp;
            float experiencePerc = 100 - ((user.RemainingExp / difference) * 100);

            var userHealthPerc = (user.Stats.Health * 100) / user.MaxHealth;
            var userExpSize = new Vector2(experiencePerc, 2);
            var userHealthSize = new Vector2(userHealthPerc, 10);
            var userHealthRec = new Rectangle(userpos.X + 48, userpos.Y - 20, (int)userHealthSize.X, (int)userHealthSize.Y);
            var userExpRec = new Rectangle(userHealthRec.X, userHealthRec.Y + 31, (int)userExpSize.X, (int)userExpSize.Y);

            var opponentHealthPerc = (opponent.Stats.Health * 100) / opponent.MaxHealth;
            var currentOpponentHealthSize = new Vector2(opponentHealthPerc, 10);
            var opponentHealthRec = new Rectangle(opponentpos.X, opponentpos.Y - 12, (int)currentOpponentHealthSize.X, (int)currentOpponentHealthSize.Y);

            var userCol = Color.SpringGreen;
            var opponentCol = Color.SpringGreen;
            if (userHealthPerc <= 50) userCol = Color.Orange; if (userHealthPerc <= 20) userCol = Color.Red;
            if (opponentHealthPerc <= 50) opponentCol = Color.Orange; if (opponentHealthPerc <= 20) opponentCol = Color.Red;

            batch.Draw(ContentLoader.HealthBorderUser, new Vector2(userHealthRec.X - 33, userHealthRec.Y - 4), Color.Gray);
            batch.DrawString(ContentLoader.Arial, user.Name, new Vector2(userHealthRec.X - 31, userHealthRec.Y - 22), Color.Black);
            batch.DrawString(ContentLoader.Arial, $"Lv. {user.Level}", new Vector2(userHealthRec.X + (font.MeasureString($"{user.Name} Lv. {user.Level}").X) - 48, userHealthRec.Y - 22), Color.Black);
            if (user.Stats.Health < 0) user.Stats.Health = 0;
            batch.DrawString(ContentLoader.Arial, $"{user.Stats.Health}/{user.MaxHealth}", new Vector2(userHealthRec.X - 12, userHealthRec.Y + 12), Color.Black);
            if (user.Ailment != Ailment.Normal)
                batch.Draw(GetAilmentTexture(user.Ailment), new Vector2(userHealthRec.X - 31, userHealthRec.Y - 2), Color.White);
            batch.Draw(ContentLoader.Health, userHealthRec, userCol);
            batch.Draw(ContentLoader.Health, userExpRec, Color.DeepSkyBlue);

            batch.Draw(ContentLoader.HealthBorder, new Vector2(opponentHealthRec.X - 33, opponentHealthRec.Y - 4), Color.Gray);
            batch.DrawString(ContentLoader.Arial, opponent.Name, new Vector2(opponentpos.X - 31, opponentpos.Y - 33), Color.Black);
            batch.DrawString(ContentLoader.Arial, $"Lv. {opponent.Level}", new Vector2(opponentpos.X + (font.MeasureString($"{opponent.Name} Lv. {opponent.Level}").X) - 48, opponentpos.Y - 33), Color.Black);
            //batch.DrawString(ContentLoader.Arial, $"{opponent.Stats.Health}/{opponent.MaxHealth}", new Vector2(opponentpos.X, opponentpos.Y), Color.Blue);
            if (opponent.Ailment != Ailment.Normal)
                batch.Draw(GetAilmentTexture(opponent.Ailment), new Vector2(opponentHealthRec.X - 31, opponentHealthRec.Y - 2), Color.White);
            batch.Draw(ContentLoader.Health, opponentHealthRec, opponentCol);
        }
Esempio n. 10
0
        public static void UseBuff(Battle b, Monster user, Monster receiver)
        {
            List<Move> moveList = new List<Move>();
            foreach (var move in user.Moves)
            {
                if (move.Kind == Kind.NonDamage)
                {
                    moveList.Add(move);
                }
            }
            if (moveList.Count != 0)
            {
                Random r = new Random();

                b.Attack(user, receiver, moveList[r.Next(0, moveList.Count)]);
            }
        }
Esempio n. 11
0
        public static void UseMedicine(Battle b, Character player, Monster user)
        {
            List<Medicine> medicineList = new List<Medicine>();

            foreach (var medicine in player.Inventory.Medicine.Values)
            {
                if (medicine.HealAmount != 0)
                {
                    medicineList.Add(medicine);
                }

            }
            if (medicineList.Count != 0)
            {
                Random r = new Random();
                var medicine = medicineList[r.Next(0, medicineList.Count)];
                Drawer.AddMessage(new List<string> { $"{medicine.Name} used on {user.Name}." });
                medicine.Use(user, player);
            }
        }
Esempio n. 12
0
 public double GetDamageModifier(Monster receiver)
 {
     double modifier = 1;
     var prim = receiver.PrimaryType;
     var secon = receiver.SecondaryType;
     switch (Type) {
     case Type.Normal:
         if (prim == Type.Ghost || secon == Type.Ghost) { modifier *= 0; }
         if (prim == Type.Sound || secon == Type.Sound) { modifier *= 2; }
         break;
     case Type.Fight:
         if (prim == Type.Normal || secon == Type.Normal) { modifier *= 2; }
         if (prim == Type.Rock || secon == Type.Rock) { modifier *= 2; }
         if (prim == Type.Ghost || secon == Type.Ghost) { modifier *= 0; }
         break;
     case Type.Fire:
         if (prim == Type.Grass || secon == Type.Grass) { modifier *= 2; }
         if (prim == Type.Water || secon == Type.Water) { modifier *= .5; }
         if (prim == Type.Rock || secon == Type.Rock) { modifier *= .5; }
         if (prim == Type.Ice || secon == Type.Ice) { modifier *= 2; }
         break;
     case Type.Water:
         if (prim == Type.Fire || secon == Type.Fire) { modifier *= 2; }
         if (prim == Type.Grass || secon == Type.Grass) { modifier *= .5; }
         if (prim == Type.Rock || secon == Type.Rock) { modifier *= 2; }
         break;
     case Type.Grass:
         if (prim == Type.Water || secon == Type.Water) { modifier *= 2; }
         if (prim == Type.Fire || secon == Type.Fire) { modifier *= .5; }
         if (prim == Type.Rock || secon == Type.Rock) { modifier *= 2; }
         if (prim == Type.Poison || secon == Type.Poison) { modifier *= .5; }
         break;
     case Type.Rock:
         if (prim == Type.Fire || secon == Type.Fire) { modifier *= 2; }
         if (prim == Type.Ice || secon == Type.Ice) { modifier *= 2; }
         break;
     case Type.Poison:
         if (prim == Type.Psych || secon == Type.Psych) { modifier *= 2; }
         if (prim == Type.Grass || secon == Type.Grass) { modifier *= 2; }
         break;
     case Type.Psych:
         if (prim == Type.Ghost || secon == Type.Ghost) { modifier *= 2; }
         break;
     case Type.Flying:
         if (prim == Type.Grass || secon == Type.Grass) { modifier *= 2; }
         if (prim == Type.Ice || secon == Type.Ice) { modifier *= 2; }
         if (prim == Type.Fight || secon == Type.Fight) { modifier *= 2; }
         break;
     case Type.Ice:
         if (prim == Type.Water || secon == Type.Water) { modifier *= .5; }
         if (prim == Type.Fire || secon == Type.Fire) { modifier *= 2; }
         if (prim == Type.Grass || secon == Type.Grass) { modifier *= 2; }
         if (prim == Type.Rock || secon == Type.Rock) { modifier *= 2; }
         if (prim == Type.Poison || secon == Type.Poison) { modifier *= 2; }
         if (prim == Type.Flying || secon == Type.Flying) { modifier *= 2; }
         if (prim == Type.Sound || secon == Type.Sound) { modifier *= .5; }
         break;
     case Type.Ghost:
         if (prim == Type.Normal || secon == Type.Normal) { modifier *= 0; }
         if (prim == Type.Psych || secon == Type.Psych) { modifier *= 2; }
         if (prim == Type.Ghost || secon == Type.Ghost) { modifier *= 2; }
         break;
     case Type.Sound:
         if (prim == Type.Normal || secon == Type.Normal) { modifier *= .5; }
         if (prim == Type.Water || secon == Type.Water) { modifier *= .5; }
         if (prim == Type.Psych || secon == Type.Psych) { modifier *= 2; }
         if (prim == Type.Rock || secon == Type.Rock) { modifier *= .5; }
         if (prim == Type.Ice || secon == Type.Ice) { modifier *= 2; }
         if (prim == Type.Ghost || secon == Type.Ghost) { modifier *= 2; }
         break;
     default:
         throw new ArgumentOutOfRangeException();
     }
     return modifier;
 }
Esempio n. 13
0
 public BoxedMonster(Monster monster, int page)
 {
     Monster = monster;
     Page = page;
 }
Esempio n. 14
0
 /// <summary>
 /// Checks if the opponent has an ability that can trigger an ailment on hit
 /// </summary>
 /// <param name="user"></param>
 /// <param name="opponent"></param>
 /// <param name="move"></param>
 /// <returns></returns>
 public Ailment GetAilment(Monster user, Monster opponent, Move move)
 {
     //If user already has an ailment
     if (user.Ailment != Ailment.Normal) return user.Ailment;
     //If move does not make contact with the opponent
     if (move.Kind != Kind.Physical) return user.Ailment;
     var rand = new CryptoRandom();
     switch (opponent.Ability.Id) {
     case AbilityId.ToxicBody:
         if (rand.Next(0, 100) <= 10) {
             Drawer.AddMessage(new List<string> { $"{opponent.Name}s {opponent.Ability.Name} made {user.Name} poisoned!" });
             return Ailment.Poisoned;
         }
         break;
     case AbilityId.Warm:
         if (rand.Next(0, 100) <= 7.5) {
             Drawer.AddMessage(new List<string> { $"{opponent.Name}s {opponent.Ability.Name} made {user.Name} fall asleep!" });
             return Ailment.Sleep;
         }
         break;
     case AbilityId.OnFire:
         if (rand.Next(0, 100) <= 7.5) {
             Drawer.AddMessage(new List<string> { $"{opponent.Name}s {opponent.Ability.Name} made {user.Name} catch fire!" });
             return Ailment.Burned;
         }
         break;
     }
     return Ailment.Normal;
 }
Esempio n. 15
0
        public void Use(Monster monster, Character player)
        {
            //Throw the net
            Random random = new Random();
            int capturechance = 0;

            CaptureAnimation(new List<Vector2>
            {
                new Vector2(20,20),
                new Vector2(50,50)
            });

            if (monster.Stats.Health < (monster.PreviousStats.Health / 100 * 20)) capturechance += 25;
            else if (monster.Stats.Health < (monster.PreviousStats.Health / 100 * 40)) capturechance += 20;
            else if (monster.Stats.Health < (monster.PreviousStats.Health / 100 * 60)) capturechance += 15;
            else if (monster.Stats.Health < (monster.PreviousStats.Health / 100 * 80)) capturechance += 10;

            switch (monster.Ailment) {
            case Ailment.Sleep: capturechance += 20; break;
            case Ailment.Poisoned: capturechance += 10; break;
            case Ailment.Burned: capturechance += 10; break;
            case Ailment.Dazzled: capturechance += 10; break;
            case Ailment.Frozen: capturechance += 20; break;
            case Ailment.Frenzied: capturechance += 5; break;
            }

            capturechance += CaptureChance;
            capturechance += (player.Monsters[0].Level - monster.Level);
            capturechance -= monster.CaptureChance;

            if (capturechance < 5) capturechance = 5;
            var dice = random.Next(0, 100);
            if (dice < capturechance) {
                //Add monster to caught list
                //if (!player.CaughtMonster.ContainsKey(monster.Id)) player.CaughtMonster.Add(monster.Id, monster);
                monster.UId = RandomId.GenerateRandomUId();
                if (player.Monsters.Count >= 6) player.Box.Add(monster);
                else player.Monsters.Add(monster);
            }
            Amount--;

            if (Amount < 1) player.Inventory.Captures.Remove(Id);
        }
Esempio n. 16
0
 public double GetDodgePercent(Monster user)
 {
     double dodge = 0;
     switch (user.Ability.Id) {
     case AbilityId.Fuzzy: dodge += 7.5; break;
     case AbilityId.AfterImage: dodge += 3; break;
     case AbilityId.Evasive: dodge += 5; break;
     }
     return dodge;
 }
Esempio n. 17
0
 public bool SkipTurn(Monster user)
 {
     if (user.Ability.Id == AbilityId.Silly) {
         ChanceToSkipTurn = 10f;
         var rand = new CryptoRandom();
         int ran = rand.Next(0, 100);
         if (ran <= ChanceToSkipTurn) {
             Drawer.AddMessage(new List<string> { $"{user.Name}s {user.Ability.Name} made {user.Name} skip a turn!" });
             return true;
         }
     }
     return false;
 }
Esempio n. 18
0
 public bool IsImmune(Monster reciever, Move move)
 {
     if (reciever.Ability.Id == AbilityId.Deaf && move.Type == Type.Sound) {
         Drawer.AddMessage(new List<string> { $"{reciever.Name} is immune to Sound attacks." });
         return true;
     }
     return false;
 }
Esempio n. 19
0
 public void GetStatBoosts(Monster user)
 {
     switch (user.Ability.Id) {
     case AbilityId.Buff: user.Stats = new StatModifier(1, 1.25, 1, 1, 1).ApplyModifiers(user); break;
     case AbilityId.Enraged: user.Stats = new StatModifier(1.25, 1, 1, 1, 1).ApplyModifiers(user); break;
     case AbilityId.Swift: user.Stats = new StatModifier(1, 1, 1, 1, 1.25).ApplyModifiers(user); break;
     case AbilityId.Relaxed: user.MaxHealth += user.MaxHealth / 95; break;
     case AbilityId.StrongFist: user.Stats = new StatModifier(1.50, 0.75, 1, 1, 1).ApplyModifiers(user); break;
     case AbilityId.AfterImage: user.Stats = new StatModifier(1, 1, 1, 1, 1.20).ApplyModifiers(user); break;
     case AbilityId.Enjoyer: user.Stats = new StatModifier(1.1, 1.1, 1.1, 1.1, 1.1).ApplyModifiers(user); break;
     case AbilityId.Squishy: user.Stats = new StatModifier(1, .80, 1, 1, 1.30).ApplyModifiers(user); break;
     case AbilityId.Confident: foreach (var move in user.Moves) { move.Accuracy += 25; } break;
     }
 }
Esempio n. 20
0
 public int GetMoneyModifier(Monster user, int money)
 {
     if (user.Ability.Id == AbilityId.Musician) return Convert.ToInt32(money + (money * .10f));
     return money;
 }
Esempio n. 21
0
        /// <summary>
        /// Execute a move
        /// </summary>
        /// <param name="user">Monster that is using this move</param>
        /// <param name="receiver">Monster that is receiving this move</param>
        public void Execute(Monster user, Monster receiver)
        {
            Uses -= 1;
            double critMultiplier = 1;
            //Check if the move hit
            var chanceToHit = Accuracy + ((user.Stats.Speed - receiver.Stats.Speed) / 3);
            if (user.Ailment == Ailment.Frenzied) Convert.ToInt32(chanceToHit/=2);
            chanceToHit -= Convert.ToInt32(receiver.Ability.GetDodgePercent(receiver));
            if (chanceToHit < Accuracy / 2) chanceToHit = Accuracy / 2;
            Random rand = new Random();
            //If random number is below chanceToHit the move did hit
            if (rand.Next(0, 100) <= chanceToHit) {
                Missed = false;
                //if random number is below the CriticalHitChance, the move did a critical
                if (rand.Next(0, 100) <= user.CriticalHitChance) critMultiplier = user.CriticalHitMultiplier;

                if (Kind == Kind.Physical)
                {
                    Damage = GetDamage(user.Stats.Attack, receiver.Stats.Defense, GetDamageModifier(receiver),
                        critMultiplier);
                    if (receiver.Ability.IsImmune(receiver, this)) Damage = 0;
                        switch (user.Ailment)
                    {
                        case Ailment.Burned: receiver.Stats.Health -= Damage/2; break;
                        case Ailment.Frenzied: receiver.Stats.Health -= Convert.ToInt32(Damage*1.5); break;
                        default: receiver.Stats.Health -= Damage; break;
                    }
                }
                else if (Kind == Kind.Special)
                {
                    Damage = GetDamage(user.Stats.SpecialAttack, receiver.Stats.SpecialDefense,
                        GetDamageModifier(receiver), critMultiplier);
                    if (receiver.Ability.IsImmune(receiver, this)) Damage = 0;
                    switch (user.Ailment)
                    {
                        case Ailment.Dazzled: receiver.Stats.Health -= Damage / 2; break;
                        case Ailment.Frenzied: receiver.Stats.Health -= Convert.ToInt32(Damage * 1.5); break;
                        default: receiver.Stats.Health -= Damage; break;
                    }
                }
                if (HitModifier != null) {
                    if (HitModifier.ApplyToOpponent) receiver.Stats = HitModifier.Modifier.ApplyModifiers(receiver);
                    if (HitModifier.ApplyToUser) user.Stats = HitModifier.Modifier.ApplyModifiers(user);
                }
                if (AilmentChance > rand.Next(0, 100))
                {
                    receiver.Ailment = Ailment;
                }
                user.Ailment = user.Ability.GetAilment(user, receiver, this);
            }
            //User missed
            else {
                Drawer.AddMessage(new List<string> { "But it missed.." });
                Missed = true;
                if (MissModifier != null) {
                    if (MissModifier.ApplyToOpponent)
                        receiver.Stats = MissModifier.Modifier.ApplyModifiers(receiver);
                    if (MissModifier.ApplyToUser) user.Stats = MissModifier.Modifier.ApplyModifiers(user);
                    //receiver.Stats = MissModifier.ApplyModifiers(receiver);
                }
            }
            // Check if either monster died
            if (user.Stats.Health <= 0) user.Ailment = Ailment.Fainted;
            if (receiver.Stats.Health <= 0) receiver.Ailment = Ailment.Fainted;
        }
Esempio n. 22
0
 public static void EnemyAttack(Battle b, Monster user, Monster receiver)
 {
     strongestAttack = Move.Glare();
     //user.GetMoves();
     foreach (var m in user.Moves.Where(x => x.Uses != 0))
     {
         m.Damage = m.GetDamage(user.Stats.SpecialAttack, receiver.Stats.SpecialDefense,
                    m.GetDamageModifier(receiver), 1);
         if (m.Damage > strongestAttack.Damage)
         {
             strongestAttack = m;
         }
     }
     b.Attack(user, receiver, strongestAttack);
 }
Esempio n. 23
0
 public static Monster GetMonster(int monsterId, int level)
 {
     Monster mon = null;
     var monsterCmd = connection.CreateCommand();
     monsterCmd.CommandText = $"SELECT * FROM `monster` WHERE `Id` = @id";
     monsterCmd.Parameters.AddWithValue("@id", monsterId);
     using (var rdr = monsterCmd.ExecuteReader()) {
         while (rdr.Read()) {
             var id = rdr.GetInt32("Id");
             if (id == monsterId) {
                 var name = rdr.GetString("Name");
                 var description = rdr.GetString("Description");
                 var primaryType = TypeMethods.GetTypeFromString(rdr.GetString("PrimaryType"));
                 var secondType = TypeMethods.GetTypeFromString(rdr.GetString("SecondType"));
                 var maleChance = rdr.GetInt32("MaleChance");
                 var captureChance = rdr.GetInt32("CaptureChance");
                 var abilityOne = Ability.GetAbilityFromString(rdr.GetString("AbilityOne"));
                 var abilityTwo = Ability.GetAbilityFromString(rdr.GetString("AbilityTwo"));
                 var baseHealth = rdr.GetInt32("BaseHealth");
                 var baseAttack = rdr.GetInt32("BaseAttack");
                 var baseDefense = rdr.GetInt32("BaseDefense");
                 var baseSpecialAttack = rdr.GetInt32("BaseSpecialAttack");
                 var baseSpecialDefense = rdr.GetInt32("BaseSpecialDefense");
                 var baseSpeed = rdr.GetInt32("BaseSpeed");
                 var baseStats = new Stats(baseHealth, baseAttack, baseDefense, baseSpecialAttack, baseSpecialDefense, baseSpeed, level);
                 var abilities = new List<Ability>();
                 abilities.AddManyIfNotNull(abilityOne, abilityTwo);
                 var front = ContentLoader.GetTextureFromMonsterId(id, TextureFace.Front);
                 var back = ContentLoader.GetTextureFromMonsterId(id, TextureFace.Back);
                 var party = ContentLoader.GetTextureFromMonsterId(id, TextureFace.World);
                 mon = new Monster(id, level, name, description, primaryType, secondType, maleChance, captureChance, new Item(), baseStats, abilities, front, back, party, true);
                 break;
             }
         }
     }
     if (mon.Name != String.Empty) {
         mon.UId = RandomId.GenerateRandomUId();
         mon.StatId = RandomId.GenerateStatsId();
         return mon;
     }
     return null;
 }
Esempio n. 24
0
        public static void MakeDecision(Battle b, Move m, Monster user, Monster receiver, Character player)
        {
            Random random = new Random();

            switch (random.Next(1, 5))
            {
                case 1:
                    EnemyAttack(b, user, receiver);
                    break;
                case 2:
                    UseBuff(b, user, receiver);
                    break;
                case 3:
                    if (user.Ailment != Ailment.Normal)
                    {
                        if (player != null)
                        {
                            foreach (var value in player.Inventory.Medicine.Values)
                            {
                                if (Medicine.CuresAilment(user.Ailment))
                                {
                                    UseMedicine(b, player, user);
                                }
                            }
                        }
                    }
                    else
                    {
                        EnemyAttack(b, user, receiver);
                    }
                    break;
                case 4:
                    if (user.Stats.Health < user.MaxHealth / 100 * 20)
                    {
                        if (player != null)
                        {
                            if (player.Inventory.Medicine.Count != 0)
                            {
                                UseMedicine(b, player, user);
                            }
                            else
                            {
                                EnemyAttack(b, user, receiver);
                            }
                        }
                        else
                        {
                            EnemyAttack(b, user, receiver);
                        }
                    }
                    else
                    {
                        EnemyAttack(b, user, receiver);
                    }
                    break;
                case 5:
                    if (user.Ailment != Ailment.Normal)
                    {
                        foreach (var value in player.Inventory.Medicine.Values)
                        {
                            if (Medicine.CuresAilment(user.Ailment))
                            {
                                UseMedicine(b, player, user);
                            }
                        }
                    }

                    if (user.Stats.Health < user.MaxHealth / 100 * 20)
                    {
                        if (player != null)
                        {
                            if (player.Inventory.Medicine.Count != 0)
                            {
                                UseMedicine(b, player, user);
                            }
                            else
                            {
                                if (m.Damage != null)
                                {
                                    if (m.Damage > user.Stats.Health)
                                    {
                                        EnemyAttack(b, user, receiver);
                                    }
                                    else
                                    {
                                        UseBuff(b, user, receiver);
                                    }
                                }
                                else
                                {
                                    UseBuff(b, user, receiver);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (m != null)
                        {
                            if (m.Damage != 0)
                            {
                                if (m.Damage > user.Stats.Health)
                                {
                                    EnemyAttack(b, user, receiver);
                                }
                                else
                                {
                                    UseBuff(b, user, receiver);
                                }
                            }
                            else
                            {
                                UseBuff(b, user, receiver);
                            }
                        }
                        else
                        {
                            UseBuff(b, user, receiver);
                        }
                    }
                    break;
            }
        }