public static IContentReviewer CreateReviewer(ZoneResourceType type) { switch (type) { case ZoneResourceType.Maps: return(new MapContentReviewer()); case ZoneResourceType.RDungeons: return(new RDungeonContentReviewer()); case ZoneResourceType.NPCs: return(new NPCContentReviewer()); default: return(null); } }
public async Task AddAsync(int id, ZoneResourceType resource, int amount) { if (!ZoneManager.Zones.Zones.ContainsKey(id)) { await Context.Channel.SendMessageAsync("Invalid zone id specified."); return; } var addedResources = ZoneManager.AddResources(id, resource, amount); var responseBuilder = new StringBuilder(); responseBuilder.AppendLine("New resources have been added:"); responseBuilder.AppendLine(); var resourceListing = GenerateResourceListing(addedResources); responseBuilder.Append(resourceListing); await Context.Channel.SendMessageAsync(responseBuilder.ToString()); }
public static List <ZoneResource> AddResources(int id, ZoneResourceType resourceType, int amount) { var results = new List <ZoneResource>(); if (!ZoneManager.Zones.Zones.ContainsKey(id)) { return(results); } switch (resourceType) { case ZoneResourceType.Dungeons: { var addedCount = 0; for (var i = 0; i < Dungeons.DungeonManager.Dungeons.Count; i++) { var resource = Dungeons.DungeonManager.Dungeons[i]; if (resource.ZoneID == 0) { resource.ZoneID = id; Dungeons.DungeonManager.SaveDungeon(i); results.Add(new ZoneResource() { Num = i, Name = resource.Name, Type = resourceType }); addedCount++; } if (addedCount == amount) { break; } } } break; case ZoneResourceType.Items: { var addedCount = 0; for (var i = 0; i < Items.ItemManager.Items.MaxItems; i++) { var resource = Items.ItemManager.Items[i]; if (resource.ZoneID == 0) { resource.ZoneID = id; Items.ItemManager.SaveItem(i); results.Add(new ZoneResource() { Num = i, Name = resource.Name, Type = resourceType }); addedCount++; } if (addedCount == amount) { break; } } } break; case ZoneResourceType.NPCs: { var addedCount = 0; for (var i = 1; i < Npcs.NpcManager.Npcs.MaxNpcs; i++) { var resource = Npcs.NpcManager.Npcs[i]; if (resource.ZoneID == 0) { resource.ZoneID = id; Npcs.NpcManager.SaveNpc(i); results.Add(new ZoneResource() { Num = i, Name = resource.Name, Type = resourceType }); addedCount++; } if (addedCount == amount) { break; } } } break; case ZoneResourceType.RDungeons: { var addedCount = 0; for (var i = 0; i < RDungeons.RDungeonManager.RDungeons.Count; i++) { var resource = RDungeons.RDungeonManager.RDungeons[i]; if (resource.ZoneID == 0) { resource.ZoneID = id; RDungeons.RDungeonManager.SaveRDungeon(i); results.Add(new ZoneResource() { Num = i, Name = resource.DungeonName, Type = resourceType }); addedCount++; } if (addedCount == amount) { break; } } } break; case ZoneResourceType.Shops: { var addedCount = 0; for (var i = 1; i < Shops.ShopManager.Shops.MaxShops; i++) { var resource = Shops.ShopManager.Shops[i]; if (resource.ZoneID == 0) { resource.ZoneID = id; Shops.ShopManager.SaveShop(i); results.Add(new ZoneResource() { Num = i, Name = resource.Name, Type = resourceType }); addedCount++; } if (addedCount == amount) { break; } } } break; case ZoneResourceType.Stories: { var addedCount = 0; for (var i = 1; i < Stories.StoryManager.Stories.MaxStories; i++) { var resource = Stories.StoryManager.Stories[i]; if (resource.ZoneID == 0) { resource.ZoneID = id; Stories.StoryManager.SaveStory(i); results.Add(new ZoneResource() { Num = i, Name = resource.Name, Type = resourceType }); addedCount++; } if (addedCount == amount) { break; } } } break; case ZoneResourceType.Maps: { using (var dbConnection = new DatabaseConnection(DatabaseID.Data)) { var pendingZonedMaps = Maps.MapManager.LoadPendingZonedMaps(dbConnection.Database, amount); foreach (var pendingZonedMap in pendingZonedMaps) { var map = Maps.MapManager.RetrieveMap(pendingZonedMap); map.ZoneID = id; if (map.MapType != Enums.MapType.Standard) { throw new NotSupportedException("Invalid map type."); } Maps.MapManager.SaveStandardMap(dbConnection, map.MapID, (Maps.Map)map); results.Add(new ZoneResource() { Num = map.MapID.Trim('s').ToInt(), Name = map.Name, Type = resourceType }); } } } break; } return(results); }