Beispiel #1
0
        public async Task RemoveZoneFlag(string zoneName, params string[] flagNames)
        {
            IZone zone = await this.GetZoneOrReplyAsync(zoneName);

            if (zone.IsValid())
            {
                ZoneFlags parsedFlags = ParseZoneFlags(flagNames);

                IEnumerable <string> parsedFlagNames = Enum.GetValues(typeof(ZoneFlags)).Cast <ZoneFlags>()
                                                       .Where(value => value != ZoneFlags.None)
                                                       .Where(value => parsedFlags.HasFlag(value))
                                                       .Select(flag => flag.ToString());

                if (parsedFlags == ZoneFlags.None)
                {
                    await ReplyErrorAsync("No valid flags were specified.");
                }
                else
                {
                    zone.Flags &= ~parsedFlags;

                    await Db.UpdateZoneAsync(zone);

                    await ReplySuccessAsync($"Flag(s) {StringUtilities.ConjunctiveJoin(parsedFlagNames.Select(name => name.ToBold()))} successfully unset for {zone.GetFullName().ToBold()}.");
                }
            }
        }
Beispiel #2
0
        private async Task <IEnumerable <string> > GetMissingRolesInZoneIdeasAsync()
        {
            // Checks for roles that are unfulfilled for a given zone

            List <string> ideas = new List <string>();

            string query = @"SELECT Zones.id AS zone_id1, Zones.name AS zone_name, Zones.flags AS zone_flags, Roles.id AS role_id1, Roles.name AS role_name FROM Zones, Roles WHERE
	            NOT EXISTS(SELECT * FROM SpeciesRoles WHERE role_id = role_id1 AND species_id IN (SELECT species_id FROM SpeciesZones WHERE zone_id = zone_id1));"    ;

            using (SQLiteCommand cmd = new SQLiteCommand(query)) {
                foreach (DataRow row in await Db.GetRowsAsync(cmd))
                {
                    ZoneFlags zoneFlags = ZoneFlags.None;

                    if (!row.IsNull("zone_flags"))
                    {
                        zoneFlags = (ZoneFlags)row.Field <long>("zone_flags");
                    }

                    if (!zoneFlags.HasFlag(ZoneFlags.Retired))
                    {
                        string zoneName = row.Field <string>("zone_name");
                        string roleName = row.Field <string>("role_name");

                        ideas.Add($"{ZoneUtilities.GetFullName(zoneName).ToBold()} does not have any {roleName.ToTitle().ToPlural().ToBold()}. Why not fill this role?");
                    }
                }
            }

            return(ideas.ToArray());
        }