mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2025-01-09 17:53:50 +00:00
Merge branch 'master' of https://gitlab.com/ToontownUnited/src
This commit is contained in:
commit
712e41a369
29 changed files with 61 additions and 3507 deletions
11
.gitignore
vendored
11
.gitignore
vendored
|
@ -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/
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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)
|
|
@ -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)
|
|
@ -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)
|
|
@ -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)
|
File diff suppressed because it is too large
Load diff
|
@ -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
|
|
@ -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:
|
||||
|
|
|
@ -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 = []
|
||||
|
|
|
@ -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)
|
|
@ -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
|
|
@ -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)
|
|
@ -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
|
|
@ -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']
|
|
@ -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:
|
||||
|
|
|
@ -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
|
|
@ -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)
|
|
@ -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)
|
|
@ -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)
|
|
@ -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
|
||||
|
|
|
@ -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)):
|
||||
|
|
|
@ -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])
|
|
@ -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
|
|
@ -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!'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue