Esempio n. 1
0
        public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var id = request.Data.GetOrDefault <int>(k.ID);

                var character = request.Session.Character;

                var teleport = _sparkTeleportHelper.Get(id);
                if (teleport.Character != character)
                {
                    return;
                }

                _sparkTeleportHelper.DeleteAndInform(teleport);

                Transaction.Current.OnCommited(() =>
                {
                    var info = _sparkTeleportHelper.GetSparkTeleportDescriptionInfos(character);
                    Message.Builder.FromRequest(request).WithData(info).Send();
                });

                scope.Complete();
            }
        }
Esempio n. 2
0
        public void HandleRequest(IRequest request)
        {
            var character = request.Session.Character;
            var info      = _sparkTeleportHelper.GetSparkTeleportDescriptionInfos(character);

            info.Add(k.fee, SparkTeleport.SPARK_TELEPORT_USE_FEE);
            info.Add("placeFee", SparkTeleport.SPARK_TELEPORT_PLACE_FEE);

            Message.Builder.FromRequest(request).WithData(info).Send();
        }
        public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var character = request.Session.Character;
                character.IsDocked.ThrowIfFalse(ErrorCodes.CharacterHasToBeDocked);

                var dockingBase = character.GetCurrentDockingBase();
                dockingBase.IsDockingAllowed(character).ThrowIfError();
                if (dockingBase.Zone is TrainingZone)
                {
                    throw new PerpetuumException(ErrorCodes.TrainingCharacterInvolved);
                }

                var sparkTeleports = _sparkTeleportHelper.GetAllSparkTeleports(character).ToArray();
                if (sparkTeleports.Any(d => d.DockingBase == dockingBase))
                {
                    throw new PerpetuumException(ErrorCodes.BaseAlreadySparkTeleportDestination);
                }

                var alreadySpent = _sparkTeleportHelper.GetCostFromDescriptions(sparkTeleports);
                var maxCount     = _sparkTeleportHelper.GetMaxSparkTeleportCount(character);
                if (alreadySpent + dockingBase.Zone.Configuration.SparkCost > maxCount)
                {
                    throw new PerpetuumException(ErrorCodes.NotEnoughSparkTeleportSlots);
                }

                character.SubtractFromWallet(TransactionType.SparkTeleportPlace, SparkTeleport.SPARK_TELEPORT_PLACE_FEE);

                _sparkTeleportHelper.CreateSparkTeleport(dockingBase, character);

                Transaction.Current.OnCommited(() =>
                {
                    var info = _sparkTeleportHelper.GetSparkTeleportDescriptionInfos(character);
                    Message.Builder.FromRequest(request).WithData(info).Send();
                });

                scope.Complete();
            }
        }