Пример #1
0
        private GuildResultInfo GuildOperationMemberPromote(GuildMember member, Player player, ClientGuildOperation operation)
        {
            GuildMember targetMember = null;

            GuildResultInfo GetResult()
            {
                if (!member.Rank.HasPermission(GuildRankPermission.ChangeMemberRank))
                {
                    return(new GuildResultInfo(GuildResult.RankLacksSufficientPermissions));
                }

                targetMember = GetMember(operation.TextValue);
                if (targetMember == null)
                {
                    return(new GuildResultInfo(GuildResult.CharacterNotInYourGuild, referenceString: operation.TextValue));
                }

                if (member.Rank.Index >= targetMember.Rank.Index)
                {
                    return(new GuildResultInfo(GuildResult.CannotPromote));
                }

                return(new GuildResultInfo(GuildResult.Success));
            }

            GuildResultInfo info = GetResult();

            if (info.Result == GuildResult.Success)
            {
                GuildRank newRank = GetPromotedRank(targetMember.Rank.Index);
                MemberChangeRank(targetMember, newRank);

                AnnounceGuildMemberChange(targetMember);
                AnnounceGuildResult(GuildResult.PromotedMember, referenceText: operation.TextValue);
            }

            return(info);
        }
Пример #2
0
        private GuildResultInfo GuildOperationEditPlayerNote(GuildMember member, Player player, ClientGuildOperation operation)
        {
            GuildResultInfo GetResult()
            {
                if (!TextFilterManager.Instance.IsTextValid(operation.TextValue) ||
                    !TextFilterManager.Instance.IsTextValid(operation.TextValue, UserText.GuildMemberNote))
                {
                    return(new GuildResultInfo(GuildResult.InvalidMemberNote));
                }

                return(new GuildResultInfo(GuildResult.Success));
            }

            GuildResultInfo info = GetResult();

            if (info.Result == GuildResult.Success)
            {
                member.Note = operation.TextValue;
                AnnounceGuildMemberChange(member);
            }

            return(info);
        }
Пример #3
0
 private void GuildOperationInitGuildWindow(GuildMember member, Player player, ClientGuildOperation operation)
 {
     // Probably want to send roster update
 }
Пример #4
0
 private void GuildOperationSetNameplateAffiliation(GuildMember member, Player player, ClientGuildOperation operation)
 {
     player.GuildManager.UpdateGuildAffiliation(Id);
 }
Пример #5
0
 private void GuildOperationRosterRequest(GuildMember member, Player player, ClientGuildOperation operation)
 {
     SendGuildRoster(player.Session);
 }
Пример #6
0
        private GuildResultInfo GuildOperationCommunityPlotReservation(GuildMember member, Player player, ClientGuildOperation operation)
        {
            if (!member.Rank.HasPermission(GuildRankPermission.ReserveCommunityPlot))
            {
                return(new GuildResultInfo(GuildResult.RankLacksSufficientPermissions));
            }

            if (operation.Data.Int32Data < -1 || operation.Data.Int32Data > 4)
            {
                throw new InvalidPacketValueException();
            }

            Residence residence = player.ResidenceManager.Residence;

            if (residence == null)
            {
                throw new InvalidPacketValueException();
            }

            ResidenceChild sourceResidence = Residence.GetChild(member.CharacterId);

            if (operation.Data.Int32Data != -1)
            {
                ResidenceChild targetResidence = Residence.GetChild((PropertyInfoId)(100 + operation.Data.Int32Data));
                if (targetResidence == null)
                {
                    ResidenceEntrance entrance = GlobalResidenceManager.Instance.GetResidenceEntrance((PropertyInfoId)(100 + operation.Data.Int32Data));
                    if (entrance == null)
                    {
                        throw new InvalidPacketValueException();
                    }

                    if (sourceResidence != null)
                    {
                        // current plot reservation must be temporary to reserve a new plot
                        if (!sourceResidence.IsTemporary)
                        {
                            throw new InvalidPacketValueException();
                        }

                        // for residences on a community just remove the residence
                        // any players on the map at the time can stay in the instance
                        if (residence.Map != null)
                        {
                            residence.Map.RemoveChild(residence);
                        }
                        else
                        {
                            residence.Parent.RemoveChild(residence);
                        }

                        player.Rotation = entrance.Rotation.ToEulerDegrees();
                        player.TeleportTo(entrance.Entry, entrance.Position, Residence.Id);
                    }
                    else
                    {
                        // move owner to new instance only if not on the same instance as the residence
                        // otherwise they will be moved to the new instance during the unload
                        if (residence.Map != player.Map)
                        {
                            player.Rotation = entrance.Rotation.ToEulerDegrees();
                            player.TeleportTo(entrance.Entry, entrance.Position, Residence.Id);
                        }

                        // for individual residences remove the entire instance
                        // move any players on the map at the time to the community
                        residence.Map?.Unload(new MapPosition
                        {
                            Info = new MapInfo
                            {
                                Entry      = entrance.Entry,
                                InstanceId = Residence.Id,
                            },
                            Position = entrance.Position
                        });
                    }

                    // update residence with new plot location and add to community
                    residence.PropertyInfoId = (PropertyInfoId)(100 + operation.Data.Int32Data);

                    if (Residence.Map != null)
                    {
                        Residence.Map.AddChild(residence, false);
                    }
                    else
                    {
                        Residence.AddChild(residence, false);
                    }
                }
                else
                {
                    // can only remove reservation if one already exists
                    if (targetResidence != sourceResidence)
                    {
                        throw new InvalidPacketValueException();
                    }

                    targetResidence.IsTemporary = false;
                }
            }
            else
            {
                // can only remove reservation if one already exists
                if (sourceResidence == null)
                {
                    throw new InvalidPacketValueException();
                }

                // removing the reservation does not remove the plot only removes the permanent status
                sourceResidence.IsTemporary = true;
            }

            member.CommunityPlotReservation = operation.Data.Int32Data;
            AnnounceGuildMemberChange(member);

            return(new GuildResultInfo(GuildResult.Success));
        }