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

Source Code for Module horizons.ai.aiplayer.constants

  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 typing import Dict 
 23   
 24  from horizons.constants import BUILDINGS 
25 26 27 -class BUILD_RESULT:
28 OK = 0 29 NEED_RESOURCES = 1 30 IMPOSSIBLE = 2 31 UNKNOWN_ERROR = 3 32 ALL_BUILT = 4 33 NEED_PARENT_FIRST = 5 34 SKIP = 6 35 OUT_OF_SETTLEMENT = 7
36
37 38 -class GOAL_RESULT:
39 SKIP = 0 # just execute the next goal 40 BLOCK_SETTLEMENT_RESOURCE_USAGE = 1 # don't execute any goal that uses resources in this settlement 41 BLOCK_ALL_BUILDING_ACTIONS = 2 # no more building during this tick
42
43 44 -class BUILDING_PURPOSE:
45 NONE = 1 46 RESERVED = 2 47 WAREHOUSE = 3 48 ROAD = 4 49 FISHER = 5 50 LUMBERJACK = 6 51 TREE = 7 52 STORAGE = 8 53 FARM = 9 54 POTATO_FIELD = 10 55 CLAY_PIT = 11 56 BRICKYARD = 12 57 PASTURE = 13 58 WEAVER = 14 59 SUGARCANE_FIELD = 15 60 DISTILLERY = 16 61 MAIN_SQUARE = 17 62 RESIDENCE = 18 63 PAVILION = 19 64 VILLAGE_SCHOOL = 20 65 TAVERN = 21 66 MINE = 22 67 SMELTERY = 23 68 TOOLMAKER = 24 69 CHARCOAL_BURNER = 25 70 BOAT_BUILDER = 26 71 SIGNAL_FIRE = 27 72 TOBACCO_FIELD = 28 73 TOBACCONIST = 29 74 SALT_PONDS = 30 75 FIRE_STATION = 31 76 DOCTOR = 32 77 HERBARY = 33 78 STONE_PIT = 34 79 STONEMASON = 35 80 81 purpose_to_building = {} # type: Dict[int, int] 82 building_to_purpose = {} # type: Dict[int, int] 83 84 @classmethod
85 - def init_translation(cls):
86 cls.purpose_to_building[cls.WAREHOUSE] = BUILDINGS.WAREHOUSE 87 cls.purpose_to_building[cls.ROAD] = BUILDINGS.TRAIL 88 cls.purpose_to_building[cls.FISHER] = BUILDINGS.FISHER 89 cls.purpose_to_building[cls.LUMBERJACK] = BUILDINGS.LUMBERJACK 90 cls.purpose_to_building[cls.TREE] = BUILDINGS.TREE 91 cls.purpose_to_building[cls.STORAGE] = BUILDINGS.STORAGE 92 cls.purpose_to_building[cls.FARM] = BUILDINGS.FARM 93 cls.purpose_to_building[cls.POTATO_FIELD] = BUILDINGS.POTATO_FIELD 94 cls.purpose_to_building[cls.CLAY_PIT] = BUILDINGS.CLAY_PIT 95 cls.purpose_to_building[cls.BRICKYARD] = BUILDINGS.BRICKYARD 96 cls.purpose_to_building[cls.PASTURE] = BUILDINGS.PASTURE 97 cls.purpose_to_building[cls.WEAVER] = BUILDINGS.WEAVER 98 cls.purpose_to_building[cls.SUGARCANE_FIELD] = BUILDINGS.SUGARCANE_FIELD 99 cls.purpose_to_building[cls.DISTILLERY] = BUILDINGS.DISTILLERY 100 cls.purpose_to_building[cls.MAIN_SQUARE] = BUILDINGS.MAIN_SQUARE 101 cls.purpose_to_building[cls.RESIDENCE] = BUILDINGS.RESIDENTIAL 102 cls.purpose_to_building[cls.PAVILION] = BUILDINGS.PAVILION 103 cls.purpose_to_building[cls.VILLAGE_SCHOOL] = BUILDINGS.VILLAGE_SCHOOL 104 cls.purpose_to_building[cls.TAVERN] = BUILDINGS.TAVERN 105 cls.purpose_to_building[cls.MINE] = BUILDINGS.MINE 106 cls.purpose_to_building[cls.SMELTERY] = BUILDINGS.SMELTERY 107 cls.purpose_to_building[cls.TOOLMAKER] = BUILDINGS.TOOLMAKER 108 cls.purpose_to_building[cls.CHARCOAL_BURNER] = BUILDINGS.CHARCOAL_BURNER 109 cls.purpose_to_building[cls.BOAT_BUILDER] = BUILDINGS.BOAT_BUILDER 110 cls.purpose_to_building[cls.SIGNAL_FIRE] = BUILDINGS.SIGNAL_FIRE 111 cls.purpose_to_building[cls.TOBACCO_FIELD] = BUILDINGS.TOBACCO_FIELD 112 cls.purpose_to_building[cls.TOBACCONIST] = BUILDINGS.TOBACCONIST 113 cls.purpose_to_building[cls.SALT_PONDS] = BUILDINGS.SALT_PONDS 114 cls.purpose_to_building[cls.FIRE_STATION] = BUILDINGS.FIRE_STATION 115 cls.purpose_to_building[cls.DOCTOR] = BUILDINGS.DOCTOR 116 cls.purpose_to_building[cls.HERBARY] = BUILDINGS.HERBARY 117 cls.purpose_to_building[cls.STONE_PIT] = BUILDINGS.STONE_PIT 118 cls.purpose_to_building[cls.STONEMASON] = BUILDINGS.STONEMASON 119 120 for purpose, building_id in cls.purpose_to_building.items(): 121 cls.building_to_purpose[building_id] = purpose
122 123 @classmethod
124 - def get_building(cls, purpose):
125 return cls.purpose_to_building[purpose]
126 127 @classmethod
128 - def get_purpose(cls, building_id):
129 return cls.purpose_to_building[building_id]
130 131 132 BUILDING_PURPOSE.init_translation() 133