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