示例#1
0
        public async Task <Item> ModifyItem(Guid playerId, Guid itemid, ModifiedItem item)
        {
            Player player = await this.GetPlayer(playerId);

            Item newItem = new Item();

            newItem.Level = item.Level;
            newItem.Type  = item.Type;

            Item[] itemList = player.Items.ToArray();
            for (int i = 0; i < itemList.Count(); i++)
            {
                if (itemList[i].id == itemid)
                {
                    newItem.id           = itemList[i].id;
                    newItem.CreationTime = itemList[i].CreationTime;
                    itemList[i]          = newItem;
                }
            }
            player.Items = itemList.ToList();

            await _collection.ReplaceOneAsync(Builders <Player>
                                              .Filter.Eq("Id", playerId), player);

            return(newItem);
        }
示例#2
0
 public Task <Item> ModifyItem(Guid id, Guid itemID, ModifiedItem item)
 {
     foreach (var player in playerList)
     {
         if (player.Id == id)
         {
             foreach (var item1 in player.Items)
             {
                 if (item1.id == itemID)
                 {
                     item1.Level = item.Level;
                     item1.Type  = item.Type;
                     return(Task.FromResult(item1));
                 }
             }
         }
     }
     return(Task.FromResult((Item)null));
 }
示例#3
0
 public Task <Item> ModifyItem(Guid id, Guid itemID, [FromBody] ModifiedItem item)
 {
     return(IP.ModifyItem(id, itemID, item));
 }