def __init__(self, owner, consumables, equipment, crewSkills): AvatarControllerBase.__init__(self, owner) self.__skillConditions = SkillConditions(owner, SKILL_EVENT) self.__objects = { OBJ_GROUPS.CREW: [ CrewSkills(owner, obj, self.__skillConditions, index) for index, obj in enumerate(crewSkills) ], OBJ_GROUPS.CONSUMABLES: [ConsumableEquipmentFeaturedObject(obj) for obj in consumables], OBJ_GROUPS.EQUIPMENT: [ EquipmentFeaturedObject(obj, getCrewSkillsID(crewSkills)) for obj in equipment ], OBJ_GROUPS.CAMOUFLAGE: [ CamouflageFeatureObject(owner.camouflageBonusSchemeName, owner.isCamouflageSpecializedForCurMap) ] } self.__specializationIdToObj = {} for crewMember in self.__objects[OBJ_GROUPS.CREW]: self.__specializationIdToObj[ crewMember.specializationID] = crewMember self.eModifiersChanged = Event.Event() self.modifiers = Modifiers() readyToUseSubscriptions = ( EventSubscription(c.eReadyToUse, self._onConsumableReadyToUse) for c in self.__objects[OBJ_GROUPS.CONSUMABLES]) self._subscription = CompositeSubscription(*readyToUseSubscriptions) if IS_CELLAPP: self._subscription.extend( EventSubscription(self._owner.eDestruction, self.onOwnerDeath)) self._subscription.subscribe()
def __init__(self, clientArena): super(ACGameModeClient, self).__init__(clientArena) self._scoreGlobal = (0, 0) self._globalCounters = {} self._sectors = {} self._currentTick = 0 self._currentTickStartedAt = self.player.arenaStartTime self._globalTime = 0 self._dynamicTime = 0 self._isReady = False self._eManager = EventManager() self.eGameModeReady = Event(self._eManager) self._rocketV2Manager = RocketV2Manager.RocketV2Manager(self) self._signalFlaresManager = SignalFlaresManager.SignalFlaresManager( self) self._waveInfoManager = WaveInfoManager(self) self._lastPlayerManager = LastPlayerManager(self) self._pendingEvents = [] self.createSectorsData() self.registerArenaUpdateEvents(self.updateEventsMap) gameActionsManager = self.clientArena.gameActionsManager self._subscription = CompositeSubscription( EventSubscription(gameActionsManager.eWaveAdded, self._onASWaveAdded), EventSubscription(gameActionsManager.eWaveRemoved, self._onASWaveRemoved), EventSubscription(gameActionsManager.eWaveStateChanged, self._onASWaveStateChanged), EventSubscription(gameActionsManager.eBomberStateChanged, self._onASBomberStateChanged)) self._subscription.subscribe()
def _update(self, gameResult, winState): playerTeamIndex = self._player.teamIndex enemyTeamIndex = 1 - self._player.teamIndex logger.debug('RESULT::::: {0}'.format(gameResult)) if gameResult in GAME_RESULT_LOC_IDS: resIndex = 2 if winState == 2 else int(playerTeamIndex != winState) reason = GAME_RESULT_LOC_IDS[gameResult][resIndex] self._model.reason = reason logger.debug('Update: {0}, {1}, {2}, {3}'.format( gameResult, winState, playerTeamIndex, reason)) self._model.winnerTeamIndex = winState self._updateBattleTime() scoreGlobal = self._clientArena.gameMode.scoreGlobal self._model.allyPoints = scoreGlobal[playerTeamIndex] self._model.enemyPoints = scoreGlobal[enemyTeamIndex] self._updatePlayerTeamRate() self._updatePlayerEconomics() if not self._updateRateSubscription: self._updateRateSubscription = CompositeSubscription( EventSubscription(self._clientArena.onEconomicEvents, self._updatePlayerTeamRate), EventSubscription(self._clientArena.onEconomicPlayersPoints, self._updatePlayerTeamRate)) self._updateRateSubscription.subscribe() self._updateBestRankData()
def __init__(self, features): self._player = features.require(Feature.PLAYER_AVATAR) self._model = features.require(Feature.GAME_MODEL).achievements self._subscription = EventSubscription( self._player.eAchievementUnlocked, self._onAchievementUnlocked) self._subscription.subscribe() for achievementID in self._player.unlockedAchievements: self._appendAchievement(achievementID)
def __subscribe(self): self._subscription = CompositeSubscription( EventSubscription(self._playerAvatar.eUpdateHealth, self._onUpdateHealth), EventSubscription(self._playerAvatar.onStateChanged, self._onStateChanged), EventSubscription(self._playerAvatar.eTacticalRespawnEnd, self._fillPlaneData), EventSubscription(self._gameEnv.ePlayerGunnerChangedTurret, self._updateModelShootingDistance)) self._subscription.subscribe()
def __init__(self, features): self._model = features.require(Feature.GAME_MODEL).battlePoints self._economics = features.require(Feature.CLIENT_ECONOMICS) self._player = features.require(Feature.PLAYER_AVATAR) self._clientArena = features.require(Feature.CLIENT_ARENA) self._subscription = CompositeSubscription( EventSubscription(self._player.eAchievementUnlocked, self._onAchievementUnlocked), EventSubscription(self._player.eQuestCompleted, self._onQuestCompleted), EventSubscription(self._clientArena.onAvatarPlaneTypeRankChanged, self._onPlayerPlaneTypeRankUpdated)) self._subscription.subscribe() self._economics.assignModelView(self)
def _subscribe(self): self._subscription = CompositeSubscription( EventSubscription(self._clientArena.onAvatarPlaneTypeRankChanged, self._updateAvatarPlaneTypeRank), EventSubscription(self._clientArena.onAvatarPlaneTypeRankChanged, self._updatePlaneScoresData), EventSubscription( self._clientArena.onPlayerEconomicExtDataReceived, self._updatePlaneScoresData), EventSubscription(self._clientArena.onAvatarChangedPlane, self._updateAvatarPlaneTypeRank), EventSubscription(self._clientArena.onAvatarEnterWorld, self._onAvatarEnterWorld), EventSubscription(self._clientArena.onAvatarLeaveWorld, self._onAvatarLeaveWorld), EventSubscription(self._clientArena.onEconomicPlayersPoints, self._onPlayersPoints), EventSubscription(self._clientArena.onUpdatePlayerStats, self._onUpdatePlayerStats)) self._subscription.subscribe() if self._clientArena.isAllServerDataReceived(): self._onNewAvatarsInfo(None) else: self._clientArena.onNewAvatarsInfo += self._onNewAvatarsInfo return
def __init__(self, features): self._logger = BWLogging.getLogger(self.__class__.__name__) self._model = features.require( Feature.GAME_MODEL).domination.sectorsGameEffects self._clientArena = features.require(Feature.CLIENT_ARENA) self._db = features.require(Feature.DB_LOGIC) self._playerAvatar = features.require(Feature.PLAYER_AVATAR) self._gameMode = self._clientArena.gameMode self._disableBomberCallbacks = {} self._subscription = CompositeSubscription( EDSubscription(self.gameMode, AC_EVENTS.BOMBERS_LAUNCHED, self._onBombersLaunched), EDSubscription(self.gameMode, AC_EVENTS.BOMBER_ATTACK_NOTIFIED, self._onBomberAttackNotified), EDSubscription(self.gameMode, AC_EVENTS.BOMBER_BOMBS_DROPPED, self._onBomberBombsDropped), EDSubscription(self.gameMode, AC_EVENTS.BOMBERS_DIED, self._onBombersDied), EDSubscription(self.gameMode, AC_EVENTS.BOMBER_IN_WAVE_DIED, self._onBomberInWaveDied), EDSubscription(self.gameMode.rocketV2Manager, AC_EVENTS.ROCKET_V2_EFFECT_STARTED, self._onRocketEffectStarted), EDSubscription(self.gameMode.rocketV2Manager, AC_EVENTS.ROCKET_V2_EFFECT_ENDED, self._onRocketEffectEnded), EventSubscription(self._clientArena.onReceiveMarkerMessage, self._onReceiveMarkerMessage)) self.gameMode.addEventHandler( AC_EVENTS.ROCKET_V2_TARGET_SECTOR_CHANGED, self._onRocketEffectSectorChanged) if self.gameMode.isReady: self._setupModel() else: self.gameMode.eGameModeReady += self._setupModel
class AchievementsDataSource(DataSource): """Data source for achievements model """ DIRECTION_LEFT = 'left' DIRECTION_RIGHT = 'right' def __init__(self, features): self._player = features.require(Feature.PLAYER_AVATAR) self._model = features.require(Feature.GAME_MODEL).achievements self._subscription = EventSubscription( self._player.eAchievementUnlocked, self._onAchievementUnlocked) self._subscription.subscribe() for achievementID in self._player.unlockedAchievements: self._appendAchievement(achievementID) def _onAchievementUnlocked(self, achievementID, *args, **kwargs): self._appendAchievement(achievementID) def _appendAchievement(self, achievementID): model = AchievementModel.get(id=achievementID) direction = model.client.place if direction not in (self.DIRECTION_LEFT, self.DIRECTION_RIGHT): logger.error( "Wrong direction '{0}' got for achievement {1}".format( direction, model)) direction = self.DIRECTION_LEFT if achievementID < 0 else self.DIRECTION_RIGHT achievementsModel = self._model.achievements.first( lambda e: e.id.get() == achievementID) if achievementsModel is None: self._model.achievements.append( id=achievementID, iconPath=model.client.icon.big, title=model.localized.name, description=model.localized.descriptionWithProcessorData, direction=direction, priority=model.client.order) return def dispose(self): self._subscription.unsubscribe() self._subscription = None self._model = None self._player = None return
def _subscribe(self): self._subscription = CompositeSubscription( EventSubscription(self._gameEnvironment.eAvatarHealthChange, self._onAvatarHealthChanged), EDSubscription(self._gameMode, AC_EVENTS.BOMBERS_LAUNCHED, self._onACBombersWaveLaunched), EDSubscription(self._gameMode, AC_EVENTS.BOMBERS_DIED, self._onACBombersWaveDied), EDSubscription(self._gameMode, AC_EVENTS.BOMBERS_ATTACK_STARTED, self._onACBombersAttackStarted)) self._subscription.subscribe()
def __init__(self, features): self._model = features.require(Feature.GAME_MODEL).classTasks self._player = features.require(Feature.PLAYER_AVATAR) self._clientArena = features.require(Feature.CLIENT_ARENA) coachMgr = self._player.coachManager self._subscription = CompositeSubscription( EventSubscription(coachMgr.eObjectivesChanged, self._updateCurrentObjectives), EventSubscription(coachMgr.eObjectiveProgressChanged, self._updateObjectiveProgress), EventSubscription(coachMgr.eObjectiveProgressRawValueChanged, self._updateObjectiveRawProgressValue), EventSubscription(self._player.eTacticalRespawnEnd, self._updateCurrentObjectives)) self._subscription.subscribe() if self._clientArena.isAllServerDataReceived(): self._setupModel(None) else: self._clientArena.onNewAvatarsInfo += self._setupModel logger.debug('Plane type objectives data source initialized') return
def __init__(self, features): self._db = features.require(Feature.DB_LOGIC) self._bigWorld = features.require(Feature.BIG_WORLD) self._model = features.require(Feature.GAME_MODEL).currentPlayerInfo self._playerAvatar = features.require(Feature.PLAYER_AVATAR) self._clientArena = features.require(Feature.CLIENT_ARENA) self._planesConfigurationsDB = features.require( Feature.PLANES_CONFIGURATIONS_DB) self._subscription = CompositeSubscription( EventSubscription(self._playerAvatar.onStateChanged, self._onStateChanged), EventSubscription(self._playerAvatar.eTacticalRespawnEnd, self._fillPlaneData), EventSubscription(self._clientArena.onAvatarPlaneTypeRankChanged, self._onAvatarPlaneTypeRankChanged), EventSubscription(self._clientArena.onAvatarPlaneTypeRankChanged, self._updatePlaneScoresData), EventSubscription( self._clientArena.onPlayerEconomicExtDataReceived, self._updatePlaneScoresData)) self._subscription.subscribe() self._fellModel()
def _subscribeOn(self, entity): raise self._subscription is None or AssertionError('Attempt to override subscription') self._subscription = CompositeSubscription(EventSubscription(entity.eWaveAdded, self.eWaveAdded), EventSubscription(entity.eWaveRemoved, self.eWaveRemoved), EventSubscription(entity.eWaveStateChanged, self.eWaveStateChanged), EventSubscription(entity.eBomberStateChanged, self.eBomberStateChanged)) self._subscription.subscribe() return