Beispiel #1
0
        public async Task ShowWare(WareAction wareAction)
        {
            var result = await DoCommand(async() => {
                var playerId = _account.PlayerId;

                var command = new ShowWareCommand(playerId, wareAction.MyWareId);
                await _bus.SendCommand(command);
            });
        }
Beispiel #2
0
        public async Task <Unit> Handle(ShowWareCommand command, CancellationToken cancellationToken)
        {
            _logger.LogDebug($"Handle ShowWareCommand:{JsonConvert.SerializeObject(command)}");

            var myWareId = command.MyWareId;
            var playerId = command.PlayerId;

            var player = await _playerDomainService.Get(playerId);

            if (player == null)
            {
                await _bus.RaiseEvent(new DomainNotification($"角色不存在!"));

                return(Unit.Value);
            }

            var playerWare = await _playerWareDomainService.Get(myWareId);

            if (playerWare == null || playerWare.PlayerId != playerId)
            {
                await _bus.RaiseEvent(new DomainNotification($"物品不存在!"));

                return(Unit.Value);
            }

            var ware = await _wareDomainService.Get(playerWare.WareId);

            if (ware == null)
            {
                await _bus.RaiseEvent(new DomainNotification($"物品状态异常!"));

                return(Unit.Value);
            }


            var wareModel = await Computed(ware, playerWare);

            await _mudProvider.ShowWare(playerId, wareModel);

            return(Unit.Value);
        }