Package horizons :: Package ai :: Package aiplayer :: Package goal :: Module settlementgoal
[hide private]
[frames] | no frames]

Source Code for Module horizons.ai.aiplayer.goal.settlementgoal

 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.constants import BUILD_RESULT 
23  from horizons.ai.aiplayer.goal import Goal 
24  from horizons.component.namedcomponent import NamedComponent 
25  from horizons.constants import BUILDINGS 
26 27 28 -class SettlementGoal(Goal):
29 """ 30 An object of this class describes a goal that a settlement of an AI player attempts to fulfil. 31 """ 32
33 - def __init__(self, settlement_manager):
34 super().__init__(settlement_manager.owner) 35 self.settlement_manager = settlement_manager 36 self.land_manager = settlement_manager.land_manager 37 self.production_builder = settlement_manager.production_builder 38 self.village_builder = settlement_manager.village_builder 39 self.settlement = settlement_manager.settlement 40 self.island = settlement_manager.island 41 self.session = settlement_manager.session
42 43 @property
44 - def can_be_activated(self):
46
47 - def __str__(self):
48 return super().__str__() + ', ' + self.settlement_manager.settlement.get_component(NamedComponent).name
49
50 - def _log_generic_build_result(self, result, name):
51 if result == BUILD_RESULT.OK: 52 self.log.info('%s built a %s', self, name) 53 elif result == BUILD_RESULT.NEED_RESOURCES: 54 self.log.info('%s not enough materials to build a %s', self, name) 55 elif result == BUILD_RESULT.SKIP: 56 self.log.info('%s skipped building a %s', self, name) 57 else: 58 self.log.info('%s failed to build a %s (%d)', self, name, result)
59