diff --git a/.gitignore b/.gitignore index 76833471..aa9f1259 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,19 @@ -# Python artifacts: +# Python artifacts *.pyc # PyCharm .idea -# Mac directory info: +# Mac directory info .DS_Store -# Shortcuts: +# Shortcuts *.lnk -# Game-specific files and directories: +# Git +*.rej + +# Game-specific files and directories preferences.json *.json logs/ diff --git a/astron/dclass/united.dc b/astron/dclass/united.dc index aa81428b..c50a20f9 100644 --- a/astron/dclass/united.dc +++ b/astron/dclass/united.dc @@ -450,8 +450,6 @@ from toontown.estate import DistributedChangingStatuary/AI from toontown.estate import DistributedAnimatedStatuary/AI from toontown.estate import DistributedPlantBase/AI from toontown.estate import DistributedLawnDecor/AI -from toontown.minigame import DistributedTravelGame/AI -from toontown.minigame import DistributedPairingGame/AI from toontown.minigame import DistributedVineGame/AI from toontown.golf import DistributedPhysicsWorld/AI from toontown.golf import DistributedGolfHole/AI @@ -1185,8 +1183,6 @@ dclass DistributedTarget : DistributedObject { dclass DistributedMinigame : DistributedObject { setParticipants(uint32[]) broadcast ram required; setTrolleyZone(uint32) broadcast ram required; - setStartingVotes(uint16[]) broadcast ram required; - setMetagameRound(int8) broadcast ram required; setDifficultyOverrides(int32, int32) broadcast ram required; setAvatarJoined() airecv clsend; setAvatarReady() airecv clsend; @@ -1649,8 +1645,6 @@ dclass PurchaseManager : DistributedObject { setPlayerMoney(uint16, uint16, uint16, uint16) required broadcast ram; setPlayerStates(uint8, uint8, uint8, uint8) required broadcast ram; setCountdown(int16) required broadcast ram; - setMetagameRound(int8) required broadcast ram; - setVotesArray(int16[]) required broadcast ram; requestExit() airecv clsend; requestPlayAgain() airecv clsend; setInventory(blob, int16, uint8) airecv clsend; @@ -2780,27 +2774,6 @@ dclass DistributedGagTree : DistributedPlantBase { requestHarvest() airecv clsend; }; -dclass DistributedTravelGame : DistributedMinigame { - setTimerStartTime(int16) broadcast; - setAvatarChoice(uint16, uint8) airecv clsend; - setAvatarVotes(uint32, uint16) broadcast; - setAvatarChose(uint32) broadcast; - setServerChoices(int16[], uint8[], uint8, uint8) broadcast; - setMinigames(uint8[], uint8[]) broadcast; - setBonuses(uint8[], uint8[]) broadcast; - setBoardIndex(uint8) required broadcast ram; -}; - -dclass DistributedPairingGame : DistributedMinigame { - setDeckSeed(uint32) required broadcast ram; - setMaxOpenCards(uint8) broadcast ram; - openCardRequest(int16, int16) airecv clsend; - openCardResult(int16, uint32, int16, int8, int16[]) broadcast; - reportDone() airecv clsend; - setEveryoneDone() broadcast; - setSignaling(uint32) clsend broadcast; -}; - struct golfData { int16 frame; int32/100000 x; diff --git a/otp/distributed/DCClassImports.py b/otp/distributed/DCClassImports.py index c1ef04ad..e7512c35 100644 --- a/otp/distributed/DCClassImports.py +++ b/otp/distributed/DCClassImports.py @@ -2,7 +2,7 @@ from pandac.PandaModules import * -hashVal = 526795320 +hashVal = 229492426 from toontown.coghq import DistributedCashbotBossSafe, DistributedCashbotBossCrane, DistributedBattleFactory, DistributedCashbotBossTreasure, DistributedCogHQDoor, DistributedSellbotHQDoor, DistributedFactoryElevatorExt, DistributedMintElevatorExt, DistributedLawOfficeElevatorExt, DistributedLawOfficeElevatorInt, LobbyManager, DistributedMegaCorp, DistributedFactory, DistributedLawOffice, DistributedLawOfficeFloor, DistributedLift, DistributedDoorEntity, DistributedSwitch, DistributedButton, DistributedTrigger, DistributedCrushableEntity, DistributedCrusherEntity, DistributedStomper, DistributedStomperPair, DistributedLaserField, DistributedGolfGreenGame, DistributedSecurityCamera, DistributedMover, DistributedElevatorMarker, DistributedBarrelBase, DistributedGagBarrel, DistributedBeanBarrel, DistributedHealBarrel, DistributedGrid, ActiveCell, DirectionalCell, CrusherCell, DistributedCrate, DistributedSinkingPlatform, BattleBlocker, DistributedMint, DistributedMintRoom, DistributedMintBattle, DistributedStage, DistributedStageRoom, DistributedStageBattle, DistributedLawbotBossGavel, DistributedLawbotCannon, DistributedLawbotChair, DistributedCogKart, DistributedCountryClub, DistributedCountryClubRoom, DistributedMoleField, DistributedCountryClubBattle, DistributedMaze, DistributedFoodBelt, DistributedBanquetTable, DistributedGolfSpot @@ -24,7 +24,7 @@ from toontown.distributed import ToontownDistrict, ToontownDistrictStats, Distri from toontown.effects import DistributedFireworkShow from toontown.safezone import DistributedTrolley, DistributedPartyGate, DistributedBoat, DistributedButterfly, DistributedMMPiano, DistributedDGFlower, DistributedFishingSpot, SafeZoneManager, DistributedTreasure, DistributedGolfKart, DistributedPicnicBasket, DistributedPicnicTable, DistributedChineseCheckers, DistributedCheckers, DistributedFindFour from toontown.fishing import DistributedFishingPond, DistributedFishingTarget, DistributedPondBingoManager -from toontown.minigame import DistributedMinigame, DistributedMinigameTemplate, DistributedRaceGame, DistributedCannonGame, DistributedPhotoGame, DistributedPatternGame, DistributedRingGame, DistributedTagGame, DistributedMazeGame, DistributedTugOfWarGame, DistributedCatchGame, DistributedDivingGame, DistributedTargetGame, DistributedTravelGame, DistributedPairingGame, DistributedVineGame, DistributedIceGame, DistributedCogThiefGame, DistributedTwoDGame +from toontown.minigame import DistributedMinigame, DistributedMinigameTemplate, DistributedRaceGame, DistributedCannonGame, DistributedPhotoGame, DistributedPatternGame, DistributedRingGame, DistributedTagGame, DistributedMazeGame, DistributedTugOfWarGame, DistributedCatchGame, DistributedDivingGame, DistributedTargetGame, DistributedVineGame, DistributedIceGame, DistributedCogThiefGame, DistributedTwoDGame from toontown.racing import DistributedVehicle, DistributedStartingBlock, DistributedRace, DistributedKartPad, DistributedRacePad, DistributedViewPad, DistributedStartingBlock, DistributedLeaderBoard, DistributedGag, DistributedProjectile from toontown.catalog import CatalogManager, AccountDate from toontown.rpc.AwardManager import AwardManager diff --git a/toontown/hood/ToonHood.py b/toontown/hood/ToonHood.py index e758e3c9..ab11fca7 100644 --- a/toontown/hood/ToonHood.py +++ b/toontown/hood/ToonHood.py @@ -118,13 +118,13 @@ class ToonHood(Hood): self.doneStatus = doneStatus messenger.send(self.doneEvent) - def enterPurchase(self, pointsAwarded, playerMoney, avIds, playerStates, remain, metagameRound = -1, votesArray = None): + def enterPurchase(self, pointsAwarded, playerMoney, avIds, playerStates, remain): messenger.send('enterSafeZone') DistributedAvatar.DistributedAvatar.HpTextEnabled = 0 base.localAvatar.laffMeter.start() self.purchaseDoneEvent = 'purchaseDone' self.accept(self.purchaseDoneEvent, self.handlePurchaseDone) - self.purchase = Purchase.Purchase(base.localAvatar, pointsAwarded, playerMoney, avIds, playerStates, remain, self.purchaseDoneEvent, metagameRound, votesArray) + self.purchase = Purchase.Purchase(base.localAvatar, pointsAwarded, playerMoney, avIds, playerStates, remain, self.purchaseDoneEvent) self.purchase.load() self.purchase.enter() diff --git a/toontown/minigame/DistributedMinigame.py b/toontown/minigame/DistributedMinigame.py index 5cd411e5..95974584 100644 --- a/toontown/minigame/DistributedMinigame.py +++ b/toontown/minigame/DistributedMinigame.py @@ -51,8 +51,6 @@ class DistributedMinigame(DistributedObject.DistributedObject): self.trolleyZoneOverride = None self.hasLocalToon = 0 self.frameworkFSM.enterInitialState() - self.startingVotes = {} - self.metagameRound = -1 self._telemLimiter = None return @@ -428,17 +426,4 @@ class DistributedMinigame(DistributedObject.DistributedObject): Emote.globalEmote.disableAll(base.localAvatar) def unsetEmotes(self): - Emote.globalEmote.releaseAll(base.localAvatar) - - def setStartingVotes(self, startingVotesArray): - if not len(startingVotesArray) == len(self.avIdList): - self.notify.error('length does not match, startingVotes=%s, avIdList=%s' % (startingVotesArray, self.avIdList)) - return - for index in xrange(len(self.avIdList)): - avId = self.avIdList[index] - self.startingVotes[avId] = startingVotesArray[index] - - self.notify.debug('starting votes = %s' % self.startingVotes) - - def setMetagameRound(self, metagameRound): - self.metagameRound = metagameRound + Emote.globalEmote.releaseAll(base.localAvatar) \ No newline at end of file diff --git a/toontown/minigame/DistributedMinigameAI.py b/toontown/minigame/DistributedMinigameAI.py index e9f78c11..ced56f2a 100644 --- a/toontown/minigame/DistributedMinigameAI.py +++ b/toontown/minigame/DistributedMinigameAI.py @@ -11,7 +11,6 @@ from direct.task import Task import random import MinigameGlobals from direct.showbase import PythonUtil -import TravelGameGlobals from toontown.toonbase import ToontownGlobals EXITED = 0 EXPECTED = 1 @@ -45,8 +44,6 @@ class DistributedMinigameAI(DistributedObjectAI.DistributedObjectAI): self.scoreDict = {} self.difficultyOverride = None self.trolleyZoneOverride = None - self.metagameRound = -1 - self.startingVotes = {} return @@ -76,9 +73,6 @@ class DistributedMinigameAI(DistributedObjectAI.DistributedObjectAI): self.trolleyZoneOverride = trolleyZoneOverride return - def setMetagameRound(self, roundNum): - self.metagameRound = roundNum - def _playing(self): if not hasattr(self, 'gameFSM'): return False @@ -320,67 +314,9 @@ class DistributedMinigameAI(DistributedObjectAI.DistributedObjectAI): scoreList.append(score) self.requestDelete() - if self.metagameRound > -1: - self.handleMetagamePurchaseManager(scoreList) - else: - self.handleRegularPurchaseManager(scoreList) + self.handleRegularPurchaseManager(scoreList) self.frameworkFSM.request('frameworkOff') - def handleMetagamePurchaseManager(self, scoreList): - self.notify.debug('self.newbieIdList = %s' % self.newbieIdList) - votesToUse = self.startingVotes - if hasattr(self, 'currentVotes'): - votesToUse = self.currentVotes - votesArray = [] - for avId in self.avIdList: - if avId in votesToUse: - votesArray.append(votesToUse[avId]) - else: - self.notify.warning('votesToUse=%s does not have avId=%d' % (votesToUse, avId)) - votesArray.append(0) - - if self.metagameRound < TravelGameGlobals.FinalMetagameRoundIndex: - newRound = self.metagameRound - if not self.minigameId == ToontownGlobals.TravelGameId: - for index in xrange(len(scoreList)): - votesArray[index] += scoreList[index] - - self.notify.debug('votesArray = %s' % votesArray) - desiredNextGame = None - if hasattr(self, 'desiredNextGame'): - desiredNextGame = self.desiredNextGame - numToons = 0 - lastAvId = 0 - for avId in self.avIdList: - av = simbase.air.doId2do.get(avId) - if av: - numToons += 1 - lastAvId = avId - - doNewbie = False - if numToons == 1 and lastAvId in self.newbieIdList: - doNewbie = True - if doNewbie: - pm = NewbiePurchaseManagerAI.NewbiePurchaseManagerAI(self.air, lastAvId, self.avIdList, scoreList, self.minigameId, self.trolleyZone) - MinigameCreatorAI.acquireMinigameZone(self.zoneId) - pm.generateWithRequired(self.zoneId) - else: - pm = PurchaseManagerAI.PurchaseManagerAI(self.air, self.avIdList, scoreList, self.minigameId, self.trolleyZone, self.newbieIdList, votesArray, newRound, desiredNextGame) - pm.generateWithRequired(self.zoneId) - else: - self.notify.debug('last minigame, handling newbies') - if ToontownGlobals.JELLYBEAN_TROLLEY_HOLIDAY in simbase.air.holidayManager.currentHolidays or ToontownGlobals.JELLYBEAN_TROLLEY_HOLIDAY_MONTH in simbase.air.holidayManager.currentHolidays: - votesArray = map(lambda x: MinigameGlobals.JellybeanTrolleyHolidayScoreMultiplier * x, votesArray) - for id in self.newbieIdList: - pm = NewbiePurchaseManagerAI.NewbiePurchaseManagerAI(self.air, id, self.avIdList, scoreList, self.minigameId, self.trolleyZone) - MinigameCreatorAI.acquireMinigameZone(self.zoneId) - pm.generateWithRequired(self.zoneId) - - if len(self.avIdList) > len(self.newbieIdList): - pm = PurchaseManagerAI.PurchaseManagerAI(self.air, self.avIdList, scoreList, self.minigameId, self.trolleyZone, self.newbieIdList, votesArray=votesArray, metagameRound=self.metagameRound) - pm.generateWithRequired(self.zoneId) - return - def handleRegularPurchaseManager(self, scoreList): for id in self.newbieIdList: pm = NewbiePurchaseManagerAI.NewbiePurchaseManagerAI(self.air, id, self.avIdList, scoreList, self.minigameId, self.trolleyZone) @@ -426,22 +362,4 @@ class DistributedMinigameAI(DistributedObjectAI.DistributedObjectAI): def logAllPerfect(self): for avId in self.avIdList: - self.logPerfectGame(avId) - - def getStartingVotes(self): - retval = [] - for avId in self.avIdList: - if avId in self.startingVotes: - retval.append(self.startingVotes[avId]) - else: - self.notify.warning('how did this happen? avId=%d not in startingVotes %s' % (avId, self.startingVotes)) - retval.append(0) - - return retval - - def setStartingVote(self, avId, startingVote): - self.startingVotes[avId] = startingVote - self.notify.debug('setting starting vote of avId=%d to %d' % (avId, startingVote)) - - def getMetagameRound(self): - return self.metagameRound + self.logPerfectGame(avId) \ No newline at end of file diff --git a/toontown/minigame/DistributedPairingGame.py b/toontown/minigame/DistributedPairingGame.py deleted file mode 100644 index 333fa964..00000000 --- a/toontown/minigame/DistributedPairingGame.py +++ /dev/null @@ -1,532 +0,0 @@ -from pandac.PandaModules import * -from toontown.toonbase.ToonBaseGlobal import * -from DistributedMinigame import * -from direct.fsm import ClassicFSM, State -from direct.fsm import State -from toontown.toonbase import TTLocalizer, ToontownTimer -from toontown.toonbase import ToontownBattleGlobals -from toontown.minigame import PlayingCardGlobals -from toontown.minigame import PairingGameCard -from toontown.minigame import PlayingCardDeck -from toontown.minigame import PairingGameGlobals -from OrthoWalk import OrthoWalk -from OrthoDrive import OrthoDrive -from direct.interval.IntervalGlobal import Sequence, Parallel, Func, LerpColorScaleInterval, LerpScaleInterval, LerpFunctionInterval, Wait, SoundInterval -from toontown.toonbase.ToontownGlobals import GlobalDialogColor - -class DistributedPairingGame(DistributedMinigame): - TOON_SPEED = 11 - MAX_FRAME_MOVE = 1 - MAX_FACE_UP_CARDS = 2 - notify = directNotify.newCategory('DistributedPairingGame') - bonusGlowTime = 0.5 - EndGameTaskName = 'endPairingGame' - xCardInc = 4 - cardsPerRow = 8 - cardsPerCol = 5 - - def __init__(self, cr): - DistributedMinigame.__init__(self, cr) - self.gameFSM = ClassicFSM.ClassicFSM('DistributedPairingGame', [State.State('off', self.enterOff, self.exitOff, ['play']), State.State('play', self.enterPlay, self.exitPlay, ['cleanup']), State.State('cleanup', self.enterCleanup, self.exitCleanup, [])], 'off', 'cleanup') - self.addChildGameFSM(self.gameFSM) - self.cameraTopView = (17.6, 6.18756, 43.9956, 0, -89, 0) - self.cameraThreeQuarterView = (14.0, -8.93352, 33.4497, 0, -62.89, 0) - self.deckSeed = 0 - self.faceUpList = [] - self.localFaceUpList = [] - self.inList = [] - self.inactiveList = [] - self.points = 0 - self.flips = 0 - self.matches = 0 - self.yCardInc = 4 - self.startingPositions = [(0, 0, 0, -45), - ((self.cardsPerRow - 1) * self.xCardInc, - (self.cardsPerCol - 1) * self.yCardInc, - 0, - 135), - ((self.cardsPerRow - 1) * self.xCardInc, - 0, - 0, - 45), - (0, - (self.cardsPerCol - 1) * self.yCardInc, - 0, - -135)] - self.stageMin = Point2(0, 0) - self.stageMax = Point2((self.cardsPerRow - 1) * self.xCardInc, (self.cardsPerCol - 1) * self.yCardInc) - self.gameDuration = PairingGameGlobals.EasiestGameDuration - - def moveCameraToTop(self): - camera.reparentTo(render) - p = self.cameraThreeQuarterView - camera.setPosHpr(p[0], p[1], p[2], p[3], p[4], p[5]) - - def getTitle(self): - return TTLocalizer.PairingGameTitle - - def getInstructions(self): - if self.numPlayers > 1: - return TTLocalizer.PairingGameInstructionsMulti - else: - return TTLocalizer.PairingGameInstructions - - def getMaxDuration(self): - return 0 - - def load(self): - self.notify.debug('load') - DistributedMinigame.load(self) - self.gameDuration = PairingGameGlobals.calcGameDuration(self.getDifficulty()) - self.gameBoard = loader.loadModel('phase_4/models/minigames/memory_room') - self.gameBoard.setPosHpr(0.5, 0, 0, 0, 0, 0) - self.gameBoard.setScale(1.0) - self.deck = PairingGameGlobals.createDeck(self.deckSeed, self.numPlayers) - self.notify.debug('%s' % self.deck.cards) - testCard = self.getDeckOrderIndex(self.cardsPerCol - 1, 0) - if not testCard > -1: - self.yCardInc *= 1.25 - self.cards = [] - for index in xrange(len(self.deck.cards)): - cardValue = self.deck.cards[index] - oneCard = PairingGameCard.PairingGameCard(cardValue) - oneCard.load() - xPos, yPos = self.getCardPos(index) - oneCard.setPos(xPos, yPos, 0) - oneCard.reparentTo(render) - self.notify.debug('%s' % oneCard.getPos()) - self.notify.debug('suit %s rank %s value %s' % (oneCard.suit, oneCard.rank, oneCard.value)) - self.accept('entercardCollision-%d' % oneCard.value, self.enterCard) - self.accept('exitcardCollision-%d' % oneCard.value, self.exitCard) - oneCard.turnDown(doInterval=False) - self.cards.append(oneCard) - - self.bonusTraversal = range(len(self.cards)) - self.bonusGlow = render.attachNewNode('bonusGlow') - sign = loader.loadModel('phase_4/models/minigames/garden_sign_memory') - sign.find('**/sign1').removeNode() - sign.find('**/sign2').removeNode() - sign.find('**/collision').removeNode() - sign.setPos(0, 0, 0.05) - sign.reparentTo(self.bonusGlow) - self.bonusGlow.setScale(2.5) - self.pointsFrame = DirectFrame(relief=None, geom=DGG.getDefaultDialogGeom(), geom_color=GlobalDialogColor, geom_scale=(4, 1, 1), pos=(-0.33, 0, 0.9), scale=0.1, text=TTLocalizer.PairingGamePoints, text_align=TextNode.ALeft, text_scale=TTLocalizer.DPGpointsFrame, text_pos=(-1.94, -0.1, 0.0)) - self.pointsLabel = DirectLabel(parent=self.pointsFrame, relief=None, text='0', text_fg=VBase4(0, 0.5, 0, 1), text_align=TextNode.ARight, text_scale=0.7, pos=(1.82, 0, -0.15)) - self.flipsFrame = DirectFrame(relief=None, geom=DGG.getDefaultDialogGeom(), geom_color=GlobalDialogColor, geom_scale=(4, 1, 1), pos=(0.33, 0, 0.9), scale=0.1, text=TTLocalizer.PairingGameFlips, text_align=TextNode.ALeft, text_scale=TTLocalizer.DPGflipsFrame, text_pos=(-1.94, -0.1, 0.0)) - self.flipsLabel = DirectLabel(parent=self.flipsFrame, relief=None, text='0', text_fg=VBase4(0, 1.0, 0, 1), text_align=TextNode.ARight, text_scale=0.7, pos=(1.82, 0, -0.15)) - self.__textGen = TextNode('ringGame') - self.__textGen.setFont(ToontownGlobals.getSignFont()) - self.__textGen.setAlign(TextNode.ACenter) - self.sndPerfect = base.loadSfx('phase_4/audio/sfx/MG_pairing_all_matched.ogg') - self.calcBonusTraversal() - self.music = base.loadMusic('phase_4/audio/bgm/MG_Pairing.ogg') - self.matchSfx = base.loadSfx('phase_4/audio/sfx/MG_pairing_match.ogg') - self.matchWithBonusSfx = base.loadSfx('phase_4/audio/sfx/MG_pairing_match_bonus_both.ogg') - self.signalSfx = [] - for i in xrange(4): - self.signalSfx.append(base.loadSfx('phase_4/audio/sfx/MG_pairing_jumping_signal.ogg')) - - self.bonusMovesSfx = base.loadSfx('phase_4/audio/sfx/MG_pairing_bonus_moves.ogg') - return - - def unload(self): - self.notify.debug('unload') - DistributedMinigame.unload(self) - self.removeChildGameFSM(self.gameFSM) - del self.gameFSM - self.gameBoard.removeNode() - del self.gameBoard - for card in self.cards: - card.unload() - del card - - self.cards = [] - self.pointsFrame.removeNode() - del self.pointsFrame - self.flipsFrame.removeNode() - del self.flipsFrame - del self.__textGen - del self.sndPerfect - self.bonusGlow.removeNode() - del self.bonusGlow - del self.music - del self.matchSfx - del self.matchWithBonusSfx - for i in xrange(4): - del self.signalSfx[0] - - self.signalSfx = [] - del self.bonusMovesSfx - - def onstage(self): - self.notify.debug('onstage') - DistributedMinigame.onstage(self) - self.gameBoard.reparentTo(render) - for card in self.cards: - card.reparentTo(render) - - lt = base.localAvatar - lt.reparentTo(render) - lt.hideName() - self.__placeToon(self.localAvId) - lt.setAnimState('Happy', 1.0) - lt.setSpeed(0, 0) - self.moveCameraToTop() - - def offstage(self): - self.notify.debug('offstage') - self.gameBoard.hide() - for card in self.cards: - card.hide() - - DistributedMinigame.offstage(self) - - def handleDisabledAvatar(self, avId): - self.notify.debug('handleDisabledAvatar') - self.notify.debug('avatar ' + str(avId) + ' disabled') - DistributedMinigame.handleDisabledAvatar(self, avId) - - def setGameReady(self): - if not self.hasLocalToon: - return - self.notify.debug('setGameReady') - if DistributedMinigame.setGameReady(self): - return - for index in xrange(self.numPlayers): - avId = self.avIdList[index] - toon = self.getAvatar(avId) - if toon: - toon.reparentTo(render) - self.__placeToon(avId) - toon.setAnimState('Happy', 1.0) - toon.startSmooth() - toon.startLookAround() - - def setGameStart(self, timestamp): - if not self.hasLocalToon: - return - self.notify.debug('setGameStart') - DistributedMinigame.setGameStart(self, timestamp) - for avId in self.remoteAvIdList: - toon = self.getAvatar(avId) - if toon: - toon.stopLookAround() - - self.gameFSM.request('play') - - def isInPlayState(self): - if not self.gameFSM.getCurrentState(): - return False - if not self.gameFSM.getCurrentState().getName() == 'play': - return False - return True - - def enterOff(self): - self.notify.debug('enterOff') - - def exitOff(self): - pass - - def enterPlay(self): - self.notify.debug('enterPlay') - base.playMusic(self.music, looping=1, volume=0.9) - orthoDrive = OrthoDrive(self.TOON_SPEED, maxFrameMove=self.MAX_FRAME_MOVE, customCollisionCallback=self.__doPairingGameCollisions) - self.orthoWalk = OrthoWalk(orthoDrive, broadcast=not self.isSinglePlayer()) - self.orthoWalk.start() - self.accept('insert', self.__flipKeyPressed) - self.accept('delete', self.__flipKeyPressed) - self.accept('time-control', self.__beginSignal) - self.accept('time-control-up', self.__endSignal) - self.bonusGlowIndex = 0 - self.bonusGlowCard = self.bonusTraversal[self.bonusGlowIndex] - self.startBonusTask() - self.timer = ToontownTimer.ToontownTimer() - self.timer.posInTopRightCorner() - self.timer.setTime(self.gameDuration) - self.timer.countdown(self.gameDuration, self.timerExpired) - if base.localAvatar.laffMeter: - base.localAvatar.laffMeter.stop() - - def exitPlay(self): - self.music.stop() - self.orthoWalk.stop() - self.orthoWalk.destroy() - del self.orthoWalk - self.bonusGlow.hide() - self.stopBonusTask() - self.timer.stop() - self.timer.destroy() - del self.timer - self.ignoreAll() - if base.localAvatar.laffMeter: - base.localAvatar.laffMeter.start() - if hasattr(self, 'perfectIval'): - self.perfectIval.pause() - del self.perfectIval - taskMgr.remove(self.EndGameTaskName) - taskMgr.remove('pairGameContinueSignal') - - def enterCleanup(self): - self.notify.debug('enterCleanup') - - def exitCleanup(self): - pass - - def __placeToon(self, avId): - toon = self.getAvatar(avId) - if self.numPlayers == 1: - toon.setPos(0, 0, 0) - toon.setHpr(0, 0, 0) - else: - posIndex = self.avIdList.index(avId) - pos = self.startingPositions[posIndex] - toon.setPos(pos[0], pos[1], pos[2]) - toon.setHpr(pos[3], 0, 0) - - def __doPairingGameCollisions(self, oldPos, newPos): - x = bound(newPos[0], self.stageMin[0], self.stageMax[0]) - y = bound(newPos[1], self.stageMin[1], self.stageMax[1]) - newPos.setX(x) - newPos.setY(y) - if self.inList: - newPos.setZ(0.15) - else: - newPos.setZ(0.0) - if not oldPos == newPos: - taskMgr.remove('pairGameContinueSignal') - return newPos - - def getDeckOrderFromValue(self, value): - for index in xrange(len(self.cards)): - if self.cards[index].value == value: - return index - - return -1 - - def getDeckOrderFromPairingGameCard(self, into): - try: - index = self.cards.index(into) - except ValueError: - index = -1 - - return index - - def enterCard(self, colEntry): - intoName = colEntry.getIntoNodePath().getName() - parts = intoName.split('-') - value = int(parts[1]) - self.notify.debug('entered cardValue %d' % value) - deckOrder = self.getDeckOrderFromValue(value) - if deckOrder not in self.inList: - self.inList.append(deckOrder) - - def exitCard(self, colEntry): - intoName = colEntry.getIntoNodePath().getName() - parts = intoName.split('-') - value = int(parts[1]) - self.notify.debug('exited cardValue %d' % value) - deckOrder = self.getDeckOrderFromValue(value) - if deckOrder in self.inList: - self.inList.remove(deckOrder) - - def handleMatch(self, cardA, cardB, withBonus): - self.notify.debug('we got a match %d %d' % (cardA, cardB)) - self.matches += 1 - if cardA in self.faceUpList: - self.faceUpList.remove(cardA) - if cardB in self.faceUpList: - self.faceUpList.remove(cardB) - self.inactiveList.append(cardA) - self.inactiveList.append(cardB) - matchIval = Parallel() - for card in [cardA, cardB]: - self.cards[card].setTransparency(1) - cardSeq = Sequence(LerpColorScaleInterval(self.cards[card], duration=1, colorScale=Vec4(1.0, 1.0, 1.0, 0.0)), Func(self.cards[card].hide)) - matchIval.append(cardSeq) - - if withBonus: - matchIval.append(SoundInterval(self.matchWithBonusSfx, node=self.cards[card], listenerNode=base.localAvatar, cutOff=240)) - else: - matchIval.append(SoundInterval(self.matchSfx, node=self.cards[card], listenerNode=base.localAvatar, cutOff=240)) - matchIval.start() - if len(self.inactiveList) == len(self.cards): - self.sendUpdate('reportDone') - - def turnUpCard(self, deckOrder): - self.cards[deckOrder].turnUp() - self.faceUpList.append(deckOrder) - - def turnDownCard(self, deckOrder): - self.cards[deckOrder].turnDown() - if deckOrder in self.faceUpList: - self.faceUpList.remove(deckOrder) - - def __flipKeyPressed(self): - if self.inList: - shortestDistance = 10000 - cardToFlip = -1 - for deckOrder in self.inList: - dist = base.localAvatar.getDistance(self.cards[deckOrder]) - if dist < shortestDistance: - shortestDistance = dist - cardToFlip = deckOrder - - deckOrderIndex = cardToFlip - card = self.cards[deckOrderIndex] - if card.isFaceDown() and deckOrderIndex not in self.inactiveList: - self.sendUpdate('openCardRequest', [deckOrderIndex, self.bonusGlowCard]) - elif card.isFaceUp() and deckOrderIndex in self.faceUpList: - pass - - def moveBonusGlowTask(self, task): - if len(self.cards) == 0: - return Task.done - curT = self.getCurrentGameTime() - intTime = int(curT / self.bonusGlowTime) - newIndex = intTime % len(self.cards) - if not newIndex == self.bonusGlowIndex: - self.bonusGlowIndex = newIndex - self.bonusGlowCard = self.bonusTraversal[self.bonusGlowIndex] - card = self.cards[self.bonusGlowCard] - self.bonusGlow.setPos(card.getPos()) - base.playSfx(self.bonusMovesSfx, node=card, volume=0.25) - return Task.cont - - def timerExpired(self): - self.sendUpdate('reportDone') - - def setDeckSeed(self, deckSeed): - if not self.hasLocalToon: - return - self.deckSeed = deckSeed - - def updateFlipText(self): - self.flipsLabel['text'] = str(self.flips) - lowFlipModifier = PairingGameGlobals.calcLowFlipModifier(self.matches, self.flips) - red = 1.0 - lowFlipModifier - green = lowFlipModifier - self.flipsLabel['text_fg'] = Vec4(red, green, 0, 1.0) - - def openCardResult(self, cardToTurnUp, avId, matchingCard, points, cardsToTurnDown): - if not self.hasLocalToon: - return - if not self.isInPlayState(): - return - if avId == base.localAvatar.doId: - self.localFaceUpList.append(cardToTurnUp) - self.turnUpCard(cardToTurnUp) - gotBonus = False - if points - self.points > 1: - gotBonus = True - if matchingCard > -1: - self.handleMatch(cardToTurnUp, matchingCard, gotBonus) - self.flips += 1 - self.updateFlipText() - self.points = points - self.pointsLabel['text'] = str(self.points) - for card in cardsToTurnDown: - self.turnDownCard(card) - - def startBonusTask(self): - taskMgr.add(self.moveBonusGlowTask, self.taskName('moveBonusGlowTask')) - - def stopBonusTask(self): - taskMgr.remove(self.taskName('moveBonusGlowTask')) - - def setEveryoneDone(self): - if not self.hasLocalToon: - return - if self.gameFSM.getCurrentState().getName() != 'play': - self.notify.warning('ignoring setEveryoneDone msg') - return - self.notify.debug('setEveryoneDone') - - def endGame(task, self = self): - if not PairingGameGlobals.EndlessGame: - self.gameOver() - return Task.done - - self.timer.hide() - self.bonusGlow.hide() - if len(self.inactiveList) == len(self.cards): - self.notify.debug('perfect game!') - perfectTextSubnode = hidden.attachNewNode(self.__genText(TTLocalizer.PairingGamePerfect)) - perfectText = hidden.attachNewNode('perfectText') - perfectTextSubnode.reparentTo(perfectText) - frame = self.__textGen.getCardActual() - offsetY = -abs(frame[2] + frame[3]) / 2.0 - perfectTextSubnode.setPos(0, 0, offsetY) - perfectText.setColor(1, 0.1, 0.1, 1) - - def fadeFunc(t, text = perfectText): - text.setColorScale(1, 1, 1, t) - - def destroyText(text = perfectText): - text.removeNode() - - textTrack = Sequence(Func(perfectText.reparentTo, aspect2d), Parallel(LerpScaleInterval(perfectText, duration=0.5, scale=0.3, startScale=0.0), LerpFunctionInterval(fadeFunc, fromData=0.0, toData=1.0, duration=0.5)), Wait(2.0), Parallel(LerpScaleInterval(perfectText, duration=0.5, scale=1.0), LerpFunctionInterval(fadeFunc, fromData=1.0, toData=0.0, duration=0.5, blendType='easeIn')), Func(destroyText), WaitInterval(0.5), Func(endGame, None)) - soundTrack = SoundInterval(self.sndPerfect) - self.perfectIval = Parallel(textTrack, soundTrack) - self.perfectIval.start() - else: - taskMgr.doMethodLater(1, endGame, self.EndGameTaskName) - return - - def __genText(self, text): - self.__textGen.setText(text) - return self.__textGen.generate() - - def b_setSignaling(self, avId): - self.setSignaling(avId) - self.sendUpdate('setSignaling', [self.localAvId]) - - def setSignaling(self, avId): - if not self.hasLocalToon: - return - avIndex = self.avIdList.index(avId) - av = base.cr.doId2do.get(avId) - if av and avIndex >= 0 and hasattr(self, 'signalSfx') and self.signalSfx: - base.playSfx(self.signalSfx[avIndex], node=av) - - def __beginSignal(self, mouseParam): - self.notify.debug('beginSignal') - base.localAvatar.b_setEmoteState(1, 1.0) - self.b_setSignaling(self.localAvId) - taskMgr.doMethodLater(1.67, self.__continueSignal, 'pairGameContinueSignal') - - def __endSignal(self, mouseParam): - self.notify.debug('endSignal') - base.localAvatar.b_setEmoteState(-1, 1.0) - taskMgr.remove('pairGameContinueSignal') - - def __continueSignal(self, task): - base.localAvatar.b_setEmoteState(1, 1.0) - self.b_setSignaling(self.localAvId) - taskMgr.doMethodLater(1.67, self.__continueSignal, 'pairGameContinueSignal') - - def getCardPos(self, deckOrderIndex): - col = deckOrderIndex % self.cardsPerRow - row = deckOrderIndex / self.cardsPerRow - x = col * self.xCardInc - y = row * self.yCardInc - return (x, y) - - def getDeckOrderIndex(self, row, col): - retval = row * self.cardsPerRow - retval += col - if retval >= len(self.deck.cards): - retval = -1 - return retval - - def calcBonusTraversal(self): - self.bonusTraversal = [] - halfRow = self.cardsPerRow / 2 - if self.cardsPerRow % 2: - halfRow += 1 - for i in xrange(halfRow): - for j in xrange(2): - col = i + j * halfRow - for row in xrange(self.cardsPerCol): - card = self.getDeckOrderIndex(row, col) - if card > -1: - self.bonusTraversal.append(card) diff --git a/toontown/minigame/DistributedPairingGameAI.py b/toontown/minigame/DistributedPairingGameAI.py deleted file mode 100644 index 77ac1bac..00000000 --- a/toontown/minigame/DistributedPairingGameAI.py +++ /dev/null @@ -1,229 +0,0 @@ -from DistributedMinigameAI import * -from direct.fsm import ClassicFSM, State -from direct.fsm import State -from toontown.minigame import PlayingCardGlobals -from toontown.minigame import PlayingCard -from toontown.minigame.PlayingCard import PlayingCardBase -from toontown.minigame import PlayingCardDeck -from toontown.minigame import PairingGameGlobals -from toontown.ai.ToonBarrier import ToonBarrier - -class DistributedPairingGameAI(DistributedMinigameAI): - notify = directNotify.newCategory('DistributedPairingGameAI') - OneCardInMultiplayer = True - TurnDownTwoAtATime = True - - def __init__(self, air, minigameId): - try: - self.DistributedPairingGameAI_initialized - except: - self.DistributedPairingGameAI_initialized = 1 - DistributedMinigameAI.__init__(self, air, minigameId) - self.gameFSM = ClassicFSM.ClassicFSM('DistributedPairingGameAI', [State.State('inactive', self.enterInactive, self.exitInactive, ['play']), State.State('play', self.enterPlay, self.exitPlay, ['cleanup']), State.State('cleanup', self.enterCleanup, self.exitCleanup, ['inactive'])], 'inactive', 'inactive') - self.addChildGameFSM(self.gameFSM) - self.gameFSM.enterInitialState() - self.deckSeed = random.randint(0, 4000000) - self.faceUpDict = {} - self.inactiveList = [] - self.maxOpenCards = 2 - self.points = 0 - self.flips = 0 - self.matches = 0 - self.cards = [] - self.gameDuration = 90 - - def generate(self): - self.notify.debug('generate') - DistributedMinigameAI.generate(self) - - def delete(self): - self.notify.debug('delete') - del self.gameFSM - DistributedMinigameAI.delete(self) - - def setGameReady(self): - self.notify.debug('setGameReady') - if self.OneCardInMultiplayer and len(self.avIdList) > 1: - self.maxOpenCards = 1 - self.sendUpdate('setMaxOpenCards', [self.maxOpenCards]) - DistributedMinigameAI.setGameReady(self) - for avId in self.avIdList: - self.faceUpDict[avId] = [] - - self.deck = PairingGameGlobals.createDeck(self.deckSeed, self.numPlayers) - for index in xrange(len(self.deck.cards)): - cardValue = self.deck.cards[index] - oneCard = PlayingCardBase(cardValue) - self.cards.append(oneCard) - - def setGameStart(self, timestamp): - self.notify.debug('setGameStart') - DistributedMinigameAI.setGameStart(self, timestamp) - self.gameFSM.request('play') - - def setGameAbort(self): - self.notify.debug('setGameAbort') - if self.gameFSM.getCurrentState(): - self.gameFSM.request('cleanup') - DistributedMinigameAI.setGameAbort(self) - - def calcLowFlipBonus(self): - lowFlipModifier = PairingGameGlobals.calcLowFlipModifier(self.matches, self.flips) - bonus = lowFlipModifier * self.matches - self.notify.debug('low flip bonus = %d' % bonus) - return bonus - - def gameOver(self): - self.notify.debug('gameOver') - lowFlipBonus = 0 - for avId in self.avIdList: - self.scoreDict[avId] = max(1, self.points) - lowFlipBonus = self.calcLowFlipBonus() - self.scoreDict[avId] += lowFlipBonus - if self.matches == len(self.cards) / 2: - self.scoreDict[avId] += round(len(self.cards) / 4.0) - self.logAllPerfect() - - logAvId = self.avIdList[0] - self.air.writeServerEvent('minigame_pairing', self.doId, '%s|%s|%s|%s|%s|%s|%s|%s' % (ToontownGlobals.PairingGameId, - self.getSafezoneId(), - self.avIdList, - self.scoreDict[logAvId], - self.gameDuration, - self.matches, - self.flips, - lowFlipBonus)) - self.gameFSM.request('cleanup') - DistributedMinigameAI.gameOver(self) - - def enterInactive(self): - self.notify.debug('enterInactive') - - def exitInactive(self): - pass - - def enterPlay(self): - self.notify.debug('enterPlay') - - def allToonsDone(self = self): - self.notify.debug('allToonsDone') - self.sendUpdate('setEveryoneDone') - if not PairingGameGlobals.EndlessGame: - self.gameOver() - - def handleTimeout(avIds, self = self): - self.notify.debug('handleTimeout: avatars %s did not report "done"' % avIds) - self.setGameAbort() - - self.gameDuration = PairingGameGlobals.calcGameDuration(self.getDifficulty()) - self.doneBarrier = ToonBarrier('waitClientsDone', self.uniqueName('waitClientsDone'), self.avIdList, self.gameDuration + MinigameGlobals.latencyTolerance, allToonsDone, handleTimeout) - - def exitPlay(self): - self.doneBarrier.cleanup() - del self.doneBarrier - - def enterCleanup(self): - self.notify.debug('enterCleanup') - self.gameFSM.request('inactive') - - def exitCleanup(self): - pass - - def getDeckSeed(self): - return self.deckSeed - - def isCardFaceUp(self, deckOrderIndex): - retval = False - for key in self.faceUpDict.keys(): - if deckOrderIndex in self.faceUpDict[key]: - retval = True - break - - return retval - - def isCardFaceDown(self, deckOrderIndex): - return not self.isCardFaceUp(deckOrderIndex) - - def checkForMatch(self): - faceUpList = [] - for oneToonFaceUpList in self.faceUpDict.values(): - faceUpList += oneToonFaceUpList - - for i in xrange(len(faceUpList)): - cardA = faceUpList[i] - for j in xrange(i + 1, len(faceUpList)): - cardB = faceUpList[j] - if self.cards[cardA].rank == self.cards[cardB].rank: - return (cardA, cardB) - - return (-1, -1) - - def handleMatch(self, cardA, cardB): - self.notify.debug('we got a match %d %d' % (cardA, cardB)) - for key in self.faceUpDict.keys(): - if cardA in self.faceUpDict[key]: - self.faceUpDict[key].remove(cardA) - if cardB in self.faceUpDict[key]: - self.faceUpDict[key].remove(cardB) - - self.inactiveList.append(cardA) - self.inactiveList.append(cardB) - - def turnDownCard(self, cardA): - self.notify.debug('turning down card %d' % cardA) - for key in self.faceUpDict.keys(): - if cardA in self.faceUpDict[key]: - self.faceUpDict[key].remove(cardA) - - def openCardRequest(self, deckOrderIndex, bonusGlowCard): - if self.isCardFaceUp(deckOrderIndex): - return - if self.gameFSM.getCurrentState().getName() != 'play': - return - avId = self.air.getAvatarIdFromSender() - if avId not in self.avIdList: - self.air.writeServerEvent('suspicious', avId, 'openCardRequest from non-player av %s' % avId) - return - if deckOrderIndex < 0 or deckOrderIndex >= len(self.cards): - self.air.writeServerEvent('suspicious', avId, 'openCardRequest: invalid deckOrderIndex: %s' % deckOrderIndex) - return - if bonusGlowCard < 0 or bonusGlowCard >= len(self.cards): - self.air.writeServerEvent('suspicious', avId, 'openCardRequest: invalid bonusGlowCard: %s' % bonusGlowCard) - return - cardsToTurnDown = [] - faceUpList = self.faceUpDict[avId] - numCardsFaceUpAtStart = len(faceUpList) - if len(faceUpList) >= self.maxOpenCards: - oldestCard = faceUpList.pop(0) - cardsToTurnDown.append(oldestCard) - if self.TurnDownTwoAtATime and numCardsFaceUpAtStart == 2: - secondOldestCard = faceUpList.pop(0) - cardsToTurnDown.append(secondOldestCard) - cardToTurnUp = deckOrderIndex - self.faceUpDict[avId].append(cardToTurnUp) - cardA, cardB = self.checkForMatch() - matchingCard = -1 - if cardA > -1: - self.handleMatch(cardA, cardB) - if cardA == deckOrderIndex: - matchingCard = cardB - else: - matchingCard = cardA - pointsToGive = 1 - if bonusGlowCard in [cardA, cardB]: - pointsToGive += 1 - self.points += pointsToGive - self.matches += 1 - self.flips += 1 - self.sendUpdate('openCardResult', [cardToTurnUp, - avId, - matchingCard, - self.points, - cardsToTurnDown]) - - def reportDone(self): - if self.gameFSM.getCurrentState().getName() != 'play': - return - avId = self.air.getAvatarIdFromSender() - self.notify.debug('reportDone: avatar %s is done' % avId) - self.doneBarrier.clear(avId) diff --git a/toontown/minigame/DistributedTravelGame.py b/toontown/minigame/DistributedTravelGame.py deleted file mode 100644 index 743b34a5..00000000 --- a/toontown/minigame/DistributedTravelGame.py +++ /dev/null @@ -1,1035 +0,0 @@ -from pandac.PandaModules import * -from toontown.toonbase.ToonBaseGlobal import * -from toontown.toonbase.ToontownGlobals import GlobalDialogColor -from DistributedMinigame import * -from direct.fsm import ClassicFSM, State -from direct.fsm import State -from toontown.toonbase import TTLocalizer -from toontown.toonbase import ToontownTimer -import TravelGameGlobals -import math -from pandac.PandaModules import rad2Deg -from toontown.toontowngui import TTDialog -from direct.interval.IntervalGlobal import * -import VoteResultsPanel -import VoteResultsTrolleyPanel -IconDict = {ToontownGlobals.RaceGameId: 'mg_trolley_sign_race', - ToontownGlobals.CannonGameId: 'mg_trolley_sign_cannon', - ToontownGlobals.TagGameId: 'mg_trolley_sign_tag', - ToontownGlobals.PatternGameId: 'mg_trolley_sign_minnie', - ToontownGlobals.RingGameId: 'mg_trolley_sign_ring', - ToontownGlobals.MazeGameId: 'mg_trolley_sign_maze', - ToontownGlobals.TugOfWarGameId: 'mg_trolley_sign_tugawar', - ToontownGlobals.CatchGameId: 'mg_trolley_sign_catch', - ToontownGlobals.DivingGameId: 'mg_trolley_sign_dive', - ToontownGlobals.TargetGameId: 'mg_trolley_sign_umbrella', - ToontownGlobals.PairingGameId: 'mg_trolley_sign_card', - ToontownGlobals.VineGameId: 'mg_trolley_sign_vine', - ToontownGlobals.IceGameId: 'mg_trolley_sign_ice', - ToontownGlobals.PhotoGameId: 'mg_trolley_sign_photo', - ToontownGlobals.TwoDGameId: 'mg_trolley_sign_2d', - ToontownGlobals.CogThiefGameId: 'mg_trolley_sign_theif'} -MinigameNameDict = {ToontownGlobals.RaceGameId: TTLocalizer.RaceGameTitle, - ToontownGlobals.CannonGameId: TTLocalizer.CannonGameTitle, - ToontownGlobals.TagGameId: TTLocalizer.TagGameTitle, - ToontownGlobals.PatternGameId: TTLocalizer.PatternGameTitle, - ToontownGlobals.RingGameId: TTLocalizer.RingGameTitle, - ToontownGlobals.MazeGameId: TTLocalizer.MazeGameTitle, - ToontownGlobals.TugOfWarGameId: TTLocalizer.TugOfWarGameTitle, - ToontownGlobals.CatchGameId: TTLocalizer.CatchGameTitle, - ToontownGlobals.DivingGameId: TTLocalizer.DivingGameTitle, - ToontownGlobals.TargetGameId: TTLocalizer.TargetGameTitle, - ToontownGlobals.PairingGameId: TTLocalizer.PairingGameTitle, - ToontownGlobals.VineGameId: TTLocalizer.VineGameTitle, - ToontownGlobals.TravelGameId: TTLocalizer.TravelGameTitle, - ToontownGlobals.IceGameId: TTLocalizer.IceGameTitle, - ToontownGlobals.PhotoGameId: TTLocalizer.PhotoGameTitle, - ToontownGlobals.TwoDGameId: TTLocalizer.TwoDGameTitle, - ToontownGlobals.CogThiefGameId: TTLocalizer.CogThiefGameTitle} - -def makeLabel(itemName, itemNum, *extraArgs): - intVersion = int(itemName) - if intVersion < 0: - textColor = Vec4(0, 0, 1, 1) - intVersion = -intVersion - elif intVersion == 0: - textColor = Vec4(0, 0, 0, 1) - else: - textColor = Vec4(1, 0, 0, 1) - return DirectLabel(text=str(intVersion), text_fg=textColor, relief=DGG.RIDGE, frameSize=(-1.2, - 1.2, - -0.225, - 0.8), scale=1.0) - - -def map3dToAspect2d(node, point): - p3 = base.cam.getRelativePoint(node, point) - p2 = Point2() - if not base.camLens.project(p3, p2): - return None - r2d = Point3(p2[0], 0, p2[1]) - a2d = aspect2d.getRelativePoint(render2d, r2d) - return a2d - - -def invertTable(table): - index = {} - for key in table.keys(): - value = table[key] - if value not in index: - index[value] = key - - return index - - -class DistributedTravelGame(DistributedMinigame): - notify = directNotify.newCategory('DistributedTravelGame') - idToNames = MinigameNameDict - TrolleyMoveDuration = 3 - UseTrolleyResultsPanel = True - FlyCameraUp = True - FocusOnTrolleyWhileMovingUp = False - - def __init__(self, cr): - DistributedMinigame.__init__(self, cr) - self.gameFSM = ClassicFSM.ClassicFSM('DistributedTravelGame', [State.State('off', self.enterOff, self.exitOff, ['inputChoice']), - State.State('inputChoice', self.enterInputChoice, self.exitInputChoice, ['waitServerChoices', 'displayVotes', 'cleanup']), - State.State('waitServerChoices', self.enterWaitServerChoices, self.exitWaitServerChoices, ['displayVotes', 'cleanup']), - State.State('displayVotes', self.enterDisplayVotes, self.exitDisplayVotes, ['moveTrolley', 'cleanup']), - State.State('moveTrolley', self.enterMoveTrolley, self.exitMoveTrolley, ['inputChoice', 'winMovie', 'cleanup']), - State.State('winMovie', self.enterWinMovie, self.exitWinMovie, ['cleanup']), - State.State('cleanup', self.enterCleanup, self.exitCleanup, [])], 'off', 'cleanup') - self.addChildGameFSM(self.gameFSM) - self.currentVotes = {} - self.cameraTopView = (100, -20, 280, 0, -89, 0) - self.timer = None - self.timerStartTime = None - self.currentSwitch = 0 - self.destSwitch = 0 - self.minigameLabels = [] - self.minigameIcons = [] - self.bonusLabels = [] - self.trolleyAwaySfx = base.loadSfx('phase_4/audio/sfx/SZ_trolley_away.ogg') - self.trolleyBellSfx = base.loadSfx('phase_4/audio/sfx/SZ_trolley_bell.ogg') - self.turntableRotateSfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_turntble_rotate_2.ogg') - self.wonGameSfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_bonus.ogg') - self.lostGameSfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_no_bonus_2.ogg') - self.noWinnerSfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_no_bonus.ogg') - self.boardIndex = 0 - self.avNames = [] - self.disconnectedAvIds = [] - return - - def getTitle(self): - return TTLocalizer.TravelGameTitle - - def getInstructions(self): - return TTLocalizer.TravelGameInstructions - - def getMaxDuration(self): - return 0 - - def load(self): - self.notify.debug('load') - DistributedMinigame.load(self) - self.sky = loader.loadModel('phase_3.5/models/props/TT_sky') - self.gameBoard = loader.loadModel('phase_4/models/minigames/toon_cannon_gameground') - self.gameBoard.setPosHpr(100, 0, 0, 0, 0, 0) - self.gameBoard.setScale(1.0) - station = loader.loadModel('phase_4/models/modules/trolley_station_TT.bam') - self.trolleyCar = station.find('**/trolley_car') - self.trolleyCar.reparentTo(hidden) - self.trolleyCarOrigPos = self.trolleyCar.getPos() - self.trolleyCarOrigHpr = self.trolleyCar.getHpr() - self.trolleyCar.setPosHpr(0, 0, 0, 0, 0, 0) - self.trolleyCar.setScale(1.0) - self.trolleyCar.setX(self.trolleyCar.getX() - TravelGameGlobals.xInc) - station.removeNode() - self.keys = self.trolleyCar.findAllMatches('**/key') - self.numKeys = self.keys.getNumPaths() - self.keyInit = [] - self.keyRef = [] - for i in xrange(self.numKeys): - key = self.keys[i] - key.setTwoSided(1) - ref = self.trolleyCar.attachNewNode('key' + `i` + 'ref') - ref.iPosHpr(key) - self.keyRef.append(ref) - self.keyInit.append(key.getTransform()) - - self.frontWheels = self.trolleyCar.findAllMatches('**/front_wheels') - self.numFrontWheels = self.frontWheels.getNumPaths() - self.frontWheelInit = [] - self.frontWheelRef = [] - for i in xrange(self.numFrontWheels): - wheel = self.frontWheels[i] - ref = self.trolleyCar.attachNewNode('frontWheel' + `i` + 'ref') - ref.iPosHpr(wheel) - self.frontWheelRef.append(ref) - self.frontWheelInit.append(wheel.getTransform()) - - self.backWheels = self.trolleyCar.findAllMatches('**/back_wheels') - self.numBackWheels = self.backWheels.getNumPaths() - self.backWheelInit = [] - self.backWheelRef = [] - for i in xrange(self.numBackWheels): - wheel = self.backWheels[i] - ref = self.trolleyCar.attachNewNode('backWheel' + `i` + 'ref') - ref.iPosHpr(wheel) - self.backWheelRef.append(ref) - self.backWheelInit.append(wheel.getTransform()) - - trolleyAnimationReset = Func(self.resetAnimation) - self.trainSwitches = {} - self.trainTracks = {} - self.tunnels = {} - self.extraTrainTracks = [] - turnTable = loader.loadModel('phase_4/models/minigames/trolley_game_turntable') - minPoint = Point3(0, 0, 0) - maxPoint = Point3(0, 0, 0) - turnTable.calcTightBounds(minPoint, maxPoint) - self.fullLength = maxPoint[0] - for key in TravelGameGlobals.BoardLayouts[self.boardIndex].keys(): - info = TravelGameGlobals.BoardLayouts[self.boardIndex][key] - switchModel = turnTable.find('**/turntable1').copyTo(render) - switchModel.setPos(*info['pos']) - switchModel.reparentTo(hidden) - self.trainSwitches[key] = switchModel - depthOffset = 0 - for otherSwitch in info['links']: - info2 = TravelGameGlobals.BoardLayouts[self.boardIndex][otherSwitch] - x1, y1, z1 = info['pos'] - x2, y2, z2 = info2['pos'] - linkKey = (key, otherSwitch) - trainTrack = self.loadTrainTrack(x1, y1, x2, y2, depthOffset) - trainTrack.reparentTo(hidden) - self.trainTracks[linkKey] = trainTrack - depthOffset += 3 - switchModel.setDepthOffset(depthOffset) - - rootInfo = TravelGameGlobals.BoardLayouts[self.boardIndex][0] - rootX, rootY, rootZ = rootInfo['pos'] - startX = rootX - TravelGameGlobals.xInc - - tempModel = loader.loadModel('phase_4/models/minigames/trolley_game_turntable') - self.entryTunnel = tempModel.find('**/tunnel1') - self.entryTunnel.reparentTo(render) - self.entryTunnel.setH(180) - self.entryTunnel.setPos(startX, rootY, rootZ) - tempModel.removeNode() - - trainTrack = self.loadTrainTrack(startX, rootY, rootX, rootY) - self.extraTrainTracks.append(trainTrack) - tunnelX = None - for key in TravelGameGlobals.BoardLayouts[self.boardIndex].keys(): - if self.isLeaf(key): - info = TravelGameGlobals.BoardLayouts[self.boardIndex][key] - switchX, switchY, switchZ = info['pos'] - endX = switchX + TravelGameGlobals.xInc - trainTrack = self.loadTrainTrack(switchX, switchY, endX, switchY) - self.extraTrainTracks.append(trainTrack) - tempModel = loader.loadModel('phase_4/models/minigames/trolley_game_turntable') - tunnel = tempModel.find('**/tunnel1') - tunnel.reparentTo(render) - tempModel.removeNode() - if not tunnelX: - minTrackPoint = Point3(0, 0, 0) - maxTrackPoint = Point3(0, 0, 0) - trainTrack.calcTightBounds(minTrackPoint, maxTrackPoint) - tunnelX = maxTrackPoint[0] - tunnel.setPos(tunnelX, switchY, 0) - tunnel.wrtReparentTo(trainTrack) - self.tunnels[key] = tunnel - - self.clipPlane = render.attachNewNode(PlaneNode('clipPlane')) - self.clipPlane.setR(-90) - self.clipPlane.setX(tunnelX) - self.trolleyCar.setClipPlane(self.clipPlane) - - turnTable.removeNode() - self.loadGui() - self.introMovie = self.getIntroMovie() - self.music = base.loadMusic('phase_4/audio/bgm/MG_Travel.ogg') - self.flashWinningBeansTrack = None - return - - def loadTrainTrack(self, x1, y1, x2, y2, depthOffset = 0): - turnTable = loader.loadModel('phase_4/models/minigames/trolley_game_turntable') - trainPart = turnTable.find('**/track_a2') - trackHeight = 0.03 - trainTrack = render.attachNewNode('trainTrack%d%d%d%d' % (x1, - y1, - x2, - y2)) - trainTrack.setPos(x1, y1, trackHeight) - xDiff = abs(x2 - x1) - yDiff = abs(y2 - y1) - angleInRadians = math.atan((float(y2) - y1) / (x2 - x1)) - angle = rad2Deg(angleInRadians) - desiredLength = math.sqrt(xDiff * xDiff + yDiff * yDiff) - lengthToGo = desiredLength - partIndex = 0 - lengthCovered = 0 - while lengthToGo > self.fullLength / 2.0: - onePart = trainPart.copyTo(trainTrack) - onePart.setX(lengthCovered) - lengthToGo -= self.fullLength - lengthCovered += self.fullLength - - trainTrack.setH(angle) - newX = x1 + (x2 - x1) / 2.0 - newY = y1 + (y2 - y1) / 2.0 - trainTrack.setPos(x1, y1, trackHeight) - trainTrack.setDepthOffset(depthOffset) - turnTable.removeNode() - return trainTrack - - def loadGui(self): - scoreText = [str(self.currentVotes[self.localAvId])] - self.gui = DirectFrame() - self.remainingVotesFrame = DirectFrame(parent=self.gui, relief=None, geom=DGG.getDefaultDialogGeom(), geom_color=GlobalDialogColor, geom_scale=(7, 1, 1), pos=(-0.9, 0, 0.8), scale=0.1, text=TTLocalizer.TravelGameRemainingVotes, text_align=TextNode.ALeft, text_scale=TTLocalizer.DTGremainingVotesFrame, text_pos=(-3.4, -0.1, 0.0)) - self.localVotesRemaining = DirectLabel(parent=self.remainingVotesFrame, relief=None, text=scoreText, text_fg=VBase4(0, 0.5, 0, 1), text_align=TextNode.ARight, text_scale=0.7, pos=(3.2, 0, -0.15)) - guiModel = loader.loadModel('phase_3.5/models/gui/friendslist_gui') - self.choiceFrame = DirectFrame(parent=self.gui, relief=None, pos=(-0.55, 0, -0.85), image=DGG.getDefaultDialogGeom(), image_scale=(1.4, 1, 0.225), image_color=GlobalDialogColor) - self.useLabel = DirectLabel(text=TTLocalizer.TravelGameUse, parent=self.choiceFrame, pos=(-0.59, 0, -0.01), text_scale=TTLocalizer.DTGuseLabel, relief=None) - self.votesPeriodLabel = DirectLabel(text=TTLocalizer.TravelGameVotesWithPeriod, parent=self.choiceFrame, pos=(-0.21, 0, -0.01), text_scale=TTLocalizer.DTGvotesPeriodLabel, relief=None, text_align=TextNode.ALeft) - self.votesToGoLabel = DirectLabel(text=TTLocalizer.TravelGameVotesToGo, parent=self.choiceFrame, pos=(-0.21, 0, -0.01), text_scale=TTLocalizer.DTGvotesToGoLabel, relief=None, text_align=TextNode.ALeft) - self.upLabel = DirectLabel(text=TTLocalizer.TravelGameUp, parent=self.choiceFrame, pos=(0.31, 0, -0.01), text_scale=TTLocalizer.DTGupLabel, text_fg=Vec4(0, 0, 1, 1), relief=None, text_align=TextNode.ALeft) - self.downLabel = DirectLabel(text=TTLocalizer.TravelGameDown, parent=self.choiceFrame, pos=(0.31, 0, -0.01), text_scale=TTLocalizer.DTGdownLabel, text_fg=Vec4(1, 0, 0, 1), relief=None, text_align=TextNode.ALeft) - self.scrollList = DirectScrolledList(parent=self.choiceFrame, relief=None, pos=(-0.36, 0, -0.02), incButton_image=(guiModel.find('**/FndsLst_ScrollUp'), - guiModel.find('**/FndsLst_ScrollDN'), - guiModel.find('**/FndsLst_ScrollUp_Rllvr'), - guiModel.find('**/FndsLst_ScrollUp')), incButton_relief=None, incButton_pos=(0.0, 0.0, -0.04), incButton_image3_color=Vec4(0.6, 0.6, 0.6, 0.6), incButton_scale=(1.0, 1.0, -1.0), decButton_image=(guiModel.find('**/FndsLst_ScrollUp'), - guiModel.find('**/FndsLst_ScrollDN'), - guiModel.find('**/FndsLst_ScrollUp_Rllvr'), - guiModel.find('**/FndsLst_ScrollUp')), decButton_relief=None, decButton_pos=(0.0, 0.0, 0.095), decButton_image3_color=Vec4(0.6, 0.6, 0.6, 0.6), itemFrame_pos=(0.0, 0.0, 0.0), itemFrame_relief=DGG.GROOVE, numItemsVisible=1, itemMakeFunction=makeLabel, items=[], scrollSpeed=3.0, itemFrame_scale=0.1, command=self.scrollChoiceChanged) - self.putChoicesInScrollList() - buttons = loader.loadModel('phase_3/models/gui/dialog_box_buttons_gui') - okImageList = (buttons.find('**/ChtBx_OKBtn_UP'), buttons.find('**/ChtBx_OKBtn_DN'), buttons.find('**/ChtBx_OKBtn_Rllvr')) - self.voteButton = DirectButton(parent=self.choiceFrame, relief=None, image=okImageList, image_scale=3.0, pos=(0.85, 0, 0.0), text=TTLocalizer.TravelGameVoteWithExclamation, text_scale=TTLocalizer.DTGvoteButton, text_pos=(0, 0), command=self.handleInputChoice) - self.waitingChoicesLabel = DirectLabel(text=TTLocalizer.TravelGameWaitingChoices, text_fg=VBase4(1, 1, 1, 1), relief=None, pos=(-0.2, 0, -0.85), scale=0.075) - self.waitingChoicesLabel.hide() - self.gui.hide() - return - - def unload(self): - self.notify.debug('unload') - DistributedMinigame.unload(self) - self.introMovie.finish() - del self.introMovie - self.gameBoard.removeNode() - del self.gameBoard - self.sky.removeNode() - del self.sky - self.clipPlane.removeNode() - del self.clipPlane - self.entryTunnel.removeNode() - del self.entryTunnel - self.trolleyCar.removeNode() - del self.trolleyCar - for key in self.trainSwitches.keys(): - self.trainSwitches[key].removeNode() - del self.trainSwitches[key] - - self.trainSwitches = {} - for key in self.tunnels.keys(): - self.tunnels[key].removeNode() - del self.tunnels[key] - - self.tunnels = {} - for key in self.trainTracks.keys(): - self.trainTracks[key].removeNode() - del self.trainTracks[key] - - self.trainTracks = {} - for trainTrack in self.extraTrainTracks: - trainTrack.removeNode() - del trainTrack - - self.extraTrainTracks = [] - self.gui.removeNode() - del self.gui - self.waitingChoicesLabel.destroy() - del self.waitingChoicesLabel - if self.flashWinningBeansTrack: - self.flashWinningBeansTrack.finish() - del self.flashWinningBeansTrack - for label in self.minigameLabels: - label.destroy() - del label - - self.minigameLabels = [] - for icon in self.minigameIcons: - icon.destroy() - icon.removeNode() - - self.minigameIcons = [] - if hasattr(self, 'mg_icons'): - del self.mg_icons - for label in self.bonusLabels: - label.destroy() - del label - - self.bonusLabels = [] - self.scrollList.destroy() - del self.scrollList - self.voteButton.destroy() - del self.voteButton - self.removeChildGameFSM(self.gameFSM) - del self.gameFSM - del self.music - - def moveCameraToTop(self): - camera.reparentTo(render) - p = self.cameraTopView - camera.setPosHpr(p[0], p[1], p[2], p[3], p[4], p[5]) - - def moveCameraToTrolley(self): - camera.reparentTo(self.trolleyCar) - camera.setPos(-25, 0, 7.5) - camera.setHpr(-90, 0, 0) - - def onstage(self): - self.notify.debug('onstage') - NametagGlobals.setForceOnscreenChat(True) - DistributedMinigame.onstage(self) - self.gameBoard.reparentTo(render) - self.sky.reparentTo(render) - self.moveCameraToTop() - self.trolleyCar.reparentTo(render) - for key in self.trainSwitches.keys(): - self.trainSwitches[key].reparentTo(render) - - for key in self.trainTracks.keys(): - self.trainTracks[key].reparentTo(render) - - for trainTrack in self.extraTrainTracks: - trainTrack.reparentTo(render) - - base.transitions.irisIn(0.4) - base.setBackgroundColor(0.1875, 0.7929, 0) - base.playMusic(self.music, looping=1, volume=0.9) - self.introMovie.start() - - def offstage(self): - self.notify.debug('offstage') - NametagGlobals.setForceOnscreenChat(False) - base.setBackgroundColor(ToontownGlobals.DefaultBackgroundColor) - self.introMovie.finish() - self.gameBoard.hide() - self.sky.hide() - self.trolleyCar.hide() - self.gui.hide() - self.hideMinigamesAndBonuses() - for key in self.trainSwitches.keys(): - self.trainSwitches[key].hide() - - for key in self.trainTracks.keys(): - self.trainTracks[key].hide() - - for trainTrack in self.extraTrainTracks: - trainTrack.hide() - - DistributedMinigame.offstage(self) - if base.localAvatar.laffMeter: - base.localAvatar.laffMeter.start() - self.music.stop() - - def setGameReady(self): - if not self.hasLocalToon: - return - self.notify.debug('setGameReady') - if DistributedMinigame.setGameReady(self): - return - for index in xrange(self.numPlayers): - avId = self.avIdList[index] - name = '' - avatar = self.getAvatar(avId) - if avatar: - avatar.reparentTo(self.trolleyCar) - avatar.animFSM.request('Sit') - avatar.setPosHpr(-4, -4.5 + index * 3, 2.8, 90, 0, 0) - name = avatar.getName() - self.avNames.append(name) - - self.trolleyCar.setH(90) - - def setGameStart(self, timestamp): - if not self.hasLocalToon: - return - self.notify.debug('setGameStart') - DistributedMinigame.setGameStart(self, timestamp) - self.introMovie.finish() - self.gameFSM.request('inputChoice') - - def enterOff(self): - self.notify.debug('enterOff') - - def exitOff(self): - pass - - def enterInputChoice(self): - self.notify.debug('enterInputChoice') - NametagGlobals.setForceOnscreenChat(True) - self.timer = ToontownTimer.ToontownTimer() - self.timer.hide() - if self.timerStartTime != None: - self.startTimer() - if base.localAvatar.laffMeter: - base.localAvatar.laffMeter.stop() - self.gui.show() - self.showMinigamesAndBonuses() - return - - def exitInputChoice(self): - NametagGlobals.setForceOnscreenChat(False) - if self.timer != None: - self.timer.destroy() - self.timer = None - self.timerStartTime = None - self.gui.hide() - return - - def enterWaitServerChoices(self): - self.notify.debug('enterWaitServerChoices') - self.waitingChoicesLabel.show() - self.gui.hide() - - def exitWaitServerChoices(self): - self.waitingChoicesLabel.hide() - - def enterDisplayVotes(self, votes, directions, directionToGo, directionReason): - if self.UseTrolleyResultsPanel: - self.moveCameraToTrolley() - self.hideMinigamesAndBonuses() - else: - self.moveCameraToTop() - self.resultVotes = votes - self.resultDirections = directions - self.directionToGo = directionToGo - self.directionReason = directionReason - self.resultsStr = '' - directionTotals = [0] * TravelGameGlobals.MaxDirections - for index in xrange(len(votes)): - if index < len(self.avNames): - avId = self.avIdList[index] - dir = directions[index] - numVotes = votes[index] - directionTotals[dir] += numVotes - curStr = TTLocalizer.TravelGameOneToonVote % {'name': self.avNames[index], - 'numVotes': numVotes, - 'dir': TTLocalizer.TravelGameDirections[dir]} - if not (numVotes == 0 and avId in self.disconnectedAvIds): - self.resultsStr += curStr - - directionStr = TTLocalizer.TravelGameTotals - for index in xrange(len(directionTotals)): - directionStr += ' ' + TTLocalizer.TravelGameDirections[index] + ':' - directionStr += str(directionTotals[index]) - - directionStr += '\n' - self.resultsStr += directionStr - reasonStr = '' - if directionReason == TravelGameGlobals.ReasonVote: - if directionToGo == 0: - losingDirection = 1 - else: - losingDirection = 0 - diffVotes = directionTotals[directionToGo] - directionTotals[losingDirection] - reasonStr = '' - if diffVotes > 1: - reasonStr = TTLocalizer.TravelGameReasonVotesPlural % {'dir': TTLocalizer.TravelGameDirections[directionToGo], - 'numVotes': diffVotes} - else: - reasonStr = TTLocalizer.TravelGameReasonVotesSingular % {'dir': TTLocalizer.TravelGameDirections[directionToGo], - 'numVotes': diffVotes} - elif directionReason == TravelGameGlobals.ReasonRandom: - reasonStr = TTLocalizer.TravelGameReasonRandom % {'dir': TTLocalizer.TravelGameDirections[directionToGo], - 'numVotes': directionTotals[directionToGo]} - elif directionReason == TravelGameGlobals.ReasonPlaceDecider: - reasonStr = TravelGameReasonPlace % {'name': 'TODO NAME', - 'dir': TTLocalizer.TravelGameDirections[directionToGo]} - self.resultsStr += reasonStr - self.dialog = TTDialog.TTDialog(text=self.resultsStr, command=self.__cleanupDialog, style=TTDialog.NoButtons, pos=(0, 0, 1)) - self.dialog.hide() - if self.UseTrolleyResultsPanel: - self.votesPanel = VoteResultsTrolleyPanel.VoteResultsTrolleyPanel(len(self.avIdList), self.avIdList, votes, directions, self.avNames, self.disconnectedAvIds, directionToGo, directionReason, directionTotals) - else: - self.votesPanel = VoteResultsPanel.VoteResultsPanel(len(self.avIdList), self.avIdList, votes, directions, self.avNames, self.disconnectedAvIds, directionToGo, directionReason, directionTotals) - self.votesPanel.startMovie() - numPlayers = len(self.avIdList) - if TravelGameGlobals.SpoofFour: - numPlayers = 4 - delay = TravelGameGlobals.DisplayVotesTimePerPlayer * (numPlayers + 1) - taskMgr.doMethodLater(delay, self.displayVotesTimeoutTask, self.taskName('displayVotes-timeout')) - curSwitch = TravelGameGlobals.BoardLayouts[self.boardIndex][self.currentSwitch] - self.destSwitch = curSwitch['links'][directionToGo] - self.updateCurrentVotes() - - def exitDisplayVotes(self): - taskMgr.remove(self.taskName('displayVotes-timeout')) - self.__cleanupDialog(0) - if not self.UseTrolleyResultsPanel: - self.showMinigamesAndBonuses() - self.votesPanel.destroy() - - def enterMoveTrolley(self): - self.notify.debug('enterMoveTrolley') - camera.wrtReparentTo(render) - keyAngle = round(self.TrolleyMoveDuration) * 360 - dist = Vec3(self.trainSwitches[self.destSwitch].getPos() - self.trainSwitches[self.currentSwitch].getPos()).length() - wheelAngle = dist / (2.0 * math.pi * 0.95) * 360 - trolleyAnimateInterval = LerpFunctionInterval(self.animateTrolley, duration=self.TrolleyMoveDuration, blendType='easeInOut', extraArgs=[keyAngle, wheelAngle], name='TrolleyAnimate') - moveTrolley = Sequence() - moveTrolley.append(Func(self.resetAnimation)) - newPos = self.trainSwitches[self.destSwitch].getPos() - linkKey = (self.currentSwitch, self.destSwitch) - origHeading = self.trainTracks[linkKey].getH() - heading = origHeading + 90 - firstTurn = Parallel() - firstTurn.append(LerpHprInterval(self.trolleyCar, 1, Vec3(heading, 0, 0))) - firstTurn.append(LerpHprInterval(self.trainSwitches[self.currentSwitch], 1, Vec3(origHeading, 0, 0))) - firstTurn.append(LerpHprInterval(self.trainSwitches[self.destSwitch], 1, Vec3(origHeading, 0, 0))) - moveTrolley.append(firstTurn) - moveTrolley.append(Parallel(LerpPosInterval(self.trolleyCar, self.TrolleyMoveDuration, newPos, blendType='easeInOut'), trolleyAnimateInterval)) - secondTurn = Parallel() - secondTurn.append(LerpHprInterval(self.trolleyCar, 1, Vec3(90, 0, 0))) - secondTurn.append(LerpHprInterval(self.trainSwitches[self.currentSwitch], 1, Vec3(0, 0, 0))) - secondTurn.append(LerpHprInterval(self.trainSwitches[self.destSwitch], 1, Vec3(0, 0, 0))) - moveTrolley.append(secondTurn) - soundTrack = Sequence() - trolleyExitBellInterval = Parallel(SoundInterval(self.trolleyBellSfx, duration=1), SoundInterval(self.turntableRotateSfx, duration=1, volume=0.5)) - trolleyExitAwayInterval = SoundInterval(self.trolleyAwaySfx, duration=3) - soundTrack.append(trolleyExitBellInterval) - soundTrack.append(trolleyExitAwayInterval) - soundTrack.append(trolleyExitBellInterval) - self.moveTrolleyIval = Parallel(moveTrolley, soundTrack) - duration = self.moveTrolleyIval.getDuration() - - def focusOnTrolley(t, self = self): - pos = self.trolleyCar.getPos() - pos.setZ(pos.getZ() + 7.5) - camera.lookAt(pos) - self.lastFocusHpr = camera.getHpr() - - setRightHprTime = 0 - if self.FlyCameraUp: - setRightHprTime = 1.0 - camIval1 = Parallel() - camIval1.append(LerpFunc(focusOnTrolley, duration - setRightHprTime, name='focusOnTrolley')) - finalPos = Vec3(self.cameraTopView[0], self.cameraTopView[1], self.cameraTopView[2]) - finalHpr = Vec3(self.cameraTopView[3], self.cameraTopView[4], self.cameraTopView[5]) - if self.FlyCameraUp: - if self.FocusOnTrolleyWhileMovingUp: - camIval1.append(LerpPosInterval(camera, duration - setRightHprTime, finalPos, name='cameraMove')) - camIval2 = Sequence(LerpHprInterval(camera, setRightHprTime, finalHpr, name='cameraHpr')) - else: - camIval2 = Sequence(LerpPosHprInterval(camera, setRightHprTime, finalPos, finalHpr, blendType='easeIn', name='cameraHpr')) - camIval = Sequence(camIval1, camIval2) - else: - camIval = Sequence(camIval1) - if self.UseTrolleyResultsPanel: - self.moveTrolleyIval.append(camIval) - temp = self.moveTrolleyIval - self.moveTrolleyIval = Sequence(temp) - if self.isLeaf(self.destSwitch): - self.moveTrolleyIval.append(Func(self.gameFSM.request, 'winMovie')) - else: - self.moveTrolleyIval.append(Func(self.gameFSM.request, 'inputChoice')) - self.moveTrolleyIval.start() - - def exitMoveTrolley(self): - self.notify.debug('exitMoveTrolley') - self.currentSwitch = self.destSwitch - self.moveTrolleyIval.finish() - self.moveCameraToTop() - self.showMinigamesAndBonuses() - - def enterWinMovie(self): - resultStr = TTLocalizer.TravelGamePlaying % {'game': self.idToNames[self.switchToMinigameDict[self.currentSwitch]]} - numToons = 0 - for avId in self.avIdList: - if avId not in self.disconnectedAvIds: - numToons += 1 - - if numToons <= 1: - resultStr = TTLocalizer.TravelGameGoingBackToShop - reachedGoalStr = None - localAvatarWon = False - localAvatarLost = False - noWinner = True - for avId in self.avIdBonuses.keys(): - name = '' - avatar = self.getAvatar(avId) - if avatar: - name = avatar.getName() - if self.avIdBonuses[avId][0] == self.currentSwitch: - noWinner = False - reachedGoalStr = TTLocalizer.TravelGameGotBonus % {'name': name, - 'numBeans': self.avIdBonuses[avId][1]} - if avId == base.localAvatar.doId: - if not TravelGameGlobals.ReverseWin: - self.wonGameSfx.play() - bonusLabel = self.switchToBonusLabelDict[self.currentSwitch] - self.flashWinningBeansTrack = Sequence(LerpColorScaleInterval(bonusLabel, 0.75, Vec4(0.5, 1, 0.5, 1)), LerpColorScaleInterval(bonusLabel, 0.75, Vec4(1, 1, 1, 1))) - self.flashWinningBeansTrack.loop() - else: - self.lostGameSfx.play() - elif not TravelGameGlobals.ReverseWin: - self.lostGameSfx.play() - else: - self.wonGameSfx.play() - - if noWinner: - self.noWinnerSfx.play() - resultStr += '\n\n' - resultStr += TTLocalizer.TravelGameNoOneGotBonus - if reachedGoalStr: - resultStr += '\n\n' - resultStr += reachedGoalStr - self.winDialog = TTDialog.TTDialog(text=resultStr, command=self.__cleanupWinDialog, style=TTDialog.NoButtons) - info = TravelGameGlobals.BoardLayouts[self.boardIndex][self.currentSwitch] - leafX, leafY, leafZ = info['pos'] - endX = leafX + TravelGameGlobals.xInc - heading = 90 - moveTrolley = Sequence() - moveTrolley.append(LerpHprInterval(self.trolleyCar, 1, Vec3(heading, 0, 0))) - moveTrolley.append(LerpPosInterval(self.trolleyCar, 3, Vec3(endX + 20, leafY, 0))) - soundTrack = Sequence() - trolleyExitBellInterval = SoundInterval(self.trolleyBellSfx, duration=1) - trolleyExitAwayInterval = SoundInterval(self.trolleyAwaySfx, duration=3) - soundTrack.append(trolleyExitBellInterval) - soundTrack.append(trolleyExitAwayInterval) - soundTrack.append(trolleyExitBellInterval) - self.moveTrolleyIval = Parallel(moveTrolley, soundTrack) - self.moveTrolleyIval.start() - delay = 8 - taskMgr.doMethodLater(delay, self.gameOverCallback, self.taskName('playMovie')) - return - - def exitWinMovie(self): - taskMgr.remove(self.taskName('playMovie')) - self.moveTrolleyIval.finish() - - def enterCleanup(self): - self.notify.debug('enterCleanup') - - def exitCleanup(self): - pass - - def setStartingVotes(self, startingVotesArray): - if not len(startingVotesArray) == len(self.avIdList): - self.notify.error('length does not match, startingVotes=%s, avIdList=%s' % (startingVotesArray, self.avIdList)) - return - for index in xrange(len(self.avIdList)): - avId = self.avIdList[index] - self.startingVotes[avId] = startingVotesArray[index] - if avId not in self.currentVotes: - self.currentVotes[avId] = startingVotesArray[index] - - self.notify.debug('starting votes = %s' % self.startingVotes) - - def startTimer(self): - now = globalClock.getFrameTime() - elapsed = now - self.timerStartTime - self.timer.setPos(1.16, 0, -0.83) - self.timer.setTime(TravelGameGlobals.InputTimeout) - self.timer.countdown(TravelGameGlobals.InputTimeout - elapsed, self.handleChoiceTimeout) - self.timer.show() - - def setTimerStartTime(self, timestamp): - if not self.hasLocalToon: - return - self.timerStartTime = globalClockDelta.networkToLocalTime(timestamp) - if self.timer != None: - self.startTimer() - return - - def handleChoiceTimeout(self): - self.sendUpdate('setAvatarChoice', [0, 0]) - self.gameFSM.request('waitServerChoices') - - def putChoicesInScrollList(self): - available = self.currentVotes[self.localAvId] - if len(self.scrollList['items']) > 0: - self.scrollList.removeAllItems() - self.indexToVotes = {} - index = 0 - for vote in xrange(available)[::-1]: - self.scrollList.addItem(str(-(vote + 1))) - self.indexToVotes[index] = vote + 1 - index += 1 - - self.scrollList.addItem(str(0)) - self.indexToVotes[index] = 0 - self.zeroVoteIndex = index - index += 1 - for vote in xrange(available): - self.scrollList.addItem(str(vote + 1)) - self.indexToVotes[index] = vote + 1 - index += 1 - - self.scrollList.scrollTo(self.zeroVoteIndex) - - def getAbsVoteChoice(self): - available = self.currentVotes[self.localAvId] - retval = 0 - if hasattr(self, 'scrollList'): - selectedIndex = self.scrollList.getSelectedIndex() - if selectedIndex in self.indexToVotes: - retval = self.indexToVotes[selectedIndex] - return retval - - def getAbsDirectionChoice(self): - selectedIndex = self.scrollList.getSelectedIndex() - if selectedIndex < self.zeroVoteIndex: - retval = 0 - elif selectedIndex == self.zeroVoteIndex: - retval = 0 - else: - retval = 1 - return retval - - def makeTextMatchChoice(self): - self.votesPeriodLabel.hide() - self.votesToGoLabel.hide() - self.upLabel.hide() - self.downLabel.hide() - if not hasattr(self, 'scrollList') or not hasattr(self, 'zeroVoteIndex'): - return - selectedIndex = self.scrollList.getSelectedIndex() - if selectedIndex < self.zeroVoteIndex: - self.votesToGoLabel.show() - self.upLabel.show() - elif selectedIndex == self.zeroVoteIndex: - self.votesPeriodLabel.show() - else: - self.votesToGoLabel.show() - self.downLabel.show() - - def scrollChoiceChanged(self): - choiceVotes = self.getAbsVoteChoice() - if choiceVotes == 1: - self.votesToGoLabel['text'] = TTLocalizer.TravelGameVoteToGo - else: - self.votesToGoLabel['text'] = TTLocalizer.TravelGameVotesToGo - available = self.currentVotes[self.localAvId] - self.localVotesRemaining['text'] = str(available - choiceVotes) - self.makeTextMatchChoice() - - def setAvatarChose(self, avId): - if not self.hasLocalToon: - return - self.notify.debug('setAvatarChose: avatar: ' + str(avId) + ' choose a number') - - def setAvatarVotes(self, avId, votes): - if not self.hasLocalToon: - return - self.currentVotes[avId] = votes - - def handleInputChoice(self): - numVotes = self.getAbsVoteChoice() - direction = self.getAbsDirectionChoice() - self.sendUpdate('setAvatarChoice', [numVotes, direction]) - self.gameFSM.request('waitServerChoices') - - def setServerChoices(self, votes, directions, directionToGo, directionReason): - if not self.hasLocalToon: - return - self.notify.debug('requesting displayVotes, curState=%s' % self.gameFSM.getCurrentState().getName()) - self.gameFSM.request('displayVotes', [votes, - directions, - directionToGo, - directionReason]) - - def __cleanupDialog(self, value): - if self.dialog: - self.dialog.cleanup() - self.dialog = None - return - - def displayVotesTimeoutTask(self, task): - self.notify.debug('Done waiting for display votes') - self.gameFSM.request('moveTrolley') - return Task.done - - def updateCurrentVotes(self): - for index in xrange(len(self.resultVotes)): - avId = self.avIdList[index] - oldCurrentVotes = self.currentVotes[avId] - self.currentVotes[avId] -= self.resultVotes[index] - - self.putChoicesInScrollList() - self.makeTextMatchChoice() - - def isLeaf(self, switchIndex): - retval = False - links = TravelGameGlobals.BoardLayouts[self.boardIndex][switchIndex]['links'] - if len(links) == 0: - retval = True - return retval - - def __cleanupWinDialog(self, value): - if hasattr(self, 'winDialog') and self.winDialog: - self.winDialog.cleanup() - self.winDialog = None - return - - def gameOverCallback(self, task): - self.__cleanupWinDialog(0) - self.gameOver() - return Task.done - - def setMinigames(self, switches, minigames): - if not self.hasLocalToon: - return - self.switchToMinigameDict = {} - for index in xrange(len(switches)): - switch = switches[index] - minigame = minigames[index] - self.switchToMinigameDict[switch] = minigame - - self.notify.debug('minigameDict = %s' % self.switchToMinigameDict) - self.loadMinigameIcons() - - def loadMinigameIcons(self): - self.mg_icons = loader.loadModel('phase_4/models/minigames/mg_icons') - for switch in self.switchToMinigameDict.keys(): - minigame = self.switchToMinigameDict[switch] - switchPos = self.trainSwitches[switch].getPos() - labelPos = map3dToAspect2d(render, switchPos) - useText = True - iconName = None - if minigame in IconDict.keys(): - iconName = IconDict[minigame] - icon = None - if self.mg_icons: - icon = self.mg_icons.find('**/%s' % iconName) - if not icon.isEmpty(): - useText = False - if labelPos: - if useText: - labelPos.setZ(labelPos.getZ() - 0.1) - label = DirectLabel(text=self.idToNames[minigame], relief=None, scale=0.1, pos=labelPos, text_fg=(1.0, 1.0, 1.0, 1.0)) - label.hide() - self.minigameLabels.append(label) - else: - placeHolder = DirectButton(image=icon, relief=None, text=('', - '', - self.idToNames[minigame], - ''), text_scale=0.3, text_pos=(0, -0.7, 0), text_fg=(1, 1, 1, 1), clickSound=None, pressEffect=0) - placeHolder.setPos(labelPos) - placeHolder.setScale(0.2) - placeHolder.hide() - self.minigameIcons.append(placeHolder) - tunnel = self.tunnels[switch] - sign = tunnel.attachNewNode('sign') - icon.copyTo(sign) - sign.setH(-90) - sign.setZ(26) - sign.setScale(10) - - return - - def showMinigamesAndBonuses(self): - for label in self.minigameLabels: - label.show() - - for label in self.bonusLabels: - label.show() - - for icon in self.minigameIcons: - icon.show() - - def hideMinigamesAndBonuses(self): - for label in self.minigameLabels: - label.hide() - - for label in self.bonusLabels: - label.hide() - - for icon in self.minigameIcons: - icon.hide() - - def loadBonuses(self): - self.switchToBonusLabelDict = {} - for avId in self.avIdBonuses.keys(): - if avId == self.localAvId: - switch = self.avIdBonuses[avId][0] - beans = self.avIdBonuses[avId][1] - switchPos = self.trainSwitches[switch].getPos() - labelPos = map3dToAspect2d(render, switchPos) - if labelPos: - labelPos.setX(labelPos.getX() + 0.1) - labelPos.setZ(labelPos.getZ() - 0.02) - bonusStr = TTLocalizer.TravelGameBonusBeans % {'numBeans': beans} - label = DirectLabel(text=bonusStr, relief=None, scale=0.1, pos=labelPos, text_fg=(1.0, 1.0, 1.0, 1.0), text_align=TextNode.ALeft) - label.hide() - self.bonusLabels.append(label) - self.switchToBonusLabelDict[switch] = label - break - - return - - def setBonuses(self, switches, beans): - if not self.hasLocalToon: - return - self.avIdBonuses = {} - for index in xrange(len(self.avIdList)): - avId = self.avIdList[index] - switch = switches[index] - bean = beans[index] - self.avIdBonuses[avId] = (switch, bean) - - self.notify.debug('self.avIdBonuses = %s' % self.avIdBonuses) - self.loadBonuses() - - def handleDisabledAvatar(self, avId): - self.notify.warning('DistrbutedTravelGame: handleDisabledAvatar: disabled avId: ' + str(avId)) - self.disconnectedAvIds.append(avId) - - def setBoardIndex(self, boardIndex): - self.boardIndex = boardIndex - - def getIntroMovie(self): - rootInfo = TravelGameGlobals.BoardLayouts[self.boardIndex][0] - rootX, rootY, rootZ = rootInfo['pos'] - startX = rootX - TravelGameGlobals.xInc - heading = 90 - moveTrolley = Sequence() - moveTrolley.append(Func(self.trolleyCar.setH, 90)) - moveTrolley.append(LerpPosInterval(self.trolleyCar, 3, Vec3(rootX, rootY, 0), startPos=Vec3(startX, rootY, 0))) - moveTrolley.append(LerpHprInterval(self.trolleyCar, 1, Vec3(heading, 0, 0))) - soundTrack = Sequence() - trolleyExitAwayInterval = SoundInterval(self.trolleyAwaySfx, duration=3) - trolleyExitBellInterval = SoundInterval(self.trolleyBellSfx, duration=1) - soundTrack.append(trolleyExitAwayInterval) - soundTrack.append(trolleyExitBellInterval) - retval = Parallel(moveTrolley, soundTrack) - return retval - - def animateTrolley(self, t, keyAngle, wheelAngle): - for i in xrange(self.numKeys): - key = self.keys[i] - ref = self.keyRef[i] - key.setH(ref, t * keyAngle) - - for i in xrange(self.numFrontWheels): - frontWheel = self.frontWheels[i] - ref = self.frontWheelRef[i] - frontWheel.setH(ref, t * wheelAngle) - - for i in xrange(self.numBackWheels): - backWheel = self.backWheels[i] - ref = self.backWheelRef[i] - backWheel.setH(ref, t * wheelAngle) - - def resetAnimation(self): - for i in xrange(self.numKeys): - self.keys[i].setTransform(self.keyInit[i]) - - for i in xrange(self.numFrontWheels): - self.frontWheels[i].setTransform(self.frontWheelInit[i]) - - for i in xrange(self.numBackWheels): - self.backWheels[i].setTransform(self.backWheelInit[i]) diff --git a/toontown/minigame/DistributedTravelGameAI.py b/toontown/minigame/DistributedTravelGameAI.py deleted file mode 100644 index 9d277213..00000000 --- a/toontown/minigame/DistributedTravelGameAI.py +++ /dev/null @@ -1,325 +0,0 @@ -from toontown.minigame.DistributedMinigameAI import * -from direct.fsm import ClassicFSM, State -from direct.fsm import State -import TravelGameGlobals -from toontown.toonbase import ToontownGlobals - -class DistributedTravelGameAI(DistributedMinigameAI): - notify = directNotify.newCategory('DistributedTravelGameAI') - - def __init__(self, air, minigameId): - try: - self.DistributedTravelGameAI_initialized - except: - self.DistributedTravelGameAI_initialized = 1 - DistributedMinigameAI.__init__(self, air, minigameId) - self.gameFSM = ClassicFSM.ClassicFSM('DistributedTravelGameAI', [State.State('inactive', self.enterInactive, self.exitInactive, ['waitClientsChoices']), - State.State('waitClientsChoices', self.enterWaitClientsChoices, self.exitWaitClientsChoices, ['processChoices', 'cleanup']), - State.State('processChoices', self.enterProcessChoices, self.exitProcessChoices, ['waitClientsChoices', 'cleanup']), - State.State('cleanup', self.enterCleanup, self.exitCleanup, ['inactive'])], 'inactive', 'inactive') - self.addChildGameFSM(self.gameFSM) - self.currentVotes = {} - self.avatarChoices = {} - self.currentSwitch = 0 - self.destSwitch = 0 - self.gotBonus = {} - self.desiredNextGame = -1 - self.boardIndex = random.choice(range(len(TravelGameGlobals.BoardLayouts))) - - def generate(self): - self.notify.debug('generate') - DistributedMinigameAI.generate(self) - - def delete(self): - self.notify.debug('delete') - del self.gameFSM - DistributedMinigameAI.delete(self) - - def setGameReady(self): - self.notify.debug('setGameReady') - DistributedMinigameAI.setGameReady(self) - self.calcMinigames() - self.calcBonusBeans() - - def setGameStart(self, timestamp): - self.notify.debug('setGameStart') - DistributedMinigameAI.setGameStart(self, timestamp) - self.gameFSM.request('waitClientsChoices') - - def setGameAbort(self): - self.notify.debug('setGameAbort') - if self.gameFSM.getCurrentState(): - self.gameFSM.request('cleanup') - DistributedMinigameAI.setGameAbort(self) - - def gameOver(self): - self.notify.debug('gameOver') - scoreList = [] - curVotesList = [] - bonusesList = [] - for avId in self.avIdList: - scoreList.append(self.scoreDict[avId]) - curVotesList.append(self.currentVotes[avId]) - bonusesList.append((self.avIdBonuses[avId][0], self.avIdBonuses[avId][1])) - - self.air.writeServerEvent('minigame_travel', self.doId, '%s|%s|%s|%s|%s|%s|%s|%s' % (ToontownGlobals.TravelGameId, - self.getSafezoneId(), - self.avIdList, - scoreList, - self.boardIndex, - curVotesList, - bonusesList, - self.desiredNextGame)) - self.gameFSM.request('cleanup') - DistributedMinigameAI.gameOver(self) - - def enterInactive(self): - self.notify.debug('enterInactive') - - def exitInactive(self): - pass - - def enterWaitClientsChoices(self): - self.notify.debug('enterWaitClientsChoices') - self.resetChoices() - taskMgr.doMethodLater(TravelGameGlobals.InputTimeout, self.waitClientsChoicesTimeout, self.taskName('input-timeout')) - self.sendUpdate('setTimerStartTime', [globalClockDelta.getFrameNetworkTime()]) - - def exitWaitClientsChoices(self): - taskMgr.remove(self.taskName('input-timeout')) - - def enterProcessChoices(self): - self.directionVotes = [] - for dir in xrange(TravelGameGlobals.MaxDirections): - self.directionVotes.append([dir, 0]) - - for key in self.avatarChoices: - choice = self.avatarChoices[key] - numVotes = choice[0] - direction = choice[1] - self.directionVotes[direction][1] += numVotes - - def voteCompare(directionVoteA, directionVoteB): - if directionVoteA[1] < directionVoteB[1]: - return -1 - elif directionVoteA[1] == directionVoteB[1]: - return 0 - else: - return 1 - - self.directionVotes.sort(voteCompare, reverse=True) - winningVotes = self.directionVotes[0][1] - self.winningDirections = [] - self.notify.debug('self.directionVotes = %s' % self.directionVotes) - for vote in self.directionVotes: - if vote[1] == winningVotes: - self.winningDirections.append(vote[0]) - self.notify.debug('add direction %d to winning directions' % vote[0]) - - self.directionReason = TravelGameGlobals.ReasonVote - if len(self.winningDirections) > 1: - self.notify.debug('multiple winningDirections=%s' % self.winningDirections) - self.directionReason = TravelGameGlobals.ReasonRandom - self.directionToGo = random.choice(self.winningDirections) - self.notify.debug('self.directionToGo =%d' % self.directionToGo) - self.votesArray = [] - self.directionArray = [] - for avId in self.avIdList: - vote = self.avatarChoices[avId][0] - direction = self.avatarChoices[avId][1] - if vote < 0: - vote = 0 - self.votesArray.append(vote) - self.directionArray.append(direction) - - curSwitch = TravelGameGlobals.BoardLayouts[self.boardIndex][self.currentSwitch] - self.destSwitch = curSwitch['links'][self.directionToGo] - self.checkForEndGame() - - def exitProcessChoices(self): - taskMgr.remove(self.taskName('move-timeout')) - - def enterCleanup(self): - self.notify.debug('enterCleanup') - self.gameFSM.request('inactive') - - def exitCleanup(self): - pass - - def setExpectedAvatars(self, avIds): - DistributedMinigameAI.setExpectedAvatars(self, avIds) - - def createDefaultStartingVotes(self): - for avId in self.avIdList: - self.startingVotes[avId] = TravelGameGlobals.DefaultStartingVotes - self.currentVotes[avId] = TravelGameGlobals.DefaultStartingVotes - - def waitClientsChoicesTimeout(self, task): - self.notify.debug('waitClientsChoicesTimeout: did not hear from all clients') - for avId in self.avatarChoices.keys(): - if self.avatarChoices[avId] == (-1, 0): - self.avatarChoices[avId] = (0, 0) - - self.gameFSM.request('processChoices') - return Task.done - - def resetChoices(self): - for avId in self.avIdList: - self.avatarChoices[avId] = (-1, 0) - - def setAvatarChoice(self, votes, direction): - avatarId = self.air.getAvatarIdFromSender() - self.notify.debug('setAvatarChoice: avatar: ' + str(avatarId) + ' votes: ' + str(votes) + ' direction: ' + str(direction)) - self.avatarChoices[avatarId] = self.checkChoice(avatarId, votes, direction) - self.currentVotes[avatarId] -= self.avatarChoices[avatarId][0] - if self.currentVotes[avatarId] < 0: - self.notify.warning('currentVotes < 0 avId=%s, currentVotes=%s' % (avatarId, self.currentVotes[avatarId])) - self.currentVotes[avatarId] = 0 - self.avatarChoices[avatarId] = (0, 0) - self.sendUpdate('setAvatarVotes', [avatarId, self.currentVotes[avatarId]]) - self.notify.debug('currentVotes = %s' % self.currentVotes) - self.notify.debug('avatarChoices = %s' % self.avatarChoices) - self.sendUpdate('setAvatarChose', [avatarId]) - if self.allAvatarsChosen(): - self.notify.debug('setAvatarChoice: all avatars have chosen') - self.gameFSM.request('processChoices') - else: - self.notify.debug('setAvatarChoice: still waiting for more choices') - - def checkChoice(self, avId, votes, direction): - retDir = direction - if direction < 0 or direction >= TravelGameGlobals.MaxDirections: - self.notify.debug('invalid direction %d. Using 0.' % direction) - retDir = 0 - availableVotes = self.currentVotes[avId] - retVotes = min(votes, availableVotes) - retVotes = max(votes, 0) - return (retVotes, retDir) - - def allAvatarsChosen(self): - for avId in self.avatarChoices.keys(): - choice = self.avatarChoices[avId] - if choice[0] == -1 and not self.stateDict[avId] == EXITED: - return False - - return True - - def isLeaf(self, switchIndex): - retval = False - links = TravelGameGlobals.BoardLayouts[self.boardIndex][switchIndex]['links'] - if len(links) == 0: - retval = True - return retval - - def giveBonusBeans(self, endingSwitch): - noOneGotBonus = True - for avId in self.avIdBonuses.keys(): - self.scoreDict[avId] = 0 - if self.avIdBonuses[avId][0] == endingSwitch and not self.stateDict[avId] == EXITED: - noOneGotBonus = False - self.scoreDict[avId] = self.avIdBonuses[avId][1] - self.gotBonus[avId] = self.avIdBonuses[avId][1] - - if noOneGotBonus: - for avId in self.avIdBonuses.keys(): - self.scoreDict[avId] = 1 - - def checkForEndGame(self): - self.notify.debug('checkForEndgame: ') - self.currentSwitch = self.destSwitch - didWeReachMiniGame = self.isLeaf(self.currentSwitch) - numPlayers = len(self.avIdList) - if TravelGameGlobals.SpoofFour: - numPlayers = 4 - delay = TravelGameGlobals.DisplayVotesTimePerPlayer * (numPlayers + 1) + TravelGameGlobals.MoveTrolleyTime + TravelGameGlobals.FudgeTime - if didWeReachMiniGame: - self.desiredNextGame = self.switchToMinigameDict[self.currentSwitch] - taskMgr.doMethodLater(delay, self.moveTimeoutTaskGameOver, self.taskName('move-timeout')) - self.giveBonusBeans(self.currentSwitch) - else: - taskMgr.doMethodLater(delay, self.moveTimeoutTask, self.taskName('move-timeout')) - self.sendUpdate('setServerChoices', [self.votesArray, - self.directionArray, - self.directionToGo, - self.directionReason]) - - def moveTimeoutTask(self, task): - self.notify.debug('Done waiting for trolley move') - self.gameFSM.request('waitClientsChoices') - return Task.done - - def moveTimeoutTaskGameOver(self, task): - self.notify.debug('Done waiting for trolley move, gmae over') - self.gameOver() - return Task.done - - def calcMinigames(self): - numPlayers = len(self.avIdList) - allowedGames = list(ToontownGlobals.MinigamePlayerMatrix[numPlayers]) - from toontown.minigame import MinigameCreatorAI - allowedGames = MinigameCreatorAI.removeUnreleasedMinigames(allowedGames) - self.switchToMinigameDict = {} - for switch in TravelGameGlobals.BoardLayouts[self.boardIndex].keys(): - if self.isLeaf(switch): - if len(allowedGames) == 0: - allowedGames = list(ToontownGlobals.MinigamePlayerMatrix[numPlayers]) - allowedGames = MinigameCreatorAI.removeUnreleasedMinigames(allowedGames) - minigame = random.choice(allowedGames) - self.switchToMinigameDict[switch] = minigame - allowedGames.remove(minigame) - - switches = [] - minigames = [] - for key in self.switchToMinigameDict.keys(): - switches.append(key) - minigames.append(self.switchToMinigameDict[key]) - - self.sendUpdate('setMinigames', [switches, minigames]) - - def calcBonusBeans(self): - possibleLeaves = [] - for switch in TravelGameGlobals.BoardLayouts[self.boardIndex].keys(): - if self.isLeaf(switch): - possibleLeaves.append(switch) - - self.avIdBonuses = {} - for avId in self.avIdList: - switch = random.choice(possibleLeaves) - possibleLeaves.remove(switch) - beans = TravelGameGlobals.BoardLayouts[self.boardIndex][switch]['baseBonus'] - baseBeans = TravelGameGlobals.BaseBeans - numPlayerMultiplier = len(self.avIdList) / 4.0 - roundMultiplier = self.metagameRound / 2.0 + 1.0 - beans *= baseBeans * numPlayerMultiplier * roundMultiplier - self.avIdBonuses[avId] = (switch, beans) - - switches = [] - beans = [] - for avId in self.avIdList: - switches.append(self.avIdBonuses[avId][0]) - beans.append(self.avIdBonuses[avId][1]) - - self.sendUpdate('setBonuses', [switches, beans]) - - def setStartingVote(self, avId, startingVote): - DistributedMinigameAI.setStartingVote(self, avId, startingVote) - self.currentVotes[avId] = startingVote - self.notify.debug('setting current vote of avId=%d to %d' % (avId, startingVote)) - - def handleExitedAvatar(self, avId): - self.notify.warning('DistrbutedTravelGameAI: handleExitedAvatar: avatar id exited: ' + str(avId)) - self.stateDict[avId] = EXITED - allExited = True - for avId in self.avIdList: - if avId in self.stateDict.keys() and self.stateDict[avId] != EXITED: - allExited = False - break - - if allExited: - self.setGameAbort() - - def getBoardIndex(self): - return self.boardIndex - - def hasScoreMult(self): - return 0 diff --git a/toontown/minigame/MinigameCreatorAI.py b/toontown/minigame/MinigameCreatorAI.py index e4dfb7ac..cd865f22 100644 --- a/toontown/minigame/MinigameCreatorAI.py +++ b/toontown/minigame/MinigameCreatorAI.py @@ -10,41 +10,25 @@ import DistributedDivingGameAI import DistributedIceGameAI import DistributedMazeGameAI import DistributedMinigameTemplateAI -import DistributedPairingGameAI import DistributedPatternGameAI import DistributedPhotoGameAI import DistributedRaceGameAI import DistributedRingGameAI import DistributedTagGameAI import DistributedTargetGameAI -import DistributedTravelGameAI import DistributedTugOfWarGameAI import DistributedTwoDGameAI import DistributedVineGameAI -import TravelGameGlobals from otp.ai.MagicWordGlobal import * -from toontown.minigame.TempMinigameAI import * from toontown.toonbase import ToontownGlobals simbase.forcedMinigameId = simbase.config.GetInt('force-minigame', 0) RequestMinigame = {} MinigameZoneRefs = {} -DisabledMinigames = [] - - -def getDisabledMinigames(): - if not DisabledMinigames: - for name, minigameId in ToontownGlobals.MinigameNames.items(): - if not simbase.config.GetBool('want-%s-game' % name, True): - if minigameId not in DisabledMinigames: - DisabledMinigames.append(minigameId) - return DisabledMinigames[:] - def createMinigame(air, playerArray, trolleyZone, minigameZone=None, - previousGameId=ToontownGlobals.NoPreviousGameId, newbieIds=[], - startingVotes=None, metagameRound=-1, desiredNextGame=None): + previousGameId=ToontownGlobals.NoPreviousGameId, newbieIds=[]): if minigameZone is None: minigameZone = air.allocateZone() acquireMinigameZone(minigameZone) @@ -66,18 +50,10 @@ def createMinigame(air, playerArray, trolleyZone, minigameZone=None, randomList = list(copy.copy(ToontownGlobals.MinigamePlayerMatrix[len(playerArray)])) if len(playerArray) > 1: randomList = list(copy.copy(ToontownGlobals.MinigameIDs)) - for gameId in [ToontownGlobals.TravelGameId] + getDisabledMinigames(): - if gameId in randomList: - randomList.remove(gameId) if previousGameId != ToontownGlobals.NoPreviousGameId: if randomList.count(previousGameId) != 0 and len(randomList) > 1: randomList.remove(previousGameId) mgId = random.choice(randomList) - if metagameRound > -1: - if (metagameRound%2) == 0: - mgId = ToontownGlobals.TravelGameId - elif desiredNextGame: - mgId = desiredNextGame mgCtors = { ToontownGlobals.RaceGameId: DistributedRaceGameAI.DistributedRaceGameAI, ToontownGlobals.CannonGameId: DistributedCannonGameAI.DistributedCannonGameAI, @@ -90,17 +66,12 @@ def createMinigame(air, playerArray, trolleyZone, minigameZone=None, ToontownGlobals.DivingGameId: DistributedDivingGameAI.DistributedDivingGameAI, ToontownGlobals.TargetGameId: DistributedTargetGameAI.DistributedTargetGameAI, ToontownGlobals.MinigameTemplateId: DistributedMinigameTemplateAI.DistributedMinigameTemplateAI, - ToontownGlobals.PairingGameId: DistributedPairingGameAI.DistributedPairingGameAI, ToontownGlobals.VineGameId: DistributedVineGameAI.DistributedVineGameAI, ToontownGlobals.IceGameId: DistributedIceGameAI.DistributedIceGameAI, ToontownGlobals.CogThiefGameId: DistributedCogThiefGameAI.DistributedCogThiefGameAI, ToontownGlobals.TwoDGameId: DistributedTwoDGameAI.DistributedTwoDGameAI, - ToontownGlobals.TravelGameId: DistributedTravelGameAI.DistributedTravelGameAI, ToontownGlobals.PhotoGameId: DistributedPhotoGameAI.DistributedPhotoGameAI } - from TempMinigameAI import TempMgCtors - for key, value in TempMgCtors.items(): - mgCtors[key] = value try: mg = mgCtors[mgId](air, mgId) except KeyError: @@ -109,18 +80,6 @@ def createMinigame(air, playerArray, trolleyZone, minigameZone=None, mg.setNewbieIds(newbieIds) mg.setTrolleyZone(trolleyZone) mg.setDifficultyOverrides(mgDiff, mgSzId) - if startingVotes == None: - for avId in playerArray: - mg.setStartingVote(avId, TravelGameGlobals.DefaultStartingVotes) - else: - for index in xrange(len(startingVotes)): - avId = playerArray[index] - votes = startingVotes[index] - if votes < 0: - print 'createMinigame negative votes, avId=%s votes=%s' % (avId, votes) - votes = 0 - mg.setStartingVote(avId, votes) - mg.setMetagameRound(metagameRound) mg.generateWithRequired(minigameZone) toons = [] for doId in playerArray: diff --git a/toontown/minigame/MinigamePowerMeter.py b/toontown/minigame/MinigamePowerMeter.py index a409e7b7..a2f593a6 100644 --- a/toontown/minigame/MinigamePowerMeter.py +++ b/toontown/minigame/MinigamePowerMeter.py @@ -13,8 +13,8 @@ class MinigamePowerMeter(DirectFrame): if label == None: label = TTLocalizer.MinigamePowerMeterLabel self.powerText = DirectLabel(self, relief=None, text=label, text_scale=TTLocalizer.MPMpowerText, pos=(0.01, 0.0, 0.29)) - self.tooSlow = DirectLabel(parent=self, relief=None, text=TTLocalizer.MinigamePowerMeterTooSlow, scale=TTLocalizer.MPMtooSlow, pos=(-.15, 0, 0.05), color=(0.1, 0.3, 0.6)) - self.tooFast = DirectLabel(parent=self, relief=None, text=TTLocalizer.MinigamePowerMeterTooFast, scale=TTLocalizer.MPMtooFast, pos=(0.15, 0, 0.05), color=(0.1, 0.3, 0.6)) + self.tooSlow = DirectLabel(parent=self, relief=None, text=TTLocalizer.MinigamePowerMeterTooSlow, scale=TTLocalizer.MPMtooSlow, pos=(-.15, 0, 0.05), color=(0.1, 0.3, 0.6, 1.0)) + self.tooFast = DirectLabel(parent=self, relief=None, text=TTLocalizer.MinigamePowerMeterTooFast, scale=TTLocalizer.MPMtooFast, pos=(0.15, 0, 0.05), color=(0.1, 0.3, 0.6, 1.0)) self.tooSlow.hide() self.tooFast.hide() self.largeGauge = [] diff --git a/toontown/minigame/PairingGameCard.py b/toontown/minigame/PairingGameCard.py deleted file mode 100644 index 4c723196..00000000 --- a/toontown/minigame/PairingGameCard.py +++ /dev/null @@ -1,94 +0,0 @@ -from PlayingCard import PlayingCardNodePath -import PlayingCardGlobals -from pandac.PandaModules import NodePath, Vec3 -from direct.interval.IntervalGlobal import LerpHprInterval, Parallel, SoundInterval - -class PairingGameCard(PlayingCardNodePath): - DoIntervalDefault = True - FlipTime = 0.25 - UseDifferentCardColors = True - CardColors = [(0.933594, 0.265625, 0.28125, 1.0), - (0.550781, 0.824219, 0.324219, 1.0), - (0.347656, 0.820312, 0.953125, 1.0), - (0.460938, 0.378906, 0.824219, 1.0), - (0.710938, 0.234375, 0.4375, 1.0), - (0.285156, 0.328125, 0.726562, 1.0), - (0.242188, 0.742188, 0.515625, 1.0), - (0.96875, 0.691406, 0.699219, 1.0), - (0.996094, 0.957031, 0.597656, 1.0), - (0.992188, 0.480469, 0.167969, 1.0)] - - def __init__(self, value): - style = PlayingCardGlobals.Styles[0] - PlayingCardNodePath.__init__(self, style, value) - self.enterCallback = None - self.exitCallback = None - return - - def load(self): - oneCard = loader.loadModel('phase_4/models/minigames/garden_sign_memory') - prop = self.attachNewNode('prop') - PlayingCardGlobals.getImage(self.style, self.suit, self.rank).copyTo(prop) - prop.setScale(7) - oneCard.find('**/glow').removeNode() - cs = oneCard.find('**/collision') - for solidIndex in xrange(cs.node().getNumSolids()): - cs.node().modifySolid(solidIndex).setTangible(False) - - cs.node().setName('cardCollision-%d' % self.value) - sign = oneCard.find('**/sign1') - if self.UseDifferentCardColors: - index = self.rank % len(self.CardColors) - color = self.CardColors[index] - sign.setColorScale(*color) - prop.setPos(0.0, 0.0, 0.08) - prop.setP(-90) - prop.reparentTo(oneCard) - oneCard.reparentTo(self) - cardBack = oneCard.find('**/sign2') - cardBack.setColorScale(0.12, 0.35, 0.5, 1.0) - cardModel = loader.loadModel('phase_3.5/models/gui/playingCard') - logo = cardModel.find('**/logo') - logo.reparentTo(self) - logo.setScale(0.45) - logo.setP(90) - logo.setZ(0.025) - logo.setX(-0.05) - logo.setH(180) - cardModel.removeNode() - self.setR(0) - self.setScale(2.5) - self.flipIval = None - self.turnUpSound = base.loadSfx('phase_4/audio/sfx/MG_pairing_card_flip_face_up.ogg') - self.turnDownSound = base.loadSfx('phase_4/audio/sfx/MG_pairing_card_flip_face_down.ogg') - return - - def unload(self): - self.clearFlipIval() - self.removeNode() - del self.turnUpSound - del self.turnDownSound - - def turnUp(self, doInterval = DoIntervalDefault): - self.faceUp = 1 - if doInterval: - self.clearFlipIval() - self.flipIval = Parallel(LerpHprInterval(self, self.FlipTime, Vec3(0, 0, 0)), SoundInterval(self.turnUpSound, node=self, listenerNode=base.localAvatar, cutOff=240)) - self.flipIval.start() - else: - self.setR(0) - - def clearFlipIval(self): - if self.flipIval: - self.flipIval.finish() - self.flipIval = None - return - - def turnDown(self, doInterval = DoIntervalDefault): - self.faceUp = 0 - if doInterval: - self.clearFlipIval() - self.flipIval = Parallel(LerpHprInterval(self, self.FlipTime, Vec3(0, 0, 180)), SoundInterval(self.turnDownSound, node=self, listenerNode=base.localAvatar, cutOff=240)) - self.flipIval.start() - else: - self.setR(180) diff --git a/toontown/minigame/PairingGameGlobals.py b/toontown/minigame/PairingGameGlobals.py deleted file mode 100644 index 618cbda8..00000000 --- a/toontown/minigame/PairingGameGlobals.py +++ /dev/null @@ -1,39 +0,0 @@ -import PlayingCardDeck -EasiestGameDuration = 120 -HardestGameDuration = 90 -EndlessGame = config.GetBool('endless-pairing-game', 0) -MaxRankIndexUsed = [7, - 7, - 7, - 8, - 9] - -def createDeck(deckSeed, numPlayers): - deck = PlayingCardDeck.PlayingCardDeck() - deck.shuffleWithSeed(deckSeed) - deck.removeRanksAbove(MaxRankIndexUsed[numPlayers]) - return deck - - -def calcGameDuration(difficulty): - difference = EasiestGameDuration - HardestGameDuration - adjust = difference * difficulty - retval = EasiestGameDuration - adjust - return retval - - -def calcLowFlipModifier(matches, flips): - idealFlips = round(matches * 2 * 1.6) - if idealFlips < 2: - idealFlips = 2 - maxFlipsForBonus = idealFlips * 2 - retval = 0 - if flips < idealFlips: - retval = 1 - elif maxFlipsForBonus < flips: - retval = 0 - else: - divisor = maxFlipsForBonus - idealFlips - difference = maxFlipsForBonus - flips - retval = float(difference) / divisor - return retval diff --git a/toontown/minigame/PlayingCard.py b/toontown/minigame/PlayingCard.py deleted file mode 100644 index 290a5286..00000000 --- a/toontown/minigame/PlayingCard.py +++ /dev/null @@ -1,114 +0,0 @@ -from direct.gui.DirectGui import * -from pandac.PandaModules import * -from direct.task import Task -from toontown.toonbase import TTLocalizer -import PlayingCardGlobals - -class PlayingCardBase: - - def __init__(self, value): - self.faceUp = 1 - self.setValue(value) - - def getCardName(self): - PlayingCardGlobals.getCardName(self.value) - - def getRank(self): - return self.rank - - def getSuit(self): - return self.suit - - def getValue(self): - return self.value - - def setImage(self): - pass - - def setValue(self, value): - self.value = value - if self.value == PlayingCardGlobals.Unknown: - self.suit = None - self.rank = None - self.turnDown() - else: - self.suit = value / PlayingCardGlobals.MaxRank - self.rank = value % PlayingCardGlobals.MaxRank - self.setImage() - return - - def isFaceUp(self): - return self.faceUp - - def isFaceDown(self): - return not self.faceUp - - def turnUp(self): - self.faceUp = 1 - self.setImage() - - def turnDown(self): - self.faceUp = 0 - self.setImage() - - -class PlayingCardNodePath(NodePath, PlayingCardBase): - - def __init__(self, style, value): - self.image = None - self.style = style - NodePath.__init__(self, 'PlayingCard') - PlayingCardBase.__init__(self, value) - return - - def setImage(self): - if self.faceUp: - image = PlayingCardGlobals.getImage(self.style, self.suit, self.rank) - else: - image = PlayingCardGlobals.getBack(self.style) - if self.image: - self.image.removeNode() - self.image = image.copyTo(self) - - -class PlayingCardButton(PlayingCardBase, DirectButton): - - def __init__(self, style, value): - PlayingCardBase.__init__(self, value) - self.style = style - DirectButton.__init__(self, relief=None) - self.initialiseoptions(PlayingCardButton) - self.bind(DGG.B1PRESS, self.dragStart) - self.bind(DGG.B1RELEASE, self.dragStop) - return - - def setImage(self): - if self.faceUp: - image = PlayingCardGlobals.getImage(self.style, self.suit, self.rank) - else: - image = PlayingCardGlobals.getBack(self.style) - self['image'] = image - - def dragStart(self, event): - taskMgr.remove(self.taskName('dragTask')) - vWidget2render2d = self.getPos(render2d) - vMouse2render2d = Point3(event.getMouse()[0], 0, event.getMouse()[1]) - editVec = Vec3(vWidget2render2d - vMouse2render2d) - task = taskMgr.add(self.dragTask, self.taskName('dragTask')) - task.editVec = editVec - - def dragTask(self, task): - mwn = base.mouseWatcherNode - if mwn.hasMouse(): - vMouse2render2d = Point3(mwn.getMouse()[0], 0, mwn.getMouse()[1]) - newPos = vMouse2render2d + task.editVec - self.setPos(render2d, newPos) - return Task.cont - - def dragStop(self, event): - taskMgr.remove(self.taskName('dragTask')) - messenger.send('PlayingCardDrop', sentArgs=[self]) - - def destroy(self): - taskMgr.remove(self.taskName('dragTask')) - DirectButton.destroy(self) diff --git a/toontown/minigame/PlayingCardDeck.py b/toontown/minigame/PlayingCardDeck.py deleted file mode 100644 index 02938f7f..00000000 --- a/toontown/minigame/PlayingCardDeck.py +++ /dev/null @@ -1,44 +0,0 @@ -import random -import PlayingCardGlobals -from toontown.minigame.PlayingCard import PlayingCardBase - -class PlayingCardDeck: - - def __init__(self): - self.shuffle() - - def shuffle(self): - self.cards = range(0, PlayingCardGlobals.MaxSuit * PlayingCardGlobals.MaxRank) - random.shuffle(self.cards) - - def shuffleWithSeed(self, seed): - generator = random.Random() - generator.seed(seed) - self.cards = range(0, PlayingCardGlobals.MaxSuit * PlayingCardGlobals.MaxRank) - generator.shuffle(self.cards) - - def dealCard(self): - return self.cards.pop(0) - - def dealCards(self, num): - cardList = [] - for i in xrange(num): - cardList.append(self.cards.pop(0)) - - return cardList - - def count(self): - return len(self.cards) - - def removeRanksAbove(self, maxRankInDeck): - done = False - while not done: - removedOne = False - for cardValue in self.cards: - tempCard = PlayingCardBase(cardValue) - if tempCard.rank > maxRankInDeck: - self.cards.remove(cardValue) - removedOne = True - - if not removedOne: - done = True diff --git a/toontown/minigame/PlayingCardGlobals.py b/toontown/minigame/PlayingCardGlobals.py deleted file mode 100644 index 7015abea..00000000 --- a/toontown/minigame/PlayingCardGlobals.py +++ /dev/null @@ -1,85 +0,0 @@ -from toontown.toonbase import TTLocalizer -from toontown.toonbase import ToontownBattleGlobals -from pandac.PandaModules import Vec4 -Up = 1 -Down = 0 -MaxRank = 13 -MaxSuit = 4 -Hearts = 0 -Diamonds = 1 -Clubs = 2 -Spades = 3 -Suits = [Hearts, - Diamonds, - Clubs, - Spades] -Unknown = 255 -UpColor = Vec4(1, 1, 1, 1) -RolloverColor = Vec4(1, 1, 0.5, 1) -DownColor = Vec4(1, 0.9, 0.9, 1) -DisabledColor = Vec4(1, 1, 1, 0.5) -CardColors = (UpColor, - DownColor, - RolloverColor, - DisabledColor) - -def getCardName(value): - if value == Unknown: - return TTLocalizer.PlayingCardUnknown - else: - rank = value % MaxRank - suit = value / MaxRank - return TTLocalizer.getPlayingCardName(suit, rank) - - -Styles = ['standard'] -CardImages = {} -_cardImagesInitialized = 0 -_modelPathBase = 'phase_3.5/models/gui/inventory_icons' - -def convertValueToGagTrackAndLevel(value): - imageNum = int(rank / MaxSuit) - track = imageNum % (ToontownBattleGlobals.MAX_TRACK_INDEX + 1) - level = imageNum / (ToontownBattleGlobals.MAX_TRACK_INDEX + 1) - return (track, level) - - -def convertRankToGagTrackAndLevel(rank): - track = rank % (ToontownBattleGlobals.MAX_TRACK_INDEX + 1) - level = rank / (ToontownBattleGlobals.MAX_TRACK_INDEX + 1) - return (track, level) - - -def initCardImages(): - global _cardImagesInitialized - suitCodes = ('h', 'd', 'c', 's') - rankCodes = ('02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '01') - for style in Styles: - modelPath = _modelPathBase - cardModel = loader.loadModel(modelPath) - cardModel.hide() - CardImages[style] = {} - for suitIndex in xrange(MaxSuit): - CardImages[style][suitIndex] = {} - for rankIndex in xrange(MaxRank): - track, level = convertRankToGagTrackAndLevel(rankIndex) - propName = ToontownBattleGlobals.AvPropsNew[track][level] - cardNode = cardModel.find('**/%s' % propName) - CardImages[style][suitIndex][rankIndex] = cardNode - - propName = ToontownBattleGlobals.AvPropsNew[ToontownBattleGlobals.MAX_TRACK_INDEX][ToontownBattleGlobals.MAX_LEVEL_INDEX] - CardImages[style]['back'] = cardModel.find(propName) - - _cardImagesInitialized = 1 - - -def getImage(style, suit, rank): - if _cardImagesInitialized == 0: - initCardImages() - return CardImages[style][suit][rank] - - -def getBack(style): - if _cardImagesInitialized == 0: - initCardImages() - return CardImages[style]['back'] diff --git a/toontown/minigame/Purchase.py b/toontown/minigame/Purchase.py index d28d4169..b7453623 100644 --- a/toontown/minigame/Purchase.py +++ b/toontown/minigame/Purchase.py @@ -6,7 +6,6 @@ from direct.task.Task import Task import MinigameGlobals from PurchaseBase import * from toontown.distributed import DelayDelete -from toontown.minigame import TravelGameGlobals from toontown.nametag import NametagGlobals from toontown.nametag.NametagFloat2d import * from toontown.toon import ToonHead @@ -30,7 +29,7 @@ OVERMAX_SFX_START_T = 0.021 class Purchase(PurchaseBase): notify = DirectNotifyGlobal.directNotify.newCategory('Purchase') - def __init__(self, toon, pointsArray, playerMoney, ids, states, remain, doneEvent, metagameRound = -1, votesArray = None): + def __init__(self, toon, pointsArray, playerMoney, ids, states, remain, doneEvent): PurchaseBase.__init__(self, toon, doneEvent) self.ids = ids self.pointsArray = pointsArray @@ -38,9 +37,6 @@ class Purchase(PurchaseBase): self.states = states self.remain = remain self.tutorialMode = 0 - self.metagameRound = metagameRound - self.votesArray = votesArray - self.voteMultiplier = 1 self.fsm.addState(State.State('reward', self.enterReward, self.exitReward, ['purchase'])) doneState = self.fsm.getStateNamed('done') doneState.addTransition('reward') @@ -149,8 +145,6 @@ class Purchase(PurchaseBase): self.door.setScale(1.5, 1.5, 2.0) self.door.setColor(1.0, 0.8, 0, 1) doors.removeNode() - self.convertingVotesToBeansLabel = DirectLabel(text=TTLocalizer.TravelGameConvertingVotesToBeans, text_fg=VBase4(1, 1, 1, 1), relief=None, pos=(0.0, 0, -0.58), scale=0.075) - self.convertingVotesToBeansLabel.hide() self.rewardDoubledJellybeanLabel = DirectLabel(text=TTLocalizer.PartyRewardDoubledJellybean, text_fg=(1.0, 0.125, 0.125, 1.0), text_shadow=(0, 0, 0, 1), relief=None, pos=(0.0, 0, -0.67), scale=0.08) self.rewardDoubledJellybeanLabel.hide() self.countSound = base.loadSfx('phase_3.5/audio/sfx/tick_counter.ogg') @@ -191,9 +185,7 @@ class Purchase(PurchaseBase): loader.unloadModel('phase_3.5/models/modules/street_modules') loader.unloadModel('phase_4/models/modules/doors') taskMgr.remove('countUpTask') - taskMgr.remove('countVotesUpTask') taskMgr.remove('countDownTask') - taskMgr.remove('countVotesDownTask') taskMgr.remove('celebrate') taskMgr.remove('purchase-trans') taskMgr.remove('delayAdd') @@ -216,9 +208,7 @@ class Purchase(PurchaseBase): del self.collisionFloor del self.countSound del self.celebrateSound - self.convertingVotesToBeansLabel.removeNode() self.rewardDoubledJellybeanLabel.removeNode() - del self.convertingVotesToBeansLabel del self.rewardDoubledJellybeanLabel def showStatusText(self, text): @@ -355,14 +345,6 @@ class Purchase(PurchaseBase): pos += 1 self.maxPoints = max(self.pointsArray) - if self.votesArray: - self.maxVotes = max(self.votesArray) - numToons = len(self.toons) - self.voteMultiplier = TravelGameGlobals.PercentOfVotesConverted[numToons] / 100.0 - self.maxBeansFromVotes = int(self.voteMultiplier * self.maxVotes) - else: - self.maxVotes = 0 - self.maxBeansFromVotes = 0 def reqCountUp(state): self.countUp() @@ -400,22 +382,6 @@ class Purchase(PurchaseBase): celebrateTask.ids = self.ids celebrateTask.celebrateSound = self.celebrateSound - def reqCountVotesUp(state): - self.countVotesUp() - return Task.done - - def reqCountVotesDown(state): - self.countVotesDown() - return Task.done - - if self.metagameRound == TravelGameGlobals.FinalMetagameRoundIndex: - countVotesUpDelay = celebrateDelay + DELAY_AFTER_CELEBRATE - taskMgr.doMethodLater(countVotesUpDelay, reqCountVotesUp, 'countVotesUpTask') - countVotesUpTime = self.maxVotes * COUNT_UP_RATE + DELAY_AFTER_COUNT_UP - countVotesDownDelay = countVotesUpDelay + countVotesUpTime - taskMgr.doMethodLater(countVotesDownDelay, reqCountVotesDown, 'countVotesDownTask') - celebrateDelay += countVotesUpTime + self.maxVotes * COUNT_DOWN_RATE + DELAY_AFTER_COUNT_DOWN - def reqPurchase(state): self.fsm.request('purchase') return Task.done @@ -512,75 +478,10 @@ class Purchase(PurchaseBase): countDownTask.overMaxSound = self.overMaxSound countDownTask.lastSfxT = 0 - def countVotesUp(self): - totalDelay = 0 - self.convertingVotesToBeansLabel.show() - if base.cr.newsManager.isHolidayRunning(ToontownGlobals.JELLYBEAN_TROLLEY_HOLIDAY) or base.cr.newsManager.isHolidayRunning(ToontownGlobals.JELLYBEAN_TROLLEY_HOLIDAY_MONTH): - self.rewardDoubledJellybeanLabel.show() - counterIndex = 0 - for index in xrange(len(self.ids)): - avId = self.ids[index] - if self.states[index] != PURCHASE_NO_CLIENT_STATE and self.states[index] != PURCHASE_DISCONNECTED_STATE and avId in base.cr.doId2do: - self.counters[counterIndex].count = 0 - self.counters[counterIndex].max = self.votesArray[index] - self.counters[counterIndex].show() - counterIndex += 1 - - def delayAdd(state): - state.counter.count += 1 - state.counter['text'] = str(state.counter.count) - if state.toonId == base.localAvatar.doId: - base.playSfx(state.countSound) - return Task.done - - for count in xrange(0, self.maxVotes): - for counter in self.counters: - index = self.counters.index(counter) - if count < counter.max: - addTask = taskMgr.doMethodLater(totalDelay, delayAdd, 'delayAdd') - addTask.counter = counter - addTask.toonId = self.ids[index] - addTask.countSound = self.countSound - - totalDelay += COUNT_UP_RATE - - def countVotesDown(self): - totalDelay = 0 - - def delaySubtract(state): - state.counter.count -= 1 - state.counter['text'] = str(state.counter.count) - state.total.count += 1 * self.voteMultiplier - if state.total.count <= state.total.max: - state.total['text'] = str(int(state.total.count)) - if state.total.count == state.total.max + 1: - state.total['text_fg'] = (1, 0, 0, 1) - if state.toonId == base.localAvatar.doId: - if state.total.count <= state.total.max: - base.playSfx(state.countSound) - else: - base.playSfx(state.overMaxSound) - return Task.done - - for count in xrange(0, self.maxVotes): - for counter in self.counters: - if count < counter.max: - index = self.counters.index(counter) - subtractTask = taskMgr.doMethodLater(totalDelay, delaySubtract, 'delaySubtract') - subtractTask.counter = counter - subtractTask.total = self.totalCounters[index] - subtractTask.toonId = self.ids[index] - subtractTask.countSound = self.countSound - subtractTask.overMaxSound = self.overMaxSound - - totalDelay += COUNT_DOWN_RATE - def exitReward(self): self.ignore('clientCleanup') taskMgr.remove('countUpTask') - taskMgr.remove('countVotesUpTask') taskMgr.remove('countDownTask') - taskMgr.remove('countVotesDownTask') taskMgr.remove('celebrate') taskMgr.remove('purchase-trans') taskMgr.remove('delayAdd') @@ -608,7 +509,6 @@ class Purchase(PurchaseBase): self.sidewalkR.reparentTo(hidden) self.door.reparentTo(hidden) self.title.reparentTo(self.frame) - self.convertingVotesToBeansLabel.hide() self.rewardDoubledJellybeanLabel.hide() base.camLens.setMinFov(ToontownGlobals.DefaultCameraFov/(4./3.)) NametagGlobals.setForceOnscreenChat(False) @@ -623,7 +523,6 @@ class Purchase(PurchaseBase): def enterPurchase(self): PurchaseBase.enterPurchase(self) - self.convertingVotesToBeansLabel.hide() self.rewardDoubledJellybeanLabel.hide() self.bg.reparentTo(render) base.setBackgroundColor(0.78, 0.65, 0.53) @@ -640,9 +539,6 @@ class Purchase(PurchaseBase): if not config.GetBool('disable-purchase-timer', 0): self.timer.show() self.timer.countdown(self.remain, self.__timerExpired) - if config.GetBool('metagame-disable-playAgain', 0): - if self.metagameRound > -1: - self.disablePlayAgain() else: self.timer.hide() self.disablePlayAgain() @@ -655,7 +551,7 @@ class Purchase(PurchaseBase): headFrame.hide() messenger.send('gagScreenIsUp') - if base.autoPlayAgain or self.doMetagamePlayAgain(): + if base.autoPlayAgain: base.transitions.fadeOut(0) self.__handlePlayAgain() @@ -672,7 +568,7 @@ class Purchase(PurchaseBase): self.statusLabel.reparentTo(self.frame) self.ignore('purchaseStateChange') base.setBackgroundColor(ToontownGlobals.DefaultBackgroundColor) - if base.autoPlayAgain or self.doMetagamePlayAgain(): + if base.autoPlayAgain: base.transitions.fadeIn() def disableBackToPlayground(self): @@ -698,20 +594,6 @@ class Purchase(PurchaseBase): def handleGagTutorialDone(self): self.enableBackToPlayground() - def doMetagamePlayAgain(self): - if hasattr(self, 'metagamePlayAgainResult'): - return self.metagamePlayAgainResult - numToons = 0 - for avId in self.ids: - if avId in base.cr.doId2do and avId not in self.unexpectedExits: - numToons += 1 - - self.metagamePlayAgainResult = False - if numToons > 1: - if self.metagameRound > -1 and self.metagameRound < TravelGameGlobals.FinalMetagameRoundIndex: - self.metagamePlayAgainResult = True - return self.metagamePlayAgainResult - def setupUnexpectedExitHooks(self): for avId in self.ids: if avId in base.cr.doId2do: diff --git a/toontown/minigame/TempMinigameAI.py b/toontown/minigame/TempMinigameAI.py deleted file mode 100644 index 3ae7e879..00000000 --- a/toontown/minigame/TempMinigameAI.py +++ /dev/null @@ -1,26 +0,0 @@ -from toontown.toonbase import ToontownGlobals -ALLOW_TEMP_MINIGAMES = simbase.config.GetBool('allow-temp-minigames', False) -TEMP_MG_ID_COUNTER = ToontownGlobals.TravelGameId - 1 -TempMgCtors = {} - -def _printMessage(message): - print '\n\n!!!', message, '\n\n' - - -def _registerTempMinigame(name, Class, id, minPlayers = 1, maxPlayers = 4): - if not ALLOW_TEMP_MINIGAMES: - _printMessage('registerTempMinigame WARNING: allow-temp-minigames config is set to false, but we are trying to register temp minigame ' + name) - import traceback - traceback.print_stack() - return - ToontownGlobals.MinigameIDs += (id,) - ToontownGlobals.MinigameNames[name] = id - TempMgCtors[id] = Class - for i in xrange(minPlayers, maxPlayers): - ToontownGlobals.MinigamePlayerMatrix[i] += (id,) - - _printMessage('registerTempMinigame: ' + name) - - -if ALLOW_TEMP_MINIGAMES: - pass diff --git a/toontown/minigame/TravelGameGlobals.py b/toontown/minigame/TravelGameGlobals.py deleted file mode 100644 index 91edece4..00000000 --- a/toontown/minigame/TravelGameGlobals.py +++ /dev/null @@ -1,184 +0,0 @@ -DefaultStartingVotes = 5 -FinalMetagameRoundIndex = 5 -BaseBeans = 10 -PercentOfVotesConverted = {1: 50, - 2: 33, - 3: 66, - 4: 100} -InputTimeout = 15 -MaxDirections = 2 -ReasonVote = 0 -ReasonPlaceDecider = 1 -ReasonRandom = 2 -DisplayVotesTimePerPlayer = 2 -MoveTrolleyTime = 5 -FudgeTime = 0 -SpoofFour = False -ReverseWin = False -xInc = 60 -yInc = 15 -BoardLayout4VotingRounds = {0: {'links': (1, 2), - 'pos': (0, 0, 0)}, - 1: {'links': (3, 4), - 'pos': (xInc, yInc, 0)}, - 2: {'links': (4, 5), - 'pos': (xInc, -yInc, 0)}, - 3: {'links': (6, 7), - 'pos': (2 * xInc, 2 * yInc, 0)}, - 4: {'links': (7, 8), - 'pos': (2 * xInc, 0, 0)}, - 5: {'links': (8, 9), - 'pos': (2 * xInc, -2 * yInc, 0)}, - 6: {'links': (10, 11), - 'pos': (3 * xInc, 3 * yInc, 0)}, - 7: {'links': (11, 12), - 'pos': (3 * xInc, yInc, 0)}, - 8: {'links': (12, 13), - 'pos': (3 * xInc, -yInc, 0)}, - 9: {'links': (13, 14), - 'pos': (3 * xInc, -3 * yInc, 0)}, - 10: {'links': (), - 'pos': (4 * xInc, 4 * yInc, 0), - 'baseBonus': 3}, - 11: {'links': (), - 'pos': (4 * xInc, 2 * yInc, 0), - 'baseBonus': 2}, - 12: {'links': (), - 'pos': (4 * xInc, 0, 0), - 'baseBonus': 1}, - 13: {'links': (), - 'pos': (4 * xInc, -2 * yInc, 0), - 'baseBonus': 2}, - 14: {'links': (), - 'pos': (4 * xInc, -4 * yInc, 0), - 'baseBonus': 3}} -BoardLayout0 = {0: {'links': (1, 2), - 'pos': (0, 0, 0)}, - 1: {'links': (3, 4), - 'pos': (xInc, 2 * yInc, 0)}, - 2: {'links': (4, 5), - 'pos': (xInc, -2 * yInc, 0)}, - 3: {'links': (6, 7), - 'pos': (2 * xInc, 4 * yInc, 0)}, - 4: {'links': (8, 9), - 'pos': (2 * xInc, 0, 0)}, - 5: {'links': (10, 11), - 'pos': (2 * xInc, -4 * yInc, 0)}, - 6: {'links': (), - 'pos': (3 * xInc, 5 * yInc, 0), - 'baseBonus': 2}, - 7: {'links': (), - 'pos': (3 * xInc, 3 * yInc, 0), - 'baseBonus': 2}, - 8: {'links': (), - 'pos': (3 * xInc, 1 * yInc, 0), - 'baseBonus': 1}, - 9: {'links': (), - 'pos': (3 * xInc, -1 * yInc, 0), - 'baseBonus': 1}, - 10: {'links': (), - 'pos': (3 * xInc, -3 * yInc, 0), - 'baseBonus': 2}, - 11: {'links': (), - 'pos': (3 * xInc, -5 * yInc, 0), - 'baseBonus': 2}} -BoardLayout1 = {0: {'links': (1, 2), - 'pos': (0, 0, 0)}, - 1: {'links': (3, 4), - 'pos': (xInc, 3 * yInc, 0)}, - 2: {'links': (5, 6), - 'pos': (xInc, -3 * yInc, 0)}, - 3: {'links': (7, 8), - 'pos': (2 * xInc, 4 * yInc, 0)}, - 4: {'links': (8, 9), - 'pos': (2 * xInc, 2 * yInc, 0)}, - 5: {'links': (10, 11), - 'pos': (2 * xInc, -2 * yInc, 0)}, - 6: {'links': (11, 12), - 'pos': (2 * xInc, -4 * yInc, 0)}, - 7: {'links': (), - 'pos': (3 * xInc, 5 * yInc, 0), - 'baseBonus': 2}, - 8: {'links': (), - 'pos': (3 * xInc, 3 * yInc, 0), - 'baseBonus': 1}, - 9: {'links': (), - 'pos': (3 * xInc, 1 * yInc, 0), - 'baseBonus': 2}, - 10: {'links': (), - 'pos': (3 * xInc, -1 * yInc, 0), - 'baseBonus': 2}, - 11: {'links': (), - 'pos': (3 * xInc, -3 * yInc, 0), - 'baseBonus': 1}, - 12: {'links': (), - 'pos': (3 * xInc, -5 * yInc, 0), - 'baseBonus': 2}} -BoardLayout2 = {0: {'links': (1, 2), - 'pos': (0, 0, 0)}, - 1: {'links': (3, 4), - 'pos': (xInc, 3 * yInc, 0)}, - 2: {'links': (5, 6), - 'pos': (xInc, -3 * yInc, 0)}, - 3: {'links': (7, 8), - 'pos': (2 * xInc, 4 * yInc, 0)}, - 4: {'links': (8, 9), - 'pos': (2 * xInc, 2 * yInc, 0)}, - 5: {'links': (9, 10), - 'pos': (2 * xInc, 0 * yInc, 0)}, - 6: {'links': (11, 12), - 'pos': (2 * xInc, -4 * yInc, 0)}, - 7: {'links': (), - 'pos': (3 * xInc, 5 * yInc, 0), - 'baseBonus': 2}, - 8: {'links': (), - 'pos': (3 * xInc, 3 * yInc, 0), - 'baseBonus': 1}, - 9: {'links': (), - 'pos': (3 * xInc, 1 * yInc, 0), - 'baseBonus': 1}, - 10: {'links': (), - 'pos': (3 * xInc, -1 * yInc, 0), - 'baseBonus': 2}, - 11: {'links': (), - 'pos': (3 * xInc, -3 * yInc, 0), - 'baseBonus': 2}, - 12: {'links': (), - 'pos': (3 * xInc, -5 * yInc, 0), - 'baseBonus': 2}} -BoardLayout3 = {0: {'links': (1, 2), - 'pos': (0, 0, 0)}, - 1: {'links': (3, 4), - 'pos': (xInc, 2 * yInc, 0)}, - 2: {'links': (5, 6), - 'pos': (xInc, -3 * yInc, 0)}, - 3: {'links': (7, 8), - 'pos': (2 * xInc, 4 * yInc, 0)}, - 4: {'links': (9, 10), - 'pos': (2 * xInc, 0 * yInc, 0)}, - 5: {'links': (10, 11), - 'pos': (2 * xInc, -2 * yInc, 0)}, - 6: {'links': (11, 12), - 'pos': (2 * xInc, -4 * yInc, 0)}, - 7: {'links': (), - 'pos': (3 * xInc, 5 * yInc, 0), - 'baseBonus': 2}, - 8: {'links': (), - 'pos': (3 * xInc, 3 * yInc, 0), - 'baseBonus': 2}, - 9: {'links': (), - 'pos': (3 * xInc, 1 * yInc, 0), - 'baseBonus': 2}, - 10: {'links': (), - 'pos': (3 * xInc, -1 * yInc, 0), - 'baseBonus': 1}, - 11: {'links': (), - 'pos': (3 * xInc, -3 * yInc, 0), - 'baseBonus': 1}, - 12: {'links': (), - 'pos': (3 * xInc, -5 * yInc, 0), - 'baseBonus': 2}} -BoardLayouts = (BoardLayout0, - BoardLayout1, - BoardLayout2, - BoardLayout3) diff --git a/toontown/minigame/VoteResultsPanel.py b/toontown/minigame/VoteResultsPanel.py deleted file mode 100644 index 5343ff11..00000000 --- a/toontown/minigame/VoteResultsPanel.py +++ /dev/null @@ -1,108 +0,0 @@ -from direct.gui.DirectGui import DirectFrame, DGG, DirectLabel -from direct.directnotify import DirectNotifyGlobal -from toontown.toonbase import ToontownGlobals -from pandac.PandaModules import Point3, TextNode -from toontown.minigame import TravelGameGlobals -from toontown.toonbase import TTLocalizer -from direct.interval.IntervalGlobal import Parallel, Sequence, LerpFunc, Func, Wait - -class VoteResultsPanel(DirectFrame): - notify = DirectNotifyGlobal.directNotify.newCategory('VoteResultsPanel') - - def __init__(self, numPlayers, avIdList, votes, directions, namesList, disconnectedList, directionToGo, directionReason, directionTotals, *args, **kwargs): - opts = {'relief': None, - 'geom': DGG.getDefaultDialogGeom(), - 'geom_color': ToontownGlobals.GlobalDialogColor[:3] + (0.8,), - 'geom_scale': (1.75, 1, 0.75), - 'pos': (0, 0, 0.525)} - opts.update(kwargs) - DirectFrame.__init__(self, *args, **opts) - self.initialiseoptions(VoteResultsPanel) - listMultiplier = 1 - if TravelGameGlobals.SpoofFour: - listMultiplier = 4 - self.avIdList = avIdList * listMultiplier - self.numPlayers = numPlayers * listMultiplier - self.votes = votes * listMultiplier - self.directions = directions * listMultiplier - self.namesList = namesList * listMultiplier - self.disconnectedList = disconnectedList * listMultiplier - self.directionToGo = directionToGo - self.directionReason = directionReason - self.directionTotals = directionTotals - self.entryList = [] - self.rowFrame = [] - self.upDownFrame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(-1)) - self.upLabel = DirectLabel(parent=self.upDownFrame, relief=None, pos=(1.2, 0, 0.0), text=TTLocalizer.TravelGameDirections[0], text_fg=(0.0, 0.0, 1.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) - self.downLabel = DirectLabel(parent=self.upDownFrame, relief=None, pos=(1.43, 0, 0.0), text=TTLocalizer.TravelGameDirections[1], text_fg=(1.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) - self.totalFrame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(self.numPlayers)) - self.totalText = DirectLabel(parent=self.totalFrame, relief=None, pos=(1.0, 0, 0.0), text='Total', text_fg=(0.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) - self.totalVotesUpLabel = DirectLabel(parent=self.totalFrame, relief=None, pos=(1.2, 0, 0.0), text='', text_fg=(0.0, 0.0, 1.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) - self.totalVotesDownLabel = DirectLabel(parent=self.totalFrame, relief=None, pos=(1.43, 0, 0.0), text='', text_fg=(1.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) - self.totalVotesLabels = [self.totalVotesUpLabel, self.totalVotesDownLabel] - self.resultFrame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(5)) - self.resultLabel = DirectLabel(parent=self.resultFrame, text='', text_scale=0.06, pos=(0.7, 0, 0.0), text_align=TextNode.ACenter) - self.setupResultLabel() - for index in xrange(self.numPlayers): - frame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(index)) - self.rowFrame.append(frame) - nameLabel = DirectFrame(parent=frame, relief=None, pos=(0.46, 0.0, 0.0), text=self.namesList[index], text_fg=(0.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ACenter, text_font=DGG.getDefaultFont()) - votesUpLabel = DirectLabel(parent=frame, relief=None, pos=(1.2, 0.0, 0.0), text='', text_fg=(0, 0, 1, 1), text_scale=0.05, text_align=TextNode.ARight, text_font=DGG.getDefaultFont()) - votesDownLabel = DirectLabel(parent=frame, relief=None, pos=(1.43, 0.0, 0.0), text='', text_fg=(1, 0, 0, 1), text_scale=0.05, text_align=TextNode.ARight, text_font=DGG.getDefaultFont()) - nameLabel.hide() - self.entryList.append((nameLabel, votesUpLabel, votesDownLabel)) - - return - - def getRowPos(self, place): - return Point3(-0.72, -0.01, 0.2 - place * 0.1) - - def setupResultLabel(self): - reasonStr = '' - if self.directionReason == TravelGameGlobals.ReasonVote: - reasonStr = TTLocalizer.TravelGameReasonVotes % {'dir': TTLocalizer.TravelGameDirections[self.directionToGo], - 'numVotes': self.directionTotals[self.directionToGo]} - elif self.directionReason == TravelGameGlobals.ReasonRandom: - reasonStr = TTLocalizer.TravelGameReasonRandom % {'dir': TTLocalizer.TravelGameDirections[self.directionToGo], - 'numVotes': self.directionTotals[self.directionToGo]} - elif self.directionReason == TravelGameGlobals.ReasonPlaceDecider: - reasonStr = TravelGameReasonPlace % {'name': 'TODO NAME', - 'dir': TTLocalizer.TravelGameDirections[self.directionToGo]} - self.resultLabel['text'] = reasonStr - self.resultLabel.hide() - - def createOnePlayerSequence(self, index, duration): - numVotes = self.votes[index] - direction = self.directions[index] - - def ticketTicker(t, label = self.entryList[index][direction + 1], startVotes = 0, endVotes = numVotes): - label['text'] = str(int(t * endVotes + startVotes)) - - track = Parallel() - track.append(Func(self.entryList[index][0].show, name='showName %d' % index)) - track.append(LerpFunc(ticketTicker, duration=duration, name='countVotes %d' % index)) - startVotes = 0 - for prev in xrange(index): - if self.directions[prev] == direction: - startVotes += self.votes[prev] - - def totalTicker(t, label = self.totalVotesLabels[direction], startVotes = startVotes, additionalVotes = numVotes): - label['text'] = str(int(t * additionalVotes + startVotes)) - - track.append(LerpFunc(totalTicker, duration=duration, name='countTotal %d' % index)) - return track - - def startMovie(self): - self.movie = Sequence() - for index in xrange(self.numPlayers): - track = self.createOnePlayerSequence(index, 1.25) - self.movie.append(track) - self.movie.append(Wait(0.75)) - - self.movie.append(Func(self.resultLabel.show)) - self.movie.append(Wait(2.0)) - self.movie.start() - - def destroy(self): - self.movie.finish() - DirectFrame.destroy(self) diff --git a/toontown/minigame/VoteResultsTrolleyPanel.py b/toontown/minigame/VoteResultsTrolleyPanel.py deleted file mode 100644 index 9477dccf..00000000 --- a/toontown/minigame/VoteResultsTrolleyPanel.py +++ /dev/null @@ -1,225 +0,0 @@ -from direct.gui.DirectGui import DirectFrame, DGG, DirectLabel -from direct.directnotify import DirectNotifyGlobal -from toontown.toonbase import ToontownGlobals -from pandac.PandaModules import Point3, TextNode, Vec4 -from toontown.minigame import TravelGameGlobals -from toontown.toonbase import TTLocalizer -from direct.interval.IntervalGlobal import Parallel, Sequence, LerpFunc, Func, Wait, SoundInterval -from direct.showbase.PythonUtil import pdir - -class VoteResultsTrolleyPanel(DirectFrame): - notify = DirectNotifyGlobal.directNotify.newCategory('VoteResultsTrolleyPanel') - - def __init__(self, numPlayers, avIdList, votes, directions, namesList, disconnectedList, directionToGo, directionReason, directionTotals, *args, **kwargs): - opts = {'relief': None, - 'geom': DGG.getDefaultDialogGeom(), - 'geom_color': ToontownGlobals.GlobalDialogColor[:3] + (0.8,), - 'geom_scale': (1.75, 1, 0.25), - 'pos': (0, 0, 0.825)} - opts.update(kwargs) - DirectFrame.__init__(self, *args, **opts) - self.initialiseoptions(VoteResultsTrolleyPanel) - listMultiplier = 1 - if TravelGameGlobals.SpoofFour: - listMultiplier = 4 - self.avIdList = avIdList * listMultiplier - self.numPlayers = numPlayers * listMultiplier - self.votes = votes * listMultiplier - self.directions = directions * listMultiplier - self.namesList = namesList * listMultiplier - self.disconnectedList = disconnectedList * listMultiplier - self.directionToGo = directionToGo - self.directionReason = directionReason - self.directionTotals = directionTotals - self.entryList = [] - self.rowFrame = [] - self.upDownFrame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(-1)) - self.upLabel = DirectLabel(parent=self, relief=None, pos=(-0.5, 0, 0.06), text=TTLocalizer.TravelGameDirections[0] + ':', text_fg=(0.0, 0.0, 1.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) - self.downLabel = DirectLabel(parent=self, relief=None, pos=(0.5, 0, 0.06), text=TTLocalizer.TravelGameDirections[1] + ':', text_fg=(1.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) - self.totalVotesUpLabel = DirectLabel(parent=self.upLabel, relief=None, pos=(0.2, 0, 0.0), text='0', text_fg=(0.0, 0.0, 1.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) - self.totalVotesDownLabel = DirectLabel(parent=self.downLabel, relief=None, pos=(0.2, 0, 0.0), text='0', text_fg=(1.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) - self.totalFrame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(self.numPlayers)) - self.totalVotesLabels = [self.totalVotesUpLabel, self.totalVotesDownLabel] - self.resultFrame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(0.5)) - self.resultLabel = DirectLabel(parent=self.resultFrame, text='', text_scale=0.06, pos=(0.7, 0, 0.0), text_align=TextNode.ACenter) - self.setupResultLabel() - for index in xrange(self.numPlayers): - frame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(index)) - self.rowFrame.append(frame) - nameLabel = DirectFrame(parent=frame, relief=None, pos=(0.46, 0.0, 0.0), text=self.namesList[index], text_fg=(0.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ACenter, text_font=DGG.getDefaultFont()) - votesUpLabel = DirectLabel(parent=frame, relief=None, pos=(1.2, 0.0, 0.0), text='', text_fg=(0, 0, 1, 1), text_scale=0.05, text_align=TextNode.ARight, text_font=DGG.getDefaultFont()) - votesDownLabel = DirectLabel(parent=frame, relief=None, pos=(1.43, 0.0, 0.0), text='', text_fg=(1, 0, 0, 1), text_scale=0.05, text_align=TextNode.ARight, text_font=DGG.getDefaultFont()) - nameLabel.hide() - self.entryList.append((nameLabel, votesUpLabel, votesDownLabel)) - - self.avVotesLabel = {} - self.avArrows = {} - matchingGameGui = loader.loadModel('phase_3.5/models/gui/matching_game_gui') - minnieArrow = matchingGameGui.find('**/minnieArrow') - from toontown.minigame.DistributedTravelGame import map3dToAspect2d - for index in xrange(self.numPlayers): - avId = self.avIdList[index] - av = base.cr.doId2do.get(avId) - if av: - height = av.getHeight() - avPos = av.getPos(render) - avPos.setZ(av.getZ() + 5) - labelPos = map3dToAspect2d(render, avPos) - if not labelPos: - continue - labelPos.setZ(labelPos.getZ() + 0.3) - arrow = None - if self.votes[index] > 0: - arrow = aspect2d.attachNewNode('avArrow') - minnieArrow.copyTo(arrow) - arrow.setScale(1.1, 1, 1.15) - arrow.setPos(labelPos) - if self.directions[index] == 0: - arrow.setR(-90) - arrow.setColorScale(0, 0, 1, 1) - else: - arrow.setR(90) - arrow.setColorScale(1, 0, 0, 1) - arrow.wrtReparentTo(self.resultFrame) - arrow.hide() - self.avArrows[index] = arrow - fgColor = Vec4(0, 0, 0, 1) - if self.votes[index] > 0: - if self.directions[index] == 0: - fgColor = Vec4(0, 0, 1, 1) - else: - fgColor = Vec4(1, 0, 0, 1) - if self.votes[index] > 0: - newLabel = DirectLabel(parent=aspect2d, relief=None, pos=labelPos, text='test', text_fg=(1, 1, 1, 1), text_scale=0.1, text_align=TextNode.ACenter, text_font=ToontownGlobals.getSignFont(), text_pos=(0, -0.01, 0)) - else: - newLabel = DirectLabel(parent=aspect2d, geom=DGG.getDefaultDialogGeom(), geom_scale=(0.2, 1, 0.2), relief=None, pos=labelPos, text='test', text_fg=(0.5, 0.5, 0.5, 1), text_scale=0.1, text_align=TextNode.ACenter, text_font=ToontownGlobals.getSignFont(), text_pos=(0, -0.035, 0)) - newLabel.wrtReparentTo(self.resultFrame) - newLabel.hide() - self.avVotesLabel[index] = newLabel - - matchingGameGui.removeNode() - self.curArrowSfxIndex = 0 - self.upArrowSfx = [] - self.downArrowSfx = [] - for i in xrange(5): - self.upArrowSfx.append(base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_blue_arrow.ogg')) - self.downArrowSfx.append(base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_red_arrow.ogg')) - - self.winVoteSfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_win_vote.ogg') - self.noVoteSfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_square_no_vote_1.ogg') - self.loseVoteSfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_lose_vote.ogg') - self.localAvatarWon = False - self.localAvatarLost = False - localIndex = self.avIdList.index(base.localAvatar.doId) - localDirection = self.directions[localIndex] - localVotes = self.votes[localIndex] - if localVotes: - if localDirection == self.directionToGo: - if not TravelGameGlobals.ReverseWin: - self.localAvatarWon = True - else: - self.localAvatarLost = True - elif not TravelGameGlobals.ReverseWin: - self.localAvatarLost = True - else: - self.localAvatarWon = True - return - - def getRowPos(self, place): - return Point3(-0.72, -0.01, 0.0 - place * 0.1) - - def setupResultLabel(self): - reasonStr = '' - if self.directionReason == TravelGameGlobals.ReasonVote: - if self.directionToGo == 0: - losingDirection = 1 - else: - losingDirection = 0 - diffVotes = self.directionTotals[self.directionToGo] - self.directionTotals[losingDirection] - if diffVotes > 1: - reasonStr = TTLocalizer.TravelGameReasonVotesPlural % {'dir': TTLocalizer.TravelGameDirections[self.directionToGo], - 'numVotes': diffVotes} - else: - reasonStr = TTLocalizer.TravelGameReasonVotesSingular % {'dir': TTLocalizer.TravelGameDirections[self.directionToGo], - 'numVotes': diffVotes} - elif self.directionReason == TravelGameGlobals.ReasonRandom: - reasonStr = TTLocalizer.TravelGameReasonRandom % {'dir': TTLocalizer.TravelGameDirections[self.directionToGo], - 'numVotes': self.directionTotals[self.directionToGo]} - elif self.directionReason == TravelGameGlobals.ReasonPlaceDecider: - reasonStr = TravelGameReasonPlace % {'name': 'TODO NAME', - 'dir': TTLocalizer.TravelGameDirections[self.directionToGo]} - self.resultLabel['text'] = reasonStr - self.resultLabel.hide() - - def createOnePlayerSequence(self, index, duration): - numVotes = self.votes[index] - direction = self.directions[index] - - def ticketTicker(t, label = self.entryList[index][direction + 1], startVotes = 0, endVotes = numVotes): - label['text'] = str(int(t * endVotes + startVotes)) - - track = Parallel() - startVotes = 0 - for prev in xrange(index): - if self.directions[prev] == direction: - startVotes += self.votes[prev] - - def totalTicker(t, label = self.totalVotesLabels[direction], startVotes = startVotes, additionalVotes = numVotes): - label['text'] = str(int(t * additionalVotes + startVotes)) - - track.append(LerpFunc(totalTicker, duration=duration, name='countTotal %d' % index)) - if index in self.avVotesLabel: - - def avVotesTicker(t, label = self.avVotesLabel[index], startVotes = 0, endVotes = numVotes, direction = direction): - oldValue = label['text'] - newValue = int(t * endVotes + startVotes) - label['text'] = str(newValue) - if not oldValue == label['text']: - if newValue: - if direction == 0: - self.upArrowSfx[self.curArrowSfxIndex].play() - else: - self.downArrowSfx[self.curArrowSfxIndex].play() - self.curArrowSfxIndex += 1 - if self.curArrowSfxIndex >= len(self.upArrowSfx): - self.curArrowSfxIndex = 0 - - label = self.avVotesLabel[index] - track.append(Func(self.avVotesLabel[index].show, name='showName %d' % index)) - if index in self.avArrows: - track.append(Func(self.avArrows[index].show, name='showArrow %d' % index)) - if direction == 0 and numVotes: - pass - elif direction == 1 and numVotes: - pass - else: - track.append(SoundInterval(self.noVoteSfx)) - track.append(LerpFunc(avVotesTicker, duration=duration, name='countAvVotes %d' % index)) - return track - - def startMovie(self): - self.movie = Sequence() - for index in xrange(self.numPlayers): - track = self.createOnePlayerSequence(index, 1.25) - self.movie.append(track) - self.movie.append(Wait(0.75)) - - self.movie.append(Func(self.resultLabel.show)) - soundAndWait = Parallel() - soundAndWait.append(Wait(2.0)) - if self.localAvatarWon: - soundAndWait.append(SoundInterval(self.winVoteSfx)) - elif self.localAvatarLost: - soundAndWait.append(SoundInterval(self.loseVoteSfx, duration=0.43)) - self.movie.append(soundAndWait) - self.movie.start() - - def destroy(self): - self.movie.finish() - del self.movie - del self.winVoteSfx - del self.noVoteSfx - del self.upArrowSfx - del self.loseVoteSfx - del self.downArrowSfx - DirectFrame.destroy(self) diff --git a/toontown/quest/Quests.py b/toontown/quest/Quests.py index c3f6943d..a59bd8ae 100644 --- a/toontown/quest/Quests.py +++ b/toontown/quest/Quests.py @@ -1059,23 +1059,20 @@ class BuildingQuest(CogQuest): type = TTLocalizer.Cog else: type = self.trackNames[self.trackCodes.index(buildingTrack)] - floors = TTLocalizer.QuestsBuildingQuestFloorNumbers[self.getNumFloors() - 1] + floors = '' if self.isCogdo(): - if count == 1: - return TTLocalizer.QuestsCogdoQuestDesc + if buildingTrack == Any: + text = TTLocalizer.QuestsCogdoQuestDescU if count == 1 else TTLocalizer.QuestsCogdoQuestDescUM else: - return TTLocalizer.QuestsCogdoQuestDescC + text = TTLocalizer.QuestsCogdoQuestDesc if count == 1 else TTLocalizer.QuestsCogdoQuestDescM else: + floors = TTLocalizer.QuestsBuildingQuestFloorNumbers[self.getNumFloors() - 1] + if count == 1: - if floors == '': - text = TTLocalizer.QuestsBuildingQuestDesc - else: - text = TTLocalizer.QuestsBuildingQuestDescF - elif floors == '': - text = TTLocalizer.QuestsBuildingQuestDescC + text = TTLocalizer.QuestsBuildingQuestDesc if floors == '' else TTLocalizer.QuestsBuildingQuestDescF else: - text = TTLocalizer.QuestsBuildingQuestDescCF + text = TTLocalizer.QuestsBuildingQuestDescC if floors == '' else TTLocalizer.QuestsBuildingQuestDescCF return (text % {'count': count, 'floors': floors, @@ -1089,32 +1086,29 @@ class BuildingQuest(CogQuest): return getFinishToonTaskSCStrings(toNpcId) count = self.getNumBuildings() buildingTrack = self.getBuildingTrack() + floors = '' + if buildingTrack == Any: type = TTLocalizer.Cog else: type = self.trackNames[self.trackCodes.index(buildingTrack)] - floors = TTLocalizer.QuestsBuildingQuestFloorNumbers[self.getNumFloors() - 1] if self.isCogdo(): - if count == 1: - return TTLocalizer.QuestsCogdoQuestDesc + if buildingTrack == Any: + text = TTLocalizer.QuestsCogdoQuestDescU if count == 1 else TTLocalizer.QuestsCogdoQuestDescMUI else: - return TTLocalizer.QuestsCogdoQuestDescI + text = TTLocalizer.QuestsCogdoQuestDesc if count == 1 else TTLocalizer.QuestsCogdoQuestDescMI else: + floors = TTLocalizer.QuestsBuildingQuestFloorNumbers[self.getNumFloors() - 1] + if count == 1: - if floors == '': - text = TTLocalizer.QuestsBuildingQuestDesc - else: - text = TTLocalizer.QuestsBuildingQuestDescF - elif floors == '': - text = TTLocalizer.QuestsBuildingQuestDescI + text = TTLocalizer.QuestsBuildingQuestDesc if floors == '' else TTLocalizer.QuestsBuildingQuestDescF else: - text = TTLocalizer.QuestsBuildingQuestDescIF + text = TTLocalizer.QuestsBuildingQuestDescI if floors == '' else TTLocalizer.QuestsBuildingQuestDescIF objective = text % {'floors': floors, 'type': type} - location = self.getLocationName() return TTLocalizer.QuestsBuildingQuestSCString % {'objective': objective, - 'location': location} + 'location': self.getLocationName()} def getHeadlineString(self): return TTLocalizer.QuestsBuildingQuestHeadline diff --git a/toontown/safezone/DistributedTrolleyAI.py b/toontown/safezone/DistributedTrolleyAI.py index 994c533d..0c7f60ad 100644 --- a/toontown/safezone/DistributedTrolleyAI.py +++ b/toontown/safezone/DistributedTrolleyAI.py @@ -270,18 +270,8 @@ class DistributedTrolleyAI(DistributedObjectAI.DistributedObjectAI): for i in self.seats: if i not in [None, 0]: playerArray.append(i) - startingVotes = None - metagameRound = -1 - trolleyGoesToMetagame = simbase.config.GetBool('want-travel-game', 0) - trolleyHoliday = bboard.get(TrolleyHolidayMgrAI.TrolleyHolidayMgrAI.PostName) - trolleyWeekend = bboard.get(TrolleyWeekendMgrAI.TrolleyWeekendMgrAI.PostName) - if trolleyGoesToMetagame and (trolleyHoliday or trolleyWeekend): - metagameRound = 0 - if len(playerArray) == 1: - metagameRound = -1 mgDict = MinigameCreatorAI.createMinigame( - self.air, playerArray, self.zoneId, newbieIds=newbieIds, - startingVotes=startingVotes, metagameRound=metagameRound) + self.air, playerArray, self.zoneId, newbieIds=newbieIds) minigameZone = mgDict['minigameZone'] minigameId = mgDict['minigameId'] for seatIndex in xrange(len(self.seats)): diff --git a/toontown/shtiker/PurchaseManager.py b/toontown/shtiker/PurchaseManager.py index 0d9ae947..10356413 100644 --- a/toontown/shtiker/PurchaseManager.py +++ b/toontown/shtiker/PurchaseManager.py @@ -3,7 +3,6 @@ from PurchaseManagerConstants import * from direct.distributed.ClockDelta import * from direct.distributed import DistributedObject from direct.directnotify import DirectNotifyGlobal -from toontown.minigame import TravelGameGlobals class PurchaseManager(DistributedObject.DistributedObject): notify = DirectNotifyGlobal.directNotify.newCategory('PurchaseManager') @@ -59,14 +58,10 @@ class PurchaseManager(DistributedObject.DistributedObject): self.moneyArray, self.avIds, self.playerStates, - remain, - self.metagameRound, - self.votesArray]) + remain]) def calcHasLocalToon(self): retval = base.localAvatar.doId not in self.newbieIds and base.localAvatar.doId in self.avIds - if self.metagameRound > -1 and self.metagameRound < TravelGameGlobals.FinalMetagameRoundIndex: - retval = base.localAvatar.doId in self.avIds self.notify.debug('calcHasLocalToon returning %s' % retval) return retval @@ -97,12 +92,4 @@ class PurchaseManager(DistributedObject.DistributedObject): if self.hasLocalToon: self.ignore('boughtGag') self.d_setInventory(base.localAvatar.inventory.makeNetString(), base.localAvatar.getMoney(), 1) - messenger.send('purchaseOver', [self.playAgain]) - - def setMetagameRound(self, round): - self.notify.debug('setMetagameRound: %s' % (round,)) - self.metagameRound = round - - def setVotesArray(self, votesArray): - self.notify.debug('setVotesArray: %s' % votesArray) - self.votesArray = votesArray + messenger.send('purchaseOver', [self.playAgain]) \ No newline at end of file diff --git a/toontown/shtiker/PurchaseManagerAI.py b/toontown/shtiker/PurchaseManagerAI.py index f9967d73..f4af7288 100644 --- a/toontown/shtiker/PurchaseManagerAI.py +++ b/toontown/shtiker/PurchaseManagerAI.py @@ -6,14 +6,13 @@ import copy from direct.task.Task import Task from direct.distributed import DistributedObjectAI from direct.directnotify import DirectNotifyGlobal -from toontown.minigame import TravelGameGlobals from toontown.toonbase import ToontownGlobals from toontown.minigame import MinigameGlobals class PurchaseManagerAI(DistributedObjectAI.DistributedObjectAI): notify = DirectNotifyGlobal.directNotify.newCategory('PurchaseManagerAI') - def __init__(self, air, avArray, mpArray, previousMinigameId, trolleyZone, newbieIdList = [], votesArray = None, metagameRound = -1, desiredNextGame = None): + def __init__(self, air, avArray, mpArray, previousMinigameId, trolleyZone, newbieIdList = []): DistributedObjectAI.DistributedObjectAI.__init__(self, air) self.avIds = copy.deepcopy(avArray) self.minigamePoints = copy.deepcopy(mpArray) @@ -21,12 +20,6 @@ class PurchaseManagerAI(DistributedObjectAI.DistributedObjectAI): self.trolleyZone = trolleyZone self.newbieIds = copy.deepcopy(newbieIdList) self.isShutdown = 0 - if votesArray: - self.votesArray = copy.deepcopy(votesArray) - else: - self.votesArray = [] - self.metagameRound = metagameRound - self.desiredNextGame = desiredNextGame for i in xrange(len(self.avIds), 4): self.avIds.append(0) @@ -79,16 +72,6 @@ class PurchaseManagerAI(DistributedObjectAI.DistributedObjectAI): self.trolleyZone, self.avIds, self.minigamePoints[avIndex])) - if self.metagameRound == TravelGameGlobals.FinalMetagameRoundIndex: - numPlayers = len(self.votesArray) - extraBeans = self.votesArray[avIndex] * TravelGameGlobals.PercentOfVotesConverted[numPlayers] / 100.0 - if self.air.holidayManager.isHolidayRunning(ToontownGlobals.JELLYBEAN_TROLLEY_HOLIDAY) or self.air.holidayManager.isHolidayRunning(ToontownGlobals.JELLYBEAN_TROLLEY_HOLIDAY_MONTH): - extraBeans *= MinigameGlobals.JellybeanTrolleyHolidayScoreMultiplier - av.addMoney(extraBeans) - self.air.writeServerEvent('minigame_extraBeans', avId, '%s|%s|%s|%s' % (self.previousMinigameId, - self.trolleyZone, - self.avIds, - extraBeans)) self.receivingInventory = 1 self.receivingButtons = 1 @@ -104,15 +87,13 @@ class PurchaseManagerAI(DistributedObjectAI.DistributedObjectAI): for avId in self.avIds: if avId not in self.newbieIds: avIds.append(avId) - elif self.metagameRound > -1 and self.metagameRound < TravelGameGlobals.FinalMetagameRoundIndex: - avIds.append(avId) return avIds def getMinigamePoints(self): return self.minigamePoints - def getavIds(self): + def getAvIds(self): return self.avIds def getNewbieIds(self): @@ -255,18 +236,6 @@ class PurchaseManagerAI(DistributedObjectAI.DistributedObjectAI): self.receivingInventory = 1 return None - def getVotesArrayMatchingPlayAgainList(self, playAgainList): - retval = [] - for playAgainIndex in xrange(len(playAgainList)): - avId = playAgainList[playAgainIndex] - origIndex = self.avIds.index(avId) - if self.votesArray and origIndex < len(self.votesArray): - retval.append(self.votesArray[origIndex]) - else: - retval.append(0) - - return retval - def shutDown(self): if self.isShutdown: self.notify.warning('Got shutDown twice') @@ -275,20 +244,7 @@ class PurchaseManagerAI(DistributedObjectAI.DistributedObjectAI): from toontown.minigame import MinigameCreatorAI playAgainNum = self.getNumPlayAgain() if playAgainNum > 0: - playAgainList = self.getPlayAgainList() - newVotesArray = self.getVotesArrayMatchingPlayAgainList(playAgainList) - newRound = self.metagameRound - newbieIdsToPass = [] - if newRound > -1: - newbieIdsToPass = self.newbieIds - if newRound < TravelGameGlobals.FinalMetagameRoundIndex: - newRound += 1 - else: - newRound = 0 - newVotesArray = [TravelGameGlobals.DefaultStartingVotes] * len(playAgainList) - if len(playAgainList) == 1 and simbase.config.GetBool('metagame-min-2-players', 1): - newRound = -1 - MinigameCreatorAI.createMinigame(self.air, playAgainList, self.trolleyZone, minigameZone=self.zoneId, previousGameId=self.previousMinigameId, newbieIds=newbieIdsToPass, startingVotes=newVotesArray, metagameRound=newRound, desiredNextGame=self.desiredNextGame) + MinigameCreatorAI.createMinigame(self.air, self.getPlayAgainList(), self.trolleyZone, minigameZone=self.zoneId, previousGameId=self.previousMinigameId, newbieIds=self.newbieIds) else: MinigameCreatorAI.releaseMinigameZone(self.zoneId) self.requestDelete() @@ -358,10 +314,4 @@ class PurchaseManagerAI(DistributedObjectAI.DistributedObjectAI): return def handlePlayerLeaving(self, avId): - pass - - def getMetagameRound(self): - return self.metagameRound - - def getVotesArray(self): - return self.votesArray + pass \ No newline at end of file diff --git a/toontown/toonbase/TTLocalizerEnglish.py b/toontown/toonbase/TTLocalizerEnglish.py index 39cec280..452d3420 100644 --- a/toontown/toonbase/TTLocalizerEnglish.py +++ b/toontown/toonbase/TTLocalizerEnglish.py @@ -279,8 +279,11 @@ QuestsBuildingQuestDescCF = '%(count)s %(floors)s story %(type)s Buildings' QuestsBuildingQuestDescI = 'some %(type)s Buildings' QuestsBuildingQuestDescIF = 'some %(floors)s story %(type)s Buildings' QuestsCogdoQuestDesc = 'a %(type)s Field Office' -QuestsCogdoQuestDescC = '%(count)s %(type)s Field Offices' -QuestsCogdoQuestDescI = 'some %(type)s Field Offices' +QuestsCogdoQuestDescM = '%(count)s %(type)s Field Offices' +QuestsCogdoQuestDescMUI = 'some %(type)s Field Offices' +QuestsCogdoQuestDescU = 'a Field Office' +QuestsCogdoQuestDescUM = '%(count)s Field Offices' +QuestsCogdoQuestDescMI = 'some Field Offices' QuestFactoryQuestFactory = 'Factory' QuestsFactoryQuestFactories = 'Factories' QuestsFactoryQuestHeadline = 'DEFEAT' @@ -3473,13 +3476,11 @@ MusicCreateAToon = 'The New Toon in Town' MusicTtuTheme = 'The Toontown United Theme' MusicTtTheme = 'The Toontown Theme' MusicMinigameRace = 'Slow and Steady' -MusicMgPairing = 'Remember Me?' MusicTcNbrhood = 'Toontown Central' MusicMgDiving = 'Treasure Lullaby' MusicMgCannonGame = 'Fire the Cannons!' MusicMgTwodgame = 'Running Toon' MusicMgCogthief = 'Catch That Cog!' -MusicMgTravel = 'Traveling Music' MusicMgTugOWar = 'Tug-of-War' MusicMgVine = 'The Jungle Swing' MusicMgIcegame = 'Slippery Situation' @@ -8276,38 +8277,6 @@ def getResultPlantedSomethingSentence(flowerName): retval = ResultPlantedSomething % flowerName return retval - -TravelGameTitle = 'Trolley Tracks' -TravelGameInstructions = 'Click up or down to set your number of votes. Click the vote button to cast it. Reach your secret goal to get bonus beans. Earn more votes by doing well in the other games.' -TravelGameRemainingVotes = 'Remaining Votes:' -TravelGameUse = 'Use' -TravelGameVotesWithPeriod = 'votes.' -TravelGameVotesToGo = 'votes to go' -TravelGameVoteToGo = 'vote to go' -TravelGameUp = 'UP.' -TravelGameDown = 'DOWN.' -TravelGameVoteWithExclamation = 'Vote!' -TravelGameWaitingChoices = 'Waiting for other toons to vote...' -TravelGameDirections = ['UP', 'DOWN'] -TravelGameTotals = 'Totals ' -TravelGameReasonVotes = 'The trolley is moving %(dir)s, winning by %(numVotes)d votes.' -TravelGameReasonVotesPlural = 'The trolley is moving %(dir)s, winning by %(numVotes)d votes.' -TravelGameReasonVotesSingular = 'The trolley is moving %(dir)s, winning by %(numVotes)d vote.' -TravelGameReasonPlace = '%(name)s breaks the tie. The trolley is moving %(dir)s.' -TravelGameReasonRandom = 'The trolley is randomly moving %(dir)s.' -TravelGameOneToonVote = '%(name)s used %(numVotes)s votes to go %(dir)s\n' -TravelGameBonusBeans = '%(numBeans)d Beans' -TravelGamePlaying = 'Up next, the %(game)s trolley game.' -TravelGameGotBonus = '%(name)s got a bonus of %(numBeans)s Jellybeans!' -TravelGameNoOneGotBonus = 'No one reached their secret goal. Everyone gets 1 Jellybean.' -TravelGameConvertingVotesToBeans = 'Converting some votes to Jellybeans...' -TravelGameGoingBackToShop = "Only 1 toon left. Going to Goofy's Gag Shop." -PairingGameTitle = 'Toon Memory Game' -PairingGameInstructions = 'Press Delete to open a card. Match 2 cards to score a point. Make a match with the bonus glow and earn an extra point. Earn more points by keeping the flips low.' -PairingGameInstructionsMulti = 'Press Delete to open a card. Press Control to signal another toon to open a card. Match 2 cards to score a point. Make a match with the bonus glow and earn an extra point. Earn more points by keeping the flips low.' -PairingGamePerfect = 'PERFECT!!' -PairingGameFlips = 'Flips:' -PairingGamePoints = 'Points:' TrolleyHolidayStart = 'Trolley Tracks is about to begin! Board any trolley with 2 or more toons to play.' TrolleyHolidayOngoing = 'Welcome! Trolley Tracks is currently in progress.' TrolleyHolidayEnd = "That's all for today's Trolley Tracks. See you next week!" @@ -8862,7 +8831,6 @@ InteractivePropTrackBonusTerms = {0: 'Super Toon-Up!', 4: 'Super Throw!', 5: 'Super Squirt!', 6: ''} -PlayingCardUnknown = 'Card Name is unknown' GloveSameColorMessage = 'You already have those gloves!' GloveNoMoneyMessage = "You don't have enough jellybeans!" GloveSuccessMessage = 'Have fun with your new gloves!' diff --git a/toontown/toonbase/TTLocalizerEnglishProperty.py b/toontown/toonbase/TTLocalizerEnglishProperty.py index feddcfa6..6629f773 100644 --- a/toontown/toonbase/TTLocalizerEnglishProperty.py +++ b/toontown/toonbase/TTLocalizerEnglishProperty.py @@ -99,15 +99,6 @@ MPMgaugeTargetTop = 0.35 MPMgaugeTargetBot = 0.35 PstatusLabel = 0.08 PBstatusLabel = 0.08 -DPGpointsFrame = 0.7 -DPGflipsFrame = 0.7 -DTGvoteButton = 0.07 -DTGuseLabel = 0.1 -DTGvotesPeriodLabel = 0.1 -DTGvotesToGoLabel = 0.1 -DTGupLabel = 0.125 -DTGdownLabel = 0.125 -DTGremainingVotesFrame = 0.7 CStoonFrame = 0.0575 NSmaxNameWidth = 8.0 NSdirectScrolleList = 0.1 diff --git a/toontown/toonbase/ToontownGlobals.py b/toontown/toonbase/ToontownGlobals.py index 111ca4bf..801637e6 100644 --- a/toontown/toonbase/ToontownGlobals.py +++ b/toontown/toonbase/ToontownGlobals.py @@ -342,13 +342,11 @@ TugOfWarGameId = 7 CatchGameId = 8 DivingGameId = 9 TargetGameId = 10 -PairingGameId = 11 -VineGameId = 12 -IceGameId = 13 -CogThiefGameId = 14 -TwoDGameId = 15 -PhotoGameId = 16 -TravelGameId = 100 +VineGameId = 11 +IceGameId = 12 +CogThiefGameId = 13 +TwoDGameId = 14 +PhotoGameId = 15 MinigameNames = {'race': RaceGameId, 'cannon': CannonGameId, 'tag': TagGameId, @@ -362,13 +360,11 @@ MinigameNames = {'race': RaceGameId, 'catch': CatchGameId, 'diving': DivingGameId, 'target': TargetGameId, - 'pairing': PairingGameId, 'vine': VineGameId, 'ice': IceGameId, 'thief': CogThiefGameId, '2d': TwoDGameId, - 'photo': PhotoGameId, - 'travel': TravelGameId} + 'photo': PhotoGameId} MinigameTemplateId = -1 MinigameIDs = (RaceGameId, CannonGameId, @@ -380,18 +376,16 @@ MinigameIDs = (RaceGameId, CatchGameId, DivingGameId, TargetGameId, - PairingGameId, VineGameId, IceGameId, CogThiefGameId, TwoDGameId, - PhotoGameId, - TravelGameId) + PhotoGameId) MinigamePlayerMatrix = { - 1: (CannonGameId, MazeGameId, TugOfWarGameId, RingGameId, VineGameId, CogThiefGameId, TwoDGameId, DivingGameId, PairingGameId, CatchGameId, TargetGameId, PhotoGameId), - 2: (CannonGameId, MazeGameId, TugOfWarGameId, PatternGameId, TagGameId, RingGameId, VineGameId, IceGameId, CogThiefGameId, TwoDGameId, DivingGameId, PairingGameId, CatchGameId, TargetGameId, PhotoGameId), - 3: (CannonGameId, MazeGameId, TugOfWarGameId, PatternGameId, RaceGameId, TagGameId, VineGameId, RingGameId, IceGameId, CogThiefGameId, TwoDGameId, DivingGameId, PairingGameId, CatchGameId, TargetGameId, PhotoGameId), - 4: (CannonGameId, MazeGameId, TugOfWarGameId, PatternGameId, RaceGameId, TagGameId, VineGameId, RingGameId, IceGameId, CogThiefGameId, TwoDGameId, DivingGameId, PairingGameId, CatchGameId, TargetGameId, PhotoGameId), + 1: (CannonGameId, MazeGameId, TugOfWarGameId, RingGameId, VineGameId, CogThiefGameId, TwoDGameId, DivingGameId, CatchGameId, TargetGameId, PhotoGameId), + 2: (CannonGameId, MazeGameId, TugOfWarGameId, PatternGameId, TagGameId, RingGameId, VineGameId, IceGameId, CogThiefGameId, TwoDGameId, DivingGameId, CatchGameId, TargetGameId, PhotoGameId), + 3: (CannonGameId, MazeGameId, TugOfWarGameId, PatternGameId, RaceGameId, TagGameId, VineGameId, RingGameId, IceGameId, CogThiefGameId, TwoDGameId, DivingGameId, CatchGameId, TargetGameId, PhotoGameId), + 4: (CannonGameId, MazeGameId, TugOfWarGameId, PatternGameId, RaceGameId, TagGameId, VineGameId, RingGameId, IceGameId, CogThiefGameId, TwoDGameId, DivingGameId, CatchGameId, TargetGameId, PhotoGameId), } KeyboardTimeout = 300 phaseMap = {Tutorial: 4,