Imported Upstream version 2008.1+svn1553
[opeanno-debian-packaging.git] / game / world / building / production.py
blobb47733ed863a14d5c5af1a9daaf8a90f74a7ec39
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 building import Building, Selectable
23 from game.world.production import SecondaryProducer, PrimaryProducer
24 from buildable import BuildableSingleWithSurrounding, BuildableSingle
25 from game.gui.tabwidget import TabWidget
26 from game.util.point import Point
27 import game.main
29 class AnimalFarm(Selectable, SecondaryProducer, BuildableSingleWithSurrounding, Building):
30 _surroundingBuildingClass = 18
31 """ This class builds pasturage in the radius automatically,
32 so that farm animals can graze there """
34 def create_carriage(self):
35 self.animals = []
36 animals = game.main.db("SELECT animal, count from data.animals where building = ?", self.id)
37 for (animal,number) in animals:
38 for i in xrange(0,number):
39 self.animals.append(game.main.session.entities.units[animal](self))
41 self.local_carriages.append(game.main.session.entities.units[7](self))
43 class Lumberjack(Selectable, SecondaryProducer, BuildableSingleWithSurrounding, Building):
44 _surroundingBuildingClass = 17
45 """Class representing a Lumberjack."""
47 class Weaver(Selectable, SecondaryProducer, BuildableSingle, Building):
48 pass
50 class Fisher(Selectable, PrimaryProducer, BuildableSingle, Building):
52 def show_menu(self):
53 game.main.session.ingame_gui.show_menu(TabWidget(4, self))
55 @classmethod
56 def isGroundBuildRequirementSatisfied(cls, x, y, island, **state):
57 #todo: check cost line
58 coast_tile_found = False
59 for xx,yy in [ (xx,yy) for xx in xrange(x, x + cls.size[0]) for yy in xrange(y, y + cls.size[1]) ]:
60 print "x y:", xx, yy
61 tile = island.get_tile(Point(xx,yy))
62 classes = tile.__class__.classes
63 print classes
64 if 'coastline' in classes:
65 coast_tile_found = True
66 elif 'constructible' not in classes:
67 return None
69 return {} if coast_tile_found else None
71 class Church(Selectable, PrimaryProducer, BuildableSingle, Building):
72 pass