Example #1
0
        /// <summary>
        /// Called when [timer tick].
        /// </summary>
        /// <param name="lastHealth">The last health.</param>
        /// <param name="untilGrown">The until grown.</param>
        internal void OnTimerTick(DateTime lastHealth, DateTime untilGrown)
        {
            if ((int)LiveState != 0)
            {
                return;
            }
            var span = lastHealth - DateTime.Now;

            if (span.TotalSeconds <= 0)
            {
                KillPlant();
            }
            else if (GrowingStatus != 7)
            {
                var span2 = untilGrown - DateTime.Now;
                if (span2.TotalSeconds <= 10 && GrowingStatus == 6)
                {
                    GrowingStatus   = 7;
                    LiveState       = MoplaState.Grown;
                    _dbUpdateNeeded = true;
                }
                else if (span2.TotalSeconds <= 24000 && GrowingStatus == 5)
                {
                    GrowingStatus   = 6;
                    _dbUpdateNeeded = true;
                }
                else if (span2.TotalSeconds <= 48000 && GrowingStatus == 4)
                {
                    GrowingStatus   = 5;
                    _dbUpdateNeeded = true;
                }
                else if (span2.TotalSeconds <= 96000 && GrowingStatus == 3)
                {
                    GrowingStatus   = 4;
                    _dbUpdateNeeded = true;
                }
                else if (span2.TotalSeconds <= 110000 && GrowingStatus == 2)
                {
                    GrowingStatus   = 3;
                    _dbUpdateNeeded = true;
                }
                else if (span2.TotalSeconds <= 160000 && GrowingStatus == 1)
                {
                    GrowingStatus   = 2;
                    _dbUpdateNeeded = true;
                }

                if (Math.Abs(span2.TotalSeconds % 8) < 0)
                {
                    _pet.Energy--;
                }
            }
            if (!_dbUpdateNeeded)
            {
                return;
            }
            UpdateInDb();
        }
Example #2
0
 internal MoplaBreed(DataRow Row)
 {
     this.PetId         = uint.Parse(Row["pet_id"].ToString());
     this.Rarity        = int.Parse(Row["rarity"].ToString());
     this.MoplaName     = Row["plant_name"].ToString();
     this.BreedData     = Row["plant_data"].ToString();
     this.LiveState     = (MoplaState)int.Parse(Row["plant_state"].ToString());
     this.GrowingStatus = int.Parse(Row["growing_status"].ToString());
 }
Example #3
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MoplaBreed" /> class.
 /// </summary>
 /// <param name="row">The row.</param>
 internal MoplaBreed(DataRow row)
 {
     _petId        = uint.Parse(row["pet_id"].ToString());
     _rarity       = int.Parse(row["rarity"].ToString());
     Name          = row["plant_name"].ToString();
     PlantData     = row["plant_data"].ToString();
     LiveState     = (MoplaState)int.Parse(row["plant_state"].ToString());
     GrowingStatus = int.Parse(row["growing_status"].ToString());
 }
Example #4
0
 internal MoplaBreed(DataRow Row)
 {
     this.PetId = uint.Parse(Row["pet_id"].ToString());
     this.Rarity = int.Parse(Row["rarity"].ToString());
     this.MoplaName = Row["plant_name"].ToString();
     this.BreedData = Row["plant_data"].ToString();
     this.LiveState = (MoplaState)int.Parse(Row["plant_state"].ToString());
     this.GrowingStatus = int.Parse(Row["growing_status"].ToString());
 }
Example #5
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MoplaBreed" /> class.
 /// </summary>
 /// <param name="row">The row.</param>
 internal MoplaBreed(DataRow row)
 {
     _petId = uint.Parse(row["pet_id"].ToString());
     _rarity = int.Parse(row["rarity"].ToString());
     Name = row["plant_name"].ToString();
     PlantData = row["plant_data"].ToString();
     LiveState = (MoplaState) int.Parse(row["plant_state"].ToString());
     GrowingStatus = int.Parse(row["growing_status"].ToString());
 }
Example #6
0
 internal bool RevivePlant()
 {
     if (this.LiveState != MoplaState.DEAD)
     {
         return(false);
     }
     this.LiveState = (this.GrowingStatus < 7) ? MoplaState.ALIVE : MoplaState.GROWN;
     DBUpdateNeeded = true;
     return(true);
 }
Example #7
0
 internal MoplaBreed(Pet Pet, uint PetId, int Rarity, string MoplaName, string BreedData, int LiveState, int GrowingStatus)
 {
     this.Pet           = Pet;
     this.PetId         = PetId;
     this.Rarity        = Rarity;
     this.MoplaName     = MoplaName;
     this.BreedData     = BreedData;
     this.LiveState     = (MoplaState)LiveState;
     this.GrowingStatus = GrowingStatus;
 }
Example #8
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MoplaBreed" /> class.
 /// </summary>
 /// <param name="pet">The pet.</param>
 /// <param name="petId">The pet identifier.</param>
 /// <param name="rarity">The rarity.</param>
 /// <param name="moplaName">Name of the mopla.</param>
 /// <param name="breedData">The breed data.</param>
 /// <param name="liveState">State of the live.</param>
 /// <param name="growingStatus">The growing status.</param>
 internal MoplaBreed(Pet pet, uint petId, int rarity, string moplaName, string breedData, int liveState, int growingStatus)
 {
     _pet = pet;
     _petId = petId;
     _rarity = rarity;
     Name = moplaName;
     PlantData = breedData;
     LiveState = (MoplaState) liveState;
     GrowingStatus = growingStatus;
 }
Example #9
0
 /// <summary>
 ///     Revives the plant.
 /// </summary>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 internal bool RevivePlant()
 {
     if (LiveState != MoplaState.Dead)
     {
         return(false);
     }
     LiveState       = GrowingStatus < 7 ? MoplaState.Alive : MoplaState.Grown;
     _dbUpdateNeeded = true;
     return(true);
 }
Example #10
0
 internal MoplaBreed(Pet Pet, uint PetId, int Rarity, string MoplaName, string BreedData, int LiveState, int GrowingStatus)
 {
     this.Pet = Pet;
     this.PetId = PetId;
     this.Rarity = Rarity;
     this.MoplaName = MoplaName;
     this.BreedData = BreedData;
     this.LiveState = (MoplaState)LiveState;
     this.GrowingStatus = GrowingStatus;
 }
Example #11
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MoplaBreed" /> class.
 /// </summary>
 /// <param name="pet">The pet.</param>
 /// <param name="petId">The pet identifier.</param>
 /// <param name="rarity">The rarity.</param>
 /// <param name="moplaName">Name of the mopla.</param>
 /// <param name="breedData">The breed data.</param>
 /// <param name="liveState">State of the live.</param>
 /// <param name="growingStatus">The growing status.</param>
 internal MoplaBreed(Pet pet, uint petId, int rarity, string moplaName, string breedData, int liveState, int growingStatus)
 {
     _pet          = pet;
     _petId        = petId;
     _rarity       = rarity;
     Name          = moplaName;
     PlantData     = breedData;
     LiveState     = (MoplaState)liveState;
     GrowingStatus = growingStatus;
 }
Example #12
0
 internal bool RevivePlant()
 {
     if (this.LiveState != MoplaState.DEAD)
     {
         return false;
     }
     this.LiveState = (this.GrowingStatus < 7) ? MoplaState.ALIVE : MoplaState.GROWN;
     DBUpdateNeeded = true;
     return true;
 }
Example #13
0
        internal void OnTimerTick(DateTime LastHealth, DateTime UntilGrown)
        {
            if ((int)LiveState != 0)
            {
                return;
            }
            TimeSpan span = (TimeSpan)(LastHealth - DateTime.Now);
            if (span.TotalSeconds <= 0)
            {
                this.KillPlant();
            }
            else
            {
               
                if (this.GrowingStatus != 7)
                {
                    TimeSpan span2 = (TimeSpan)(UntilGrown - DateTime.Now);
                    if (span2.TotalSeconds <= 10 && this.GrowingStatus == 6)
                    {
                        this.GrowingStatus = 7;
                        this.LiveState = MoplaState.GROWN;
                        this.DBUpdateNeeded = true;
                    }
                    else if (span2.TotalSeconds <= 24000 && this.GrowingStatus == 5)
                    {
                        this.GrowingStatus = 6;
                        this.DBUpdateNeeded = true;
                    }
                    else if (span2.TotalSeconds <= 48000 && this.GrowingStatus == 4)
                    {
                        this.GrowingStatus = 5;
                        this.DBUpdateNeeded = true;
                    }
                    else if (span2.TotalSeconds <= 96000 && this.GrowingStatus == 3)
                    {
                        this.GrowingStatus = 4;
                        this.DBUpdateNeeded = true;
                    }
                    else if (span2.TotalSeconds <= 110000 && this.GrowingStatus == 2)
                    {
                        this.GrowingStatus = 3;
                        this.DBUpdateNeeded = true;
                    }
                    else if (span2.TotalSeconds <= 160000 && this.GrowingStatus == 1)
                    {
                        this.GrowingStatus = 2;
                        this.DBUpdateNeeded = true;
                    }

                    if (span2.TotalSeconds % 8 == 0)
                    {
                        Pet.Energy--;
                    }
                }
            }
            if (this.DBUpdateNeeded)
            {
                using (IQueryAdapter adapter = MercuryEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    adapter.setQuery("REPLACE INTO bots_monsterplants (pet_id, rarity, plant_name, plant_data, plant_state, growing_status) VALUES (@petid , @rarity , @plantname , @plantdata , @plantstate , @growing)");
                    adapter.addParameter("petid", this.PetId);
                    adapter.addParameter("rarity", this.Rarity);
                    adapter.addParameter("plantname", this.MoplaName);
                    adapter.addParameter("plantdata", this.BreedData);
                    adapter.addParameter("plantstate", ((int)this.LiveState).ToString());
                    adapter.addParameter("growing", this.GrowingStatus);
                    adapter.runQuery();
                }
            }
        }
Example #14
0
 internal void KillPlant()
 {
     this.LiveState = MoplaState.DEAD;
     this.DBUpdateNeeded = true;
 }
Example #15
0
 internal void KillPlant()
 {
     this.LiveState      = MoplaState.DEAD;
     this.DBUpdateNeeded = true;
 }
Example #16
0
        internal void OnTimerTick(DateTime LastHealth, DateTime UntilGrown)
        {
            if ((int)LiveState != 0)
            {
                return;
            }
            TimeSpan span = (TimeSpan)(LastHealth - DateTime.Now);

            if (span.TotalSeconds <= 0)
            {
                this.KillPlant();
            }
            else
            {
                if (this.GrowingStatus != 7)
                {
                    TimeSpan span2 = (TimeSpan)(UntilGrown - DateTime.Now);
                    if (span2.TotalSeconds <= 10 && this.GrowingStatus == 6)
                    {
                        this.GrowingStatus  = 7;
                        this.LiveState      = MoplaState.GROWN;
                        this.DBUpdateNeeded = true;
                    }
                    else if (span2.TotalSeconds <= 24000 && this.GrowingStatus == 5)
                    {
                        this.GrowingStatus  = 6;
                        this.DBUpdateNeeded = true;
                    }
                    else if (span2.TotalSeconds <= 48000 && this.GrowingStatus == 4)
                    {
                        this.GrowingStatus  = 5;
                        this.DBUpdateNeeded = true;
                    }
                    else if (span2.TotalSeconds <= 96000 && this.GrowingStatus == 3)
                    {
                        this.GrowingStatus  = 4;
                        this.DBUpdateNeeded = true;
                    }
                    else if (span2.TotalSeconds <= 110000 && this.GrowingStatus == 2)
                    {
                        this.GrowingStatus  = 3;
                        this.DBUpdateNeeded = true;
                    }
                    else if (span2.TotalSeconds <= 160000 && this.GrowingStatus == 1)
                    {
                        this.GrowingStatus  = 2;
                        this.DBUpdateNeeded = true;
                    }

                    if (span2.TotalSeconds % 8 == 0)
                    {
                        Pet.Energy--;
                    }
                }
            }
            if (this.DBUpdateNeeded)
            {
                using (IQueryAdapter adapter = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                {
                    adapter.setQuery("REPLACE INTO bots_monsterplants (pet_id, rarity, plant_name, plant_data, plant_state, growing_status) VALUES (@petid , @rarity , @plantname , @plantdata , @plantstate , @growing)");
                    adapter.addParameter("petid", this.PetId);
                    adapter.addParameter("rarity", this.Rarity);
                    adapter.addParameter("plantname", this.MoplaName);
                    adapter.addParameter("plantdata", this.BreedData);
                    adapter.addParameter("plantstate", ((int)this.LiveState).ToString());
                    adapter.addParameter("growing", this.GrowingStatus);
                    adapter.runQuery();
                }
            }
        }
Example #17
0
 /// <summary>
 ///     Kills the plant.
 /// </summary>
 internal void KillPlant()
 {
     LiveState       = MoplaState.Dead;
     _dbUpdateNeeded = true;
 }
Example #18
0
 /// <summary>
 ///     Kills the plant.
 /// </summary>
 internal void KillPlant()
 {
     LiveState = MoplaState.Dead;
     _dbUpdateNeeded = true;
 }
Example #19
0
        /// <summary>
        ///     Called when [timer tick].
        /// </summary>
        /// <param name="lastHealth">The last health.</param>
        /// <param name="untilGrown">The until grown.</param>
        internal void OnTimerTick(DateTime lastHealth, DateTime untilGrown)
        {
            if (LiveState != 0)
                return;

            TimeSpan span = lastHealth - DateTime.Now;

            if (span.TotalSeconds <= 0)
                KillPlant();

            else if (GrowingStatus != 7)
            {
                TimeSpan span2 = untilGrown - DateTime.Now;

                if (span2.TotalSeconds <= 10 && GrowingStatus == 6)
                {
                    GrowingStatus = 7;
                    LiveState = MoplaState.Grown;
                    _dbUpdateNeeded = true;
                }
                else if (span2.TotalSeconds <= 24000 && GrowingStatus == 5)
                {
                    GrowingStatus = 6;
                    _dbUpdateNeeded = true;
                }
                else if (span2.TotalSeconds <= 48000 && GrowingStatus == 4)
                {
                    GrowingStatus = 5;
                    _dbUpdateNeeded = true;
                }
                else if (span2.TotalSeconds <= 96000 && GrowingStatus == 3)
                {
                    GrowingStatus = 4;
                    _dbUpdateNeeded = true;
                }
                else if (span2.TotalSeconds <= 110000 && GrowingStatus == 2)
                {
                    GrowingStatus = 3;
                    _dbUpdateNeeded = true;
                }
                else if (span2.TotalSeconds <= 160000 && GrowingStatus == 1)
                {
                    GrowingStatus = 2;
                    _dbUpdateNeeded = true;
                }

                if (Math.Abs(span2.TotalSeconds%8) < 0)
                    _pet.Energy--;
            }

            if (!_dbUpdateNeeded)
                return;

            UpdateInDb();
        }
Example #20
0
 /// <summary>
 ///     Revives the plant.
 /// </summary>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 internal bool RevivePlant()
 {
     if (LiveState != MoplaState.Dead)
         return false;
     LiveState = GrowingStatus < 7 ? MoplaState.Alive : MoplaState.Grown;
     _dbUpdateNeeded = true;
     return true;
 }