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); } } }
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); }
public async Task AddPet(InventoryPet pet) { await _dao.AddPlayerPetAsync(pet, _player.Id); Pets.Add(pet.Id, pet); }
public bool TryGetPet(int id, out InventoryPet pet) => Pets.TryGetValue(id, out pet);
internal async Task UpdatePlayerPetAsync(InventoryPet pet) { await InsertAsync("UPDATE `pets` SET `room_id` = @0 WHERE `id` = @1;", pet.RoomId, pet.Id); }
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); }