/// <summary> /// Generates the pet from row. /// </summary> /// <param name="Row">The row.</param> /// <param name="mRow">The m row.</param> /// <returns>Pet.</returns> internal static Pet GeneratePetFromRow(DataRow Row, DataRow mRow) { if (Row == null) return null; MoplaBreed moplaBreed = null; if (Convert.ToUInt32(mRow["type"]) == 16u) { using (var queryReactor = Azure.GetDatabaseManager().GetQueryReactor()) { queryReactor.SetQuery($"SELECT * FROM pets_plants WHERE pet_id = {Convert.ToUInt32(Row["id"])}"); var row = queryReactor.GetRow(); moplaBreed = new MoplaBreed(row); } } return new Pet(Convert.ToUInt32(Row["id"]), Convert.ToUInt32(Row["user_id"]), Convert.ToUInt32(Row["room_id"]), (string)Row["name"], Convert.ToUInt32(mRow["type"]), (string)mRow["race"], (string)mRow["color"], (int)mRow["experience"], (int)mRow["energy"], (int)mRow["nutrition"], (int)mRow["respect"], Convert.ToDouble(mRow["createstamp"]), (int)Row["x"], (int)Row["y"], Convert.ToDouble(Row["z"]), (int)mRow["have_saddle"] == 1, (int)mRow["anyone_ride"], (int)mRow["hairdye"], (int)mRow["pethair"], (int)mRow["rarity"], Azure.UnixToDateTime((int)mRow["lasthealth_stamp"]), Azure.UnixToDateTime((int)mRow["untilgrown_stamp"]), moplaBreed); }
/// <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; PetCommands = PetCommandHandler.GetPetCommands(this); WaitingForBreading = 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); var breed = new MoplaBreed(pet, pet.PetId, pet.Rarity, tuple.Item1, tuple.Item2, 0, 1); using (var adapter = AzureEmulator.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; }