func GetZoneByName(name string) types.Zone { for _, id := range db.Find(types.ZoneType, bson.M{"name": utils.FormatName(name)}) { return GetZone(id) } return nil }
func GetSpawnerNpcs(spawnerId types.Id) types.NPCList { ids := db.Find(types.NpcType, bson.M{"spawnerid": spawnerId}) npcs := make(types.NPCList, len(ids)) for i, id := range ids { npcs[i] = GetNpc(id) } return npcs }
func GetAreaSpawners(areaId types.Id) types.SpawnerList { ids := db.Find(types.SpawnerType, bson.M{"areaid": areaId}) spawners := make(types.SpawnerList, len(ids)) for i, id := range ids { spawners[i] = GetSpawner(id) } return spawners }
func GetTemplateItems(templateId types.Id) types.ItemList { ids := db.Find(types.ItemType, bson.M{"templateid": templateId}) items := make(types.ItemList, len(ids)) for i, id := range ids { items[i] = db.Retrieve(id, types.ItemType).(types.Item) } return items }
func GetAreaRooms(areaId types.Id) types.RoomList { ids := db.Find(types.RoomType, bson.M{"areaid": areaId}) rooms := make(types.RoomList, len(ids)) for i, id := range ids { rooms[i] = GetRoom(id) } return rooms }
func ItemsIn(containerId types.Id) types.ItemList { ids := db.Find(types.ItemType, bson.M{"containerid": containerId}) items := make(types.ItemList, len(ids)) for i, id := range ids { items[i] = GetItem(id) } return items }
func NpcsIn(roomId types.Id) types.NPCList { ids := db.Find(types.NpcType, bson.M{"roomid": roomId}) npcs := make(types.NPCList, len(ids)) for i, id := range ids { npcs[i] = GetNpc(id) } return npcs }
func GetUserCharacters(userId types.Id) types.PCList { ids := db.Find(types.PcType, bson.M{"userid": userId}) pcs := make(types.PCList, len(ids)) for i, id := range ids { pcs[i] = GetPlayerCharacter(id) } return pcs }
func GetRoomsInZone(zoneId types.Id) types.RoomList { zone := GetZone(zoneId) ids := db.Find(types.RoomType, bson.M{"zoneid": zone.GetId()}) rooms := make(types.RoomList, len(ids)) for i, id := range ids { rooms[i] = GetRoom(id) } return rooms }
func PlayerCharactersIn(roomId types.Id, except types.Id) types.PCList { ids := db.Find(types.PcType, bson.M{"roomid": roomId}) var pcs types.PCList for _, id := range ids { pc := GetPlayerCharacter(id) if pc.IsOnline() && id != except { pcs = append(pcs, pc) } } return pcs }
func CountItemsIn(containerId types.Id) int { return len(db.Find(types.ItemType, bson.M{"containerid": containerId})) }