Package horizons :: Package ai :: Package aiplayer :: Package building :: Module fakeresourcedeposit
[hide private]
[frames] | no frames]

Source Code for Module horizons.ai.aiplayer.building.fakeresourcedeposit

 1  # ################################################### 
 2  # Copyright (C) 2008-2017 The Unknown Horizons Team 
 3  # team@unknown-horizons.org 
 4  # This file is part of Unknown Horizons. 
 5  # 
 6  # Unknown Horizons 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. 
10  # 
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. 
15  # 
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  # ################################################### 
21   
22  from horizons.ai.aiplayer.building import AbstractBuilding 
23  from horizons.entities import Entities 
24  from horizons.world.production.producer import Producer 
25  from horizons.world.production.productionline import ProductionLine 
26 27 28 -class AbstractFakeResourceDeposit(AbstractBuilding):
29 - def __init__(self, building_id, name, settler_level):
30 super().__init__(building_id, name, settler_level) 31 self.lines = {} # output_resource_id: ProductionLine 32 self.__init_production_lines()
33 34 @classmethod
36 raise NotImplementedError('This function has to be overridden.')
37
38 - def __init_production_lines(self):
39 production_lines = self._get_producer_building().get_component_template(Producer)['productionlines'] 40 for key, value in production_lines.items(): 41 production_line = ProductionLine(key, value) 42 production_line.id = None 43 production_line.production = {} 44 production_line.produced_res = {} 45 for resource_id, amount in production_line.consumed_res.items(): 46 production_line.production[resource_id] = -amount 47 production_line.produced_res[resource_id] = -amount 48 production_line.consumed_res = {} 49 self.lines[list(production_line.produced_res.keys())[0]] = production_line
50
51 - def _get_producer_building(self):
53 54 @classmethod
55 - def load(cls, db, building_id):
56 # load the higher level building data because resource deposits don't actually produce anything 57 name = cls._load_name(db, building_id) 58 settler_level = cls._load_settler_level(building_id) 59 return cls(building_id, name, settler_level)
60
61 - def get_expected_cost(self, resource_id, production_needed, settlement_manager):
62 """ you don't actually build resource deposits """ 63 return 0
64 65 @property
66 - def directly_buildable(self):
67 """ You don't actually build resource deposits """ 68 return False
69 70 @property
71 - def ignore_production(self):
72 return True
73