public GuildCreateStatus CreateGuild(string guildName, out DbGuild guild) { guild = null; if (String.IsNullOrWhiteSpace(guildName)) { return(GuildCreateStatus.InvalidName); } guildName = guildName.Trim(); int newGuildId = (int)Strings.Increment(0, "newGuildId").Exec(); if (!Hashes.SetIfNotExists(0, "guilds", guildName.ToUpperInvariant(), Convert.ToString(newGuildId)).Exec()) { return(GuildCreateStatus.UsedName); } guild = new DbGuild(this, newGuildId) { Name = guildName, Level = 0, Fame = 0, TotalFame = 0 }; guild.Flush(); return(GuildCreateStatus.OK); }
public DbGuild GetGuild(int id) { var ret = new DbGuild(this, id); if (ret.IsNull) { return(null); } return(ret); }
public bool SetGuildBoard(DbGuild guild, string text) { if (guild.IsNull) { return(false); } guild.Board = text; guild.Flush(); return(true); }
public bool ChangeGuildLevel(DbGuild guild, int level) { if (level != 1 && level != 2 && level != 3) { return(false); } guild.Level = level; guild.Flush(); return(true); }
public AddGuildMemberStatus AddGuildMember(DbGuild guild, DbAccount acc, bool founder = false) { if (acc == null) { return(AddGuildMemberStatus.Error); } if (acc.NameChosen == false) { return(AddGuildMemberStatus.NameNotChosen); } if (Convert.ToInt32(acc.GuildId) == guild.Id) { return(AddGuildMemberStatus.AlreadyInGuild); } if (Convert.ToInt32(acc.GuildId) > 0) { return(AddGuildMemberStatus.InAnotherGuild); } int guildSize = 100; if (guild.Members.Length >= guildSize) { return(AddGuildMemberStatus.GuildFull); } var members = guild.Members.ToList(); if (members.Contains(Convert.ToInt32(acc.AccountId))) { return(AddGuildMemberStatus.IsAMember); } members.Add(Convert.ToInt32(acc.AccountId)); guild.Members = members.ToArray(); guild.Flush(); acc.GuildId = Convert.ToString(guild.Id); acc.GuildRank = (founder) ? 40 : 0; acc.Flush(); return(AddGuildMemberStatus.OK); }