예제 #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);
 }