Loading

Paste #pmbcr4rmo

  1. class IndustryLocationChecks(object):
  2.     """class to hold location checks for an industry"""
  3.     def __init__(self, **kwargs):
  4.         self.incompatible = kwargs.get('incompatible', {})
  5.  
  6.     def get_render_tree(self, switch_prefix):
  7.         result = []
  8.         for industry_type, distance in self.incompatible.items():
  9.             result.append(LocationCheckIncompatible(industry_type, distance))
  10.  
  11.         prev = None
  12.         for lc in reversed(result):
  13.             if prev is not None:
  14.                 lc.switch_result = prev.industry_type
  15.             prev = lc
  16.  
  17.         return result
  18.  
  19.  
  20.  
  21. class LocationCheckIncompatible(object):
  22.     def __init__(self, industry_type, distance):
  23.         self.industry_type = industry_type
  24.         self.distance = distance
  25.         self.switch_result = 'CB_RESULT_LOCATION_ALLOW' # default result, value may also be id for next switch

Version history

Revision # Author Created at
pnduplzx4 Anonymous 04 Feb 2015, 20:06:48 UTC Diff

Comments