def _invalidate(self, resetSubscription=False): """ Invalidates _SWITCHED_METHODS mapping: for the event vehicle switch the appropriate entity's method to the extension methods. For all other vehicles, restore original methods. """ from gui.prb_control.entities.event.pre_queue.entity import EventBattleSubscriber activate = self.__isEventsEnabled and g_currentVehicle.isEvent() if self.__isActivated != activate: prevSubscriber = self.__getSubscriber() if activate: method = self._patchMethod newSubscriber = EventBattleSubscriber() else: method = self._unpatchMethod newSubscriber = self.__originalSubscriber for name in _SWITCHED_METHODS: method(name) if resetSubscription: prevSubscriber.unsubscribe(self.__entity) newSubscriber.subscribe(self.__entity) self.__setSubscriber(newSubscriber) self.__isActivated = activate LOG_DEBUG('Event Vehicle Entity is {} to entity {}'.format( 'set' if self.__isActivated else 'unset', self.__entity))
def _invalidate(self, resetSubscription = False): """ Invalidates _SWITCHED_METHODS mapping: for the event vehicle switch the appropriate functional method to the extension methods. For all other vehicles, restore original methods. """ activate = self.__isEventsEnabled and g_currentVehicle.isPresent() and g_currentVehicle.isEvent() if self.__isActivated != activate: prevSubscriber = self.__getSubscriber() if activate: method = self._patchMethod from gui.prb_control.functional.event_battles import EventBattlesEventsSubscriber newSubscriber = EventBattlesEventsSubscriber() else: method = self._unpatchMethod newSubscriber = self.__originalSubscriber for name in _SWITCHED_METHODS: method(name) if resetSubscription: prevSubscriber.unsubscribe(self.__functional) newSubscriber.subscribe(self.__functional) self.__setSubscriber(newSubscriber) self.__isActivated = activate LOG_DEBUG('Event Vehicle Functional is {} to functional {}'.format('set' if self.__isActivated else 'unset', self.__functional))
def check(self, teamLimits): if not g_currentVehicle.isPresent(): return (False, PREBATTLE_RESTRICTION.VEHICLE_NOT_PRESENT) if g_currentVehicle.isEvent(): return (False, PREBATTLE_RESTRICTION.VEHICLE_NOT_SUPPORTED) if g_currentVehicle.isRotationGroupLocked(): return (False, PREBATTLE_RESTRICTION.VEHICLE_ROTATION_GROUP_LOCKED) if not g_currentVehicle.isReadyToPrebattle(): return (False, PREBATTLE_RESTRICTION.VEHICLE_NOT_READY) vehicle = g_currentVehicle.item shellsList = [] for shell in vehicle.shells: shellsList.extend([shell.intCD, shell.count]) return isVehicleValid(vehicle.descriptor, shellsList, teamLimits)
def check(self, teamLimits): if not g_currentVehicle.isPresent(): return (False, PREBATTLE_RESTRICTION.VEHICLE_NOT_PRESENT) if g_currentVehicle.isEvent(): return (False, PREBATTLE_RESTRICTION.VEHICLE_NOT_SUPPORTED) if g_currentVehicle.isFalloutOnly() and not getFalloutCtrl().isSelected(): return (False, PREBATTLE_RESTRICTION.VEHICLE_FALLOUT_ONLY) if not g_currentVehicle.isReadyToFight(): return (False, PREBATTLE_RESTRICTION.VEHICLE_NOT_READY) vehicle = g_currentVehicle.item shellsList = [] for shell in vehicle.shells: shellsList.extend([shell.intCD, shell.count]) return isVehicleValid(vehicle.descriptor, shellsList, teamLimits)
def _invalidate(self, resetSubscription=False): from gui.prb_control.entities.event.pre_queue.entity import EventBattleSubscriber activate = self.__isEventsEnabled and g_currentVehicle.isEvent() if self.__isActivated != activate: prevSubscriber = self.__getSubscriber() if activate: method = self._patchMethod newSubscriber = EventBattleSubscriber() else: method = self._unpatchMethod newSubscriber = self.__originalSubscriber for name in _SWITCHED_METHODS: method(name) if resetSubscription: prevSubscriber.unsubscribe(self.__entity) newSubscriber.subscribe(self.__entity) self.__setSubscriber(newSubscriber) self.__isActivated = activate LOG_DEBUG('Event Vehicle Entity is {} to entity {}'.format( 'set' if self.__isActivated else 'unset', self.__entity))