예제 #1
0
        public async Task <Item> CreateItem(Guid playerId, NewItem item)
        {
            Item newItem = new Item();

            newItem.Modify(item);
            newItem.Id           = Guid.NewGuid();
            newItem.CreationDate = System.DateTime.Now;

            Player player = await _repository.GetPlayer(playerId);

            if (newItem.Type == Item.ItemType.Sword && player.Level < 3)
            {
                throw new LowLevelPlayerException("Player too low level for sword!");
            }

            return(await _repository.CreateItem(playerId, newItem));
        }
예제 #2
0
 public void Modify(NewItem item)
 {
     Level = item.Level;
     Type  = item.Type;
 }
예제 #3
0
 public Task <Item> CreateItem(Guid playerId, [FromBody] NewItem item)
 {
     return(_processor.CreateItem(playerId, item));
 }