Exemplo n.º 1
0
        /// <summary>
        /// Creates a new <see cref="Structures.Guild"/> from the <paramref name="info"/> provided.
        /// </summary>
        /// <returns>The id of the new guild</returns>
        public static uint CreateGuild(Structures.CreateGuildInfo info)
        {
            var dbGuild = new DbGuild
            {
                Name       = info.Name,
                Announce   = string.Empty,
                LeaderId   = info.LeaderId,
                LeaderName = info.LeaderName,
                Money      = info.Money
            };

            try
            {
                ServerDatabase.Context.Guilds.Add(dbGuild);
            }
            catch (Exception)
            {
                return(0);
            }
            info.GuildId = dbGuild.Id;

            if (GetGuild(info.GuildId) != null)
            {
                return(info.GuildId);
            }

            var guild = new Structures.Guild();

            if (guild.Create(info, true))
            {
                _guilds.Add(guild.Id, guild);

                var leader = PlayerManager.GetUser(info.LeaderId);
                if (leader != null)
                {
                    leader.GuildAttribute.Rank = GuildRank.GuildLeader;
                }
            }

            return(dbGuild.Id);
        }
Exemplo n.º 2
0
        public static bool Initialize()
        {
            var results = ServerDatabase.Context.Guilds.GetAll();

            foreach (var res in results)
            {
                var guild = new Structures.Guild();
                if (guild.Create(res))
                {
                    _guilds.Add(guild.Id, guild);
                }
            }

            var winnerID = ServerDatabase.Context.Events.GetWinner();

            if (winnerID != null)
            {
                GuildWar.CurrentWinner = GuildManager.GetGuild(winnerID.WinnerID);
            }

            return(true);
        }