示例#1
0
 def init(self):
     super(PlayerFortRequester, self).init()
     fort = getClientFort()
     if fort:
         fort.onResponseReceived += self._fort_onResponseReceived
     else:
         LOG_DEBUG('Fort is not defined')
示例#2
0
 def init(self):
     super(PlayerFortRequester, self).init()
     fort = getClientFort()
     if fort:
         fort.onResponseReceived += self._fort_onResponseReceived
     else:
         LOG_DEBUG('Fort is not defined')
示例#3
0
 def update(self, provider):
     result = False
     fort = getClientFort()
     if not fort.isEmpty() and fort.isStartingScriptDone():
         state = HasFortState()
         result = state.update(provider)
         if not result:
             result = True
             provider.changeState(state)
     return result
示例#4
0
 def isOrderValid(self, orderTypeID, count = 1, add = True):
     fort = getClientFort()
     if fort is None:
         return (False, FORT_RESTRICTION.UNKNOWN)
     order = fort.getOrder(orderTypeID)
     if order is None:
         return (False, FORT_RESTRICTION.UNKNOWN)
     if add and order.count + count > order.maxCount:
         return (False, FORT_RESTRICTION.ORDER_MAX_COUNT)
     return (True, '')
示例#5
0
 def isOrderValid(self, orderTypeID, count=1, add=True):
     fort = getClientFort()
     if fort is None:
         return (False, FORT_RESTRICTION.UNKNOWN)
     order = fort.getOrder(orderTypeID)
     if order is None:
         return (False, FORT_RESTRICTION.UNKNOWN)
     if add and order.count + count > order.maxCount:
         return (False, FORT_RESTRICTION.ORDER_MAX_COUNT)
     return (True, '')
示例#6
0
 def update(self, provider):
     result = False
     fort = getClientFort()
     if not fort.isEmpty() and fort.isStartingScriptDone():
         state = HasFortState()
         result = state.update(provider)
         if not result:
             result = True
             provider.changeState(state)
     return result
示例#7
0
 def getUIMode(self, provider, transportingProgress = None):
     fort = getClientFort()
     if not fort.getOpenedDirections() and provider.getController().getPermissions().canOpenDirection():
         return FORTIFICATION_ALIASES.MODE_DIRECTIONS
     if transportingProgress is not None:
         if fort.isTransportationAvailable():
             return transportingProgress
         else:
             return FORTIFICATION_ALIASES.MODE_TRANSPORTING_NOT_AVAILABLE
     return FORTIFICATION_ALIASES.MODE_COMMON
示例#8
0
 def canActivateOrder(self, orderID):
     fort = getClientFort()
     if fort is None:
         return (False, FORT_RESTRICTION.UNKNOWN)
     order = fort.getOrder(orderID)
     canActivate = False
     if order.hasBuilding and order.count > 0 and not order.inCooldown:
         if order.isPermanent:
             canActivate = fort.isDefenceHourEnabled()
         else:
             canActivate = order.isCompatible or not fort.hasActivatedContinualOrders()
     return (canActivate, '')
示例#9
0
 def isDirectionValid(self, direction, open = True):
     if direction < 1:
         return (False, FORT_RESTRICTION.DIRECTION_MIN_COUNT)
     if direction > fortified_regions.g_cache.maxDirections:
         return (False, FORT_RESTRICTION.DIRECTION_MAX_COUNT)
     fort = getClientFort()
     if fort is None:
         return (False, FORT_RESTRICTION.UNKNOWN)
     openedDirections = len(fort.getOpenedDirections())
     if open and self.getDirectionsMembersRequirements().get(openedDirections + 1, 0) > self.getClanMembersCount():
         return (False, FORT_RESTRICTION.DIRECTION_NOT_ENOUGH_MEMBERS)
     return (True, '')
示例#10
0
 def isDirectionValid(self, direction, open=True):
     if direction < 1:
         return (False, FORT_RESTRICTION.DIRECTION_MIN_COUNT)
     if direction > fortified_regions.g_cache.maxDirections:
         return (False, FORT_RESTRICTION.DIRECTION_MAX_COUNT)
     fort = getClientFort()
     if fort is None:
         return (False, FORT_RESTRICTION.UNKNOWN)
     openedDirections = len(fort.getOpenedDirections())
     if open and self.getDirectionsMembersRequirements().get(
             openedDirections + 1, 0) > self.getClanMembersCount():
         return (False, FORT_RESTRICTION.DIRECTION_NOT_ENOUGH_MEMBERS)
     return (True, '')
示例#11
0
 def canActivateOrder(self, orderID):
     fort = getClientFort()
     if fort is None:
         return (False, FORT_RESTRICTION.UNKNOWN)
     order = fort.getOrder(orderID)
     canActivate = False
     if order.hasBuilding and order.count > 0 and not order.inCooldown:
         if order.isPermanent:
             canActivate = fort.isDefenceHourEnabled()
         else:
             canActivate = order.isCompatible or not fort.hasActivatedContinualOrders(
             )
     return (canActivate, '')
示例#12
0
 def getUIMode(self, provider, transportingProgress = None):
     fort = getClientFort()
     if fort.state & FORT_STATE.FIRST_DIR_OPEN == 0:
         return FORTIFICATION_ALIASES.MODE_DIRECTIONS_TUTORIAL
     if fort.state & FORT_STATE.FIRST_BUILD_START == 0:
         return FORTIFICATION_ALIASES.MODE_COMMON_TUTORIAL
     if transportingProgress is not None:
         if fort.isTransportationAvailable():
             return transportingProgress
         else:
             return FORTIFICATION_ALIASES.MODE_TRANSPORTING_NOT_AVAILABLE
     elif fort.state & FORT_STATE.FIRST_BUILD_DONE == 0:
         return FORTIFICATION_ALIASES.MODE_TRANSPORTING_TUTORIAL
     return FORTIFICATION_ALIASES.MODE_COMMON
示例#13
0
 def update(self, provider):
     result = False
     state = None
     fort = getClientFort()
     if not fort.isEmpty():
         if isStartingScriptDone():
             state = HasFortState()
         elif provider.getController().getPermissions().canCreate():
             state = WizardState()
     if state:
         result = state.update(provider)
         if not result:
             result = True
             provider.changeState(state)
     return result
示例#14
0
 def update(self, provider):
     result = False
     state = None
     fort = getClientFort()
     if fort and not fort.isEmpty():
         if isStartingScriptDone():
             state = HasFortState()
         elif provider.getController().getPermissions().canCreate():
             state = WizardState()
     if state:
         result = state.update(provider)
         if not result:
             result = True
             provider.changeState(state)
     return result
示例#15
0
 def isSortieCreationValid(self, level = None):
     from gui.prb_control.dispatcher import g_prbLoader
     fort = getClientFort()
     if fort is None:
         return (False, FORT_RESTRICTION.UNKNOWN)
     if level is not None and level not in SORTIE_DIVISION._ORDER:
         return (False, FORT_RESTRICTION.SORTIE_LEVEL_INVALID)
     if not fort.isStartingScriptDone():
         return (False, FORT_RESTRICTION.STARTING_SCRIPT_NOT_DONE)
     if len(fort.sorties) >= fortified_regions.g_cache.maxSorties:
         return (False, FORT_RESTRICTION.SORTIE_MAX_COUNT)
     state = g_prbLoader.getDispatcher().getFunctionalState()
     if not state.isInUnit(PREBATTLE_TYPE.SORTIE) and state.hasModalEntity:
         return (False, FORT_RESTRICTION.SORTIE_HAS_MODAL_ENTITY)
     return (True, '')
示例#16
0
 def isSortieCreationValid(self, level=None):
     from gui.prb_control.dispatcher import g_prbLoader
     fort = getClientFort()
     if fort is None:
         return (False, FORT_RESTRICTION.UNKNOWN)
     if level is not None and level not in SORTIE_DIVISION._ORDER:
         return (False, FORT_RESTRICTION.SORTIE_LEVEL_INVALID)
     if not fort.isStartingScriptDone():
         return (False, FORT_RESTRICTION.STARTING_SCRIPT_NOT_DONE)
     if len(fort.sorties) >= fortified_regions.g_cache.maxSorties:
         return (False, FORT_RESTRICTION.SORTIE_MAX_COUNT)
     state = g_prbLoader.getDispatcher().getFunctionalState()
     if not state.isInUnit(PREBATTLE_TYPE.SORTIE) and state.hasModalEntity:
         return (False, FORT_RESTRICTION.SORTIE_HAS_MODAL_ENTITY)
     return (True, '')
示例#17
0
 def canUpgrade(self, buildingTypeID):
     fort = getClientFort()
     restrict, restricType = True, ''
     if fort is None:
         return (False, FORT_RESTRICTION.UNKNOWN)
     building = fort.getBuilding(buildingTypeID)
     if building is None:
         return (False, FORT_RESTRICTION.UNKNOWN)
     upgradeCost = building.levelRef.upgradeCost
     if not upgradeCost:
         restrict, restricType = False, FORT_RESTRICTION.BUILDING_CANT_UPGRADE
     level = building.level
     baseDescr = fort.getBuilding(FORT_BUILDING_TYPE.MILITARY_BASE)
     if buildingTypeID != FORT_BUILDING_TYPE.MILITARY_BASE and level >= baseDescr.level:
         restrict, restricType = False, FORT_RESTRICTION.BUILDING_FORT_LEVEL_TOO_LOW
     if buildingTypeID == FORT_BUILDING_TYPE.MILITARY_BASE and baseDescr.level >= MAX_FORTIFICATION_LEVEL:
         restrict, restricType = False, FORT_RESTRICTION.BUILDING_CANT_UPGRADE
     if building.storage < upgradeCost:
         if buildingTypeID != FORT_BUILDING_TYPE.MILITARY_BASE and level >= baseDescr.level:
             return (False, FORT_RESTRICTION.BUILDING_NOT_ENOUGH_RESOURCE_AND_LOW_LEVEL)
         restrict, restricType = False, FORT_RESTRICTION.BUILDING_NOT_ENOUGH_RESOURCE
     return (restrict, restricType)
示例#18
0
 def canUpgrade(self, buildingTypeID):
     fort = getClientFort()
     restrict, restricType = True, ''
     if fort is None:
         return (False, FORT_RESTRICTION.UNKNOWN)
     building = fort.getBuilding(buildingTypeID)
     if building is None:
         return (False, FORT_RESTRICTION.UNKNOWN)
     upgradeCost = building.levelRef.upgradeCost
     if not upgradeCost:
         restrict, restricType = False, FORT_RESTRICTION.BUILDING_CANT_UPGRADE
     level = building.level
     baseDescr = fort.getBuilding(FORT_BUILDING_TYPE.MILITARY_BASE)
     if buildingTypeID != FORT_BUILDING_TYPE.MILITARY_BASE and level >= baseDescr.level:
         restrict, restricType = False, FORT_RESTRICTION.BUILDING_FORT_LEVEL_TOO_LOW
     if buildingTypeID == FORT_BUILDING_TYPE.MILITARY_BASE and baseDescr.level >= MAX_FORTIFICATION_LEVEL:
         restrict, restricType = False, FORT_RESTRICTION.BUILDING_CANT_UPGRADE
     if building.storage < upgradeCost:
         if buildingTypeID != FORT_BUILDING_TYPE.MILITARY_BASE and level >= baseDescr.level:
             return (False, FORT_RESTRICTION.
                     BUILDING_NOT_ENOUGH_RESOURCE_AND_LOW_LEVEL)
         restrict, restricType = False, FORT_RESTRICTION.BUILDING_NOT_ENOUGH_RESOURCE
     return (restrict, restricType)
示例#19
0
 def getFort(self):
     return getClientFort()
示例#20
0
 def canBuild(self, buildingID):
     fort = getClientFort()
     if fort is None:
         return (False, FORT_RESTRICTION.UNKNOWN)
     else:
         return (True, '')
示例#21
0
 def canBuild(self, buildingID):
     fort = getClientFort()
     if fort is None:
         return (False, FORT_RESTRICTION.UNKNOWN)
     return (True, '')
示例#22
0
 def fini(self):
     fort = getClientFort()
     if fort:
         fort.onResponseReceived -= self._fort_onResponseReceived
     super(PlayerFortRequester, self).fini()
示例#23
0
 def getFort(self):
     return getClientFort()
示例#24
0
 def fini(self):
     fort = getClientFort()
     if fort:
         fort.onResponseReceived -= self._fort_onResponseReceived
     super(PlayerFortRequester, self).fini()