Beispiel #1
0
Datei: Pet.cs Projekt: sgf/Yupi
 /// <summary>
 ///     Initializes a new instance of the <see cref="Pet" /> class.
 /// </summary>
 /// <param name="petId">The pet identifier.</param>
 /// <param name="ownerId">The owner identifier.</param>
 /// <param name="roomId">The room identifier.</param>
 /// <param name="name">The name.</param>
 /// <param name="type">The type.</param>
 /// <param name="race">The race.</param>
 /// <param name="color">The color.</param>
 /// <param name="experience">The experience.</param>
 /// <param name="energy">The energy.</param>
 /// <param name="nutrition">The nutrition.</param>
 /// <param name="respect">The respect.</param>
 /// <param name="creationStamp">The creation stamp.</param>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 /// <param name="z">The z.</param>
 /// <param name="havesaddle">if set to <c>true</c> [havesaddle].</param>
 /// <param name="anyoneCanRide">The anyone can ride.</param>
 /// <param name="dye">The dye.</param>
 /// <param name="petHer">The pet her.</param>
 /// <param name="rarity">The rarity.</param>
 /// <param name="lastHealth">The last health.</param>
 /// <param name="untilGrown">The until grown.</param>
 /// <param name="moplaBreed">The mopla breed.</param>
 internal Pet(uint petId, uint ownerId, uint roomId, string name, uint type, string race, string color,
              int experience, int energy, int nutrition, int respect, double creationStamp, int x, int y, double z,
              bool havesaddle, int anyoneCanRide, int dye, int petHer, int rarity, DateTime lastHealth,
              DateTime untilGrown, MoplaBreed moplaBreed)
 {
     PetId              = petId;
     OwnerId            = ownerId;
     RoomId             = roomId;
     Name               = name;
     Type               = type;
     Race               = race;
     Color              = color;
     Experience         = experience;
     Energy             = energy;
     Nutrition          = nutrition;
     Respect            = respect;
     CreationStamp      = creationStamp;
     X                  = x;
     Y                  = y;
     Z                  = z;
     PlacedInRoom       = false;
     DbState            = DatabaseUpdateState.Updated;
     HaveSaddle         = havesaddle;
     AnyoneCanRide      = anyoneCanRide;
     PetHair            = petHer;
     HairDye            = dye;
     Rarity             = rarity;
     LastHealth         = lastHealth;
     UntilGrown         = untilGrown;
     MoplaBreed         = moplaBreed;
     WaitingForBreading = 0;
 }
Beispiel #2
0
        /// <summary>
        ///     Creates the monsterplant breed.
        /// </summary>
        /// <param name="pet">The pet.</param>
        /// <returns>MoplaBreed.</returns>
        internal static MoplaBreed CreateMonsterplantBreed(Pet pet)
        {
            if (pet.Type != 16)
            {
                return(null);
            }

            Tuple <string, string> tuple = GeneratePlantData(pet.Rarity);
            MoplaBreed             breed = new MoplaBreed(pet, pet.PetId, pet.Rarity, tuple.Item1, tuple.Item2, 0, 1);

            using (IQueryAdapter adapter = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                adapter.SetQuery("INSERT INTO pets_plants (pet_id, rarity, plant_name, plant_data) VALUES (@petid , @rarity , @plantname , @plantdata)");
                adapter.AddParameter("petid", pet.PetId);
                adapter.AddParameter("rarity", pet.Rarity);
                adapter.AddParameter("plantname", tuple.Item1);
                adapter.AddParameter("plantdata", tuple.Item2);
                adapter.RunQuery();
            }

            return(breed);
        }
Beispiel #3
0
        /// <summary>
        ///     Generates the pet from row.
        /// </summary>
        /// <param name="row">The row.</param>
        /// <returns>Pet.</returns>
        internal static Pet GeneratePetFromRow(DataRow row)
        {
            MoplaBreed moplaBreed = null;

            if ((string) row["pet_type"] == "pet_monster")
            {
                using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                {
                    queryReactor.SetQuery(
                        $"SELECT * FROM pets_plants WHERE pet_id = {Convert.ToUInt32(row["id"])}");

                    DataRow sRow = queryReactor.GetRow();

                    moplaBreed = new MoplaBreed(sRow);
                }
            }

            return new Pet(Convert.ToUInt32(row["id"]), Convert.ToUInt32(row["user_id"]),
                Convert.ToUInt32(row["room_id"]), (string) row["name"], (string) row["pet_type"],
                (uint) row["race_id"], (uint) row["experience"], (uint) row["energy"],
                (uint) row["nutrition"], (uint) row["respect"], Convert.ToDouble(row["createstamp"].ToString()),
                (int) row["x"],
                (int) row["y"], Convert.ToDouble(row["z"]), Convert.ToInt32(row["have_saddle"].ToString()) == 1,
                Convert.ToInt32(row["anyone_ride"].ToString()),
                (int) row["hairdye"], (int) row["pethair"], (int) row["rarity"],
                Yupi.UnixToDateTime((int) row["lasthealth_stamp"]),
                Yupi.UnixToDateTime((int) row["untilgrown_stamp"]), moplaBreed, (string) row["color"]);
        }
Beispiel #4
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Pet" /> class.
 /// </summary>
 /// <param name="petId">The pet identifier.</param>
 /// <param name="ownerId">The owner identifier.</param>
 /// <param name="roomId">The room identifier.</param>
 /// <param name="name">The name.</param>
 /// <param name="type">The type.</param>
 /// <param name="race">The race.</param>
 /// <param name="experience">The experience.</param>
 /// <param name="energy">The energy.</param>
 /// <param name="nutrition">The nutrition.</param>
 /// <param name="respect">The respect.</param>
 /// <param name="creationStamp">The creation stamp.</param>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 /// <param name="z">The z.</param>
 /// <param name="havesaddle">if set to <c>true</c> [havesaddle].</param>
 /// <param name="anyoneCanRide">The anyone can ride.</param>
 /// <param name="dye">The dye.</param>
 /// <param name="petHer">The pet her.</param>
 /// <param name="rarity">The rarity.</param>
 /// <param name="lastHealth">The last health.</param>
 /// <param name="untilGrown">The until grown.</param>
 /// <param name="moplaBreed">The mopla breed.</param>
 /// <param name="color"></param>
 internal Pet(uint petId, uint ownerId, uint roomId, string name, string type, uint race,
     uint experience, uint energy, uint nutrition, uint respect, double creationStamp, int x, int y, double z,
     bool havesaddle, int anyoneCanRide, int dye, int petHer, int rarity, DateTime lastHealth,
     DateTime untilGrown, MoplaBreed moplaBreed, string color)
 {
     PetId = petId;
     OwnerId = ownerId;
     RoomId = roomId;
     Name = name;
     Type = type;
     Race = race;
     Experience = experience;
     Energy = energy;
     Nutrition = nutrition;
     Respect = respect;
     CreationStamp = creationStamp;
     X = x;
     Y = y;
     Z = z;
     PlacedInRoom = false;
     DbState = DatabaseUpdateState.Updated;
     HaveSaddle = havesaddle;
     AnyoneCanRide = anyoneCanRide;
     PetHair = petHer;
     HairDye = dye;
     Rarity = rarity;
     LastHealth = lastHealth;
     UntilGrown = untilGrown;
     MoplaBreed = moplaBreed;
     WaitingForBreading = 0;
     RaceId = PetTypeManager.GetPetRaceIdByType(Type);
     Color = color;
 }
Beispiel #5
0
        /// <summary>
        ///     Creates the monsterplant breed.
        /// </summary>
        /// <param name="pet">The pet.</param>
        /// <returns>MoplaBreed.</returns>
        internal static MoplaBreed CreateMonsterplantBreed(Pet pet)
        {
            if (pet.Type != "pet_monster")
                return null;

            Tuple<string, string> tuple = GeneratePlantData(pet.Rarity);
            MoplaBreed breed = new MoplaBreed(pet, pet.PetId, pet.Rarity, tuple.Item1, tuple.Item2, 0, 1);

            using (IQueryAdapter adapter = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                adapter.SetQuery(
                    "INSERT INTO pets_plants (pet_id, rarity, plant_name, plant_data) VALUES (@petid , @rarity , @plantname , @plantdata)");
                adapter.AddParameter("petid", pet.PetId);
                adapter.AddParameter("rarity", pet.Rarity);
                adapter.AddParameter("plantname", tuple.Item1);
                adapter.AddParameter("plantdata", tuple.Item2);
                adapter.RunQuery();
            }

            return breed;
        }