Example #1
0
		protected override void OnSyncGuildMemberAdded(Guild guild, GuildMember member)
		{
			// Only announce new members once they've become actual members,
			// no applicants.
			if (member.Rank > GuildMemberRank.Member)
				return;

			var user = MsgrServer.Instance.UserManager.GetUserByCharacterId(member.CharacterId);
			if (user == null)
			{
				user = MsgrServer.Instance.Database.GetUserByCharacterId(member.CharacterId);
				user.Status = ContactStatus.Offline;
			}

			ForOnlineMembers(guild, memberUser =>
			{
				if (memberUser != user)
					Send.GuildMemberState(memberUser.Client, guild, member, user, user.Status);
			});
		}
Example #2
0
		/// <summary>
		/// Broadcasts GuildUpdateMember in range of creature.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="guild"></param>
		/// <param name="member"></param>
		public static void GuildUpdateMember(Creature creature, Guild guild, GuildMember member)
		{
			var packet = new Packet(Op.GuildUpdateMember, creature.EntityId);
			packet.PutInt(guild == null ? 0 : 1);
			if (guild != null)
			{
				packet.PutString(guild.Name);
				packet.PutLong(guild.Id);
				packet.PutInt((int)member.Rank);
				packet.PutByte(0); // messages?
			}

			creature.Region.Broadcast(packet, creature);
		}
Example #3
0
 /// <summary>
 /// Called when a guild member's rank changes during synchronization.
 /// </summary>
 /// <param name="guild"></param>
 protected virtual void OnSyncGuildMemberUpdated(Guild guild, GuildMember guildMember)
 {
 }
Example #4
0
 /// <summary>
 /// Called when a guild member is declined from a guild during
 /// synchronization.
 /// </summary>
 /// <param name="guild"></param>
 protected virtual void OnSyncGuildMemberDeclined(Guild guild, GuildMember guildMember)
 {
 }
Example #5
0
 /// <summary>
 /// Called when a guild member is accepted into a guild during
 /// synchronization.
 /// </summary>
 /// <param name="guild"></param>
 protected virtual void OnSyncGuildMemberAccepted(Guild guild, GuildMember guildMember)
 {
 }
Example #6
0
 /// <summary>
 /// Called when a guild member is removed from a guild during
 /// synchronization.
 /// </summary>
 /// <param name="guild"></param>
 protected virtual void OnSyncGuildMemberRemoved(Guild guild, GuildMember guildMember)
 {
 }
Example #7
0
		protected override void OnSyncGuildMemberDeclined(Guild guild, GuildMember member)
		{
			this.OnSyncGuildMemberRemoved(guild, member);
		}
		/// <summary>
		/// Called when a guild member is declined from a guild during
		/// synchronization.
		/// </summary>
		/// <param name="guild"></param>
		protected virtual void OnSyncGuildMemberDeclined(Guild guild, GuildMember guildMember)
		{
		}
Example #9
0
		/// <summary>
		/// Adds creature to the guild as applicant.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="guild"></param>
		public void Apply(Creature creature, Guild guild, string application)
		{
			if (guild.HasMember(creature.EntityId))
				throw new ArgumentException("Character is already a member of this guild. (" + creature.Name + ", " + guild.Name + ")");

			var member = new GuildMember();
			member.GuildId = guild.Id;
			member.CharacterId = creature.EntityId;
			member.Rank = GuildMemberRank.Applied;
			member.JoinedDate = DateTime.Now;
			member.Application = application;

			creature.Guild = guild;
			creature.GuildMember = member;

			guild.AddMember(member);

			ChannelServer.Instance.Database.AddGuildMember(member);
		}
Example #10
0
		/// <summary>
		/// Called when a member's rank changed during synchronization.
		/// </summary>
		/// <remarks>
		/// For example, when the leader changed their rank.
		/// </remarks>
		/// <param name="guild"></param>
		/// <param name="member"></param>
		protected override void OnSyncGuildMemberUpdated(Guild guild, GuildMember member)
		{
			var creature = ChannelServer.Instance.World.GetCreature(member.CharacterId);
			if (creature != null)
				Send.GuildUpdateMember(creature, guild, member);
		}
Example #11
0
		/// <summary>
		/// Called when a member's rank changes from Applied to Declined
		/// during synchronization.
		/// </summary>
		/// <param name="guild"></param>
		/// <param name="member"></param>
		protected override void OnSyncGuildMemberDeclined(Guild guild, GuildMember member)
		{
			ChannelServer.Instance.Database.RemoveGuildMember(member);

			var creature = ChannelServer.Instance.World.GetCreature(member.CharacterId);
			if (creature != null)
			{
				creature.Guild = null;
				creature.GuildMember = null;
				Send.GuildUpdateMember(creature, null, null);
				Send.GuildMessage(creature, guild, guild.RejectionMessage, guild.Name);
			}
		}
Example #12
0
		/// <summary>
		/// Called when a member's rank changes from Applied to !Declined
		/// during synchronization.
		/// </summary>
		/// <param name="guild"></param>
		/// <param name="member"></param>
		protected override void OnSyncGuildMemberAccepted(Guild guild, GuildMember member)
		{
			this.OnSyncGuildMemberAdded(guild, member);
		}
Example #13
0
		/// <summary>
		/// Called when a guild member is added during synchronization.
		/// </summary>
		/// <remarks>
		/// Shouldn't happen during normal game-play, as the member is added
		/// to the guild when they apply.
		/// </remarks>
		/// <param name="guild"></param>
		/// <param name="member"></param>
		protected override void OnSyncGuildMemberAdded(Guild guild, GuildMember member)
		{
			var creature = ChannelServer.Instance.World.GetCreature(member.CharacterId);
			if (creature != null)
			{
				creature.Guild = guild;
				creature.GuildMember = member;
				Send.GuildUpdateMember(creature, guild, member);
				Send.GuildMessage(creature, guild, guild.WelcomeMessage, guild.Name);
			}
		}
Example #14
0
		/// <summary>
		/// Called when a guild member is removed from a guild during
		/// synchronization.
		/// </summary>
		/// <param name="guild"></param>
		protected virtual void OnSyncGuildMemberRemoved(Guild guild, GuildMember guildMember)
		{
		}
Example #15
0
		/// <summary>
		/// Creates new guild with the members from the party.
		/// </summary>
		/// <param name="party"></param>
		/// <exception cref="ArgumentException">
		/// Thrown if one of the party members already is in a guild.
		/// </exception>
		public void CreateGuild(Party party, string name, GuildType type, GuildVisibility visibility)
		{
			var partyMembers = party.GetMembers();
			if (partyMembers.Any(a => a.GuildId != 0))
				throw new ArgumentException("One of the party members is in a guild already.");

			var leader = party.Leader;

			lock (_syncLock)
			{
				// Add guild
				var guild = new Guild();
				guild.Name = name;
				guild.LeaderName = leader.Name;
				guild.Title = "";
				guild.EstablishedDate = DateTime.Now;
				guild.Server = ChannelServer.Instance.Conf.Channel.ChannelServer;
				guild.Type = type;
				guild.Visibility = visibility;
				guild.IntroMessage = string.Format(Localization.Get("Guild stone for the {0} guild."), guild.Name);
				guild.WelcomeMessage = string.Format(Localization.Get("Welcome to the {0} guild!"), guild.Name);
				guild.LeavingMessage = string.Format(Localization.Get("You have left the {0} guild."), guild.Name);
				guild.RejectionMessage = string.Format(Localization.Get("You have been denied admission to the {0} guild."), guild.Name);

				ChannelServer.Instance.Database.AddGuild(guild);
				this.LoadGuild(guild);

				// Add members
				foreach (var creature in partyMembers)
				{
					var guildMember = new GuildMember();
					guildMember.GuildId = guild.Id;
					guildMember.CharacterId = creature.EntityId;
					guildMember.JoinedDate = DateTime.Now;
					guildMember.Application = "";
					if (creature != leader)
						guildMember.Rank = GuildMemberRank.Member;

					ChannelServer.Instance.Database.AddGuildMember(guildMember);
					guild.AddMember(guildMember);

					creature.Guild = guild;
					creature.GuildMember = guildMember;
					Send.GuildUpdateMember(creature, guild, guildMember);
				}
			}
		}
Example #16
0
		/// <summary>
		/// Called when a guild member is accepted into a guild during
		/// synchronization.
		/// </summary>
		/// <param name="guild"></param>
		protected virtual void OnSyncGuildMemberAccepted(Guild guild, GuildMember guildMember)
		{
		}
Example #17
0
		/// <summary>
		/// Sends GuildMemberState to client.
		/// </summary>
		/// <param name="client"></param>
		/// <param name="guild"></param>
		/// <param name="member"></param>
		/// <param name="user"></param>
		/// <param name="status"></param>
		public static void GuildMemberState(MsgrClient client, Guild guild, GuildMember member, User user, ContactStatus status)
		{
			var packet = new Packet(Op.Msgr.GuildMemberState, 0);
			packet.PutByte(true);
			packet.PutInt(user.Id);
			packet.PutByte((byte)(status == ContactStatus.Online ? ContactStatus.Online : ContactStatus.Offline));
			packet.PutString(user.ChannelName);
			packet.PutLong(user.LastLogin.Ticks);
			packet.PutInt((int)member.Rank);
			packet.PutString(user.FullName);

			client.Send(packet);
		}
Example #18
0
		/// <summary>
		/// Called when a guild member's rank changes during synchronization.
		/// </summary>
		/// <param name="guild"></param>
		protected virtual void OnSyncGuildMemberUpdated(Guild guild, GuildMember guildMember)
		{
		}
Example #19
0
		protected override void OnSyncGuildMemberRemoved(Guild guild, GuildMember member)
		{
			var user = MsgrServer.Instance.Database.GetUserByCharacterId(member.CharacterId);
			ForOnlineMembers(guild, memberUser =>
			{
				if (memberUser != user)
					Send.GuildMemberRemove(memberUser.Client, user.Id);
			});
		}