コード例 #1
0
ファイル: AvatarEntry.cs プロジェクト: NotHuza/Cerberus-v4
        /// <summary>
        ///     Sets the data.
        /// </summary>
        public void SetData(LogicClientAvatar avatar)
        {
            this._avatarId        = avatar.GetId();
            this._homeId          = avatar.GetCurrentHomeId();
            this._avatarName      = avatar.GetName();
            this._facebookId      = avatar.GetFacebookId();
            this._expLevel        = avatar.GetExpLevel();
            this._leagueType      = avatar.GetLeagueType();
            this._nameChangeState = avatar.GetNameChangeState();
            this._nameSetByUser   = avatar.GetNameSetByUser();

            if (avatar.IsInAlliance())
            {
                this._allianceId       = avatar.GetAllianceId();
                this._allianceName     = avatar.GetAllianceName();
                this._allianceExpLevel = avatar.GetAllianceExpLevel();
                this._allianceRole     = avatar.GetAllianceRole();
                this._badgeId          = avatar.GetAllianceBadge();
            }
        }
コード例 #2
0
        private void OnChangeAvatarNameMessageReceived(ChangeAvatarNameMessage message)
        {
            if (message.GetNameSetByUser())
            {
                string name = message.RemoveAvatarName();

                if (name == null)
                {
                    return;
                }

                name = StringUtil.RemoveMultipleSpaces(name.Trim());

                if (name.Length < 2)
                {
                    AvatarNameChangeFailedMessage avatarNameChangeFailedMessage = new AvatarNameChangeFailedMessage();
                    avatarNameChangeFailedMessage.SetErrorCode(AvatarNameChangeFailedMessage.ErrorCode.TOO_SHORT);
                    this.m_session.SendPiranhaMessage(avatarNameChangeFailedMessage, 1);
                    return;
                }

                if (name.Length > 16)
                {
                    AvatarNameChangeFailedMessage avatarNameChangeFailedMessage = new AvatarNameChangeFailedMessage();
                    avatarNameChangeFailedMessage.SetErrorCode(AvatarNameChangeFailedMessage.ErrorCode.TOO_LONG);
                    this.m_session.SendPiranhaMessage(avatarNameChangeFailedMessage, 1);
                    return;
                }

                if (WordCensorUtil.IsValidMessage(name))
                {
                    LogicClientAvatar logicClientAvatar = this.m_session.GameAvatar.LogicClientAvatar;

                    if (logicClientAvatar.GetNameChangeState() >= 1)
                    {
                        AvatarNameChangeFailedMessage avatarNameChangeFailedMessage = new AvatarNameChangeFailedMessage();
                        avatarNameChangeFailedMessage.SetErrorCode(AvatarNameChangeFailedMessage.ErrorCode.ALREADY_CHANGED);
                        this.m_session.SendPiranhaMessage(avatarNameChangeFailedMessage, 1);
                        return;
                    }

                    if (logicClientAvatar.GetNameChangeState() == 0 && logicClientAvatar.GetTownHallLevel() < LogicDataTables.GetGlobals().GetEnableNameChangeTownHallLevel())
                    {
                        AvatarNameChangeFailedMessage avatarNameChangeFailedMessage = new AvatarNameChangeFailedMessage();
                        avatarNameChangeFailedMessage.SetErrorCode(AvatarNameChangeFailedMessage.ErrorCode.TH_LEVEL_TOO_LOW);
                        this.m_session.SendPiranhaMessage(avatarNameChangeFailedMessage, 1);
                        return;
                    }

                    LogicChangeAvatarNameCommand serverCommand = new LogicChangeAvatarNameCommand();

                    serverCommand.SetAvatarName(name);
                    serverCommand.SetAvatarNameChangeState(logicClientAvatar.GetNameChangeState() + 1);

                    this.m_session.GameAvatar.LogicClientAvatar.SetName(name);
                    this.m_session.GameAvatar.LogicClientAvatar.SetNameChangeState(logicClientAvatar.GetNameChangeState() + 1);
                    this.m_session.GameAvatar.AddServerCommand(serverCommand);
                }
                else
                {
                    AvatarNameChangeFailedMessage avatarNameChangeFailedMessage = new AvatarNameChangeFailedMessage();
                    avatarNameChangeFailedMessage.SetErrorCode(AvatarNameChangeFailedMessage.ErrorCode.BAD_WORD);
                    this.m_session.SendPiranhaMessage(avatarNameChangeFailedMessage, 1);
                }
            }
        }
コード例 #3
0
        private void OnAvatarNameCheckRequestMessageReceived(AvatarNameCheckRequestMessage message)
        {
            string name = message.GetName();

            if (name == null)
            {
                return;
            }

            name = StringUtil.RemoveMultipleSpaces(name.Trim());

            if (name.Length < 2)
            {
                AvatarNameCheckResponseMessage avatarNameCheckResponseMessage = new AvatarNameCheckResponseMessage();

                avatarNameCheckResponseMessage.SetName(message.GetName());
                avatarNameCheckResponseMessage.SetInvalid(true);
                avatarNameCheckResponseMessage.SetErrorCode(AvatarNameCheckResponseMessage.ErrorCode.NAME_TOO_SHORT);

                this.m_session.SendPiranhaMessage(avatarNameCheckResponseMessage, 1);
                return;
            }

            if (name.Length > 16)
            {
                AvatarNameCheckResponseMessage avatarNameCheckResponseMessage = new AvatarNameCheckResponseMessage();

                avatarNameCheckResponseMessage.SetName(message.GetName());
                avatarNameCheckResponseMessage.SetInvalid(true);
                avatarNameCheckResponseMessage.SetErrorCode(AvatarNameCheckResponseMessage.ErrorCode.NAME_TOO_LONG);

                this.m_session.SendPiranhaMessage(avatarNameCheckResponseMessage, 1);
                return;
            }

            if (WordCensorUtil.IsValidMessage(name))
            {
                LogicClientAvatar logicClientAvatar = this.m_session.GameAvatar.LogicClientAvatar;

                if (logicClientAvatar.GetNameChangeState() >= 1)
                {
                    AvatarNameCheckResponseMessage avatarNameCheckResponseMessage = new AvatarNameCheckResponseMessage();

                    avatarNameCheckResponseMessage.SetName(message.GetName());
                    avatarNameCheckResponseMessage.SetInvalid(true);
                    avatarNameCheckResponseMessage.SetErrorCode(AvatarNameCheckResponseMessage.ErrorCode.NAME_ALREADY_CHANGED);

                    this.m_session.SendPiranhaMessage(avatarNameCheckResponseMessage, 1);
                    return;
                }

                if (logicClientAvatar.GetNameChangeState() == 0 && logicClientAvatar.GetTownHallLevel() < LogicDataTables.GetGlobals().GetEnableNameChangeTownHallLevel())
                {
                    AvatarNameCheckResponseMessage avatarNameCheckResponseMessage = new AvatarNameCheckResponseMessage();

                    avatarNameCheckResponseMessage.SetName(message.GetName());
                    avatarNameCheckResponseMessage.SetInvalid(true);
                    avatarNameCheckResponseMessage.SetErrorCode(AvatarNameCheckResponseMessage.ErrorCode.NAME_TH_LEVEL_TOO_LOW);

                    this.m_session.SendPiranhaMessage(avatarNameCheckResponseMessage, 1);
                }
                else
                {
                    AvatarNameCheckResponseMessage avatarNameCheckResponseMessage = new AvatarNameCheckResponseMessage();
                    avatarNameCheckResponseMessage.SetName(message.GetName());
                    this.m_session.SendPiranhaMessage(avatarNameCheckResponseMessage, 1);
                }
            }
            else
            {
                AvatarNameCheckResponseMessage avatarNameCheckResponseMessage = new AvatarNameCheckResponseMessage();

                avatarNameCheckResponseMessage.SetName(message.GetName());
                avatarNameCheckResponseMessage.SetInvalid(true);
                avatarNameCheckResponseMessage.SetErrorCode(AvatarNameCheckResponseMessage.ErrorCode.INVALID_NAME);

                this.m_session.SendPiranhaMessage(avatarNameCheckResponseMessage, 1);
            }
        }