Exemplo n.º 1
0
        public async Task <Item> ModifyItem(Guid itemId, ModifiedItem item, Guid playerId)
        {
            var filter = Builders <Player> .Filter.Eq("Id", playerId);

            Player _player = new Player();

            _player = await _db.GetCollection <Player>("Players").Find(filter).FirstOrDefaultAsync();

            foreach (Item i in _player.items)
            {
                if (i.Id == itemId)
                {
                    i.Type  = item.Type;
                    i.Level = item.Level;
                }
            }
            await _db.GetCollection <Player>("Players").DeleteOneAsync(filter);

            await _db.GetCollection <Player>("Players").InsertOneAsync(_player);

            return(null);
        }
Exemplo n.º 2
0
 public async Task <Item> ModifyItem(Guid itemId, ModifiedItem item, Guid playerId)
 {
     if (_players.Count > 0)
     {
         foreach (Player p in _players)
         {
             if (p.Id == playerId)
             {
                 if (p.items.Count > 0)
                 {
                     foreach (Item i in p.items)
                     {
                         if (i.Id == itemId)
                         {
                             i.Type  = item.Type;
                             i.Level = item.Level;
                         }
                     }
                 }
             }
         }
     }
     return(null);
 }
Exemplo n.º 3
0
 public Task <Item> Modify(Guid id, [FromBody] ModifiedItem modifiedItem, Guid playerId)
 {
     return(_ItemsProcessor.Modify(id, modifiedItem, playerId));
 }
Exemplo n.º 4
0
 public Task <Item> Modify(Guid id, ModifiedItem item, Guid playerId)
 {
     return(_IRepository.ModifyItem(id, item, playerId));
 }