/// <summary> /// Adds an enemy guild. /// </summary> /// <param name="guild">The guild to add as an enemy.</param> /// <returns>True if the enemy was added.</returns> public bool AddEnemy(Guild guild) { if (_enemies.Count >= 5) { return(false); } var association = new Database.Models.DbGuildAssociation { GuildId = Guild.Id, AssociationGuildId = guild.Id, AssociationType = "Enemy" }; if (association.Create() && _enemies.TryAdd(guild.Id, guild)) { var enemyPacket = new Models.Packets.Guilds.GuildPacket { Data = (uint)guild.Id, Action = Enums.GuildAction.SetEnemy }; SendMessageFormat("NEW_ENEMY", Enums.GuildMessageType.Red, guild.DbGuild.Name); foreach (var member in GetMembers()) { if (member.Online) { member.Player.ClientSocket.Send(enemyPacket); } } } return(true); }
/// <summary> /// Adds an allie to the guild. /// </summary> /// <param name="guild">The guild to allie.</param> /// <param name="isAllie">A boolean determining whether the guild is an allie.</param> /// <returns>True if the allie was added.</returns> public bool AddAllie(Guild guild, bool isAllie = false) { if (_allies.Count >= 5) { return(false); } var association = new Database.Models.DbGuildAssociation { GuildId = Guild.Id, AssociationGuildId = guild.Id, AssociationType = "Allie" }; if (!isAllie && guild.AddAllie(Guild, true) && association.Create() && _allies.TryAdd(guild.Id, guild) || isAllie && association.Create() && _allies.TryAdd(guild.Id, guild)) { var alliePacket = new Models.Packets.Guilds.GuildPacket { Data = (uint)guild.Id, Action = Enums.GuildAction.SetAlly }; SendMessageFormat("NEW_ALLIE", Enums.GuildMessageType.Green, guild.DbGuild.Name); foreach (var member in GetMembers()) { if (member.Online) { member.Player.ClientSocket.Send(alliePacket); } } } return(true); }