예제 #1
0
        public Task <Item> CreateItem(Guid playerid, NewItem item)
        {
            Player player = _repository.GetPlayer(playerid).Result;

            if (player.Level < 3 && item.Type == "sword")
            {
                throw new PlayerAlligatorException();
            }
            Item newItem = new Item();

            newItem.Name = item.Name;
            // set other values for new player
            newItem.Id           = Guid.NewGuid();
            newItem.CreationDate = System.DateTime.Now;

            return(_repository.CreateItem(playerid, newItem));
        }
예제 #2
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));
        }
예제 #3
0
 public Task <Item> CreateItem(Guid playerid, NewItem item)
 {
     return(_processor.CreateItem(playerid, item));
 }
예제 #4
0
 public Task <Item> CreateItem(Guid playerId, [FromBody] NewItem item)
 {
     return(_processor.CreateItem(playerId, item));
 }
예제 #5
0
 public void Modify(NewItem item)
 {
     Level = item.Level;
     Type  = item.Type;
 }