1 # ###################################################
2 # Copyright (C) 2008 The OpenAnno Team
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
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
):
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
):
50 class Fisher(Selectable
, PrimaryProducer
, BuildableSingle
, Building
):
53 game
.main
.session
.ingame_gui
.show_menu(TabWidget(4, self
))
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]) ]:
61 tile
= island
.get_tile(Point(xx
,yy
))
62 classes
= tile
.__class
__.classes
64 if 'coastline' in classes
:
65 coast_tile_found
= True
66 elif 'constructible' not in classes
:
69 return {} if coast_tile_found
else None
71 class Church(Selectable
, PrimaryProducer
, BuildableSingle
, Building
):