Esempio n. 1
0
func GetZoneByName(name string) types.Zone {
	for _, id := range db.Find(types.ZoneType, bson.M{"name": utils.FormatName(name)}) {
		return GetZone(id)
	}

	return nil
}
Esempio n. 2
0
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
}
Esempio n. 3
0
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
}
Esempio n. 4
0
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
}
Esempio n. 5
0
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

}
Esempio n. 6
0
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
}
Esempio n. 7
0
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
}
Esempio n. 8
0
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
}
Esempio n. 9
0
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
}
Esempio n. 10
0
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
}
Esempio n. 11
0
func CountItemsIn(containerId types.Id) int {
	return len(db.Find(types.ItemType, bson.M{"containerid": containerId}))
}