Esempio n. 1
0
        public async Task <Player> ModifyInventory(Guid id, ModifiedPlayerInventory player)
        {
            var filter = Builders <Player> .Filter.Eq("Id", id);

            Player _player = await Get(id);

            _player.Items = player.Items;
            await _collection.ReplaceOneAsync(filter, _player);

            return(_player);
        }
Esempio n. 2
0
        public async Task <Item> CreateItem(Guid playerId, Item item)
        {
            Player _p = await Get(playerId);

            _p.Items.Add(item);
            ModifiedPlayerInventory _modP = new ModifiedPlayerInventory();

            _modP.Items = _p.Items;
            await ModifyInventory(_p.Id, _modP);

            return(item);
        }
Esempio n. 3
0
        public async Task <Item> DeleteItem(Guid playerId, Guid itemId)
        {
            Player _p = await Get(playerId);

            for (int i = 0; i < _p.Items.Count; i++)
            {
                if (_p.Items[i].Id == itemId)
                {
                    _p.Items.Remove(_p.Items[i]);
                    ModifiedPlayerInventory _modP = new ModifiedPlayerInventory();
                    _modP.Items = _p.Items;
                    await ModifyInventory(playerId, _modP);

                    return(_p.Items[i]);
                }
            }
            throw new System.ArgumentException("Unable to find given ID.");
        }
Esempio n. 4
0
 Task <Player> IRepository.ModifyInventory(Guid id, ModifiedPlayerInventory player)
 {
     throw new NotImplementedException("nope");
 }