コード例 #1
0
 private void RemoveGuildContainer(GuildContainer guildContainer)
 {
     this.guildDictionary.Remove(guildContainer.Id);
     this.guildIdMapping.Remove(guildContainer.Guild.Id);
     this.idGenerator.GiveBack((int)guildContainer.Id);
     guildContainer.DatabaseContext.Dispose();
 }
コード例 #2
0
        private GuildContainer CreateGuildContainer(Guild guild, IGuildServerContext databaseContext)
        {
            var id = (uint)this.idGenerator.GetId();

            var guildContainer = new GuildContainer(guild, id, databaseContext);

            this.guildDictionary.Add(id, guildContainer);
            this.guildIdMapping.Add(guild.Id, id);

            return(guildContainer);
        }
コード例 #3
0
        /// <inheritdoc/>
        public ushort GuildMemberEnterGame(Guid guildId, string guildMemberName, byte serverId)
        {
            GuildContainer guild = this.GetOrCreateGuildContainer(guildId);

            if (guild != null)
            {
                guild.SetServerId(guildMemberName, serverId);
                return(guild.ShortId);
            }

            return(NonGuild);
        }
コード例 #4
0
        /// <summary>
        /// Removes a guild from the server and the database.
        /// First we are trying to get the guild out of our dictionary.
        /// We are assuming that all guilds are in the dictionary, because
        /// we are holding all guilds of all ingame-characters in it.
        /// So this method is only called usefully from the gameserver itself,
        /// by player interaction.
        /// </summary>
        /// <param name="guildContainer">The container of the guild which should be deleted</param>
        private void DeleteGuild(GuildContainer guildContainer)
        {
            guildContainer.DatabaseContext.Delete(guildContainer.Guild);

            this.RemoveGuildContainer(guildContainer);

            foreach (var gameServer in this.gameServers.Values)
            {
                gameServer.GuildDeleted(guildContainer.Id);
            }

            // TODO: Inform gameServers that guildwar/hostility ended
        }
コード例 #5
0
        private GuildContainer CreateGuildContainer(Guild guild, IContext databaseContext)
        {
            if (!this.freeIds.TryDequeue(out ushort shortId))
            {
                throw new Exception("no free short id");
            }

            var guildContainer = new GuildContainer(guild, shortId, databaseContext);

            this.guildDictionary.Add(guild.Id, guildContainer);

            return(guildContainer);
        }