public async Task UpdateBot(InventoryBot bot)
        {
            await _dao.UpdatePlayerBotAsync(bot);

            if (bot.RoomId != 0)
            {
                Bots.Remove(bot.Id);
            }
            else
            {
                if (!Bots.ContainsKey(bot.Id))
                {
                    Bots.Add(bot.Id, bot);
                }
            }
        }
Beispiel #2
0
        internal async Task <Dictionary <int, InventoryBot> > ReadPlayerBotsAsync(int id)
        {
            Dictionary <int, InventoryBot> bots = new Dictionary <int, InventoryBot>();

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

            return(bots);
        }
        public async Task AddBot(InventoryBot bot)
        {
            await _dao.AddPlayerBotAsync(bot, _player.Id);

            Bots.Add(bot.Id, bot);
        }
 public bool TryGetBot(int id, out InventoryBot bot) => Bots.TryGetValue(id, out bot);
Beispiel #5
0
 internal async Task UpdatePlayerBotAsync(InventoryBot bot)
 {
     await InsertAsync("UPDATE `bots` SET `room_id` = @0 WHERE `id` = @1;", bot.RoomId, bot.Id);
 }
Beispiel #6
0
 internal async Task AddPlayerBotAsync(InventoryBot bot, int userId)
 {
     bot.Id = await InsertAsync("INSERT INTO `bots` (`name`, `motto`, `look`, `gender`, `user_id`) VALUES (@0, @1, @2, @3, @4);", bot.Name, bot.Motto, bot.Look, bot.Gender, userId);
 }