Imported Upstream version 2008.1+svn1656
[opeanno-debian-packaging.git] / game / entities.py
blob923194b2231be4eba9e2866550e38bddc0c01efd
1 # ###################################################
2 # Copyright (C) 2008 The OpenAnno Team
3 # team@openanno.org
4 # This file is part of OpenAnno.
6 # OpenAnno is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the
18 # Free Software Foundation, Inc.,
19 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 # ###################################################
22 from game.world.building import BuildingClass
23 from game.world.units import UnitClass
24 from game.world.ground import GroundClass
25 import game.main
26 from game.util import livingObject
28 class Entities(livingObject):
29 """Class that stores all the special classes for buildings, grounds etc. Stores class objects, not instances.
30 Loads everything from the db"""
31 def begin(self):
32 super(Entities, self).begin()
34 self.grounds = {}
35 for (ground_id,) in game.main.db("SELECT rowid FROM data.ground"):
36 self.grounds[ground_id] = GroundClass(ground_id)
38 self.buildings = {}
39 for (building_id,) in game.main.db("SELECT rowid FROM data.building"):
40 self.buildings[building_id] = BuildingClass(building_id)
42 self.units = {}
43 for (unit_id,) in game.main.db("SELECT rowid FROM data.unit"):
44 self.units[unit_id] = UnitClass(unit_id)