Esempio n. 1
0
 private void CheckMinimum(Stats curStats, Stats prevStats)
 {
     double attDif = prevStats.Attack - curStats.Attack;
     double defDif = prevStats.Defense - curStats.Defense;
     double specAttDif = prevStats.SpecialAttack - curStats.SpecialAttack;
     double specDefDif = prevStats.SpecialDefense - curStats.SpecialDefense;
     double spdDif = prevStats.Speed - curStats.Speed;
     //Check if stats are below 40% of the original
     if (attDif != 0) if ((attDif / prevStats.Attack) >= 0.75) { curStats.Attack = Convert.ToInt32(prevStats.Attack * 0.25); AttackMod = 1; }
     if (defDif != 0) if ((defDif / prevStats.Defense) >= 0.75) { curStats.Defense = Convert.ToInt32(prevStats.Defense * 0.25); DefenseMod = 1; }
     if (specAttDif != 0) if ((specAttDif / prevStats.SpecialAttack) >= 0.75) { curStats.SpecialAttack = Convert.ToInt32(prevStats.SpecialAttack * 0.25); SpecialAttackMod = 1; }
     if (specAttDif != 0) if ((specDefDif / prevStats.SpecialDefense) >= 0.75) { curStats.SpecialDefense = Convert.ToInt32(prevStats.SpecialDefense * 0.25); SpecialDefenseMod = 1; }
     if (spdDif != 0) if ((spdDif / prevStats.Speed) >= 0.75) { curStats.Speed = Convert.ToInt32(prevStats.Speed * 0.25); SpeedMod = 1; }
 }
Esempio n. 2
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. 3
0
 /// <summary>
 /// Monster with one type
 /// </summary>
 /// <param name="id">ID of the monster</param>
 /// <param name="level">Level</param>
 /// <param name="name">Name</param>
 /// <param name="description">Short description of the monster</param>
 /// <param name="maleChance">Chance for the monster to be male</param>
 /// <param name="captureChance">Chance to capture this monster</param>
 /// <param name="helditem">Item the monster is carrying</param>
 /// <param name="stats">Stats the monster has</param>
 /// <param name="type">Type which changes how much damage certain moves do</param>
 /// <param name="abilities">All possible abilities the monster can have</param>
 /// <param name="front">Texture that is shown when fighting against this monster</param>
 /// <param name="back">Texture that is shown when you've send out this monster</param>
 /// <param name="party">Texture that is shown in the party view</param>
 public Monster(int id, int level, string name, string description, Type type, int maleChance, int captureChance, Item helditem, Stats stats, List<Ability> abilities,
     Texture2D front, Texture2D back, Texture2D party, bool database = false)
 {
     Id = id;
     if (!database) {
         StatId = RandomId.GenerateStatsId();
         UId = RandomId.GenerateRandomUId();
     }
     Level = level;
     experience = level * level * 5;
     RemainingExp = ((level + 1) * (level + 1) * 5) - experience;
     Name = name;
     Description = description;
     PrimaryType = type;
     SecondaryType = Type.None;
     Gender = GetGender(maleChance);
     CaptureChance = captureChance;
     HeldItem = helditem;
     Stats = stats;
     PossibleAbilities = abilities;
     Ability = GetAbility(abilities);
     FrontSprite = front;
     BackSprite = back;
     PartySprite = party;
     Ailment = Ailment.Normal;
     GetMoves();
     MaxHealth = Stats.Health;
 }
Esempio n. 4
0
 public void RestorePreviousStats()
 {
     var stats = Stats;
     PreviousStats = new Stats(stats, Level, stats.RandAttack, stats.RandDefense, stats.RandSpecialAttack, stats.RandSpecialDefense, stats.RandSpeed);
 }
Esempio n. 5
0
        /// <summary>
        /// Stats with randomize disabled
        /// </summary>
        /// <param name="stats">Current stats</param>
        /// <param name="level">Level</param>
        /// <param name="randAttack"></param>
        /// <param name="randDefense"></param>
        /// <param name="randSpecialAttack"></param>
        /// <param name="randSpecialDefense"></param>
        /// <param name="randSpeed"></param>
        public Stats(Stats stats, int level, int randAttack, int randDefense, int randSpecialAttack, int randSpecialDefense, int randSpeed)
        {
            BaseHealth = stats.BaseHealth;
            BaseAttack = stats.BaseAttack;
            BaseDefense = stats.BaseDefense;
            BaseSpecialAttack = stats.BaseSpecialAttack;
            BaseSpecialDefense = stats.BaseSpecialDefense;
            BaseSpeed = stats.BaseSpeed;

            RandAttack = randAttack;
            RandDefense = randDefense;
            RandSpecialAttack = randSpecialAttack;
            RandSpecialDefense = randSpecialDefense;
            RandSpeed = randSpeed;

            CalculateStats(level);
        }