Пример #1
0
        public async Task UpdatePet(InventoryPet pet)
        {
            await _dao.UpdatePlayerPetAsync(pet);

            if (pet.RoomId != 0)
            {
                Pets.Remove(pet.Id);
            }
            else
            {
                if (!Pets.ContainsKey(pet.Id))
                {
                    Pets.Add(pet.Id, pet);
                }
            }
        }
Пример #2
0
        internal async Task <Dictionary <int, InventoryPet> > ReadPlayerPetsAsync(int id)
        {
            Dictionary <int, InventoryPet> pets = new Dictionary <int, InventoryPet>();

            await SelectAsync(async reader =>
            {
                while (await reader.ReadAsync())
                {
                    InventoryPet pet = new InventoryPet(reader);
                    if (!pets.ContainsKey(pet.Id))
                    {
                        pets.Add(pet.Id, pet);
                    }
                }
            }, "SELECT * FROM `pets` WHERE `user_id` = @0 AND `room_id` = 0", id);

            return(pets);
        }
Пример #3
0
        public async Task AddPet(InventoryPet pet)
        {
            await _dao.AddPlayerPetAsync(pet, _player.Id);

            Pets.Add(pet.Id, pet);
        }
Пример #4
0
 public bool TryGetPet(int id, out InventoryPet pet) => Pets.TryGetValue(id, out pet);
Пример #5
0
 internal async Task UpdatePlayerPetAsync(InventoryPet pet)
 {
     await InsertAsync("UPDATE `pets` SET `room_id` = @0 WHERE `id` = @1;", pet.RoomId, pet.Id);
 }
Пример #6
0
 internal async Task AddPlayerPetAsync(InventoryPet pet, int userId)
 {
     pet.Id = await InsertAsync("INSERT INTO `pets` (`name`, `type`, `race`, `colour`, `user_id`) VALUES (@0, @1, @2, @3, @4);", pet.Name, pet.Type, pet.Race, pet.Colour, userId);
 }