Exemple #1
0
        public bool Create()
        {
            if (_data != null)
            {
                return(false);
            }
            if (_client == null)
            {
                return(false);
            }

            _data = ServerDatabase.Context.GuildAttributes.GetById(_client.UID);
            if (_data == null)
            {
                return(true);
            }

            if (GuildManager.GetGuild(GuildId) == null)
            {
                _data = null;
                return(true);
            }

            return(true);
        }
Exemple #2
0
        public bool LeaveGuild(bool deleteRecord = true, bool synchro = true)
        {
            if (_data == null)
            {
                return(false);
            }

            var oldGuildId = GuildId;

            if (deleteRecord)
            {
                ServerDatabase.Context.GuildAttributes.Remove(_data);
            }
            _data = null;

            if (synchro)
            {
                var guild = GuildManager.GetGuild(oldGuildId);
                if (guild != null && guild.Amount > 0)
                {
                    guild.Amount--;
                    guild.RemoveMemberList(_client.Name);
                }

                SynchroInfo();
            }

            return(true);
        }
Exemple #3
0
        public bool JoinGuild(uint id, GuildRank rank = GuildRank.Member, int donation = 0)
        {
            if (_data != null)
            {
                return(false);
            }

            _data = new DbGuildAttr
            {
                Id       = _client.UID,
                GuildId  = id,
                Rank     = rank,
                JoinDate = (uint)Common.Clock
            };
            ServerDatabase.Context.GuildAttributes.AddOrUpdate(_data);

            var guild = GuildManager.GetGuild(GuildId);

            if (guild != null)
            {
                guild.Amount++;
                guild.SaveInfo();
            }

            AddMemberList(id, _client.Name, Rank, _client.Level);

            SynchroInfo(true);
            if (guild != null)
            {
                guild.SendInfoToClient(_client);
            }

            return(true);
        }
Exemple #4
0
 public GuildAttr(Player client)
 {
     _client = client;
     _data   = ServerDatabase.Context.GuildAttributes.GetGuildId(_client.UID);
 }