public void HandleRequest(IRequest request)
        {
            var character = request.Session.Character;
            var member    = Character.Get(request.Data.GetOrDefault <int>(k.memberID));

            var currentGang = _gangManager.GetGangByMember(member);

            if (currentGang != null)
            {
                throw new PerpetuumException(ErrorCodes.CharacterAlreadyInGang);
            }

            var gang = _gangManager.GetGangByMember(character);

            if (gang == null)
            {
                throw new PerpetuumException(ErrorCodes.CharacterNotInGang);
            }

            gang.CanInvite(character).ThrowIfFalse(ErrorCodes.OnlyGangLeaderOrAssistantCanDoThis);

            _gangInviteService.GetInvite(member).ThrowIfNotNull(ErrorCodes.CharacterAlreadyHasPendingGangInvitation);
            _gangInviteService.AddInvite(new GangInviteInfo(gang.Id, character, member));

            var data = new Dictionary <string, object>
            {
                { k.name, gang.Name }, { k.characterID, character.Id }
            };

            Message.Builder.SetCommand(Commands.GangInvite).WithData(data).ToCharacter(member).Send();
            Message.Builder.FromRequest(request).WithOk().Send();
        }
Example #2
0
        public void SetComponentsFromRunningTargets(Character character)
        {
            var gang = _gangManager.GetGangByMember(character);

            if (gang == null)
            {
                var missionGuid = CollectComponentsFromIndustrialMissions(character);
                if (missionGuid == Guid.Empty)
                {
                    Logger.Info("not in gang, not in mission, falling back to fake components. CPRG:" + this.Eid);
                }
                return;
            }

            var gangMembers = gang.GetOnlineMembers().ToArray();

            if (gangMembers.Length == 1)
            {
                //alone in gang
                Logger.Info("alone in gang, and not in mission. falling back to fake components. CPRG:" + this.Eid);
            }

            foreach (var gangMember in gangMembers)
            {
                var missionGuid = CollectComponentsFromIndustrialMissions(gangMember);
                if (missionGuid != Guid.Empty)
                {
                    return;
                }
            }
        }
        public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var character = request.Session.Character;
                var member    = Character.Get(request.Data.GetOrDefault <int>(k.memberID));

                var gang = _gangManager.GetGangByMember(character);
                if (gang == null)
                {
                    throw new PerpetuumException(ErrorCodes.CharacterNotInGang);
                }

                if (character != gang.Leader)
                {
                    throw new PerpetuumException(ErrorCodes.OnlyGangLeaderCanDoThis);
                }

                _gangManager.ChangeLeader(gang, member);

                Message.Builder.FromRequest(request).WithOk().Send();

                scope.Complete();
            }
        }
Example #4
0
        public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var character = request.Session.Character;
                var answer    = request.Data.GetOrDefault <int>(k.answer);

                var currentGang = _gangManager.GetGangByMember(character);
                if (currentGang != null)
                {
                    throw new PerpetuumException(ErrorCodes.CharacterAlreadyInGang);
                }

                var gangInvite = _gangInviteService.GetInvite(character).ThrowIfNull(ErrorCodes.NoSuchGangInvite);
                var gang       = _gangManager.GetGang(gangInvite.gangGuid).ThrowIfNull(ErrorCodes.GangNotFound);

                _gangInviteService.RemoveInvite(gangInvite);

                if (answer > 0)
                {
                    _gangManager.JoinMember(gang, character, true);
                }

                Transaction.Current.OnCommited(() =>
                {
                    var data = new Dictionary <string, object>
                    {
                        { k.characterID, gangInvite.member.Id },
                        { k.answer, answer }
                    };

                    // feladonak
                    Message.Builder.SetCommand(Commands.GangInviteReply)
                    .WithData(data)
                    .ToCharacter(gangInvite.sender)
                    .Send();

                    data = new Dictionary <string, object> {
                        { k.answer, answer }
                    };

                    if (answer > 0)
                    {
                        data.Add(k.gang, gang.ToDictionary());
                    }

                    // membernek
                    Message.Builder.FromRequest(request).WithData(data).Send();
                });

                scope.Complete();
            }
        }
        public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var character = request.Session.Character;

                var gang = _gangManager.GetGangByMember(character);
                if (gang.Leader != character)
                {
                    throw new PerpetuumException(ErrorCodes.OnlyGangLeaderCanDoThis);
                }
                _gangManager.DisbandGang(gang);

                _gangInviteService.RemoveInvitesByGang(gang);
                Message.Builder.FromRequest(request).WithOk().Send();

                scope.Complete();
            }
        }
Example #6
0
        public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var character = request.Session.Character;

                var gang = _gangManager.GetGangByMember(character);
                if (gang == null)
                {
                    throw new PerpetuumException(ErrorCodes.CharacterNotInGang);
                }

                _gangManager.RemoveMember(gang, character, false);

                Message.Builder.FromRequest(request).WithOk().Send();

                scope.Complete();
            }
        }
        public void HandleRequest(IRequest request)
        {
            var character = request.Session.Character;

            var messageBuilder = Message.Builder.FromRequest(request);

            var gang = _gangManager.GetGangByMember(character);

            if (gang == null)
            {
                messageBuilder.WithEmpty();
            }
            else
            {
                messageBuilder.WithData(gang.ToDictionary());
            }

            messageBuilder.Send();
        }
        public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var account   = _accountManager.Repository.Get(request.Session.AccountId).ThrowIfNull(ErrorCodes.AccountNotFound);
                var character = Character.Get(request.Data.GetOrDefault <int>(k.characterID));

                account.Id.ThrowIfNotEqual(character.AccountId, ErrorCodes.AccessDenied);

                Corporation.GetRoleFromSql(character).ThrowIfNotEqual(CorporationRole.NotDefined, ErrorCodes.MemberHasRolesError);

                //temporary ep penalty

                _accountManager.InsertPenaltyPoint(account, AccountExtensionPenaltyType.CharacterDelete, CHARACTER_DELETE_EP_PENALTY, false);

                character.IsActive = false;
                character.SetActiveRobot(null);

                var gang = _gangManager.GetGangByMember(character);
                _gangManager.RemoveMember(gang, character, false);

                // clean up channels
                _channelManager.LeaveAllChannels(character);

                //clean corp and know character data
                character.CleanGameRelatedData();

                var oldCorporation = character.GetCorporation();

                //if he was in private corp -> move the member to his default corp
                if (oldCorporation is PrivateCorporation)
                {
                    character.GetDefaultCorporation().AddMember(character, CorporationRole.NotDefined, oldCorporation);
                    oldCorporation.RemoveMember(character);
                }

                Message.Builder.FromRequest(request).WithOk().Send();

                scope.Complete();
            }
        }
Example #9
0
        public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var character = request.Session.Character;
                var gangName  = request.Data.GetOrDefault <string>(k.name);
                var memberId  = request.Data.GetOrDefault <int>(k.characterID);

                var currentGang = _gangManager.GetGangByMember(character);
                _gangManager.RemoveMember(currentGang, character, false);

                var newGang = _gangManager.CreateGang(gangName, character);

                Transaction.Current.OnCommited(() =>
                {
                    var result = newGang.ToDictionary();
                    result.Add(k.characterID, memberId);
                    Message.Builder.FromRequest(request).WithData(result).Send();
                });

                scope.Complete();
            }
        }
Example #10
0
 public void SetGang(Player player)
 {
     player.Gang = _gangManager.GetGangByMember(player.Character);
 }