mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2025-01-09 17:53:50 +00:00
Merge branch 'rental-items'
Conflicts: config/release/dev.prc otp/distributed/DCClassImports.py toontown/estate/DistributedEstateAI.py
This commit is contained in:
commit
8c7498d548
24 changed files with 2845 additions and 634 deletions
|
@ -484,7 +484,6 @@ from toontown.parties import DistributedPartyValentineJukebox40Activity/AI
|
||||||
from toontown.friends import TTUFriendsManager/UD
|
from toontown.friends import TTUFriendsManager/UD
|
||||||
from toontown.safezone import DistributedGolfKart/AI
|
from toontown.safezone import DistributedGolfKart/AI
|
||||||
from toontown.safezone import DistributedPicnicBasket/AI
|
from toontown.safezone import DistributedPicnicBasket/AI
|
||||||
from toontown.safezone import DistributedGameTable/AI
|
|
||||||
from toontown.distributed import DistributedTimer/AI
|
from toontown.distributed import DistributedTimer/AI
|
||||||
from toontown.suit import DistributedBossbotBoss/AI
|
from toontown.suit import DistributedBossbotBoss/AI
|
||||||
from toontown.coghq import DistributedCogKart/AI
|
from toontown.coghq import DistributedCogKart/AI
|
||||||
|
@ -502,6 +501,7 @@ from toontown.coghq import DistributedGolfSpot/AI
|
||||||
from toontown.minigame import DistributedIceGame/AI
|
from toontown.minigame import DistributedIceGame/AI
|
||||||
from toontown.minigame import DistributedCogThiefGame/AI
|
from toontown.minigame import DistributedCogThiefGame/AI
|
||||||
from toontown.minigame import DistributedTwoDGame/AI
|
from toontown.minigame import DistributedTwoDGame/AI
|
||||||
|
from toontown.safezone import DistributedPicnicTable/AI
|
||||||
from toontown.safezone import DistributedChineseCheckers/AI
|
from toontown.safezone import DistributedChineseCheckers/AI
|
||||||
from toontown.safezone import DistributedCheckers/AI
|
from toontown.safezone import DistributedCheckers/AI
|
||||||
from toontown.safezone import DistributedFindFour/AI
|
from toontown.safezone import DistributedFindFour/AI
|
||||||
|
@ -3144,6 +3144,28 @@ dclass DistributedTwoDGame : DistributedMinigame {
|
||||||
setEveryoneDone() broadcast;
|
setEveryoneDone() broadcast;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dclass DistributedPicnicTable : DistributedNode {
|
||||||
|
setTableIndex(uint8) required broadcast ram;
|
||||||
|
fillSlot(uint32, uint8, int16/10, int16/10, int16/10, int16/10, int16/10, int16/10, int16, uint32) broadcast;
|
||||||
|
emptySlot(uint32, uint8, int16) broadcast;
|
||||||
|
requestTableState() airecv clsend;
|
||||||
|
setTableState(uint32 [], uint8) broadcast ram;
|
||||||
|
setGameZone(uint32, uint8) broadcast;
|
||||||
|
setIsPlaying(uint8) broadcast ram;
|
||||||
|
requestJoin(uint8, int16/10, int16/10, int16/10, int16/10, int16/10, int16/10) airecv clsend;
|
||||||
|
rejectJoin() broadcast;
|
||||||
|
requestObserve() airecv clsend;
|
||||||
|
leaveObserve() airecv clsend;
|
||||||
|
requestGameZone() airecv clsend;
|
||||||
|
requestPickedGame(uint8) clsend airecv;
|
||||||
|
requestExit() airecv clsend;
|
||||||
|
requestZone() clsend airecv;
|
||||||
|
announceWinner(string, uint32) broadcast;
|
||||||
|
allowObserve() broadcast;
|
||||||
|
allowPick() broadcast;
|
||||||
|
setZone(uint32) broadcast;
|
||||||
|
};
|
||||||
|
|
||||||
dclass DistributedChineseCheckers : DistributedNode {
|
dclass DistributedChineseCheckers : DistributedNode {
|
||||||
requestExit() clsend airecv;
|
requestExit() clsend airecv;
|
||||||
requestBegin() clsend airecv;
|
requestBegin() clsend airecv;
|
||||||
|
|
|
@ -15,7 +15,7 @@ shard-mid-pop 100
|
||||||
want-rpc-server #f
|
want-rpc-server #f
|
||||||
rpc-server-endpoint http://localhost:8080/
|
rpc-server-endpoint http://localhost:8080/
|
||||||
|
|
||||||
# DClass file:
|
# DClass files (in reverse order):
|
||||||
dc-file astron/dclass/united.dc
|
dc-file astron/dclass/united.dc
|
||||||
|
|
||||||
# Core features:
|
# Core features:
|
||||||
|
@ -23,7 +23,12 @@ want-pets #t
|
||||||
want-parties #t
|
want-parties #t
|
||||||
want-cogdominiums #t
|
want-cogdominiums #t
|
||||||
want-lawbot-cogdo #t
|
want-lawbot-cogdo #t
|
||||||
|
want-achievements #f
|
||||||
want-anim-props #t
|
want-anim-props #t
|
||||||
|
want-game-tables #t
|
||||||
|
want-find-four #f
|
||||||
|
want-chinese-checkers #t
|
||||||
|
want-checkers #f
|
||||||
|
|
||||||
# Chat:
|
# Chat:
|
||||||
want-whitelist #f
|
want-whitelist #f
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
from pandac.PandaModules import *
|
from pandac.PandaModules import *
|
||||||
|
|
||||||
|
|
||||||
hashVal = 2698095309L
|
hashVal = 1973332971
|
||||||
|
|
||||||
|
|
||||||
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
|
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
|
||||||
|
@ -14,7 +14,7 @@ from otp.level import DistributedLevel, DistributedEntity, DistributedInteractiv
|
||||||
from toontown.shtiker import DeleteManager, PurchaseManager, NewbiePurchaseManager
|
from toontown.shtiker import DeleteManager, PurchaseManager, NewbiePurchaseManager
|
||||||
from toontown.groups import GroupManager
|
from toontown.groups import GroupManager
|
||||||
from toontown.uberdog.ClientServicesManager import ClientServicesManager
|
from toontown.uberdog.ClientServicesManager import ClientServicesManager
|
||||||
from toontown.ai import WelcomeValleyManager, NewsManager, DistributedAprilToonsMgr, DistributedBlackCatMgr, DistributedReportMgr, DistributedPolarPlaceEffectMgr, DistributedGreenToonEffectMgr, DistributedResistanceEmoteMgr, DistributedScavengerHuntTarget, DistributedTrickOrTreatTarget, DistributedWinterCarolingTarget, DistributedSillyMeterMgr
|
from toontown.ai import WelcomeValleyManager, NewsManager, DistributedAprilToonsMgr, DistributedBlackCatMgr, DistributedReportMgr, DistributedPolarBearMgr, DistributedPolarPlaceEffectMgr, DistributedGreenToonEffectMgr, DistributedResistanceEmoteMgr, DistributedScavengerHuntTarget, DistributedTrickOrTreatTarget, DistributedWinterCarolingTarget, DistributedSillyMeterMgr
|
||||||
from otp.chat import ChatAgent
|
from otp.chat import ChatAgent
|
||||||
from toontown.parties.GlobalPartyManager import GlobalPartyManager
|
from toontown.parties.GlobalPartyManager import GlobalPartyManager
|
||||||
from toontown.racing.DistributedStartingBlock import DistributedViewingBlock
|
from toontown.racing.DistributedStartingBlock import DistributedViewingBlock
|
||||||
|
@ -22,7 +22,7 @@ from toontown.pets.PetDCImports import *
|
||||||
from toontown.suit import DistributedSuitPlanner, DistributedSuitBase, DistributedSuit, DistributedTutorialSuit, DistributedFactorySuit, DistributedMintSuit, DistributedStageSuit, DistributedSellbotBoss, DistributedCashbotBoss, DistributedCashbotBossGoon, DistributedGoon, DistributedGridGoon, DistributedLawbotBoss, DistributedLawbotBossSuit, DistributedBossbotBoss
|
from toontown.suit import DistributedSuitPlanner, DistributedSuitBase, DistributedSuit, DistributedTutorialSuit, DistributedFactorySuit, DistributedMintSuit, DistributedStageSuit, DistributedSellbotBoss, DistributedCashbotBoss, DistributedCashbotBossGoon, DistributedGoon, DistributedGridGoon, DistributedLawbotBoss, DistributedLawbotBossSuit, DistributedBossbotBoss
|
||||||
from toontown.distributed import ToontownDistrict, ToontownDistrictStats, DistributedTimer
|
from toontown.distributed import ToontownDistrict, ToontownDistrictStats, DistributedTimer
|
||||||
from toontown.effects import DistributedFireworkShow
|
from toontown.effects import DistributedFireworkShow
|
||||||
from toontown.safezone import DistributedTrolley, DistributedPartyGate, DistributedBoat, DistributedButterfly, DistributedMMPiano, DistributedDGFlower, DistributedFishingSpot, SafeZoneManager, DistributedTreasure, DistributedGolfKart, DistributedPicnicBasket, DistributedGameTable, DistributedChineseCheckers, DistributedCheckers, DistributedFindFour
|
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.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, DistributedTravelGame, DistributedPairingGame, DistributedVineGame, DistributedIceGame, DistributedCogThiefGame, DistributedTwoDGame
|
||||||
from toontown.racing import DistributedVehicle, DistributedStartingBlock, DistributedRace, DistributedKartPad, DistributedRacePad, DistributedViewPad, DistributedStartingBlock, DistributedLeaderBoard, DistributedGag, DistributedProjectile
|
from toontown.racing import DistributedVehicle, DistributedStartingBlock, DistributedRace, DistributedKartPad, DistributedRacePad, DistributedViewPad, DistributedStartingBlock, DistributedLeaderBoard, DistributedGag, DistributedProjectile
|
||||||
|
|
|
@ -536,6 +536,7 @@ MonthlySchedule = ((7,
|
||||||
#CatalogGardenItem(104, 1),
|
#CatalogGardenItem(104, 1),
|
||||||
CatalogToonStatueItem(105, endPoseIndex=108),
|
CatalogToonStatueItem(105, endPoseIndex=108),
|
||||||
CatalogRentalItem(1, 2880, 1000),
|
CatalogRentalItem(1, 2880, 1000),
|
||||||
|
CatalogRentalItem(2, 2890, 1000),
|
||||||
#CatalogGardenStarterItem(), # We don't want Gardens yet.
|
#CatalogGardenStarterItem(), # We don't want Gardens yet.
|
||||||
CatalogNametagItem(100),
|
CatalogNametagItem(100),
|
||||||
CatalogNametagItem(0),
|
CatalogNametagItem(0),
|
||||||
|
|
|
@ -130,5 +130,7 @@ def getAllRentalItems():
|
||||||
list = []
|
list = []
|
||||||
for rentalType in (ToontownGlobals.RentalCannon,):
|
for rentalType in (ToontownGlobals.RentalCannon,):
|
||||||
list.append(CatalogRentalItem(rentalType, 2880, 1000))
|
list.append(CatalogRentalItem(rentalType, 2880, 1000))
|
||||||
|
for rentalType in (ToontownGlobals.RentalGameTable,):
|
||||||
|
list.append(CatalogRentalItem(rentalType, 2890, 1000))
|
||||||
|
|
||||||
return list
|
return list
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
from direct.controls.ControlManager import CollisionHandlerRayStart
|
from pandac.PandaModules import *
|
||||||
from direct.distributed import DistributedObject
|
from toontown.toonbase.ToonBaseGlobal import *
|
||||||
|
from toontown.toonbase import ToontownGlobals
|
||||||
from direct.distributed.ClockDelta import *
|
from direct.distributed.ClockDelta import *
|
||||||
|
from direct.interval.IntervalGlobal import *
|
||||||
from direct.fsm import ClassicFSM, State
|
from direct.fsm import ClassicFSM, State
|
||||||
from direct.fsm import State
|
from direct.fsm import State
|
||||||
from direct.gui.DirectGui import *
|
|
||||||
from direct.interval.IntervalGlobal import *
|
|
||||||
from direct.task.Task import Task
|
|
||||||
import math
|
|
||||||
from pandac.PandaModules import *
|
|
||||||
from pandac.PandaModules import *
|
|
||||||
|
|
||||||
import CannonGlobals
|
|
||||||
from toontown.effects import DustCloud
|
|
||||||
from toontown.effects import Splash
|
|
||||||
from toontown.effects import Wake
|
|
||||||
from toontown.minigame import CannonGameGlobals
|
|
||||||
from toontown.minigame import Trajectory
|
|
||||||
from toontown.nametag.NametagFloat3d import NametagFloat3d
|
|
||||||
from toontown.toon import ToonHead
|
|
||||||
from toontown.toonbase import TTLocalizer
|
|
||||||
from toontown.toonbase import ToontownGlobals
|
|
||||||
from toontown.toonbase import ToontownGlobals
|
from toontown.toonbase import ToontownGlobals
|
||||||
from toontown.toonbase import ToontownTimer
|
from toontown.toonbase import ToontownTimer
|
||||||
from toontown.toonbase.ToonBaseGlobal import *
|
from direct.task.Task import Task
|
||||||
|
from toontown.minigame import Trajectory
|
||||||
|
import math
|
||||||
|
from toontown.toon import ToonHead
|
||||||
|
from toontown.effects import Splash
|
||||||
|
from toontown.effects import DustCloud
|
||||||
|
from toontown.minigame import CannonGameGlobals
|
||||||
|
import CannonGlobals
|
||||||
|
from direct.gui.DirectGui import *
|
||||||
|
from pandac.PandaModules import *
|
||||||
|
from toontown.toonbase import TTLocalizer
|
||||||
|
from direct.distributed import DistributedObject
|
||||||
|
from toontown.effects import Wake
|
||||||
|
from direct.controls.ControlManager import CollisionHandlerRayStart
|
||||||
|
|
||||||
|
from toontown.nametag.NametagFloat3d import NametagFloat3d
|
||||||
|
from toontown.nametag.Nametag import Nametag
|
||||||
|
|
||||||
LAND_TIME = 2
|
LAND_TIME = 2
|
||||||
WORLD_SCALE = 2.0
|
WORLD_SCALE = 2.0
|
||||||
|
@ -258,8 +258,8 @@ class DistributedCannon(DistributedObject.DistributedObject):
|
||||||
base.cr.playGame.getPlace().setState('fishing')
|
base.cr.playGame.getPlace().setState('fishing')
|
||||||
base.localAvatar.setTeleportAvailable(0)
|
base.localAvatar.setTeleportAvailable(0)
|
||||||
base.localAvatar.collisionsOff()
|
base.localAvatar.collisionsOff()
|
||||||
base.setCellsActive([base.bottomCells[3], base.bottomCells[4]], 0)
|
base.setCellsAvailable([base.bottomCells[3], base.bottomCells[4]], 0)
|
||||||
base.setCellsActive([base.rightCells[1]], 0)
|
base.setCellsAvailable([base.rightCells[1]], 0)
|
||||||
self.localToonShooting = 1
|
self.localToonShooting = 1
|
||||||
self.__makeGui()
|
self.__makeGui()
|
||||||
camera.reparentTo(self.barrel)
|
camera.reparentTo(self.barrel)
|
||||||
|
@ -267,7 +267,7 @@ class DistributedCannon(DistributedObject.DistributedObject):
|
||||||
self.curPinballScore = 0
|
self.curPinballScore = 0
|
||||||
self.curPinballMultiplier = 1
|
self.curPinballMultiplier = 1
|
||||||
self.incrementPinballInfo(0, 0)
|
self.incrementPinballInfo(0, 0)
|
||||||
if self.avId in self.cr.doId2do:
|
if self.cr.doId2do.has_key(self.avId):
|
||||||
self.av = self.cr.doId2do[self.avId]
|
self.av = self.cr.doId2do[self.avId]
|
||||||
self.acceptOnce(self.av.uniqueName('disable'), self.__avatarGone)
|
self.acceptOnce(self.av.uniqueName('disable'), self.__avatarGone)
|
||||||
self.av.stopSmooth()
|
self.av.stopSmooth()
|
||||||
|
@ -275,8 +275,8 @@ class DistributedCannon(DistributedObject.DistributedObject):
|
||||||
else:
|
else:
|
||||||
self.notify.warning('Unknown avatar %d in cannon %d' % (self.avId, self.doId))
|
self.notify.warning('Unknown avatar %d in cannon %d' % (self.avId, self.doId))
|
||||||
if wasLocalToon and not self.localToonShooting:
|
if wasLocalToon and not self.localToonShooting:
|
||||||
base.setCellsActive([base.bottomCells[3], base.bottomCells[4]], 1)
|
base.setCellsAvailable([base.bottomCells[3], base.bottomCells[4]], 1)
|
||||||
base.setCellsActive([base.rightCells[1]], 1)
|
base.setCellsAvailable([base.rightCells[1]], 1)
|
||||||
|
|
||||||
def __avatarGone(self):
|
def __avatarGone(self):
|
||||||
self.setMovie(CannonGlobals.CANNON_MOVIE_CLEAR, 0)
|
self.setMovie(CannonGlobals.CANNON_MOVIE_CLEAR, 0)
|
||||||
|
@ -411,7 +411,7 @@ class DistributedCannon(DistributedObject.DistributedObject):
|
||||||
self.av.loop('neutral')
|
self.av.loop('neutral')
|
||||||
self.av.setPlayRate(1.0, 'run')
|
self.av.setPlayRate(1.0, 'run')
|
||||||
if hasattr(self.av, 'nametag'):
|
if hasattr(self.av, 'nametag'):
|
||||||
self.av.nametag.remove(self.toonHead.tag)
|
self.av.nametag.removeNametag(self.toonHead.tag)
|
||||||
if self.toonHead != None:
|
if self.toonHead != None:
|
||||||
self.toonHead.stopBlink()
|
self.toonHead.stopBlink()
|
||||||
self.toonHead.stopLookAroundNow()
|
self.toonHead.stopLookAroundNow()
|
||||||
|
@ -467,12 +467,11 @@ class DistributedCannon(DistributedObject.DistributedObject):
|
||||||
self.toonHead.setupHead(self.av.style)
|
self.toonHead.setupHead(self.av.style)
|
||||||
self.toonHead.reparentTo(hidden)
|
self.toonHead.reparentTo(hidden)
|
||||||
tag = NametagFloat3d()
|
tag = NametagFloat3d()
|
||||||
tag.hideNametag()
|
tag.setContents(Nametag.CSpeech | Nametag.CThought)
|
||||||
tag.update()
|
|
||||||
tag.setBillboardOffset(0)
|
tag.setBillboardOffset(0)
|
||||||
tag.setAvatar(self.toonHead)
|
tag.setAvatar(self.toonHead)
|
||||||
toon.nametag.add(tag)
|
toon.nametag.addNametag(tag)
|
||||||
tagPath = self.toonHead.attachNewNode(tag.upcastToPandaNode())
|
tagPath = self.toonHead.attachNewNode(tag)
|
||||||
tagPath.setPos(0, 0, 1)
|
tagPath.setPos(0, 0, 1)
|
||||||
self.toonHead.tag = tag
|
self.toonHead.tag = tag
|
||||||
self.__loadToonInCannon()
|
self.__loadToonInCannon()
|
||||||
|
@ -844,6 +843,7 @@ class DistributedCannon(DistributedObject.DistributedObject):
|
||||||
flyTask.info = info
|
flyTask.info = info
|
||||||
seqTask = Task.sequence(shootTask, smokeTask, flyTask)
|
seqTask = Task.sequence(shootTask, smokeTask, flyTask)
|
||||||
if self.av == base.localAvatar:
|
if self.av == base.localAvatar:
|
||||||
|
print 'disable controls'
|
||||||
base.localAvatar.disableAvatarControls()
|
base.localAvatar.disableAvatarControls()
|
||||||
taskMgr.add(seqTask, self.taskName('flyingToon') + '-' + str(avId))
|
taskMgr.add(seqTask, self.taskName('flyingToon') + '-' + str(avId))
|
||||||
self.acceptOnce(self.uniqueName('stopFlyTask'), self.__stopFlyTask)
|
self.acceptOnce(self.uniqueName('stopFlyTask'), self.__stopFlyTask)
|
||||||
|
@ -865,6 +865,7 @@ class DistributedCannon(DistributedObject.DistributedObject):
|
||||||
|
|
||||||
def removeAvFromCannon(self):
|
def removeAvFromCannon(self):
|
||||||
place = base.cr.playGame.getPlace()
|
place = base.cr.playGame.getPlace()
|
||||||
|
print 'removeAvFromCannon'
|
||||||
self.notify.debug('self.inWater = %s' % self.inWater)
|
self.notify.debug('self.inWater = %s' % self.inWater)
|
||||||
if place:
|
if place:
|
||||||
if not hasattr(place, 'fsm'):
|
if not hasattr(place, 'fsm'):
|
||||||
|
@ -884,7 +885,7 @@ class DistributedCannon(DistributedObject.DistributedObject):
|
||||||
if place and not self.inWater:
|
if place and not self.inWater:
|
||||||
place.fsm.request('walk')
|
place.fsm.request('walk')
|
||||||
self.av.setPlayRate(1.0, 'run')
|
self.av.setPlayRate(1.0, 'run')
|
||||||
self.av.nametag.remove(self.toonHead.tag)
|
self.av.nametag.removeNametag(self.toonHead.tag)
|
||||||
if self.av.getParent().getName() == 'toonOriginChange':
|
if self.av.getParent().getName() == 'toonOriginChange':
|
||||||
self.av.wrtReparentTo(render)
|
self.av.wrtReparentTo(render)
|
||||||
self.__setToonUpright(self.av)
|
self.__setToonUpright(self.av)
|
||||||
|
@ -893,6 +894,7 @@ class DistributedCannon(DistributedObject.DistributedObject):
|
||||||
self.av.startSmooth()
|
self.av.startSmooth()
|
||||||
self.av.setScale(1, 1, 1)
|
self.av.setScale(1, 1, 1)
|
||||||
if self.av == base.localAvatar:
|
if self.av == base.localAvatar:
|
||||||
|
print 'enable controls'
|
||||||
base.localAvatar.enableAvatarControls()
|
base.localAvatar.enableAvatarControls()
|
||||||
self.ignore(self.av.uniqueName('disable'))
|
self.ignore(self.av.uniqueName('disable'))
|
||||||
self.__destroyToonModels()
|
self.__destroyToonModels()
|
||||||
|
@ -1160,6 +1162,7 @@ class DistributedCannon(DistributedObject.DistributedObject):
|
||||||
if hitP[2] > ToontownGlobals.EstateWakeWaterHeight:
|
if hitP[2] > ToontownGlobals.EstateWakeWaterHeight:
|
||||||
self.notify.debug('we hit the ground before we hit water')
|
self.notify.debug('we hit the ground before we hit water')
|
||||||
self.__hitGround(avatar, pos, extraArgs)
|
self.__hitGround(avatar, pos, extraArgs)
|
||||||
|
print 'but not really'
|
||||||
return
|
return
|
||||||
self.inWater = 1
|
self.inWater = 1
|
||||||
self.notify.debug('hit water')
|
self.notify.debug('hit water')
|
||||||
|
@ -1242,7 +1245,7 @@ class DistributedCannon(DistributedObject.DistributedObject):
|
||||||
for id in doIds:
|
for id in doIds:
|
||||||
t = self.cr.doId2do.get(id)
|
t = self.cr.doId2do.get(id)
|
||||||
if t:
|
if t:
|
||||||
pos = t.pos
|
pos = t.nodePath.getPos()
|
||||||
rad = 10.5
|
rad = 10.5
|
||||||
height = 10.0
|
height = 10.0
|
||||||
t_impact = trajectory.checkCollisionWithCylinderSides(pos, rad, height)
|
t_impact = trajectory.checkCollisionWithCylinderSides(pos, rad, height)
|
||||||
|
@ -1508,7 +1511,7 @@ class DistributedCannon(DistributedObject.DistributedObject):
|
||||||
(0, 1, 5, 4),
|
(0, 1, 5, 4),
|
||||||
(0, 4, 7, 3),
|
(0, 4, 7, 3),
|
||||||
(1, 2, 6, 5)]
|
(1, 2, 6, 5)]
|
||||||
for i in xrange(len(vertices)):
|
for i in range(len(vertices)):
|
||||||
vertex = vertices[i]
|
vertex = vertices[i]
|
||||||
vertexWriter.addData3f(vertex[0], vertex[1], vertex[2])
|
vertexWriter.addData3f(vertex[0], vertex[1], vertex[2])
|
||||||
colorWriter.addData4f(*colors[i])
|
colorWriter.addData4f(*colors[i])
|
||||||
|
@ -1577,4 +1580,5 @@ class DistributedCannon(DistributedObject.DistributedObject):
|
||||||
|
|
||||||
def turnOnBumperCollision(self, whatever = 0):
|
def turnOnBumperCollision(self, whatever = 0):
|
||||||
if self.bumperCol:
|
if self.bumperCol:
|
||||||
self.bumperCol.setCollideMask(ToontownGlobals.WallBitmask)# decompiled 0 files: 0 okay, 1 failed, 0 verify failed
|
self.bumperCol.setCollideMask(ToontownGlobals.WallBitmask)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ from direct.directnotify import DirectNotifyGlobal
|
||||||
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
||||||
from toontown.toonbase import ToontownGlobals
|
from toontown.toonbase import ToontownGlobals
|
||||||
import HouseGlobals
|
import HouseGlobals
|
||||||
import time
|
import time, random
|
||||||
|
|
||||||
from toontown.fishing.DistributedFishingPondAI import DistributedFishingPondAI
|
from toontown.fishing.DistributedFishingPondAI import DistributedFishingPondAI
|
||||||
from toontown.fishing.DistributedFishingTargetAI import DistributedFishingTargetAI
|
from toontown.fishing.DistributedFishingTargetAI import DistributedFishingTargetAI
|
||||||
|
@ -10,8 +10,103 @@ from toontown.fishing.DistributedPondBingoManagerAI import DistributedPondBingoM
|
||||||
from toontown.fishing import FishingTargetGlobals
|
from toontown.fishing import FishingTargetGlobals
|
||||||
from toontown.safezone.DistributedFishingSpotAI import DistributedFishingSpotAI
|
from toontown.safezone.DistributedFishingSpotAI import DistributedFishingSpotAI
|
||||||
from toontown.safezone.SZTreasurePlannerAI import SZTreasurePlannerAI
|
from toontown.safezone.SZTreasurePlannerAI import SZTreasurePlannerAI
|
||||||
|
from toontown.safezone import DistributedTreasureAI
|
||||||
from toontown.safezone import TreasureGlobals
|
from toontown.safezone import TreasureGlobals
|
||||||
|
|
||||||
|
from DistributedCannonAI import *
|
||||||
|
from DistributedTargetAI import *
|
||||||
|
import CannonGlobals
|
||||||
|
|
||||||
|
import TableGlobals
|
||||||
|
|
||||||
|
class Rental:
|
||||||
|
def __init__(self, estate):
|
||||||
|
self.estate = estate
|
||||||
|
self.objects = set()
|
||||||
|
|
||||||
|
def destroy(self):
|
||||||
|
del self.estate
|
||||||
|
for object in self.objects:
|
||||||
|
if not object.isDeleted():
|
||||||
|
object.requestDelete()
|
||||||
|
taskMgr.remove(object.uniqueName('delete'))
|
||||||
|
self.objects = set()
|
||||||
|
|
||||||
|
class CannonRental(Rental):
|
||||||
|
def generateObjects(self):
|
||||||
|
target = DistributedTargetAI(self.estate.air)
|
||||||
|
target.generateWithRequired(self.estate.zoneId)
|
||||||
|
|
||||||
|
for drop in CannonGlobals.cannonDrops:
|
||||||
|
cannon = DistributedCannonAI(self.estate.air)
|
||||||
|
cannon.setEstateId(self.estate.doId)
|
||||||
|
cannon.setTargetId(target.doId)
|
||||||
|
cannon.setPosHpr(*drop)
|
||||||
|
cannon.generateWithRequired(self.estate.zoneId)
|
||||||
|
self.objects.add(cannon)
|
||||||
|
|
||||||
|
self.generateTreasures()
|
||||||
|
self.estate.b_setClouds(1)
|
||||||
|
|
||||||
|
def destroy(self):
|
||||||
|
self.estate.b_setClouds(0)
|
||||||
|
Rental.destroy(self)
|
||||||
|
|
||||||
|
def generateTreasures(self):
|
||||||
|
doIds = []
|
||||||
|
z = 35
|
||||||
|
|
||||||
|
for i in xrange(20):
|
||||||
|
x = random.randint(100, 300) - 200
|
||||||
|
y = random.randint(100, 300) - 200
|
||||||
|
treasure = DistributedTreasureAI.DistributedTreasureAI(self.estate.air, self, 7, x, y, z)
|
||||||
|
treasure.generateWithRequired(self.estate.zoneId)
|
||||||
|
self.objects.add(treasure)
|
||||||
|
doIds.append(treasure.doId)
|
||||||
|
|
||||||
|
self.estate.sendUpdate("setTreasureIds", [doIds])
|
||||||
|
|
||||||
|
def grabAttempt(self, avId, treasureId):
|
||||||
|
av = self.estate.air.doId2do.get(avId)
|
||||||
|
if av == None:
|
||||||
|
self.estate.air.writeServerEvent('suspicious', avId, 'TreasurePlannerAI.grabAttempt unknown avatar')
|
||||||
|
self.estate.notify.warning('avid: %s does not exist' % avId)
|
||||||
|
return
|
||||||
|
|
||||||
|
treasure = self.estate.air.doId2do.get(treasureId)
|
||||||
|
if self.validAvatar(av):
|
||||||
|
treasure.d_setGrab(avId)
|
||||||
|
self.deleteTreasureSoon(treasure)
|
||||||
|
|
||||||
|
else:
|
||||||
|
treasure.d_setReject()
|
||||||
|
|
||||||
|
def deleteTreasureSoon(self, treasure):
|
||||||
|
taskName = treasure.uniqueName('delete')
|
||||||
|
taskMgr.doMethodLater(5, self.__deleteTreasureNow, taskName, extraArgs=(treasure, taskName))
|
||||||
|
|
||||||
|
def __deleteTreasureNow(self, treasure, taskName):
|
||||||
|
treasure.requestDelete()
|
||||||
|
|
||||||
|
def validAvatar(self, av):
|
||||||
|
if av.getMaxHp() == av.getHp():
|
||||||
|
return 0
|
||||||
|
|
||||||
|
av.toonUp(3)
|
||||||
|
return 1
|
||||||
|
|
||||||
|
class TableRental(Rental):
|
||||||
|
# Once we make rental game tables.
|
||||||
|
def generateObjects(self):
|
||||||
|
for drop in TableGlobals.tableDrops:
|
||||||
|
table = None
|
||||||
|
table.setEstateId(self.estate.doId)
|
||||||
|
table.setPosHpr(*drop)
|
||||||
|
table.generateWithRequired(self.estate.zoneId)
|
||||||
|
self.objects.add(table)
|
||||||
|
|
||||||
|
def destroy(self):
|
||||||
|
Rental.destroy(self)
|
||||||
|
|
||||||
class DistributedEstateAI(DistributedObjectAI):
|
class DistributedEstateAI(DistributedObjectAI):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedEstateAI")
|
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedEstateAI")
|
||||||
|
@ -23,26 +118,32 @@ class DistributedEstateAI(DistributedObjectAI):
|
||||||
self.cloudType = 0
|
self.cloudType = 0
|
||||||
self.dawnTime = 0
|
self.dawnTime = 0
|
||||||
self.lastEpochTimestamp = 0
|
self.lastEpochTimestamp = 0
|
||||||
|
self.rentalType = 0
|
||||||
|
self.rentalHandle = None
|
||||||
self.rentalTimestamp = 0
|
self.rentalTimestamp = 0
|
||||||
self.houses = [None] * 6
|
self.houses = [None] * 6
|
||||||
|
|
||||||
self.pond = None
|
self.pond = None
|
||||||
self.spots = []
|
self.spots = []
|
||||||
|
|
||||||
self.targets = []
|
self.targets = []
|
||||||
self.owner = None
|
|
||||||
|
|
||||||
|
self.owner = None
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
DistributedObjectAI.generate(self)
|
DistributedObjectAI.generate(self)
|
||||||
|
|
||||||
self.pond = DistributedFishingPondAI(simbase.air)
|
self.pond = DistributedFishingPondAI(simbase.air)
|
||||||
self.pond.setArea(ToontownGlobals.MyEstate)
|
self.pond.setArea(ToontownGlobals.MyEstate)
|
||||||
self.pond.generateWithRequired(self.zoneId)
|
self.pond.generateWithRequired(self.zoneId)
|
||||||
|
|
||||||
for i in xrange(FishingTargetGlobals.getNumTargets(ToontownGlobals.MyEstate)):
|
for i in xrange(FishingTargetGlobals.getNumTargets(ToontownGlobals.MyEstate)):
|
||||||
target = DistributedFishingTargetAI(self.air)
|
target = DistributedFishingTargetAI(self.air)
|
||||||
target.setPondDoId(self.pond.getDoId())
|
target.setPondDoId(self.pond.getDoId())
|
||||||
target.generateWithRequired(self.zoneId)
|
target.generateWithRequired(self.zoneId)
|
||||||
self.targets.append(target)
|
self.targets.append(target)
|
||||||
|
|
||||||
|
|
||||||
spot = DistributedFishingSpotAI(self.air)
|
spot = DistributedFishingSpotAI(self.air)
|
||||||
spot.setPondDoId(self.pond.getDoId())
|
spot.setPondDoId(self.pond.getDoId())
|
||||||
spot.setPosHpr(49.1029, -124.805, 0.344704, 90, 0, 0)
|
spot.setPosHpr(49.1029, -124.805, 0.344704, 90, 0, 0)
|
||||||
|
@ -69,6 +170,7 @@ class DistributedEstateAI(DistributedObjectAI):
|
||||||
|
|
||||||
self.createTreasurePlanner()
|
self.createTreasurePlanner()
|
||||||
|
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
for house in self.houses:
|
for house in self.houses:
|
||||||
if house:
|
if house:
|
||||||
|
@ -84,6 +186,10 @@ class DistributedEstateAI(DistributedObjectAI):
|
||||||
if self.treasurePlanner:
|
if self.treasurePlanner:
|
||||||
self.treasurePlanner.stop()
|
self.treasurePlanner.stop()
|
||||||
|
|
||||||
|
if self.rentalHandle:
|
||||||
|
self.rentalHandle.destroy()
|
||||||
|
self.rentalHandle = None
|
||||||
|
|
||||||
self.requestDelete()
|
self.requestDelete()
|
||||||
|
|
||||||
def setEstateReady(self):
|
def setEstateReady(self):
|
||||||
|
@ -91,13 +197,13 @@ class DistributedEstateAI(DistributedObjectAI):
|
||||||
|
|
||||||
def setClientReady(self):
|
def setClientReady(self):
|
||||||
self.sendUpdate('setEstateReady', [])
|
self.sendUpdate('setEstateReady', [])
|
||||||
|
|
||||||
def setClosestHouse(self, todo0):
|
def setClosestHouse(self, todo0):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def setTreasureIds(self, todo0):
|
def setTreasureIds(self, todo0):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def createTreasurePlanner(self):
|
def createTreasurePlanner(self):
|
||||||
treasureType, healAmount, spawnPoints, spawnRate, maxTreasures = TreasureGlobals.SafeZoneTreasureSpawns[ToontownGlobals.MyEstate]
|
treasureType, healAmount, spawnPoints, spawnRate, maxTreasures = TreasureGlobals.SafeZoneTreasureSpawns[ToontownGlobals.MyEstate]
|
||||||
self.treasurePlanner = SZTreasurePlannerAI(self.zoneId, treasureType, healAmount, spawnPoints, spawnRate, maxTreasures)
|
self.treasurePlanner = SZTreasurePlannerAI(self.zoneId, treasureType, healAmount, spawnPoints, spawnRate, maxTreasures)
|
||||||
|
@ -112,14 +218,14 @@ class DistributedEstateAI(DistributedObjectAI):
|
||||||
|
|
||||||
def setDawnTime(self, dawnTime):
|
def setDawnTime(self, dawnTime):
|
||||||
self.dawnTime = dawnTime
|
self.dawnTime = dawnTime
|
||||||
|
|
||||||
def d_setDawnTime(self, dawnTime):
|
def d_setDawnTime(self, dawnTime):
|
||||||
self.sendUpdate('setDawnTime', [dawnTime])
|
self.sendUpdate('setDawnTime', [dawnTime])
|
||||||
|
|
||||||
def b_setDawnTime(self, dawnTime):
|
def b_setDawnTime(self, dawnTime):
|
||||||
self.setDawnTime(dawnTime)
|
self.setDawnTime(dawnTime)
|
||||||
self.d_setDawnTime(dawnTime)
|
self.d_setDawnTime(dawnTime)
|
||||||
|
|
||||||
def getDawnTime(self):
|
def getDawnTime(self):
|
||||||
return self.dawnTime
|
return self.dawnTime
|
||||||
|
|
||||||
|
@ -128,59 +234,101 @@ class DistributedEstateAI(DistributedObjectAI):
|
||||||
|
|
||||||
def setDecorData(self, decorData):
|
def setDecorData(self, decorData):
|
||||||
self.decorData = decorData
|
self.decorData = decorData
|
||||||
|
|
||||||
def d_setDecorData(self, decorData):
|
def d_setDecorData(self, decorData):
|
||||||
self.sendUpdate('setDecorData', [decorData])
|
self.sendUpdate('setDecorData', [decorData])
|
||||||
|
|
||||||
def b_setDecorData(self, decorData):
|
def b_setDecorData(self, decorData):
|
||||||
self.setDecorData(decorData)
|
self.setDecorData(decorData)
|
||||||
self.d_setDecorData(decorData)
|
self.d_setDecorData(decorData)
|
||||||
|
|
||||||
def getDecorData(self):
|
def getDecorData(self):
|
||||||
return self.decorData
|
return self.decorData
|
||||||
|
|
||||||
def setLastEpochTimeStamp(self, last):
|
def setLastEpochTimeStamp(self, last): #how do I do this
|
||||||
self.lastEpochTimestamp = last
|
self.lastEpochTimestamp = last
|
||||||
|
|
||||||
def d_setLastEpochTimeStamp(self, last):
|
def d_setLastEpochTimeStamp(self, last):
|
||||||
self.sendUpdate('setLastEpochTimeStamp', [last])
|
self.sendUpdate('setLastEpochTimeStamp', [last])
|
||||||
|
|
||||||
def b_setLastEpochTimeStamp(self, last):
|
def b_setLastEpochTimeStamp(self, last):
|
||||||
self.setLastEpochTimeStamp(last)
|
self.setLastEpochTimeStamp(last)
|
||||||
self.d_setLastEpochTimeStamp(last)
|
self.d_setLastEpochTimeStamp(last)
|
||||||
|
|
||||||
def getLastEpochTimeStamp(self):
|
def getLastEpochTimeStamp(self):
|
||||||
return self.lastEpochTimestamp
|
return self.lastEpochTimestamp
|
||||||
|
|
||||||
def setRentalTimeStamp(self, rental):
|
def setRentalTimeStamp(self, rental):
|
||||||
self.rentalTimestamp = rental
|
self.rentalTimestamp = rental
|
||||||
|
|
||||||
def d_setRentalTimeStamp(self, rental):
|
def d_setRentalTimeStamp(self, rental):
|
||||||
self.sendUpdate('setRentalTimeStamp', [rental])
|
self.sendUpdate('setRentalTimeStamp', [rental])
|
||||||
|
|
||||||
def b_setRentalTimeStamp(self, rental):
|
def b_setRentalTimeStamp(self, rental):
|
||||||
self.setRentalTimeStamp(self, rental)
|
self.setRentalTimeStamp(rental)
|
||||||
self.b_setRentalTimeStamp(self, rental)
|
self.d_setRentalTimeStamp(rental)
|
||||||
|
|
||||||
def getRentalTimeStamp(self):
|
def getRentalTimeStamp(self):
|
||||||
return self.rentalTimestamp
|
return self.rentalTimestamp
|
||||||
|
|
||||||
def setRentalType(self, todo0):
|
def b_setRentalType(self, type):
|
||||||
pass
|
self.d_setRentalType(type)
|
||||||
|
self.setRentalType(type)
|
||||||
|
|
||||||
|
def d_setRentalType(self, type):
|
||||||
|
self.sendUpdate("setRentalType", [type])
|
||||||
|
|
||||||
|
def setRentalType(self, type):
|
||||||
|
expirestamp = self.getRentalTimeStamp()
|
||||||
|
if expirestamp == 0:
|
||||||
|
expire = 0
|
||||||
|
|
||||||
|
else:
|
||||||
|
expire = int(expirestamp - time.time())
|
||||||
|
|
||||||
|
if expire < 0:
|
||||||
|
self.rentalType = 0
|
||||||
|
self.d_setRentalType(0)
|
||||||
|
self.b_setRentalTimeStamp(0)
|
||||||
|
|
||||||
|
else:
|
||||||
|
if self.rentalType == type:
|
||||||
|
return
|
||||||
|
|
||||||
|
self.rentalType = type
|
||||||
|
if self.rentalHandle:
|
||||||
|
self.rentalHandle.destroy()
|
||||||
|
self.rentalHandle = None
|
||||||
|
|
||||||
|
if self.rentalType == ToontownGlobals.RentalCannon:
|
||||||
|
self.rentalHandle = CannonRental(self)
|
||||||
|
elif self.rentalType == ToontownGlobals.RentalGameTable:
|
||||||
|
self.rentalHandle = TableRental(self)
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.notify.warning('Unknown rental %s' % self.rentalType)
|
||||||
|
return
|
||||||
|
|
||||||
|
self.rentalHandle.generateObjects()
|
||||||
|
|
||||||
def getRentalType(self):
|
def getRentalType(self):
|
||||||
return 0
|
return self.rentalType
|
||||||
|
|
||||||
|
def rentItem(self, rentType, duration):
|
||||||
|
self.rentalType = rentType
|
||||||
|
self.b_setRentalTimeStamp(time.time() + duration * 60)
|
||||||
|
self.b_setRentalType(rentType)
|
||||||
|
|
||||||
def setSlot0ToonId(self, id):
|
def setSlot0ToonId(self, id):
|
||||||
self.toons[0] = id
|
self.toons[0] = id
|
||||||
|
|
||||||
def d_setSlot0ToonId(self, id):
|
def d_setSlot0ToonId(self, id):
|
||||||
self.sendUpdate('setSlot0ToonId', [id])
|
self.sendUpdate('setSlot0ToonId', [id])
|
||||||
|
|
||||||
def b_setSlot0ToonId(self, id):
|
def b_setSlot0ToonId(self, id):
|
||||||
self.setSlot0ToonId(id)
|
self.setSlot0ToonId(id)
|
||||||
self.d_setSlot0ToonId(id)
|
self.d_setSlot0ToonId(id)
|
||||||
|
|
||||||
def getSlot0ToonId(self):
|
def getSlot0ToonId(self):
|
||||||
return self.toons[0]
|
return self.toons[0]
|
||||||
|
|
||||||
|
@ -189,37 +337,37 @@ class DistributedEstateAI(DistributedObjectAI):
|
||||||
|
|
||||||
def d_setSlot0Items(self, items):
|
def d_setSlot0Items(self, items):
|
||||||
self.sendUpdate('setSlot5Items', [items])
|
self.sendUpdate('setSlot5Items', [items])
|
||||||
|
|
||||||
def b_setSlot0Items(self, items):
|
def b_setSlot0Items(self, items):
|
||||||
self.setSlot0Items(items)
|
self.setSlot0Items(items)
|
||||||
self.d_setSlot0Items(items)
|
self.d_setSlot0Items(items)
|
||||||
|
|
||||||
def getSlot0Items(self):
|
def getSlot0Items(self):
|
||||||
return self.items[0]
|
return self.items[0]
|
||||||
|
|
||||||
def setSlot1ToonId(self, id):
|
def setSlot1ToonId(self, id):
|
||||||
self.toons[1] = id
|
self.toons[1] = id
|
||||||
|
|
||||||
def d_setSlot1ToonId(self, id):
|
def d_setSlot1ToonId(self, id):
|
||||||
self.sendUpdate('setSlot1ToonId', [id])
|
self.sendUpdate('setSlot1ToonId', [id])
|
||||||
|
|
||||||
def b_setSlot1ToonId(self, id):
|
def b_setSlot1ToonId(self, id):
|
||||||
self.setSlot1ToonId(id)
|
self.setSlot1ToonId(id)
|
||||||
self.d_setSlot1ToonId(id)
|
self.d_setSlot1ToonId(id)
|
||||||
|
|
||||||
def getSlot1ToonId(self):
|
def getSlot1ToonId(self):
|
||||||
return self.toons[1]
|
return self.toons[1]
|
||||||
|
|
||||||
def setSlot1Items(self, items):
|
def setSlot1Items(self, items):
|
||||||
self.items[1] = items
|
self.items[1] = items
|
||||||
|
|
||||||
def d_setSlot1Items(self, items):
|
def d_setSlot1Items(self, items):
|
||||||
self.sendUpdate('setSlot2Items', [items])
|
self.sendUpdate('setSlot2Items', [items])
|
||||||
|
|
||||||
def b_setSlot1Items(self, items):
|
def b_setSlot1Items(self, items):
|
||||||
self.setSlot2Items(items)
|
self.setSlot2Items(items)
|
||||||
self.d_setSlot2Items(items)
|
self.d_setSlot2Items(items)
|
||||||
|
|
||||||
def getSlot1Items(self):
|
def getSlot1Items(self):
|
||||||
return self.items[1]
|
return self.items[1]
|
||||||
|
|
||||||
|
@ -228,11 +376,11 @@ class DistributedEstateAI(DistributedObjectAI):
|
||||||
|
|
||||||
def d_setSlot2ToonId(self, id):
|
def d_setSlot2ToonId(self, id):
|
||||||
self.sendUpdate('setSlot2ToonId', [id])
|
self.sendUpdate('setSlot2ToonId', [id])
|
||||||
|
|
||||||
def b_setSlot2ToonId(self, id):
|
def b_setSlot2ToonId(self, id):
|
||||||
self.setSlot2ToonId(id)
|
self.setSlot2ToonId(id)
|
||||||
self.d_setSlot2ToonId(id)
|
self.d_setSlot2ToonId(id)
|
||||||
|
|
||||||
def getSlot2ToonId(self):
|
def getSlot2ToonId(self):
|
||||||
return self.toons[2]
|
return self.toons[2]
|
||||||
|
|
||||||
|
@ -241,89 +389,90 @@ class DistributedEstateAI(DistributedObjectAI):
|
||||||
|
|
||||||
def d_setSlot2Items(self, items):
|
def d_setSlot2Items(self, items):
|
||||||
self.sendUpdate('setSlot2Items', [items])
|
self.sendUpdate('setSlot2Items', [items])
|
||||||
|
|
||||||
def b_setSlot2Items(self, items):
|
def b_setSlot2Items(self, items):
|
||||||
self.setSlot2Items(items)
|
self.setSlot2Items(items)
|
||||||
self.d_setSlot2Items(items)
|
self.d_setSlot2Items(items)
|
||||||
|
|
||||||
def getSlot2Items(self):
|
def getSlot2Items(self):
|
||||||
return self.items[2]
|
return self.items[2]
|
||||||
|
|
||||||
def setSlot3ToonId(self, id):
|
def setSlot3ToonId(self, id):
|
||||||
self.toons[3] = id
|
self.toons[3] = id
|
||||||
|
|
||||||
def d_setSlot3ToonId(self, id):
|
def d_setSlot3ToonId(self, id):
|
||||||
self.sendUpdate('setSlot3ToonId', [id])
|
self.sendUpdate('setSlot3ToonId', [id])
|
||||||
|
|
||||||
def b_setSlot3ToonId(self, id):
|
def b_setSlot3ToonId(self, id):
|
||||||
self.setSlot3ToonId(id)
|
self.setSlot3ToonId(id)
|
||||||
self.d_setSlot3ToonId(id)
|
self.d_setSlot3ToonId(id)
|
||||||
|
|
||||||
def getSlot3ToonId(self):
|
def getSlot3ToonId(self):
|
||||||
return self.toons[3]
|
return self.toons[3]
|
||||||
|
|
||||||
def setSlot3Items(self, items):
|
def setSlot3Items(self, items):
|
||||||
self.items[3] = items
|
self.items[3] = items
|
||||||
|
|
||||||
def d_setSlot3Items(self, items):
|
def d_setSlot3Items(self, items):
|
||||||
self.sendUpdate('setSlot3Items', [items])
|
self.sendUpdate('setSlot3Items', [items])
|
||||||
|
|
||||||
def b_setSlot3Items(self, items):
|
def b_setSlot3Items(self, items):
|
||||||
self.setSlot3Items(items)
|
self.setSlot3Items(items)
|
||||||
self.d_setSlot3Items(items)
|
self.d_setSlot3Items(items)
|
||||||
|
|
||||||
def getSlot3Items(self):
|
def getSlot3Items(self):
|
||||||
return self.items[3]
|
return self.items[3]
|
||||||
|
|
||||||
def setSlot4ToonId(self, id):
|
def setSlot4ToonId(self, id):
|
||||||
self.toons[4] = id
|
self.toons[4] = id
|
||||||
|
|
||||||
def d_setSlot4ToonId(self, id):
|
def d_setSlot4ToonId(self, id):
|
||||||
self.sendUpdate('setSlot4ToonId', [id])
|
self.sendUpdate('setSlot4ToonId', [id])
|
||||||
|
|
||||||
def b_setSlot5ToonId(self, id):
|
def b_setSlot5ToonId(self, id):
|
||||||
self.setSlot4ToonId(id)
|
self.setSlot4ToonId(id)
|
||||||
self.d_setSlot4ToonId(id)
|
self.d_setSlot4ToonId(id)
|
||||||
|
|
||||||
def getSlot4ToonId(self):
|
def getSlot4ToonId(self):
|
||||||
return self.toons[4]
|
return self.toons[4]
|
||||||
|
|
||||||
|
|
||||||
def setSlot4Items(self, items):
|
def setSlot4Items(self, items):
|
||||||
self.items[4] = items
|
self.items[4] = items
|
||||||
|
|
||||||
def d_setSlot4Items(self, items):
|
def d_setSlot4Items(self, items):
|
||||||
self.sendUpdate('setSlot4Items', [items])
|
self.sendUpdate('setSlot4Items', [items])
|
||||||
|
|
||||||
def b_setSlot4Items(self, items):
|
def b_setSlot4Items(self, items):
|
||||||
self.setSlot4Items(items)
|
self.setSlot4Items(items)
|
||||||
self.d_setSlot4Items(items)
|
self.d_setSlot4Items(items)
|
||||||
|
|
||||||
def getSlot4Items(self):
|
def getSlot4Items(self):
|
||||||
return self.items[4]
|
return self.items[4]
|
||||||
|
|
||||||
def setSlot5ToonId(self, id):
|
def setSlot5ToonId(self, id):
|
||||||
self.toons[5] = id
|
self.toons[5] = id
|
||||||
|
|
||||||
def d_setSlot5ToonId(self, id):
|
def d_setSlot5ToonId(self, id):
|
||||||
self.sendUpdate('setSlot5ToonId', [id])
|
self.sendUpdate('setSlot5ToonId', [id])
|
||||||
|
|
||||||
def b_setSlot5ToonId(self, id):
|
def b_setSlot5ToonId(self, id):
|
||||||
self.setSlot5ToonId(id)
|
self.setSlot5ToonId(id)
|
||||||
self.d_setSlot5ToonId(id)
|
self.d_setSlot5ToonId(id)
|
||||||
|
|
||||||
def getSlot5ToonId(self):
|
def getSlot5ToonId(self):
|
||||||
return self.toons[5]
|
return self.toons[5]
|
||||||
|
|
||||||
def setSlot5Items(self, items):
|
def setSlot5Items(self, items):
|
||||||
self.items[5] = items
|
self.items[5] = items
|
||||||
|
|
||||||
def d_setSlot5Items(self, items):
|
def d_setSlot5Items(self, items):
|
||||||
self.sendUpdate('setSlot5Items', [items])
|
self.sendUpdate('setSlot5Items', [items])
|
||||||
|
|
||||||
def b_setSlot5Items(self, items):
|
def b_setSlot5Items(self, items):
|
||||||
self.setSlot5Items(items)
|
self.setSlot5Items(items)
|
||||||
self.d_setSlot5Items(items)
|
self.d_setSlot5Items(items)
|
||||||
|
|
||||||
def getSlot5Items(self):
|
def getSlot5Items(self):
|
||||||
return self.items[5]
|
return self.items[5]
|
||||||
|
|
||||||
|
@ -332,14 +481,14 @@ class DistributedEstateAI(DistributedObjectAI):
|
||||||
if i >= 6:
|
if i >= 6:
|
||||||
return
|
return
|
||||||
self.toons[i] = idList[i]
|
self.toons[i] = idList[i]
|
||||||
|
|
||||||
def d_setIdList(self, idList):
|
def d_setIdList(self, idList):
|
||||||
self.sendUpdate('setIdList', [idList])
|
self.sendUpdate('setIdList', [idList])
|
||||||
|
|
||||||
def b_setIdList(self, idList):
|
def b_setIdList(self, idList):
|
||||||
self.setIdList(idList)
|
self.setIdList(idList)
|
||||||
self.d_setIdLst(idList)
|
self.d_setIdLst(idList)
|
||||||
|
|
||||||
def completeFlowerSale(self, todo0):
|
def completeFlowerSale(self, todo0):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -348,14 +497,14 @@ class DistributedEstateAI(DistributedObjectAI):
|
||||||
|
|
||||||
def setClouds(self, clouds):
|
def setClouds(self, clouds):
|
||||||
self.cloudType = clouds
|
self.cloudType = clouds
|
||||||
|
|
||||||
def d_setClouds(self, clouds):
|
def d_setClouds(self, clouds):
|
||||||
self.sendUpdate('setClouds', [clouds])
|
self.sendUpdate('setClouds', [clouds])
|
||||||
|
|
||||||
def b_setClouds(self, clouds):
|
def b_setClouds(self, clouds):
|
||||||
self.setClouds(clouds)
|
self.setClouds(clouds)
|
||||||
self.d_setClouds(clouds)
|
self.d_setClouds(clouds)
|
||||||
|
|
||||||
def getClouds(self):
|
def getClouds(self):
|
||||||
return self.cloudType
|
return self.cloudType
|
||||||
|
|
||||||
|
|
1
toontown/estate/TableGlobals.py
Normal file
1
toontown/estate/TableGlobals.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
tableDrops = [(0, 0, 0, 0, 0, 0)] #TODO
|
|
@ -1,10 +1,15 @@
|
||||||
from toontown.hood import HoodAI
|
from toontown.hood import HoodAI
|
||||||
|
from pandac.PandaModules import *
|
||||||
from toontown.toonbase import ToontownGlobals
|
from toontown.toonbase import ToontownGlobals
|
||||||
from toontown.distributed.DistributedTimerAI import DistributedTimerAI
|
from toontown.distributed.DistributedTimerAI import DistributedTimerAI
|
||||||
|
import string
|
||||||
from toontown.dna.DNAParser import DNAGroup, DNAVisGroup
|
from toontown.dna.DNAParser import DNAGroup, DNAVisGroup
|
||||||
from toontown.safezone.DistributedPicnicBasketAI import DistributedPicnicBasketAI
|
from toontown.safezone.DistributedPicnicBasketAI import DistributedPicnicBasketAI
|
||||||
from toontown.safezone import DistributedGameTableAI
|
from toontown.safezone import DistributedPicnicTableAI
|
||||||
|
from toontown.safezone import DistributedChineseCheckersAI
|
||||||
|
from toontown.safezone import DistributedCheckersAI
|
||||||
from toontown.hood import ZoneUtil
|
from toontown.hood import ZoneUtil
|
||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
class OZHoodAI(HoodAI.HoodAI):
|
class OZHoodAI(HoodAI.HoodAI):
|
||||||
|
@ -31,6 +36,7 @@ class OZHoodAI(HoodAI.HoodAI):
|
||||||
self.timer = DistributedTimerAI(self.air)
|
self.timer = DistributedTimerAI(self.air)
|
||||||
self.timer.generateWithRequired(self.zoneId)
|
self.timer.generateWithRequired(self.zoneId)
|
||||||
|
|
||||||
|
|
||||||
def findPicnicTables(self, dnaGroup, zoneId, area, overrideDNAZone=False):
|
def findPicnicTables(self, dnaGroup, zoneId, area, overrideDNAZone=False):
|
||||||
picnicTables = []
|
picnicTables = []
|
||||||
if isinstance(dnaGroup, DNAGroup) and ('picnic_table' in dnaGroup.getName()):
|
if isinstance(dnaGroup, DNAGroup) and ('picnic_table' in dnaGroup.getName()):
|
||||||
|
@ -74,9 +80,11 @@ class OZHoodAI(HoodAI.HoodAI):
|
||||||
if 'game_table' in childDnaGroup.getName():
|
if 'game_table' in childDnaGroup.getName():
|
||||||
pos = childDnaGroup.getPos()
|
pos = childDnaGroup.getPos()
|
||||||
hpr = childDnaGroup.getHpr()
|
hpr = childDnaGroup.getHpr()
|
||||||
gameTable = DistributedGameTableAI.DistributedGameTableAI(simbase.air)
|
nameInfo = childDnaGroup.getName().split('_')
|
||||||
gameTable.setPosHpr(pos[0], pos[1], pos[2], hpr[0], hpr[1], hpr[2])
|
tableIndex = int(childDnaGroup.get_parent().getName().split('_')[-1])
|
||||||
gameTable.generateWithRequired(zoneId)
|
gameTable = DistributedPicnicTableAI.DistributedPicnicTableAI(simbase.air, zoneId, nameInfo[2], pos[0], pos[1], pos[2], hpr[0], hpr[1], hpr[2])
|
||||||
|
gameTable.setTableIndex(tableIndex)
|
||||||
|
gameTable.generateOtpObject(simbase.air.districtId, zoneId, ['setX', 'setY', 'setZ', 'setH', 'setP', 'setR'])
|
||||||
elif isinstance(dnaGroup, DNAVisGroup) and (not overrideDNAZone):
|
elif isinstance(dnaGroup, DNAVisGroup) and (not overrideDNAZone):
|
||||||
zoneId = ZoneUtil.getTrueZoneId(int(dnaGroup.getName().split(':')[0]), zoneId)
|
zoneId = ZoneUtil.getTrueZoneId(int(dnaGroup.getName().split(':')[0]), zoneId)
|
||||||
for i in xrange(dnaGroup.getNumChildren()):
|
for i in xrange(dnaGroup.getNumChildren()):
|
||||||
|
|
|
@ -4,7 +4,7 @@ class CheckersBoard:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.squareList = []
|
self.squareList = []
|
||||||
for x in range(32):
|
for x in xrange(32):
|
||||||
self.squareList.append(CheckersTile(x))
|
self.squareList.append(CheckersTile(x))
|
||||||
|
|
||||||
self.squareList[0].setAdjacent([None,
|
self.squareList[0].setAdjacent([None,
|
||||||
|
@ -285,14 +285,14 @@ class CheckersBoard:
|
||||||
|
|
||||||
def getStates(self):
|
def getStates(self):
|
||||||
retList = []
|
retList = []
|
||||||
for x in range(32):
|
for x in xrange(32):
|
||||||
retList.append(self.squareList[x].getState())
|
retList.append(self.squareList[x].getState())
|
||||||
|
|
||||||
return retList
|
return retList
|
||||||
|
|
||||||
def setStates(self, squares):
|
def setStates(self, squares):
|
||||||
y = 0
|
y = 0
|
||||||
for x in range(32):
|
for x in xrange(32):
|
||||||
self.squareList[x].setState(squares[x])
|
self.squareList[x].setState(squares[x])
|
||||||
|
|
||||||
def getJumps(self, squareNum):
|
def getJumps(self, squareNum):
|
||||||
|
|
|
@ -4,7 +4,7 @@ class ChineseCheckersBoard:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.squareList = []
|
self.squareList = []
|
||||||
for x in range(121):
|
for x in xrange(121):
|
||||||
self.squareList.append(CheckersSquare(x))
|
self.squareList.append(CheckersSquare(x))
|
||||||
|
|
||||||
self.squareList[0].setAdjacent([None,
|
self.squareList[0].setAdjacent([None,
|
||||||
|
@ -767,14 +767,14 @@ class ChineseCheckersBoard:
|
||||||
|
|
||||||
def getStates(self):
|
def getStates(self):
|
||||||
retList = []
|
retList = []
|
||||||
for x in range(121):
|
for x in xrange(121):
|
||||||
retList.append(self.squareList[x].getState())
|
retList.append(self.squareList[x].getState())
|
||||||
|
|
||||||
return retList
|
return retList
|
||||||
|
|
||||||
def setStates(self, squares):
|
def setStates(self, squares):
|
||||||
y = 0
|
y = 0
|
||||||
for x in range(121):
|
for x in xrange(121):
|
||||||
self.squareList[x].setState(squares[x])
|
self.squareList[x].setState(squares[x])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ class DistributedCheckers(DistributedNode.DistributedNode):
|
||||||
x = self.boardNode.find('**/locator*')
|
x = self.boardNode.find('**/locator*')
|
||||||
self.locatorList = x.getChildren()
|
self.locatorList = x.getChildren()
|
||||||
tempList = []
|
tempList = []
|
||||||
for x in xrange(0, 32):
|
for x in range(0, 32):
|
||||||
self.locatorList[x].setTag('GamePeiceLocator', '%d' % x)
|
self.locatorList[x].setTag('GamePeiceLocator', '%d' % x)
|
||||||
tempList.append(self.locatorList[x].attachNewNode(CollisionNode('picker%d' % x)))
|
tempList.append(self.locatorList[x].attachNewNode(CollisionNode('picker%d' % x)))
|
||||||
tempList[x].node().addSolid(CollisionSphere(0, 0, 0, 0.39))
|
tempList[x].node().addSolid(CollisionSphere(0, 0, 0, 0.39))
|
||||||
|
@ -451,7 +451,7 @@ class DistributedCheckers(DistributedNode.DistributedNode):
|
||||||
|
|
||||||
def existsLegalJumpsFrom(self, index, peice):
|
def existsLegalJumpsFrom(self, index, peice):
|
||||||
if peice == 'king':
|
if peice == 'king':
|
||||||
for x in xrange(4):
|
for x in range(4):
|
||||||
if self.board.squareList[index].getAdjacent()[x] != None and \
|
if self.board.squareList[index].getAdjacent()[x] != None and \
|
||||||
self.board.squareList[index].getJumps()[x] != None:
|
self.board.squareList[index].getJumps()[x] != None:
|
||||||
adj = self.board.squareList[self.board.squareList[index].getAdjacent()[x]]
|
adj = self.board.squareList[self.board.squareList[index].getAdjacent()[x]]
|
||||||
|
@ -513,7 +513,7 @@ class DistributedCheckers(DistributedNode.DistributedNode):
|
||||||
else:
|
else:
|
||||||
moveForward = [0, 3]
|
moveForward = [0, 3]
|
||||||
if peice == 'king':
|
if peice == 'king':
|
||||||
for x in xrange(4):
|
for x in range(4):
|
||||||
if firstSquare.getAdjacent()[x] != None:
|
if firstSquare.getAdjacent()[x] != None:
|
||||||
if self.board.squareList[firstSquare.getAdjacent()[x]].getState() == 0 and secondSquare.getNum() in firstSquare.getAdjacent():
|
if self.board.squareList[firstSquare.getAdjacent()[x]].getState() == 0 and secondSquare.getNum() in firstSquare.getAdjacent():
|
||||||
return True
|
return True
|
||||||
|
@ -583,7 +583,7 @@ class DistributedCheckers(DistributedNode.DistributedNode):
|
||||||
self.playerNum = 1
|
self.playerNum = 1
|
||||||
self.playerColorString = 'white'
|
self.playerColorString = 'white'
|
||||||
isObserve = True
|
isObserve = True
|
||||||
for xx in xrange(32):
|
for xx in range(32):
|
||||||
for blah in self.locatorList[xx].getChildren():
|
for blah in self.locatorList[xx].getChildren():
|
||||||
blah.hide()
|
blah.hide()
|
||||||
if self.locatorList[xx].getChildren().index(blah) != 0:
|
if self.locatorList[xx].getChildren().index(blah) != 0:
|
||||||
|
@ -671,7 +671,7 @@ class DistributedCheckers(DistributedNode.DistributedNode):
|
||||||
return
|
return
|
||||||
|
|
||||||
def hideChildren(self, nodeList):
|
def hideChildren(self, nodeList):
|
||||||
for x in xrange(1, 2):
|
for x in range(1, 2):
|
||||||
nodeList[x].hide()
|
nodeList[x].hide()
|
||||||
|
|
||||||
def animatePeice(self, tableState, moveList, type, playerColor):
|
def animatePeice(self, tableState, moveList, type, playerColor):
|
||||||
|
@ -693,7 +693,7 @@ class DistributedCheckers(DistributedNode.DistributedNode):
|
||||||
|
|
||||||
checkersPeiceTrack = Sequence()
|
checkersPeiceTrack = Sequence()
|
||||||
length = len(moveList)
|
length = len(moveList)
|
||||||
for x in xrange(length - 1):
|
for x in range(length - 1):
|
||||||
checkersPeiceTrack.append(Parallel(SoundInterval(self.moveSound), ProjectileInterval(gamePeiceForAnimation, endPos=self.locatorList[moveList[x + 1]].getPos(), duration=0.5)))
|
checkersPeiceTrack.append(Parallel(SoundInterval(self.moveSound), ProjectileInterval(gamePeiceForAnimation, endPos=self.locatorList[moveList[x + 1]].getPos(), duration=0.5)))
|
||||||
|
|
||||||
checkersPeiceTrack.append(Func(gamePeiceForAnimation.removeNode))
|
checkersPeiceTrack.append(Func(gamePeiceForAnimation.removeNode))
|
||||||
|
|
|
@ -1,48 +1,675 @@
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
# File: D (Python 2.4)
|
||||||
|
|
||||||
from direct.distributed.DistributedNodeAI import DistributedNodeAI
|
from direct.distributed.DistributedNodeAI import DistributedNodeAI
|
||||||
|
from direct.distributed.ClockDelta import *
|
||||||
|
from direct.fsm import ClassicFSM, State
|
||||||
|
from direct.fsm import State
|
||||||
|
from direct.fsm import StateData
|
||||||
|
from direct.distributed.ClockDelta import *
|
||||||
|
from toontown.safezone import CheckersBoard
|
||||||
|
|
||||||
class DistributedCheckersAI(DistributedNodeAI):
|
class DistributedCheckersAI(DistributedNodeAI):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedCheckersAI")
|
|
||||||
|
def __init__(self, air, parent, name, x, y, z, h, p, r):
|
||||||
|
DistributedNodeAI.__init__(self, air)
|
||||||
|
self.name = name
|
||||||
|
self.air = air
|
||||||
|
self.setPos(x, y, z)
|
||||||
|
self.setHpr(h, p, r)
|
||||||
|
self.myPos = (x, y, z)
|
||||||
|
self.myHpr = (h, p, r)
|
||||||
|
self.board = CheckersBoard.CheckersBoard()
|
||||||
|
self.parent = self.air.doId2do[parent]
|
||||||
|
self.parentDo = parent
|
||||||
|
self.wantStart = []
|
||||||
|
self.playersPlaying = []
|
||||||
|
self.playersSitting = 0
|
||||||
|
self.playersTurn = 1
|
||||||
|
self.movesMade = 0
|
||||||
|
self.playerNum = 1
|
||||||
|
self.hasWon = False
|
||||||
|
self.playersGamePos = [
|
||||||
|
None,
|
||||||
|
None]
|
||||||
|
self.wantTimer = True
|
||||||
|
self.timerEnd = 0
|
||||||
|
self.turnEnd = 0
|
||||||
|
self.playersObserving = []
|
||||||
|
self.winLaffPoints = 20
|
||||||
|
self.movesRequiredToWin = 10
|
||||||
|
self.zoneId = self.air.allocateZone()
|
||||||
|
self.generateOtpObject(air.districtId, self.zoneId, optionalFields = [
|
||||||
|
'setX',
|
||||||
|
'setY',
|
||||||
|
'setZ',
|
||||||
|
'setH',
|
||||||
|
'setP',
|
||||||
|
'setR'])
|
||||||
|
self.parent.setCheckersZoneId(self.zoneId)
|
||||||
|
self.startingPositions = [
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
5,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10,
|
||||||
|
11],
|
||||||
|
[
|
||||||
|
20,
|
||||||
|
21,
|
||||||
|
22,
|
||||||
|
23,
|
||||||
|
24,
|
||||||
|
25,
|
||||||
|
26,
|
||||||
|
27,
|
||||||
|
28,
|
||||||
|
29,
|
||||||
|
30,
|
||||||
|
31]]
|
||||||
|
self.kingPositions = [
|
||||||
|
[
|
||||||
|
31,
|
||||||
|
30,
|
||||||
|
29,
|
||||||
|
28],
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3]]
|
||||||
|
self.timerStart = None
|
||||||
|
self.fsm = ClassicFSM.ClassicFSM('Checkers', [
|
||||||
|
State.State('waitingToBegin', self.enterWaitingToBegin, self.exitWaitingToBegin, [
|
||||||
|
'playing']),
|
||||||
|
State.State('playing', self.enterPlaying, self.exitPlaying, [
|
||||||
|
'gameOver']),
|
||||||
|
State.State('gameOver', self.enterGameOver, self.exitGameOver, [
|
||||||
|
'waitingToBegin'])], 'waitingToBegin', 'waitingToBegin')
|
||||||
|
self.fsm.enterInitialState()
|
||||||
|
|
||||||
def requestExit(self):
|
|
||||||
pass
|
def announceGenerate(self):
|
||||||
|
self.parent.setGameDoId(self.doId)
|
||||||
|
|
||||||
def requestBegin(self):
|
|
||||||
pass
|
def getTableDoId(self):
|
||||||
|
return self.parentDo
|
||||||
|
|
||||||
|
|
||||||
|
def delete(self):
|
||||||
|
self.fsm.requestFinalState()
|
||||||
|
self.board.delete()
|
||||||
|
del self.fsm
|
||||||
|
DistributedNodeAI.delete(self)
|
||||||
|
|
||||||
|
|
||||||
|
def informGameOfPlayer(self):
|
||||||
|
self.playersSitting += 1
|
||||||
|
if self.playersSitting < 2:
|
||||||
|
self.timerEnd = 0
|
||||||
|
elif self.playersSitting == 2:
|
||||||
|
self.timerEnd = globalClock.getRealTime() + 20
|
||||||
|
self.parent.isAccepting = False
|
||||||
|
self.parent.sendUpdate('setIsPlaying', [
|
||||||
|
1])
|
||||||
|
elif self.playersSitting > 2:
|
||||||
|
pass
|
||||||
|
|
||||||
|
self.sendUpdate('setTimer', [
|
||||||
|
globalClockDelta.localToNetworkTime(self.timerEnd)])
|
||||||
|
|
||||||
|
|
||||||
|
def informGameOfPlayerLeave(self):
|
||||||
|
self.playersSitting -= 1
|
||||||
|
if self.playersSitting < 2 and self.fsm.getCurrentState().getName() == 'waitingToBegin':
|
||||||
|
self.timerEnd = 0
|
||||||
|
self.parent.isAccepting = True
|
||||||
|
self.parent.sendUpdate('setIsPlaying', [
|
||||||
|
0])
|
||||||
|
|
||||||
|
if self.playersSitting > 2 and self.fsm.getCurrentState().getName() == 'waitingToBegin':
|
||||||
|
pass
|
||||||
|
1
|
||||||
|
self.timerEnd = 0
|
||||||
|
if self.timerEnd != 0:
|
||||||
|
self.sendUpdate('setTimer', [
|
||||||
|
globalClockDelta.localToNetworkTime(self.timerEnd)])
|
||||||
|
else:
|
||||||
|
self.sendUpdate('setTimer', [
|
||||||
|
0])
|
||||||
|
|
||||||
|
|
||||||
|
def setGameCountdownTime(self):
|
||||||
|
self.timerEnd = globalClock.getRealTime() + 10
|
||||||
|
|
||||||
|
|
||||||
|
def setTurnCountdownTime(self):
|
||||||
|
self.turnEnd = globalClock.getRealTime() + 40
|
||||||
|
|
||||||
|
|
||||||
|
def getTimer(self):
|
||||||
|
if self.timerEnd != 0:
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def getTurnTimer(self):
|
||||||
|
return globalClockDelta.localToNetworkTime(self.turnEnd)
|
||||||
|
|
||||||
|
|
||||||
def requestTimer(self):
|
def requestTimer(self):
|
||||||
pass
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
self.sendUpdateToAvatarId(avId, 'setTimer', [
|
||||||
|
globalClockDelta.localToNetworkTime(self.timerEnd)])
|
||||||
|
|
||||||
def requestMove(self, todo0):
|
|
||||||
pass
|
def handlePlayerExit(self, avId):
|
||||||
|
if avId in self.wantStart:
|
||||||
|
self.wantStart.remove(avId)
|
||||||
|
|
||||||
|
if self.fsm.getCurrentState().getName() == 'playing':
|
||||||
|
gamePos = self.playersGamePos.index(avId)
|
||||||
|
self.playersGamePos[gamePos] = None
|
||||||
|
self.fsm.request('gameOver')
|
||||||
|
|
||||||
|
|
||||||
def startBeginTimer(self, todo0, todo1):
|
|
||||||
pass
|
def handleEmptyGame(self):
|
||||||
|
self.movesMade = 0
|
||||||
def gameStart(self, todo0):
|
self.playersTurn = 1
|
||||||
pass
|
self.playerNum = 1
|
||||||
|
self.fsm.request('waitingToBegin')
|
||||||
def setTableDoId(self, todo0):
|
self.parent.isAccepting = True
|
||||||
pass
|
|
||||||
|
|
||||||
def setGameState(self, todo0, todo1):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def setTimer(self, todo0):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def setTurnTimer(self, todo0):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def sendTurn(self, todo0):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def requestWin(self):
|
def requestWin(self):
|
||||||
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
|
||||||
|
|
||||||
|
def distributeLaffPoints(self):
|
||||||
|
for x in self.parent.seats:
|
||||||
|
if x != None:
|
||||||
|
av = self.air.doId2do.get(x)
|
||||||
|
av.toonUp(self.winLaffPoints)
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def enterWaitingToBegin(self):
|
||||||
|
self.setGameCountdownTime()
|
||||||
|
self.parent.isAccepting = True
|
||||||
|
|
||||||
|
|
||||||
|
def exitWaitingToBegin(self):
|
||||||
|
self.turnEnd = 0
|
||||||
|
|
||||||
|
|
||||||
|
def enterPlaying(self):
|
||||||
|
self.parent.isAccepting = False
|
||||||
|
for x in self.playersGamePos:
|
||||||
|
if x != None:
|
||||||
|
self.playersTurn = self.playersGamePos.index(x)
|
||||||
|
self.d_sendTurn(self.playersTurn + 1)
|
||||||
|
break
|
||||||
|
continue
|
||||||
|
|
||||||
|
self.setTurnCountdownTime()
|
||||||
|
self.sendUpdate('setTurnTimer', [
|
||||||
|
globalClockDelta.localToNetworkTime(self.turnEnd)])
|
||||||
|
|
||||||
|
|
||||||
|
def exitPlaying(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def announceWin(self, todo0):
|
|
||||||
|
def enterGameOver(self):
|
||||||
|
self.timerEnd = 0
|
||||||
|
isAccepting = True
|
||||||
|
self.parent.handleGameOver()
|
||||||
|
self.playersObserving = []
|
||||||
|
self.playersTurn = 1
|
||||||
|
self.playerNum = 1
|
||||||
|
self.clearBoard()
|
||||||
|
self.sendGameState([])
|
||||||
|
self.movesMade = 0
|
||||||
|
self.playersGamePos = [
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None]
|
||||||
|
self.parent.isAccepting = True
|
||||||
|
self.fsm.request('waitingToBegin')
|
||||||
|
|
||||||
|
|
||||||
|
def exitGameOver(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def illegalMove(self):
|
|
||||||
pass
|
def requestBegin(self):
|
||||||
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
if avId not in self.wantStart:
|
||||||
|
self.wantStart.append(avId)
|
||||||
|
|
||||||
|
numPlayers = 0
|
||||||
|
for x in self.parent.seats:
|
||||||
|
if x != None:
|
||||||
|
numPlayers = numPlayers + 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
if len(self.wantStart) == numPlayers and numPlayers >= 2:
|
||||||
|
self.d_gameStart(avId)
|
||||||
|
self.parent.sendIsPlaying()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def d_gameStart(self, avId):
|
||||||
|
for x in self.playersObserving:
|
||||||
|
self.sendUpdateToAvatarId(x, 'gameStart', [
|
||||||
|
255])
|
||||||
|
|
||||||
|
zz = 0
|
||||||
|
numPlayers = 0
|
||||||
|
for x in self.parent.seats:
|
||||||
|
if x != None:
|
||||||
|
numPlayers += 1
|
||||||
|
self.playersPlaying.append(x)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if numPlayers == 2:
|
||||||
|
player1 = self.playersPlaying[0]
|
||||||
|
self.sendUpdateToAvatarId(player1, 'gameStart', [
|
||||||
|
1])
|
||||||
|
self.playersGamePos[0] = player1
|
||||||
|
for x in self.startingPositions[0]:
|
||||||
|
self.board.setState(x, 1)
|
||||||
|
|
||||||
|
player2 = self.playersPlaying[1]
|
||||||
|
self.sendUpdateToAvatarId(player2, 'gameStart', [
|
||||||
|
2])
|
||||||
|
self.playersGamePos[1] = player2
|
||||||
|
for x in self.startingPositions[1]:
|
||||||
|
self.board.setState(x, 2)
|
||||||
|
|
||||||
|
|
||||||
|
self.sendGameState([])
|
||||||
|
self.wantStart = []
|
||||||
|
self.fsm.request('playing')
|
||||||
|
self.parent.getTableState()
|
||||||
|
|
||||||
|
|
||||||
|
def d_sendTurn(self, playersTurn):
|
||||||
|
self.sendUpdate('sendTurn', [
|
||||||
|
playersTurn])
|
||||||
|
|
||||||
|
|
||||||
|
def advancePlayerTurn(self):
|
||||||
|
if self.playersTurn == 0:
|
||||||
|
self.playersTurn = 1
|
||||||
|
self.playerNum = 2
|
||||||
|
else:
|
||||||
|
self.playerNum = 1
|
||||||
|
self.playersTurn = 0
|
||||||
|
|
||||||
|
|
||||||
|
def requestMove(self, moveList):
|
||||||
|
if self.checkLegalMoves(moveList) == True:
|
||||||
|
self.makeMove(moveList)
|
||||||
|
self.advancePlayerTurn()
|
||||||
|
self.d_sendTurn(self.playersTurn + 1)
|
||||||
|
self.setTurnCountdownTime()
|
||||||
|
self.sendUpdate('setTurnTimer', [
|
||||||
|
globalClockDelta.localToNetworkTime(self.turnEnd)])
|
||||||
|
else:
|
||||||
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
self.sendUpdateToAvatarId(avId, 'illegalMove', [])
|
||||||
|
self.air.writeServerEvent('suspicious', avId, 'has requested an illegal move in Regular checkers - not possible')
|
||||||
|
|
||||||
|
|
||||||
|
def checkLegalMoves(self, moveList):
|
||||||
|
if self.board.squareList[moveList[0]].getState() >= 3:
|
||||||
|
moveType = 'king'
|
||||||
|
else:
|
||||||
|
moveType = 'normal'
|
||||||
|
if len(moveList) == 2:
|
||||||
|
firstSquare = self.board.squareList[moveList[0]]
|
||||||
|
secondSquare = self.board.squareList[moveList[1]]
|
||||||
|
if self.checkLegalMove(firstSquare, secondSquare, moveType) == True:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
for x in range(len(moveList) - 1):
|
||||||
|
y = self.checkLegalJump(self.board.getSquare(moveList[x]), self.board.getSquare(moveList[x + 1]), moveType)
|
||||||
|
if y == False:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
elif len(moveList) > 2:
|
||||||
|
for x in range(len(moveList) - 1):
|
||||||
|
y = self.checkLegalJump(self.board.getSquare(moveList[x]), self.board.getSquare(moveList[x + 1]), moveType)
|
||||||
|
if y == False:
|
||||||
|
return False
|
||||||
|
continue
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def makeMove(self, moveList):
|
||||||
|
for x in range(len(moveList) - 1):
|
||||||
|
firstSquare = self.board.squareList[moveList[x]]
|
||||||
|
secondSquare = self.board.squareList[moveList[x + 1]]
|
||||||
|
if firstSquare.getNum() in secondSquare.getAdjacent():
|
||||||
|
break
|
||||||
|
|
||||||
|
index = firstSquare.jumps.index(secondSquare.getNum())
|
||||||
|
self.board.squareList[firstSquare.getAdjacent()[index]].setState(0)
|
||||||
|
|
||||||
|
haveMoved = False
|
||||||
|
squareState = self.board.squareList[moveList[0]].getState()
|
||||||
|
if squareState <= 2:
|
||||||
|
piecetype = 'normal'
|
||||||
|
if squareState == 1:
|
||||||
|
playerNum = 1
|
||||||
|
else:
|
||||||
|
playerNum = 2
|
||||||
|
else:
|
||||||
|
piecetype = 'king'
|
||||||
|
if squareState == 3:
|
||||||
|
playerNum = 1
|
||||||
|
else:
|
||||||
|
playerNum = 2
|
||||||
|
if piecetype == 'normal':
|
||||||
|
lastElement = moveList[len(moveList) - 1]
|
||||||
|
if playerNum == 1:
|
||||||
|
if lastElement in self.kingPositions[0]:
|
||||||
|
self.board.squareList[moveList[0]].setState(0)
|
||||||
|
self.board.squareList[lastElement].setState(3)
|
||||||
|
haveMoved = True
|
||||||
|
self.sendGameState(moveList)
|
||||||
|
|
||||||
|
elif lastElement in self.kingPositions[1]:
|
||||||
|
self.board.squareList[moveList[0]].setState(0)
|
||||||
|
self.board.squareList[lastElement].setState(4)
|
||||||
|
haveMoved = True
|
||||||
|
self.sendGameState(moveList)
|
||||||
|
|
||||||
|
|
||||||
|
if haveMoved == False:
|
||||||
|
spot1 = self.board.squareList[moveList[0]].getState()
|
||||||
|
self.board.squareList[moveList[0]].setState(0)
|
||||||
|
self.board.squareList[moveList[len(moveList) - 1]].setState(spot1)
|
||||||
|
self.sendGameState(moveList)
|
||||||
|
|
||||||
|
temp = self.playerNum
|
||||||
|
self.playerNum = 1
|
||||||
|
if self.hasWon == True:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if self.hasPeicesAndMoves(1, 3) == False:
|
||||||
|
self.parent.announceWinner('Checkers', self.playersPlaying[1])
|
||||||
|
self.fsm.request('gameOver')
|
||||||
|
self.hasWon = True
|
||||||
|
return None
|
||||||
|
|
||||||
|
self.playerNum = temp
|
||||||
|
temp = self.playerNum
|
||||||
|
self.playerNum = 2
|
||||||
|
if self.hasPeicesAndMoves(2, 4) == False:
|
||||||
|
self.parent.announceWinner('Checkers', self.playersPlaying[0])
|
||||||
|
self.fsm.request('gameOver')
|
||||||
|
self.hasWon = True
|
||||||
|
return None
|
||||||
|
|
||||||
|
self.playerNum = temp
|
||||||
|
|
||||||
|
|
||||||
|
def hasPeicesAndMoves(self, normalNum, kingNum):
|
||||||
|
for x in self.board.squareList:
|
||||||
|
if x.getState() == normalNum:
|
||||||
|
if self.existsLegalMovesFrom(x.getNum(), 'normal') == True:
|
||||||
|
return True
|
||||||
|
|
||||||
|
if self.existsLegalJumpsFrom(x.getNum(), 'normal') == True:
|
||||||
|
return True
|
||||||
|
|
||||||
|
self.existsLegalJumpsFrom(x.getNum(), 'normal') == True
|
||||||
|
if x.getState() == kingNum:
|
||||||
|
if self.existsLegalMovesFrom(x.getNum(), 'king') == True:
|
||||||
|
return True
|
||||||
|
|
||||||
|
if self.existsLegalJumpsFrom(x.getNum(), 'king') == True:
|
||||||
|
return True
|
||||||
|
|
||||||
|
self.existsLegalJumpsFrom(x.getNum(), 'king') == True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def getState(self):
|
||||||
|
return self.fsm.getCurrentState().getName()
|
||||||
|
|
||||||
|
|
||||||
|
def getName(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
|
def getGameState(self):
|
||||||
|
return [
|
||||||
|
self.board.getStates(),
|
||||||
|
[]]
|
||||||
|
|
||||||
|
|
||||||
|
def sendGameState(self, moveList):
|
||||||
|
gameState = self.board.getStates()
|
||||||
|
self.sendUpdate('setGameState', [
|
||||||
|
gameState,
|
||||||
|
moveList])
|
||||||
|
|
||||||
|
|
||||||
|
def clearBoard(self):
|
||||||
|
for x in self.board.squareList:
|
||||||
|
x.setState(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def getPosHpr(self):
|
||||||
|
return self.posHpr
|
||||||
|
|
||||||
|
|
||||||
|
def existsLegalJumpsFrom(self, index, peice):
|
||||||
|
if peice == 'king':
|
||||||
|
for x in range(4):
|
||||||
|
if self.board.squareList[index].getAdjacent()[x] != None and self.board.squareList[index].getJumps()[x] != None:
|
||||||
|
adj = self.board.squareList[self.board.squareList[index].getAdjacent()[x]]
|
||||||
|
jump = self.board.squareList[self.board.squareList[index].getJumps()[x]]
|
||||||
|
if adj.getState() == 0:
|
||||||
|
pass
|
||||||
|
elif adj.getState() == self.playerNum or adj.getState() == self.playerNum + 2:
|
||||||
|
pass
|
||||||
|
elif jump.getState() == 0:
|
||||||
|
return True
|
||||||
|
|
||||||
|
adj.getState() == self.playerNum + 2
|
||||||
|
|
||||||
|
return False
|
||||||
|
elif peice == 'normal':
|
||||||
|
if self.playerNum == 1:
|
||||||
|
moveForward = [
|
||||||
|
1,
|
||||||
|
2]
|
||||||
|
elif self.playerNum == 2:
|
||||||
|
moveForward = [
|
||||||
|
0,
|
||||||
|
3]
|
||||||
|
|
||||||
|
for x in moveForward:
|
||||||
|
if self.board.squareList[index].getAdjacent()[x] != None and self.board.squareList[index].getJumps()[x] != None:
|
||||||
|
adj = self.board.squareList[self.board.squareList[index].getAdjacent()[x]]
|
||||||
|
jump = self.board.squareList[self.board.squareList[index].getJumps()[x]]
|
||||||
|
if adj.getState() == 0:
|
||||||
|
pass
|
||||||
|
elif adj.getState() == self.playerNum or adj.getState() == self.playerNum + 2:
|
||||||
|
pass
|
||||||
|
elif jump.getState() == 0:
|
||||||
|
return True
|
||||||
|
|
||||||
|
adj.getState() == self.playerNum + 2
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def existsLegalMovesFrom(self, index, peice):
|
||||||
|
if peice == 'king':
|
||||||
|
for x in self.board.squareList[index].getAdjacent():
|
||||||
|
if x != None:
|
||||||
|
if self.board.squareList[x].getState() == 0:
|
||||||
|
return True
|
||||||
|
|
||||||
|
self.board.squareList[x].getState() == 0
|
||||||
|
|
||||||
|
return False
|
||||||
|
elif peice == 'normal':
|
||||||
|
if self.playerNum == 1:
|
||||||
|
moveForward = [
|
||||||
|
1,
|
||||||
|
2]
|
||||||
|
elif self.playerNum == 2:
|
||||||
|
moveForward = [
|
||||||
|
0,
|
||||||
|
3]
|
||||||
|
|
||||||
|
for x in moveForward:
|
||||||
|
if self.board.squareList[index].getAdjacent()[x] != None:
|
||||||
|
adj = self.board.squareList[self.board.squareList[index].getAdjacent()[x]]
|
||||||
|
if adj.getState() == 0:
|
||||||
|
return True
|
||||||
|
|
||||||
|
adj.getState() == 0
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def existsLegalJumpsFrom(self, index, peice):
|
||||||
|
if peice == 'king':
|
||||||
|
for x in range(4):
|
||||||
|
if self.board.squareList[index].getAdjacent()[x] != None and self.board.squareList[index].getJumps()[x] != None:
|
||||||
|
adj = self.board.squareList[self.board.squareList[index].getAdjacent()[x]]
|
||||||
|
jump = self.board.squareList[self.board.squareList[index].getJumps()[x]]
|
||||||
|
if adj.getState() == 0:
|
||||||
|
pass
|
||||||
|
elif adj.getState() == self.playerNum or adj.getState() == self.playerNum + 2:
|
||||||
|
pass
|
||||||
|
elif jump.getState() == 0:
|
||||||
|
return True
|
||||||
|
|
||||||
|
adj.getState() == self.playerNum + 2
|
||||||
|
|
||||||
|
return False
|
||||||
|
elif peice == 'normal':
|
||||||
|
if self.playerNum == 1:
|
||||||
|
moveForward = [
|
||||||
|
1,
|
||||||
|
2]
|
||||||
|
elif self.playerNum == 2:
|
||||||
|
moveForward = [
|
||||||
|
0,
|
||||||
|
3]
|
||||||
|
|
||||||
|
for x in moveForward:
|
||||||
|
if self.board.squareList[index].getAdjacent()[x] != None and self.board.squareList[index].getJumps()[x] != None:
|
||||||
|
adj = self.board.squareList[self.board.squareList[index].getAdjacent()[x]]
|
||||||
|
jump = self.board.squareList[self.board.squareList[index].getJumps()[x]]
|
||||||
|
if adj.getState() == 0:
|
||||||
|
pass
|
||||||
|
elif adj.getState() == self.playerNum or adj.getState() == self.playerNum + 2:
|
||||||
|
pass
|
||||||
|
elif jump.getState() == 0:
|
||||||
|
return True
|
||||||
|
|
||||||
|
adj.getState() == self.playerNum + 2
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def checkLegalMove(self, firstSquare, secondSquare, peice):
|
||||||
|
if self.playerNum == 1:
|
||||||
|
moveForward = [
|
||||||
|
1,
|
||||||
|
2]
|
||||||
|
else:
|
||||||
|
moveForward = [
|
||||||
|
0,
|
||||||
|
3]
|
||||||
|
if peice == 'king':
|
||||||
|
for x in range(4):
|
||||||
|
if firstSquare.getAdjacent()[x] != None:
|
||||||
|
if self.board.squareList[firstSquare.getAdjacent()[x]].getState() == 0:
|
||||||
|
return True
|
||||||
|
|
||||||
|
self.board.squareList[firstSquare.getAdjacent()[x]].getState() == 0
|
||||||
|
|
||||||
|
return False
|
||||||
|
elif peice == 'normal':
|
||||||
|
for x in moveForward:
|
||||||
|
if firstSquare.getAdjacent()[x] != None:
|
||||||
|
if self.board.squareList[firstSquare.getAdjacent()[x]].getState() == 0:
|
||||||
|
return True
|
||||||
|
|
||||||
|
self.board.squareList[firstSquare.getAdjacent()[x]].getState() == 0
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def checkLegalJump(self, firstSquare, secondSquare, peice):
|
||||||
|
if self.playerNum == 1:
|
||||||
|
moveForward = [
|
||||||
|
1,
|
||||||
|
2]
|
||||||
|
opposingPeices = [
|
||||||
|
2,
|
||||||
|
4]
|
||||||
|
else:
|
||||||
|
moveForward = [
|
||||||
|
0,
|
||||||
|
3]
|
||||||
|
opposingPeices = [
|
||||||
|
1,
|
||||||
|
3]
|
||||||
|
if peice == 'king':
|
||||||
|
if secondSquare.getNum() in firstSquare.getJumps():
|
||||||
|
index = firstSquare.getJumps().index(secondSquare.getNum())
|
||||||
|
if self.board.squareList[firstSquare.getAdjacent()[index]].getState() in opposingPeices:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
elif peice == 'normal':
|
||||||
|
if secondSquare.getNum() in firstSquare.getJumps():
|
||||||
|
index = firstSquare.getJumps().index(secondSquare.getNum())
|
||||||
|
if index in moveForward:
|
||||||
|
if self.board.squareList[firstSquare.getAdjacent()[index]].getState() in opposingPeices:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ class DistributedChineseCheckers(DistributedNode.DistributedNode):
|
||||||
x = self.boardNode.find('**/locators')
|
x = self.boardNode.find('**/locators')
|
||||||
self.locatorList = x.getChildren()
|
self.locatorList = x.getChildren()
|
||||||
tempList = []
|
tempList = []
|
||||||
for x in xrange(0, 121):
|
for x in range(0, 121):
|
||||||
self.locatorList[x].setTag('GamePeiceLocator', '%d' % x)
|
self.locatorList[x].setTag('GamePeiceLocator', '%d' % x)
|
||||||
tempList.append(self.locatorList[x].attachNewNode(CollisionNode('picker%d' % x)))
|
tempList.append(self.locatorList[x].attachNewNode(CollisionNode('picker%d' % x)))
|
||||||
tempList[x].node().addSolid(CollisionSphere(0, 0, 0, 0.115))
|
tempList[x].node().addSolid(CollisionSphere(0, 0, 0, 0.115))
|
||||||
|
@ -299,7 +299,7 @@ class DistributedChineseCheckers(DistributedNode.DistributedNode):
|
||||||
|
|
||||||
def announceSeatPositions(self, playerPos):
|
def announceSeatPositions(self, playerPos):
|
||||||
self.playerSeats = playerPos
|
self.playerSeats = playerPos
|
||||||
for x in xrange(6):
|
for x in range(6):
|
||||||
pos = self.table.seats[x].getPos(render)
|
pos = self.table.seats[x].getPos(render)
|
||||||
renderedPeice = loader.loadModel('phase_6/models/golf/checker_marble.bam')
|
renderedPeice = loader.loadModel('phase_6/models/golf/checker_marble.bam')
|
||||||
renderedPeice.reparentTo(self.playerTags)
|
renderedPeice.reparentTo(self.playerTags)
|
||||||
|
@ -640,7 +640,7 @@ class DistributedChineseCheckers(DistributedNode.DistributedNode):
|
||||||
self.board.setStates(squares)
|
self.board.setStates(squares)
|
||||||
self.mySquares = []
|
self.mySquares = []
|
||||||
messenger.send('wakeup')
|
messenger.send('wakeup')
|
||||||
for x in xrange(121):
|
for x in range(121):
|
||||||
self.locatorList[x].clearColor()
|
self.locatorList[x].clearColor()
|
||||||
owner = self.board.squareList[x].getState()
|
owner = self.board.squareList[x].getState()
|
||||||
if owner == self.playerNum:
|
if owner == self.playerNum:
|
||||||
|
@ -674,7 +674,7 @@ class DistributedChineseCheckers(DistributedNode.DistributedNode):
|
||||||
self.locatorList[moveList[0]].hide()
|
self.locatorList[moveList[0]].hide()
|
||||||
checkersPeiceTrack = Sequence()
|
checkersPeiceTrack = Sequence()
|
||||||
length = len(moveList)
|
length = len(moveList)
|
||||||
for x in xrange(length - 1):
|
for x in range(length - 1):
|
||||||
checkersPeiceTrack.append(Parallel(SoundInterval(self.moveSound), ProjectileInterval(gamePeiceForAnimation, endPos=self.locatorList[moveList[x + 1]].getPos(), duration=0.5)))
|
checkersPeiceTrack.append(Parallel(SoundInterval(self.moveSound), ProjectileInterval(gamePeiceForAnimation, endPos=self.locatorList[moveList[x + 1]].getPos(), duration=0.5)))
|
||||||
|
|
||||||
checkersPeiceTrack.append(Func(gamePeiceForAnimation.removeNode))
|
checkersPeiceTrack.append(Func(gamePeiceForAnimation.removeNode))
|
||||||
|
|
|
@ -1,51 +1,694 @@
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
# File: D (Python 2.4)
|
||||||
|
|
||||||
from direct.distributed.DistributedNodeAI import DistributedNodeAI
|
from direct.distributed.DistributedNodeAI import DistributedNodeAI
|
||||||
|
from direct.distributed.ClockDelta import *
|
||||||
|
from direct.fsm import ClassicFSM, State
|
||||||
|
from direct.fsm import State
|
||||||
|
from direct.fsm import StateData
|
||||||
|
from direct.distributed.ClockDelta import *
|
||||||
|
from toontown.safezone import ChineseCheckersBoard
|
||||||
|
|
||||||
class DistributedChineseCheckersAI(DistributedNodeAI):
|
class DistributedChineseCheckersAI(DistributedNodeAI):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedChineseCheckersAI")
|
|
||||||
|
def __init__(self, air, parent, name, x, y, z, h, p, r):
|
||||||
|
DistributedNodeAI.__init__(self, air)
|
||||||
|
self.name = name
|
||||||
|
self.air = air
|
||||||
|
self.setPos(x, y, z)
|
||||||
|
self.setHpr(h, p, r)
|
||||||
|
self.myPos = (x, y, z)
|
||||||
|
self.myHpr = (h, p, r)
|
||||||
|
self.board = ChineseCheckersBoard.ChineseCheckersBoard()
|
||||||
|
self.parent = self.air.doId2do[parent]
|
||||||
|
self.parentDo = parent
|
||||||
|
self.wantStart = []
|
||||||
|
self.playersPlaying = []
|
||||||
|
self.playersSitting = 0
|
||||||
|
self.playersTurn = 1
|
||||||
|
self.movesMade = 0
|
||||||
|
self.playersGamePos = [
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None]
|
||||||
|
self.wantTimer = True
|
||||||
|
self.timerEnd = 0
|
||||||
|
self.turnEnd = 0
|
||||||
|
self.playersObserving = []
|
||||||
|
self.winLaffPoints = 20
|
||||||
|
self.movesRequiredToWin = 10
|
||||||
|
self.zoneId = self.air.allocateZone()
|
||||||
|
self.generateOtpObject(air.districtId, self.zoneId, optionalFields = [
|
||||||
|
'setX',
|
||||||
|
'setY',
|
||||||
|
'setZ',
|
||||||
|
'setH',
|
||||||
|
'setP',
|
||||||
|
'setR'])
|
||||||
|
self.parent.setCheckersZoneId(self.zoneId)
|
||||||
|
self.startingPositions = [
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
5,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9],
|
||||||
|
[
|
||||||
|
10,
|
||||||
|
11,
|
||||||
|
12,
|
||||||
|
13,
|
||||||
|
23,
|
||||||
|
24,
|
||||||
|
25,
|
||||||
|
35,
|
||||||
|
36,
|
||||||
|
46],
|
||||||
|
[
|
||||||
|
65,
|
||||||
|
75,
|
||||||
|
76,
|
||||||
|
86,
|
||||||
|
87,
|
||||||
|
88,
|
||||||
|
98,
|
||||||
|
99,
|
||||||
|
100,
|
||||||
|
101],
|
||||||
|
[
|
||||||
|
111,
|
||||||
|
112,
|
||||||
|
113,
|
||||||
|
114,
|
||||||
|
115,
|
||||||
|
116,
|
||||||
|
117,
|
||||||
|
118,
|
||||||
|
119,
|
||||||
|
120],
|
||||||
|
[
|
||||||
|
74,
|
||||||
|
84,
|
||||||
|
85,
|
||||||
|
95,
|
||||||
|
96,
|
||||||
|
97,
|
||||||
|
107,
|
||||||
|
108,
|
||||||
|
109,
|
||||||
|
110],
|
||||||
|
[
|
||||||
|
19,
|
||||||
|
20,
|
||||||
|
21,
|
||||||
|
22,
|
||||||
|
32,
|
||||||
|
33,
|
||||||
|
34,
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
55]]
|
||||||
|
self.timerStart = None
|
||||||
|
self.fsm = ClassicFSM.ClassicFSM('ChineseCheckers', [
|
||||||
|
State.State('waitingToBegin', self.enterWaitingToBegin, self.exitWaitingToBegin, [
|
||||||
|
'playing']),
|
||||||
|
State.State('playing', self.enterPlaying, self.exitPlaying, [
|
||||||
|
'gameOver']),
|
||||||
|
State.State('gameOver', self.enterGameOver, self.exitGameOver, [
|
||||||
|
'waitingToBegin'])], 'waitingToBegin', 'waitingToBegin')
|
||||||
|
self.fsm.enterInitialState()
|
||||||
|
|
||||||
def requestExit(self):
|
|
||||||
pass
|
def announceGenerate(self):
|
||||||
|
self.parent.setGameDoId(self.doId)
|
||||||
|
|
||||||
def requestBegin(self):
|
|
||||||
pass
|
def getTableDoId(self):
|
||||||
|
return self.parentDo
|
||||||
|
|
||||||
def requestMove(self, todo0):
|
|
||||||
pass
|
def delete(self):
|
||||||
|
self.fsm.requestFinalState()
|
||||||
def requestTimer(self):
|
self.board.delete()
|
||||||
pass
|
self.playerSeatPos = None
|
||||||
|
del self.fsm
|
||||||
|
DistributedNodeAI.delete(self)
|
||||||
|
|
||||||
|
|
||||||
def requestSeatPositions(self):
|
def requestSeatPositions(self):
|
||||||
pass
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
self.sendUpdateToAvatarId(avId, 'announceSeatPositions', [
|
||||||
|
self.playerSeatPos])
|
||||||
|
self.sendUpdateToAvatarId(avId, 'sendTurn', [
|
||||||
|
self.playersTurn + 1])
|
||||||
|
|
||||||
def startBeginTimer(self, todo0, todo1):
|
|
||||||
pass
|
def informGameOfPlayer(self):
|
||||||
|
self.playersSitting += 1
|
||||||
|
if self.playersSitting < 2:
|
||||||
|
self.timerEnd = 0
|
||||||
|
elif self.playersSitting == 2:
|
||||||
|
self.timerEnd = globalClock.getRealTime() + 60
|
||||||
|
elif self.playersSitting > 2:
|
||||||
|
pass
|
||||||
|
|
||||||
|
self.sendUpdate('setTimer', [
|
||||||
|
globalClockDelta.localToNetworkTime(self.timerEnd)])
|
||||||
|
|
||||||
def gameStart(self, todo0):
|
|
||||||
pass
|
def informGameOfPlayerLeave(self):
|
||||||
|
self.playersSitting -= 1
|
||||||
|
if self.playersSitting < 2 and self.fsm.getCurrentState().getName() == 'waitingToBegin':
|
||||||
|
self.timerEnd = 0
|
||||||
|
|
||||||
|
if self.playersSitting > 2 and self.fsm.getCurrentState().getName() == 'waitingToBegin':
|
||||||
|
pass
|
||||||
|
1
|
||||||
|
self.timerEnd = 0
|
||||||
|
if self.timerEnd != 0:
|
||||||
|
self.sendUpdate('setTimer', [
|
||||||
|
globalClockDelta.localToNetworkTime(self.timerEnd)])
|
||||||
|
else:
|
||||||
|
self.sendUpdate('setTimer', [
|
||||||
|
0])
|
||||||
|
|
||||||
def setTableDoId(self, todo0):
|
|
||||||
pass
|
def setGameCountdownTime(self):
|
||||||
|
self.timerEnd = globalClock.getRealTime() + 60
|
||||||
|
|
||||||
def setGameState(self, todo0, todo1):
|
|
||||||
pass
|
def setTurnCountdownTime(self):
|
||||||
|
self.turnEnd = globalClock.getRealTime() + 60
|
||||||
|
|
||||||
def setTimer(self, todo0):
|
|
||||||
pass
|
def getTimer(self):
|
||||||
|
if self.timerEnd != 0:
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
def setTurnTimer(self, todo0):
|
|
||||||
pass
|
def getTurnTimer(self):
|
||||||
|
return globalClockDelta.localToNetworkTime(self.turnEnd)
|
||||||
|
|
||||||
def sendTurn(self, todo0):
|
|
||||||
pass
|
def requestTimer(self):
|
||||||
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
self.sendUpdateToAvatarId(avId, 'setTimer', [
|
||||||
|
globalClockDelta.localToNetworkTime(self.timerEnd)])
|
||||||
|
|
||||||
|
|
||||||
|
def handlePlayerExit(self, avId):
|
||||||
|
playerOrder = [
|
||||||
|
1,
|
||||||
|
4,
|
||||||
|
2,
|
||||||
|
5,
|
||||||
|
3,
|
||||||
|
6]
|
||||||
|
if avId in self.wantStart:
|
||||||
|
self.wantStart.remove(avId)
|
||||||
|
|
||||||
|
playstate = self.fsm.getStateNamed('playing')
|
||||||
|
if self.fsm.getCurrentState().getName() == 'playing':
|
||||||
|
gamePos = self.playersGamePos.index(avId)
|
||||||
|
self.playersGamePos[gamePos] = None
|
||||||
|
for x in self.board.squareList:
|
||||||
|
if x.getState() == gamePos + 1:
|
||||||
|
x.setState(0)
|
||||||
|
continue
|
||||||
|
|
||||||
|
self.sendGameState([])
|
||||||
|
if self.playersTurn == gamePos:
|
||||||
|
self.advancePlayerTurn()
|
||||||
|
self.d_sendTurn(self.playersTurn + 1)
|
||||||
|
|
||||||
|
remainingPlayers = 0
|
||||||
|
for x in self.playersGamePos:
|
||||||
|
if x != None:
|
||||||
|
remainingPlayers += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
if remainingPlayers == 1:
|
||||||
|
for x in self.playersGamePos:
|
||||||
|
if x != None:
|
||||||
|
self.clearBoard()
|
||||||
|
self.sendGameState([])
|
||||||
|
if self.movesMade >= self.movesRequiredToWin:
|
||||||
|
self.distributeLaffPoints()
|
||||||
|
self.fsm.request('gameOver')
|
||||||
|
self.parent.announceWinner('Chinese Checkers', x)
|
||||||
|
else:
|
||||||
|
self.fsm.request('gameOver')
|
||||||
|
|
||||||
|
def handleEmptyGame(self):
|
||||||
|
self.movesMade = 0
|
||||||
|
self.playersPlaying = []
|
||||||
|
self.playersTurn = 1
|
||||||
|
self.fsm.request('waitingToBegin')
|
||||||
|
|
||||||
|
|
||||||
def requestWin(self):
|
def requestWin(self):
|
||||||
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
if avId not in self.playersGamePos:
|
||||||
|
self.air.writeServerEvent('suspicious', avId, 'Has requested a Chinese Checkers win and is NOT playing! SeatList of the table - %s - PlayersGamePos - %s' % (self.parent.seats, self.playersGamePos))
|
||||||
|
return None
|
||||||
|
|
||||||
|
requestWinGamePos = self.playersGamePos.index(avId) + 1
|
||||||
|
checkSquares = []
|
||||||
|
for x in self.board.squareList:
|
||||||
|
if x.getState() == requestWinGamePos:
|
||||||
|
checkSquares.append(x.getNum())
|
||||||
|
continue
|
||||||
|
|
||||||
|
if requestWinGamePos == 1:
|
||||||
|
if checkSquares == self.startingPositions[3]:
|
||||||
|
self.distributeLaffPoints()
|
||||||
|
self.fsm.request('gameOver')
|
||||||
|
self.parent.announceWinner('Chinese Checkers', avId)
|
||||||
|
|
||||||
|
elif requestWinGamePos == 2:
|
||||||
|
if checkSquares == self.startingPositions[4]:
|
||||||
|
self.distributeLaffPoints()
|
||||||
|
self.fsm.request('gameOver')
|
||||||
|
self.parent.announceWinner('Chinese Checkers', avId)
|
||||||
|
|
||||||
|
elif requestWinGamePos == 3:
|
||||||
|
if checkSquares == self.startingPositions[5]:
|
||||||
|
self.distributeLaffPoints()
|
||||||
|
self.fsm.request('gameOver')
|
||||||
|
self.parent.announceWinner('Chinese Checkers', avId)
|
||||||
|
|
||||||
|
elif requestWinGamePos == 4:
|
||||||
|
if checkSquares == self.startingPositions[0]:
|
||||||
|
self.distributeLaffPoints()
|
||||||
|
self.fsm.request('gameOver')
|
||||||
|
self.parent.announceWinner('Chinese Checkers', avId)
|
||||||
|
|
||||||
|
elif requestWinGamePos == 5:
|
||||||
|
if checkSquares == self.startingPositions[1]:
|
||||||
|
self.fsm.request('gameOver')
|
||||||
|
self.parent.announceWinner('Chinese Checkers', avId)
|
||||||
|
|
||||||
|
elif requestWinGamePos == 6:
|
||||||
|
if checkSquares == self.startingPositions[2]:
|
||||||
|
self.distributeLaffPoints()
|
||||||
|
self.fsm.request('gameOver')
|
||||||
|
self.parent.announceWinner('Chinese Checkers', avId)
|
||||||
|
|
||||||
|
|
||||||
|
self.parent = None
|
||||||
|
|
||||||
|
|
||||||
|
def distributeLaffPoints(self):
|
||||||
|
for x in self.parent.seats:
|
||||||
|
if x != None:
|
||||||
|
av = self.air.doId2do.get(x)
|
||||||
|
av.toonUp(self.winLaffPoints)
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def enterWaitingToBegin(self):
|
||||||
|
self.setGameCountdownTime()
|
||||||
|
self.parent.isAccepting = True
|
||||||
|
|
||||||
|
|
||||||
|
def exitWaitingToBegin(self):
|
||||||
|
self.turnEnd = 0
|
||||||
|
|
||||||
|
|
||||||
|
def enterPlaying(self):
|
||||||
|
self.parent.isAccepting = False
|
||||||
|
for x in self.playersGamePos:
|
||||||
|
if x != None:
|
||||||
|
self.playersTurn = self.playersGamePos.index(x)
|
||||||
|
self.d_sendTurn(self.playersTurn + 1)
|
||||||
|
break
|
||||||
|
continue
|
||||||
|
|
||||||
|
self.setTurnCountdownTime()
|
||||||
|
self.sendUpdate('setTurnTimer', [
|
||||||
|
globalClockDelta.localToNetworkTime(self.turnEnd)])
|
||||||
|
|
||||||
|
|
||||||
|
def exitPlaying(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def announceWin(self, todo0):
|
|
||||||
|
def enterGameOver(self):
|
||||||
|
self.timerEnd = 0
|
||||||
|
isAccepting = True
|
||||||
|
self.playersObserving = []
|
||||||
|
self.parent.handleGameOver()
|
||||||
|
self.playersTurn = 1
|
||||||
|
self.playersPlaying = []
|
||||||
|
self.clearBoard()
|
||||||
|
self.sendGameState([])
|
||||||
|
self.movesMade = 0
|
||||||
|
self.playersGamePos = [
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None]
|
||||||
|
self.fsm.request('waitingToBegin')
|
||||||
|
|
||||||
|
|
||||||
|
def exitGameOver(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def announceSeatPositions(self, todo0):
|
|
||||||
pass
|
def requestBegin(self):
|
||||||
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
if avId not in self.wantStart:
|
||||||
|
self.wantStart.append(avId)
|
||||||
|
|
||||||
|
numPlayers = 0
|
||||||
|
for x in self.parent.seats:
|
||||||
|
if x != None:
|
||||||
|
numPlayers = numPlayers + 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
if len(self.wantStart) == numPlayers and numPlayers >= 2:
|
||||||
|
self.d_gameStart(avId)
|
||||||
|
self.parent.sendIsPlaying()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def d_gameStart(self, avId):
|
||||||
|
for x in self.playersObserving:
|
||||||
|
self.sendUpdateToAvatarId(x, 'gameStart', [
|
||||||
|
255])
|
||||||
|
|
||||||
|
playerJoinOrder = [
|
||||||
|
1,
|
||||||
|
4,
|
||||||
|
2,
|
||||||
|
5,
|
||||||
|
3,
|
||||||
|
6]
|
||||||
|
zz = 0
|
||||||
|
numPlayers = 0
|
||||||
|
for x in self.parent.seats:
|
||||||
|
if x != None:
|
||||||
|
numPlayers += 1
|
||||||
|
self.playersPlaying.append(x)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if numPlayers == 2:
|
||||||
|
player1 = self.playersPlaying[0]
|
||||||
|
self.sendUpdateToAvatarId(player1, 'gameStart', [
|
||||||
|
1])
|
||||||
|
self.playersGamePos[0] = player1
|
||||||
|
for x in self.startingPositions[0]:
|
||||||
|
self.board.setState(x, 1)
|
||||||
|
|
||||||
|
player2 = self.playersPlaying[1]
|
||||||
|
self.sendUpdateToAvatarId(player2, 'gameStart', [
|
||||||
|
4])
|
||||||
|
self.playersGamePos[3] = player2
|
||||||
|
for x in self.startingPositions[3]:
|
||||||
|
self.board.setState(x, 4)
|
||||||
|
|
||||||
|
elif numPlayers == 3:
|
||||||
|
player1 = self.playersPlaying[0]
|
||||||
|
self.sendUpdateToAvatarId(player1, 'gameStart', [
|
||||||
|
2])
|
||||||
|
self.playersGamePos[1] = player1
|
||||||
|
for x in self.startingPositions[1]:
|
||||||
|
self.board.setState(x, 2)
|
||||||
|
|
||||||
|
player2 = self.playersPlaying[1]
|
||||||
|
self.sendUpdateToAvatarId(player2, 'gameStart', [
|
||||||
|
4])
|
||||||
|
self.playersGamePos[3] = player2
|
||||||
|
for x in self.startingPositions[3]:
|
||||||
|
self.board.setState(x, 4)
|
||||||
|
|
||||||
|
player3 = self.playersPlaying[2]
|
||||||
|
self.sendUpdateToAvatarId(player3, 'gameStart', [
|
||||||
|
6])
|
||||||
|
self.playersGamePos[5] = player3
|
||||||
|
for x in self.startingPositions[5]:
|
||||||
|
self.board.setState(x, 6)
|
||||||
|
|
||||||
|
elif numPlayers == 4:
|
||||||
|
player1 = self.playersPlaying[0]
|
||||||
|
self.sendUpdateToAvatarId(player1, 'gameStart', [
|
||||||
|
1])
|
||||||
|
self.playersGamePos[0] = player1
|
||||||
|
for x in self.startingPositions[0]:
|
||||||
|
self.board.setState(x, 1)
|
||||||
|
|
||||||
|
player2 = self.playersPlaying[1]
|
||||||
|
self.sendUpdateToAvatarId(player2, 'gameStart', [
|
||||||
|
4])
|
||||||
|
self.playersGamePos[3] = player2
|
||||||
|
for x in self.startingPositions[3]:
|
||||||
|
self.board.setState(x, 4)
|
||||||
|
|
||||||
|
player3 = self.playersPlaying[2]
|
||||||
|
self.sendUpdateToAvatarId(player3, 'gameStart', [
|
||||||
|
2])
|
||||||
|
self.playersGamePos[1] = player3
|
||||||
|
for x in self.startingPositions[1]:
|
||||||
|
self.board.setState(x, 2)
|
||||||
|
|
||||||
|
player4 = self.playersPlaying[3]
|
||||||
|
self.sendUpdateToAvatarId(player4, 'gameStart', [
|
||||||
|
5])
|
||||||
|
self.playersGamePos[4] = player4
|
||||||
|
for x in self.startingPositions[4]:
|
||||||
|
self.board.setState(x, 5)
|
||||||
|
|
||||||
|
elif numPlayers == 5:
|
||||||
|
player1 = self.playersPlaying[0]
|
||||||
|
self.sendUpdateToAvatarId(player1, 'gameStart', [
|
||||||
|
1])
|
||||||
|
self.playersGamePos[0] = player1
|
||||||
|
for x in self.startingPositions[0]:
|
||||||
|
self.board.setState(x, 1)
|
||||||
|
|
||||||
|
player2 = self.playersPlaying[1]
|
||||||
|
self.sendUpdateToAvatarId(player2, 'gameStart', [
|
||||||
|
4])
|
||||||
|
self.playersGamePos[3] = player2
|
||||||
|
for x in self.startingPositions[3]:
|
||||||
|
self.board.setState(x, 4)
|
||||||
|
|
||||||
|
player3 = self.playersPlaying[2]
|
||||||
|
self.sendUpdateToAvatarId(player3, 'gameStart', [
|
||||||
|
2])
|
||||||
|
self.playersGamePos[1] = player3
|
||||||
|
for x in self.startingPositions[1]:
|
||||||
|
self.board.setState(x, 2)
|
||||||
|
|
||||||
|
player4 = self.playersPlaying[3]
|
||||||
|
self.sendUpdateToAvatarId(player4, 'gameStart', [
|
||||||
|
5])
|
||||||
|
self.playersGamePos[4] = player4
|
||||||
|
for x in self.startingPositions[4]:
|
||||||
|
self.board.setState(x, 5)
|
||||||
|
|
||||||
|
player5 = self.playersPlaying[4]
|
||||||
|
self.sendUpdateToAvatarId(player5, 'gameStart', [
|
||||||
|
3])
|
||||||
|
self.playersGamePos[2] = player5
|
||||||
|
for x in self.startingPositions[2]:
|
||||||
|
self.board.setState(x, 3)
|
||||||
|
|
||||||
|
elif numPlayers == 6:
|
||||||
|
player1 = self.playersPlaying[0]
|
||||||
|
self.sendUpdateToAvatarId(player1, 'gameStart', [
|
||||||
|
1])
|
||||||
|
self.playersGamePos[0] = player1
|
||||||
|
for x in self.startingPositions[0]:
|
||||||
|
self.board.setState(x, 1)
|
||||||
|
|
||||||
|
player2 = self.playersPlaying[1]
|
||||||
|
self.sendUpdateToAvatarId(player2, 'gameStart', [
|
||||||
|
4])
|
||||||
|
self.playersGamePos[3] = player2
|
||||||
|
for x in self.startingPositions[3]:
|
||||||
|
self.board.setState(x, 4)
|
||||||
|
|
||||||
|
player3 = self.playersPlaying[2]
|
||||||
|
self.sendUpdateToAvatarId(player3, 'gameStart', [
|
||||||
|
2])
|
||||||
|
self.playersGamePos[1] = player3
|
||||||
|
for x in self.startingPositions[1]:
|
||||||
|
self.board.setState(x, 2)
|
||||||
|
|
||||||
|
player4 = self.playersPlaying[3]
|
||||||
|
self.sendUpdateToAvatarId(player4, 'gameStart', [
|
||||||
|
5])
|
||||||
|
self.playersGamePos[4] = player4
|
||||||
|
for x in self.startingPositions[4]:
|
||||||
|
self.board.setState(x, 5)
|
||||||
|
|
||||||
|
player5 = self.playersPlaying[4]
|
||||||
|
self.sendUpdateToAvatarId(player5, 'gameStart', [
|
||||||
|
3])
|
||||||
|
self.playersGamePos[2] = player5
|
||||||
|
for x in self.startingPositions[2]:
|
||||||
|
self.board.setState(x, 3)
|
||||||
|
|
||||||
|
player6 = self.playersPlaying[5]
|
||||||
|
self.sendUpdateToAvatarId(player6, 'gameStart', [
|
||||||
|
6])
|
||||||
|
self.playersGamePos[5] = player6
|
||||||
|
for x in self.startingPositions[5]:
|
||||||
|
self.board.setState(x, 6)
|
||||||
|
|
||||||
|
|
||||||
|
playerSeatPos = [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0]
|
||||||
|
for x in range(6):
|
||||||
|
id = self.playersGamePos[x]
|
||||||
|
if id != None:
|
||||||
|
playerSeatPos[self.parent.seats.index(id)] = x + 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
self.sendUpdate('announceSeatPositions', [
|
||||||
|
playerSeatPos])
|
||||||
|
self.playerSeatPos = playerSeatPos
|
||||||
|
self.sendGameState([])
|
||||||
|
self.wantStart = []
|
||||||
|
self.fsm.request('playing')
|
||||||
|
self.parent.getTableState()
|
||||||
|
|
||||||
|
|
||||||
|
def d_sendTurn(self, playersTurn):
|
||||||
|
self.sendUpdate('sendTurn', [
|
||||||
|
playersTurn])
|
||||||
|
|
||||||
|
|
||||||
|
def advancePlayerTurn(self):
|
||||||
|
foundNewPlayer = False
|
||||||
|
while foundNewPlayer == False:
|
||||||
|
self.playersTurn += 1
|
||||||
|
if self.playersTurn > 5:
|
||||||
|
self.playersTurn = 0
|
||||||
|
|
||||||
|
if self.playersGamePos[self.playersTurn] != None:
|
||||||
|
foundNewPlayer = True
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
def requestMove(self, moveList):
|
||||||
|
playerOrder = [
|
||||||
|
1,
|
||||||
|
4,
|
||||||
|
2,
|
||||||
|
5,
|
||||||
|
3,
|
||||||
|
6]
|
||||||
|
if self.checkLegalMoves(moveList) == True:
|
||||||
|
self.movesMade += 1
|
||||||
|
self.makeMove(moveList)
|
||||||
|
self.advancePlayerTurn()
|
||||||
|
self.d_sendTurn(self.playersTurn + 1)
|
||||||
|
self.setTurnCountdownTime()
|
||||||
|
self.sendUpdate('setTurnTimer', [
|
||||||
|
globalClockDelta.localToNetworkTime(self.turnEnd)])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def checkLegalMoves(self, moveList):
|
||||||
|
if not moveList:
|
||||||
|
return False
|
||||||
|
elif self.board.squareList[moveList[0]].getState() == 0:
|
||||||
|
return False
|
||||||
|
|
||||||
|
for x in range(len(moveList) - 1):
|
||||||
|
y = self.checkLegalMove(self.board.getSquare(moveList[x]), self.board.getSquare(moveList[x + 1]))
|
||||||
|
if y == False:
|
||||||
|
return False
|
||||||
|
continue
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def checkLegalMove(self, firstSquare, secondSquare):
|
||||||
|
if secondSquare.getNum() in firstSquare.getAdjacent():
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
for x in firstSquare.getAdjacent():
|
||||||
|
if x == None:
|
||||||
|
continue
|
||||||
|
if self.board.squareList[x].getState() == 0:
|
||||||
|
continue
|
||||||
|
if self.board.squareList[x].getAdjacent()[firstSquare.getAdjacent().index(x)] == secondSquare.getNum():
|
||||||
|
return True
|
||||||
|
continue
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def makeMove(self, moveList):
|
||||||
|
spot1 = self.board.squareList[moveList[0]].getState()
|
||||||
|
self.board.squareList[moveList[0]].setState(0)
|
||||||
|
self.board.squareList[moveList[len(moveList) - 1]].setState(spot1)
|
||||||
|
self.sendGameState(moveList)
|
||||||
|
|
||||||
|
|
||||||
|
def getState(self):
|
||||||
|
return self.fsm.getCurrentState().getName()
|
||||||
|
|
||||||
|
|
||||||
|
def getName(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
|
def getGameState(self):
|
||||||
|
return [
|
||||||
|
self.board.getStates(),
|
||||||
|
[]]
|
||||||
|
|
||||||
|
|
||||||
|
def sendGameState(self, moveList):
|
||||||
|
gameState = self.board.getStates()
|
||||||
|
self.sendUpdate('setGameState', [
|
||||||
|
gameState,
|
||||||
|
moveList])
|
||||||
|
|
||||||
|
|
||||||
|
def clearBoard(self):
|
||||||
|
for x in self.board.squareList:
|
||||||
|
x.setState(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def getPosHpr(self):
|
||||||
|
return self.posHpr
|
||||||
|
|
||||||
|
|
||||||
|
def testWin(self):
|
||||||
|
self.clearBoard()
|
||||||
|
for x in self.startingPositions[0]:
|
||||||
|
self.board.squareList[x].setState(4)
|
||||||
|
|
||||||
|
self.board.squareList[self.startingPositions[0][len(self.startingPositions[0]) - 1]].setState(0)
|
||||||
|
self.board.squareList[51].setState(4)
|
||||||
|
for x in self.startingPositions[3]:
|
||||||
|
self.board.squareList[x].setState(1)
|
||||||
|
|
||||||
|
self.board.squareList[120].setState(0)
|
||||||
|
self.board.squareList[104].setState(1)
|
||||||
|
self.sendGameState([])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,20 @@
|
||||||
|
from pandac.PandaModules import *
|
||||||
|
from direct.distributed.ClockDelta import *
|
||||||
|
from direct.task.Task import Task
|
||||||
|
from direct.interval.IntervalGlobal import *
|
||||||
|
from TrolleyConstants import *
|
||||||
|
from direct.gui.DirectGui import *
|
||||||
|
from toontown.toonbase import TTLocalizer
|
||||||
from direct.distributed import DistributedNode
|
from direct.distributed import DistributedNode
|
||||||
from direct.distributed.ClockDelta import *
|
|
||||||
from direct.distributed.ClockDelta import *
|
|
||||||
from direct.distributed.ClockDelta import globalClockDelta
|
from direct.distributed.ClockDelta import globalClockDelta
|
||||||
|
from ChineseCheckersBoard import ChineseCheckersBoard
|
||||||
from direct.fsm import ClassicFSM, State
|
from direct.fsm import ClassicFSM, State
|
||||||
from direct.fsm import StateData
|
from direct.fsm import StateData
|
||||||
from direct.gui.DirectGui import *
|
|
||||||
from direct.interval.IntervalGlobal import *
|
|
||||||
from direct.showbase import PythonUtil
|
|
||||||
from direct.task.Task import Task
|
|
||||||
from pandac.PandaModules import *
|
|
||||||
from random import *
|
|
||||||
|
|
||||||
from ChineseCheckersBoard import ChineseCheckersBoard
|
|
||||||
from TrolleyConstants import *
|
|
||||||
from otp.otpbase import OTPGlobals
|
|
||||||
from toontown.toonbase import TTLocalizer
|
|
||||||
from toontown.toonbase import ToontownGlobals
|
|
||||||
from toontown.toonbase.ToontownTimer import ToontownTimer
|
from toontown.toonbase.ToontownTimer import ToontownTimer
|
||||||
|
from toontown.toonbase import ToontownGlobals
|
||||||
|
from direct.distributed.ClockDelta import *
|
||||||
|
from otp.otpbase import OTPGlobals
|
||||||
|
from direct.showbase import PythonUtil
|
||||||
|
|
||||||
class DistributedFindFour(DistributedNode.DistributedNode):
|
class DistributedFindFour(DistributedNode.DistributedNode):
|
||||||
|
|
||||||
|
@ -28,48 +25,8 @@ class DistributedFindFour(DistributedNode.DistributedNode):
|
||||||
self.reparentTo(render)
|
self.reparentTo(render)
|
||||||
self.boardNode = loader.loadModel('phase_6/models/golf/findfour_game.bam')
|
self.boardNode = loader.loadModel('phase_6/models/golf/findfour_game.bam')
|
||||||
self.boardNode.reparentTo(self)
|
self.boardNode.reparentTo(self)
|
||||||
self.board = [[0,
|
self.board = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0],
|
||||||
0,
|
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0],
|
|
||||||
[0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0],
|
|
||||||
[0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0],
|
|
||||||
[0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0],
|
|
||||||
[0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0],
|
|
||||||
[0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0]]
|
|
||||||
self.exitButton = None
|
self.exitButton = None
|
||||||
self.inGame = False
|
self.inGame = False
|
||||||
self.waiting = True
|
self.waiting = True
|
||||||
|
@ -119,7 +76,7 @@ class DistributedFindFour(DistributedNode.DistributedNode):
|
||||||
from direct.fsm import ClassicFSM, State
|
from direct.fsm import ClassicFSM, State
|
||||||
self.fsm = ClassicFSM.ClassicFSM('ChineseCheckers', [State.State('waitingToBegin', self.enterWaitingToBegin, self.exitWaitingToBegin, ['playing', 'gameOver']), State.State('playing', self.enterPlaying, self.exitPlaying, ['gameOver']), State.State('gameOver', self.enterGameOver, self.exitGameOver, ['waitingToBegin'])], 'waitingToBegin', 'waitingToBegin')
|
self.fsm = ClassicFSM.ClassicFSM('ChineseCheckers', [State.State('waitingToBegin', self.enterWaitingToBegin, self.exitWaitingToBegin, ['playing', 'gameOver']), State.State('playing', self.enterPlaying, self.exitPlaying, ['gameOver']), State.State('gameOver', self.enterGameOver, self.exitGameOver, ['waitingToBegin'])], 'waitingToBegin', 'waitingToBegin')
|
||||||
startLoc = self.boardNode.find('**/locators')
|
startLoc = self.boardNode.find('**/locators')
|
||||||
self.locatorList = startLoc.getChildren()
|
self.locatorList = list(startLoc.getChildren())
|
||||||
self.startingPositions = self.locatorList.pop(0)
|
self.startingPositions = self.locatorList.pop(0)
|
||||||
self.startingPositions = self.startingPositions.getChildren()
|
self.startingPositions = self.startingPositions.getChildren()
|
||||||
instancePiece = self.boardNode.find('**/pieces')
|
instancePiece = self.boardNode.find('**/pieces')
|
||||||
|
@ -566,7 +523,7 @@ class DistributedFindFour(DistributedNode.DistributedNode):
|
||||||
for x in xrange(41):
|
for x in xrange(41):
|
||||||
self.tieSequence.append(Parallel(LerpColorInterval(self.locatorList[x], 0.15, Vec4(0.5, 0.5, 0.5, 0.5), Vec4(1, 1, 1, 1)), LerpColorInterval(self.locatorList[x], 0.15, Vec4(1, 1, 1, 1), Vec4(0.5, 0.5, 0.5, 0.5))))
|
self.tieSequence.append(Parallel(LerpColorInterval(self.locatorList[x], 0.15, Vec4(0.5, 0.5, 0.5, 0.5), Vec4(1, 1, 1, 1)), LerpColorInterval(self.locatorList[x], 0.15, Vec4(1, 1, 1, 1), Vec4(0.5, 0.5, 0.5, 0.5))))
|
||||||
|
|
||||||
whisper = WhisperPopup('This Find Four game has resulted in a Tie!', OTPGlobals.getInterfaceFont(), WTNormal)
|
whisper = WhisperPopup('This Find Four game has resulted in a Tie!', OTPGlobals.getInterfaceFont(), WhisperPopup.WTNormal)
|
||||||
whisper.manage(base.marginManager)
|
whisper.manage(base.marginManager)
|
||||||
self.tieSequence.start()
|
self.tieSequence.start()
|
||||||
|
|
||||||
|
@ -608,6 +565,7 @@ class DistributedFindFour(DistributedNode.DistributedNode):
|
||||||
else:
|
else:
|
||||||
hasfound = False
|
hasfound = False
|
||||||
while hasfound == False:
|
while hasfound == False:
|
||||||
|
from random import *
|
||||||
x = randint(0, 6)
|
x = randint(0, 6)
|
||||||
if self.board[0][x] == 0:
|
if self.board[0][x] == 0:
|
||||||
self.d_requestMove(x)
|
self.d_requestMove(x)
|
||||||
|
|
|
@ -1,57 +1,638 @@
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
# File: D (Python 2.4)
|
||||||
|
|
||||||
from direct.distributed.DistributedNodeAI import DistributedNodeAI
|
from direct.distributed.DistributedNodeAI import DistributedNodeAI
|
||||||
|
from direct.distributed.ClockDelta import *
|
||||||
|
from direct.fsm import ClassicFSM, State
|
||||||
|
from direct.fsm import State
|
||||||
|
from direct.fsm import StateData
|
||||||
|
from direct.distributed.ClockDelta import *
|
||||||
|
from direct.interval.IntervalGlobal import *
|
||||||
|
|
||||||
class DistributedFindFourAI(DistributedNodeAI):
|
class DistributedFindFourAI(DistributedNodeAI):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedFindFourAI")
|
|
||||||
|
def __init__(self, air, parent, name, x, y, z, h, p, r):
|
||||||
|
DistributedNodeAI.__init__(self, air)
|
||||||
|
self.name = name
|
||||||
|
self.air = air
|
||||||
|
self.setPos(x, y, z)
|
||||||
|
self.setHpr(h, p, r)
|
||||||
|
self.myPos = (x, y, z)
|
||||||
|
self.myHpr = (h, p, r)
|
||||||
|
self.board = [
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0],
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0],
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0],
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0],
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0],
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0]]
|
||||||
|
self.parent = self.air.doId2do[parent]
|
||||||
|
self.parentDo = parent
|
||||||
|
self.wantStart = []
|
||||||
|
self.playersPlaying = []
|
||||||
|
self.playersSitting = 0
|
||||||
|
self.playersTurn = 1
|
||||||
|
self.movesMade = 0
|
||||||
|
self.playerNum = 1
|
||||||
|
self.winDirection = None
|
||||||
|
self.playersGamePos = [
|
||||||
|
None,
|
||||||
|
None]
|
||||||
|
self.wantTimer = True
|
||||||
|
self.timerEnd = 0
|
||||||
|
self.turnEnd = 0
|
||||||
|
self.playersObserving = []
|
||||||
|
self.winLaffPoints = 20
|
||||||
|
self.movesRequiredToWin = 10
|
||||||
|
self.zoneId = self.air.allocateZone()
|
||||||
|
self.generateOtpObject(air.districtId, self.zoneId, optionalFields = [
|
||||||
|
'setX',
|
||||||
|
'setY',
|
||||||
|
'setZ',
|
||||||
|
'setH',
|
||||||
|
'setP',
|
||||||
|
'setR'])
|
||||||
|
self.parent.setCheckersZoneId(self.zoneId)
|
||||||
|
self.timerStart = None
|
||||||
|
self.fsm = ClassicFSM.ClassicFSM('Checkers', [
|
||||||
|
State.State('waitingToBegin', self.enterWaitingToBegin, self.exitWaitingToBegin, [
|
||||||
|
'playing']),
|
||||||
|
State.State('playing', self.enterPlaying, self.exitPlaying, [
|
||||||
|
'gameOver']),
|
||||||
|
State.State('gameOver', self.enterGameOver, self.exitGameOver, [
|
||||||
|
'waitingToBegin'])], 'waitingToBegin', 'waitingToBegin')
|
||||||
|
self.fsm.enterInitialState()
|
||||||
|
|
||||||
def requestExit(self):
|
|
||||||
pass
|
def announceGenerate(self):
|
||||||
|
self.parent.setGameDoId(self.doId)
|
||||||
|
|
||||||
def requestBegin(self):
|
|
||||||
pass
|
def getTableDoId(self):
|
||||||
|
return self.parentDo
|
||||||
|
|
||||||
def requestMove(self, todo0):
|
|
||||||
pass
|
def delete(self):
|
||||||
|
self.fsm.requestFinalState()
|
||||||
|
self.parent = None
|
||||||
|
self.parentDo = None
|
||||||
|
del self.board
|
||||||
|
del self.fsm
|
||||||
|
DistributedNodeAI.delete(self)
|
||||||
|
|
||||||
|
|
||||||
|
def informGameOfPlayer(self):
|
||||||
|
self.playersSitting += 1
|
||||||
|
if self.playersSitting < 2:
|
||||||
|
self.timerEnd = 0
|
||||||
|
elif self.playersSitting == 2:
|
||||||
|
self.timerEnd = globalClock.getRealTime() + 20
|
||||||
|
self.parent.isAccepting = False
|
||||||
|
self.parent.sendUpdate('setIsPlaying', [
|
||||||
|
1])
|
||||||
|
elif self.playersSitting > 2:
|
||||||
|
pass
|
||||||
|
|
||||||
|
self.sendUpdate('setTimer', [
|
||||||
|
globalClockDelta.localToNetworkTime(self.timerEnd)])
|
||||||
|
|
||||||
|
|
||||||
|
def informGameOfPlayerLeave(self):
|
||||||
|
self.playersSitting -= 1
|
||||||
|
if self.playersSitting < 2 and self.fsm.getCurrentState().getName() == 'waitingToBegin':
|
||||||
|
self.timerEnd = 0
|
||||||
|
self.parent.isAccepting = True
|
||||||
|
self.parent.sendUpdate('setIsPlaying', [
|
||||||
|
0])
|
||||||
|
|
||||||
|
if self.playersSitting > 2 and self.fsm.getCurrentState().getName() == 'waitingToBegin':
|
||||||
|
pass
|
||||||
|
1
|
||||||
|
self.timerEnd = 0
|
||||||
|
if self.timerEnd != 0:
|
||||||
|
self.sendUpdate('setTimer', [
|
||||||
|
globalClockDelta.localToNetworkTime(self.timerEnd)])
|
||||||
|
else:
|
||||||
|
self.sendUpdate('setTimer', [
|
||||||
|
0])
|
||||||
|
|
||||||
|
|
||||||
|
def setGameCountdownTime(self):
|
||||||
|
self.timerEnd = globalClock.getRealTime() + 10
|
||||||
|
|
||||||
|
|
||||||
|
def setTurnCountdownTime(self):
|
||||||
|
self.turnEnd = globalClock.getRealTime() + 25
|
||||||
|
|
||||||
|
|
||||||
|
def getTimer(self):
|
||||||
|
if self.timerEnd != 0:
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def getTurnTimer(self):
|
||||||
|
return globalClockDelta.localToNetworkTime(self.turnEnd)
|
||||||
|
|
||||||
|
|
||||||
def requestTimer(self):
|
def requestTimer(self):
|
||||||
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
self.sendUpdateToAvatarId(avId, 'setTimer', [
|
||||||
|
globalClockDelta.localToNetworkTime(self.timerEnd)])
|
||||||
|
|
||||||
|
|
||||||
|
def handlePlayerExit(self, avId):
|
||||||
|
if avId in self.wantStart:
|
||||||
|
self.wantStart.remove(avId)
|
||||||
|
|
||||||
|
if self.fsm.getCurrentState().getName() == 'playing':
|
||||||
|
gamePos = self.playersGamePos.index(avId)
|
||||||
|
self.playersGamePos[gamePos] = None
|
||||||
|
self.fsm.request('gameOver')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def handleEmptyGame(self):
|
||||||
|
self.movesMade = 0
|
||||||
|
self.playersPlaying = []
|
||||||
|
self.playersTurn = 1
|
||||||
|
self.playerNum = 1
|
||||||
|
self.fsm.request('waitingToBegin')
|
||||||
|
self.parent.isAccepting = True
|
||||||
|
|
||||||
|
|
||||||
|
def requestWin(self, pieceNum):
|
||||||
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
playerNum = self.playersGamePos.index(avId) + 1
|
||||||
|
x = pieceNum[0]
|
||||||
|
y = pieceNum[1]
|
||||||
|
if self.checkWin(x, y, playerNum) == True:
|
||||||
|
self.sendUpdate('announceWinnerPosition', [
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
self.winDirection,
|
||||||
|
playerNum])
|
||||||
|
winnersSequence = Sequence(Wait(5.0), Func(self.fsm.request, 'gameOver'), Func(self.parent.announceWinner, 'Find Four', avId))
|
||||||
|
winnersSequence.start()
|
||||||
|
else:
|
||||||
|
self.sendUpdateToAvatarId(avId, 'illegalMove', [])
|
||||||
|
|
||||||
|
|
||||||
|
def distributeLaffPoints(self):
|
||||||
|
for x in self.parent.seats:
|
||||||
|
if x != None:
|
||||||
|
av = self.air.doId2do.get(x)
|
||||||
|
av.toonUp(self.winLaffPoints)
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def enterWaitingToBegin(self):
|
||||||
|
self.setGameCountdownTime()
|
||||||
|
self.parent.isAccepting = True
|
||||||
|
|
||||||
|
|
||||||
|
def exitWaitingToBegin(self):
|
||||||
|
self.turnEnd = 0
|
||||||
|
|
||||||
|
|
||||||
|
def enterPlaying(self):
|
||||||
|
self.parent.isAccepting = False
|
||||||
|
for x in self.playersGamePos:
|
||||||
|
if x != None:
|
||||||
|
self.playersTurn = self.playersGamePos.index(x)
|
||||||
|
self.d_sendTurn(self.playersTurn + 1)
|
||||||
|
break
|
||||||
|
continue
|
||||||
|
|
||||||
|
self.setTurnCountdownTime()
|
||||||
|
self.sendUpdate('setTurnTimer', [
|
||||||
|
globalClockDelta.localToNetworkTime(self.turnEnd)])
|
||||||
|
|
||||||
|
|
||||||
|
def exitPlaying(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def requestWin(self, todo0):
|
|
||||||
|
def enterGameOver(self):
|
||||||
|
self.timerEnd = 0
|
||||||
|
isAccepting = True
|
||||||
|
self.parent.handleGameOver()
|
||||||
|
self.playersObserving = []
|
||||||
|
self.playersTurn = 1
|
||||||
|
self.playerNum = 1
|
||||||
|
self.playersPlaying = []
|
||||||
|
self.movesMade = 0
|
||||||
|
self.playersGamePos = [
|
||||||
|
None,
|
||||||
|
None]
|
||||||
|
self.parent.isAccepting = True
|
||||||
|
self.fsm.request('waitingToBegin')
|
||||||
|
|
||||||
|
|
||||||
|
def exitGameOver(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def startBeginTimer(self, todo0, todo1):
|
|
||||||
pass
|
def requestBegin(self):
|
||||||
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
if avId not in self.wantStart:
|
||||||
|
self.wantStart.append(avId)
|
||||||
|
|
||||||
|
numPlayers = 0
|
||||||
|
for x in self.parent.seats:
|
||||||
|
if x != None:
|
||||||
|
numPlayers = numPlayers + 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
if len(self.wantStart) == numPlayers and numPlayers >= 2:
|
||||||
|
self.d_gameStart(avId)
|
||||||
|
self.parent.sendIsPlaying()
|
||||||
|
|
||||||
|
|
||||||
def setTableDoId(self, todo0):
|
|
||||||
pass
|
def d_gameStart(self, avId):
|
||||||
|
for x in self.playersObserving:
|
||||||
|
self.sendUpdateToAvatarId(x, 'gameStart', [
|
||||||
|
255])
|
||||||
|
|
||||||
|
zz = 0
|
||||||
|
numPlayers = 0
|
||||||
|
for x in self.parent.seats:
|
||||||
|
if x != None:
|
||||||
|
numPlayers += 1
|
||||||
|
self.playersPlaying.append(x)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if numPlayers == 2:
|
||||||
|
player1 = self.playersPlaying[0]
|
||||||
|
self.sendUpdateToAvatarId(player1, 'gameStart', [
|
||||||
|
1])
|
||||||
|
self.playersGamePos[0] = player1
|
||||||
|
player2 = self.playersPlaying[1]
|
||||||
|
self.sendUpdateToAvatarId(player2, 'gameStart', [
|
||||||
|
2])
|
||||||
|
self.playersGamePos[1] = player2
|
||||||
|
|
||||||
|
self.wantStart = []
|
||||||
|
self.fsm.request('playing')
|
||||||
|
self.parent.getTableState()
|
||||||
|
|
||||||
def setGameState(self, todo0, todo1, todo2, todo3):
|
|
||||||
pass
|
def d_sendTurn(self, playersTurn):
|
||||||
|
self.sendUpdate('sendTurn', [
|
||||||
|
playersTurn])
|
||||||
|
|
||||||
def setTimer(self, todo0):
|
|
||||||
pass
|
def advancePlayerTurn(self):
|
||||||
|
if self.playersTurn == 0:
|
||||||
|
self.playersTurn = 1
|
||||||
|
self.playerNum = 2
|
||||||
|
else:
|
||||||
|
self.playerNum = 1
|
||||||
|
self.playersTurn = 0
|
||||||
|
|
||||||
def setTurnTimer(self, todo0):
|
|
||||||
pass
|
def requestMove(self, moveColumn):
|
||||||
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
turn = self.playersTurn
|
||||||
|
if avId in self.playersGamePos:
|
||||||
|
if self.playersGamePos.index(avId) != self.playersTurn:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
if self.board[0][moveColumn] != 0:
|
||||||
|
self.sendUpdateToAvatarId(avId, 'illegalMove', [])
|
||||||
|
|
||||||
|
for x in range(6):
|
||||||
|
if self.board[x][moveColumn] == 0:
|
||||||
|
movePos = x
|
||||||
|
continue
|
||||||
|
|
||||||
|
self.board[movePos][moveColumn] = self.playersTurn + 1
|
||||||
|
if self.checkForTie() == True:
|
||||||
|
self.sendUpdate('setGameState', [
|
||||||
|
self.board,
|
||||||
|
moveColumn,
|
||||||
|
movePos,
|
||||||
|
turn])
|
||||||
|
self.sendUpdate('tie', [])
|
||||||
|
winnersSequence = Sequence(Wait(8.0), Func(self.fsm.request, 'gameOver'))
|
||||||
|
winnersSequence.start()
|
||||||
|
return None
|
||||||
|
|
||||||
|
self.movesMade += 1
|
||||||
|
self.advancePlayerTurn()
|
||||||
|
self.setTurnCountdownTime()
|
||||||
|
self.sendUpdate('setTurnTimer', [
|
||||||
|
globalClockDelta.localToNetworkTime(self.turnEnd)])
|
||||||
|
self.d_sendTurn(self.playersTurn + 1)
|
||||||
|
self.sendUpdate('setGameState', [
|
||||||
|
self.board,
|
||||||
|
moveColumn,
|
||||||
|
movePos,
|
||||||
|
turn])
|
||||||
|
|
||||||
def gameStart(self, todo0):
|
|
||||||
pass
|
def checkForTie(self):
|
||||||
|
for x in range(7):
|
||||||
|
if self.board[0][x] == 0:
|
||||||
|
return False
|
||||||
|
continue
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def sendTurn(self, todo0):
|
|
||||||
pass
|
def getState(self):
|
||||||
|
return self.fsm.getCurrentState().getName()
|
||||||
|
|
||||||
def announceWin(self, todo0):
|
|
||||||
pass
|
def getName(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
def announceWinLocation(self, todo0, todo1, todo2, todo3):
|
|
||||||
pass
|
def getGameState(self):
|
||||||
|
return [
|
||||||
|
self.board,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0]
|
||||||
|
|
||||||
def announceWinnerPosition(self, todo0, todo1, todo2, todo3):
|
|
||||||
pass
|
def clearBoard(self):
|
||||||
|
for x in self.board.squareList:
|
||||||
|
x.setState(0)
|
||||||
|
|
||||||
|
|
||||||
def illegalMove(self):
|
|
||||||
pass
|
def getPosHpr(self):
|
||||||
|
return self.posHpr
|
||||||
|
|
||||||
|
|
||||||
|
def tempSetBoardState(self):
|
||||||
|
self.board = [
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0],
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1],
|
||||||
|
[
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
1],
|
||||||
|
[
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
2],
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
1],
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
1]]
|
||||||
|
self.sendUpdate('setGameState', [
|
||||||
|
self.board,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1])
|
||||||
|
|
||||||
|
|
||||||
|
def checkWin(self, rVal, cVal, playerNum):
|
||||||
|
if self.checkHorizontal(rVal, cVal, playerNum) == True:
|
||||||
|
self.winDirection = 0
|
||||||
|
return True
|
||||||
|
elif self.checkVertical(rVal, cVal, playerNum) == True:
|
||||||
|
self.winDirection = 1
|
||||||
|
return True
|
||||||
|
elif self.checkDiagonal(rVal, cVal, playerNum) == True:
|
||||||
|
self.winDirection = 2
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
self.winDirection = None
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def checkHorizontal(self, rVal, cVal, playerNum):
|
||||||
|
if cVal == 3:
|
||||||
|
for x in range(1, 4):
|
||||||
|
if self.board[rVal][cVal - x] != playerNum:
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.board[rVal][cVal - x] == playerNum and x == 3:
|
||||||
|
return True
|
||||||
|
continue
|
||||||
|
|
||||||
|
for x in range(1, 4):
|
||||||
|
if self.board[rVal][cVal + x] != playerNum:
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.board[rVal][cVal + x] == playerNum and x == 3:
|
||||||
|
return True
|
||||||
|
continue
|
||||||
|
|
||||||
|
return False
|
||||||
|
elif cVal == 2:
|
||||||
|
for x in range(1, 4):
|
||||||
|
if self.board[rVal][cVal + x] != playerNum:
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.board[rVal][cVal + x] == playerNum and x == 3:
|
||||||
|
return True
|
||||||
|
continue
|
||||||
|
|
||||||
|
return False
|
||||||
|
elif cVal == 4:
|
||||||
|
for x in range(1, 4):
|
||||||
|
if self.board[rVal][cVal - x] != playerNum:
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.board[rVal][cVal - x] == playerNum and x == 3:
|
||||||
|
return True
|
||||||
|
continue
|
||||||
|
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def checkVertical(self, rVal, cVal, playerNum):
|
||||||
|
if rVal == 2:
|
||||||
|
for x in range(1, 4):
|
||||||
|
if self.board[rVal + x][cVal] != playerNum:
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.board[rVal + x][cVal] == playerNum and x == 3:
|
||||||
|
return True
|
||||||
|
continue
|
||||||
|
|
||||||
|
return False
|
||||||
|
elif rVal == 3:
|
||||||
|
for x in range(1, 4):
|
||||||
|
if self.board[rVal - x][cVal] != playerNum:
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.board[rVal - x][cVal] == playerNum and x == 3:
|
||||||
|
return True
|
||||||
|
continue
|
||||||
|
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def checkDiagonal(self, rVal, cVal, playerNum):
|
||||||
|
if cVal <= 2:
|
||||||
|
if rVal == 2:
|
||||||
|
for x in range(1, 4):
|
||||||
|
if self.board[rVal + x][cVal + x] != playerNum:
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.board[rVal + x][cVal + x] == playerNum and x == 3:
|
||||||
|
return True
|
||||||
|
continue
|
||||||
|
|
||||||
|
return False
|
||||||
|
elif rVal == 3:
|
||||||
|
for x in range(1, 4):
|
||||||
|
if self.board[rVal - x][cVal + x] != playerNum:
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.board[rVal - x][cVal + x] == playerNum and x == 3:
|
||||||
|
return True
|
||||||
|
continue
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
elif cVal >= 4:
|
||||||
|
if rVal == 2:
|
||||||
|
for x in range(1, 4):
|
||||||
|
if self.board[rVal + x][cVal - x] != playerNum:
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.board[rVal + x][cVal - x] == playerNum and x == 3:
|
||||||
|
return True
|
||||||
|
continue
|
||||||
|
|
||||||
|
return False
|
||||||
|
elif rVal == 3:
|
||||||
|
for x in range(1, 4):
|
||||||
|
if self.board[rVal - x][cVal - x] != playerNum:
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.board[rVal - x][cVal - x] == playerNum and x == 3:
|
||||||
|
return True
|
||||||
|
continue
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
elif rVal == 3 and rVal == 4 or rVal == 5:
|
||||||
|
for x in range(1, 4):
|
||||||
|
if self.board[rVal - x][cVal - x] != playerNum:
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.board[rVal - x][cVal - x] == playerNum and x == 3:
|
||||||
|
return True
|
||||||
|
continue
|
||||||
|
|
||||||
|
for x in range(1, 4):
|
||||||
|
if self.board[rVal + x][cVal - x] != playerNum:
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.board[rVal + x][cVal - x] == playerNum and x == 3:
|
||||||
|
return True
|
||||||
|
continue
|
||||||
|
|
||||||
|
return False
|
||||||
|
elif rVal == 0 and rVal == 1 or rVal == 2:
|
||||||
|
for x in range(1, 4):
|
||||||
|
if self.board[rVal + x][cVal - x] != playerNum:
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.board[rVal + x][cVal - x] == playerNum and x == 3:
|
||||||
|
return True
|
||||||
|
continue
|
||||||
|
|
||||||
|
for x in range(1, 4):
|
||||||
|
if self.board[rVal + x][cVal + x] != playerNum:
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.board[rVal + x][cVal + x] == playerNum and x == 3:
|
||||||
|
return True
|
||||||
|
continue
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def tie(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
|
@ -1,291 +0,0 @@
|
||||||
import math
|
|
||||||
|
|
||||||
from direct.distributed import DistributedObject
|
|
||||||
from direct.fsm import ClassicFSM, State
|
|
||||||
from direct.gui.DirectGui import *
|
|
||||||
from pandac.PandaModules import *
|
|
||||||
from toontown.distributed.DelayDelete import *
|
|
||||||
from toontown.safezone import PicnicGameGlobals
|
|
||||||
from toontown.safezone.PicnicGameSelectMenu import PicnicGameSelectMenu
|
|
||||||
from toontown.safezone.PicnicGameTutorial import *
|
|
||||||
from toontown.toonbase import TTLocalizer
|
|
||||||
from toontown.toonbase import ToontownGlobals
|
|
||||||
from toontown.toonbase.ToontownTimer import ToontownTimer
|
|
||||||
|
|
||||||
|
|
||||||
class DistributedGameTable(DistributedObject.DistributedObject):
|
|
||||||
def __init__(self, cr):
|
|
||||||
DistributedObject.DistributedObject.__init__(self, cr)
|
|
||||||
|
|
||||||
self.tableModelPath = 'phase_6/models/golf/game_table.bam'
|
|
||||||
self.numSeats = 6
|
|
||||||
self.__toonTracks = {}
|
|
||||||
self.gameMenu = None
|
|
||||||
self.game = None
|
|
||||||
self.gameDoId = 0
|
|
||||||
self.timerFunc = None
|
|
||||||
self.gameWantTimer = False
|
|
||||||
self.cameraBoardTrack = None
|
|
||||||
self.tutorial = None
|
|
||||||
self.fsm = ClassicFSM.ClassicFSM(
|
|
||||||
'DistributedGameTable',
|
|
||||||
[
|
|
||||||
State.State(
|
|
||||||
'off', self.enterOff, self.exitOff,
|
|
||||||
['chooseMode', 'observing']
|
|
||||||
),
|
|
||||||
State.State(
|
|
||||||
'chooseMode', self.enterChooseMode, self.exitChooseMode,
|
|
||||||
['sitting', 'off', 'observing']
|
|
||||||
),
|
|
||||||
State.State(
|
|
||||||
'sitting', self.enterSitting, self.exitSitting,
|
|
||||||
['off']
|
|
||||||
),
|
|
||||||
State.State(
|
|
||||||
'observing', self.enterObserving, self.exitObserving,
|
|
||||||
['off']
|
|
||||||
)
|
|
||||||
], 'off', 'off')
|
|
||||||
self.fsm.enterInitialState()
|
|
||||||
|
|
||||||
def generate(self):
|
|
||||||
DistributedObject.DistributedObject.generate(self)
|
|
||||||
|
|
||||||
self.picnicTableNode = render.attachNewNode('gameTable')
|
|
||||||
self.picnicTable = loader.loadModel(self.tableModelPath)
|
|
||||||
self.picnicTable.reparentTo(self.picnicTableNode)
|
|
||||||
self.loader = self.cr.playGame.hood.loader
|
|
||||||
self.picnicTableNode.reparentTo(self.loader.geom)
|
|
||||||
|
|
||||||
def announceGenerate(self):
|
|
||||||
DistributedObject.DistributedObject.announceGenerate(self)
|
|
||||||
|
|
||||||
self.tableCloth = self.picnicTable.find('**/basket_locator')
|
|
||||||
cn = CollisionNode('tableCloth_sphere')
|
|
||||||
self.tableClothSphereNode = self.tableCloth.attachNewNode(cn)
|
|
||||||
cs = CollisionSphere(0, 0, -2, 5.5)
|
|
||||||
self.tableClothSphereNode.node().addSolid(cs)
|
|
||||||
|
|
||||||
self.seats = []
|
|
||||||
self.jumpOffsets = []
|
|
||||||
self.picnicTableSphereNodes = []
|
|
||||||
for i in xrange(self.numSeats):
|
|
||||||
self.seats.append(self.picnicTable.find('**/*seat' + str(i+1)))
|
|
||||||
self.jumpOffsets.append(self.picnicTable.find('**/*jumpOut' + str(i+1)))
|
|
||||||
cn = CollisionNode('picnicTable_sphere_%d_%d' % (self.doId, i))
|
|
||||||
self.picnicTableSphereNodes.append(self.seats[i].attachNewNode(cn))
|
|
||||||
cs = CollisionSphere(0, 0, 0, 2)
|
|
||||||
self.picnicTableSphereNodes[i].node().addSolid(cs)
|
|
||||||
|
|
||||||
self.clockNode = ToontownTimer()
|
|
||||||
self.clockNode.setPos(1.16, 0, -0.83)
|
|
||||||
self.clockNode.setScale(0.3)
|
|
||||||
self.clockNode.hide()
|
|
||||||
|
|
||||||
self.buttonModels = loader.loadModel('phase_3.5/models/gui/inventory_gui.bam')
|
|
||||||
self.upButton = self.buttonModels.find('**//InventoryButtonUp')
|
|
||||||
self.downButton = self.buttonModels.find('**/InventoryButtonDown')
|
|
||||||
self.rolloverButton = self.buttonModels.find('**/InventoryButtonRollover')
|
|
||||||
|
|
||||||
self.joinButton = None
|
|
||||||
self.observeButton = None
|
|
||||||
self.exitButton = None
|
|
||||||
self.tutorialButton = None
|
|
||||||
|
|
||||||
angle = self.picnicTable.getH()
|
|
||||||
angle -= 90
|
|
||||||
radAngle = math.radians(angle)
|
|
||||||
unitVec = Vec3(math.cos(radAngle), math.sin(radAngle), 0)
|
|
||||||
unitVec *= 30.0
|
|
||||||
self.endPos = self.picnicTable.getPos() + unitVec
|
|
||||||
|
|
||||||
self.enableCollisions()
|
|
||||||
|
|
||||||
def disable(self):
|
|
||||||
DistributedObject.DistributedObject.disable(self)
|
|
||||||
self.fsm.request('off')
|
|
||||||
self.clearToonTracks()
|
|
||||||
# TODO: Disable choice buttons.
|
|
||||||
# TODO: Stop sleep tracking.
|
|
||||||
self.destroyGameMenu()
|
|
||||||
self.disableCollisions()
|
|
||||||
del self.gameMenu
|
|
||||||
if self.cameraBoardTrack:
|
|
||||||
self.cameraBoardTrack.finish()
|
|
||||||
del self.cameraBoardTrack
|
|
||||||
del self.tableClothSphereNode
|
|
||||||
del self.tableCloth
|
|
||||||
del self.seats
|
|
||||||
del self.jumpOffsets
|
|
||||||
del self.picnicTableSphereNodes
|
|
||||||
del self.clockNode
|
|
||||||
self.buttonModels.removeNode()
|
|
||||||
del self.buttonModels
|
|
||||||
del self.endPos
|
|
||||||
del self.loader
|
|
||||||
self.picnicTable.removeNode()
|
|
||||||
self.picnicTableNode.removeNode()
|
|
||||||
|
|
||||||
def delete(self):
|
|
||||||
DistributedObject.DistributedObject.delete(self)
|
|
||||||
|
|
||||||
del self.fsm
|
|
||||||
|
|
||||||
def enableCollisions(self):
|
|
||||||
for i in xrange(self.numSeats):
|
|
||||||
event = 'enterpicnicTable_sphere_%d_%d' % (self.doId, i)
|
|
||||||
self.accept(event, self.handleEnterPicnicTableSphere, [i])
|
|
||||||
self.picnicTableSphereNodes[i].setCollideMask(ToontownGlobals.WallBitmask)
|
|
||||||
self.tableClothSphereNode.setCollideMask(ToontownGlobals.WallBitmask)
|
|
||||||
|
|
||||||
def disableCollisions(self):
|
|
||||||
for i in xrange(self.numSeats):
|
|
||||||
self.ignore('enterpicnicTable_sphere_%d_%d' % (self.doId, i))
|
|
||||||
for i in xrange(self.numSeats):
|
|
||||||
self.picnicTableSphereNodes[i].setCollideMask(BitMask32(0))
|
|
||||||
self.tableClothSphereNode.setCollideMask(BitMask32(0))
|
|
||||||
|
|
||||||
def handleEnterPicnicTableSphere(self, i, collEntry):
|
|
||||||
self.fsm.request('chooseMode')
|
|
||||||
|
|
||||||
def enterOff(self):
|
|
||||||
base.setCellsActive(base.leftCells + base.bottomCells, 0)
|
|
||||||
|
|
||||||
def exitOff(self):
|
|
||||||
base.setCellsActive(base.bottomCells, 0)
|
|
||||||
|
|
||||||
def enterChooseMode(self):
|
|
||||||
self.enableChoiceButtons()
|
|
||||||
|
|
||||||
def exitChooseMode(self):
|
|
||||||
self.disableChoiceButtons()
|
|
||||||
|
|
||||||
def enterObserving(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def exitObserving(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def enterSitting(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def exitSitting(self):
|
|
||||||
self.destroyGameMenu()
|
|
||||||
|
|
||||||
def destroyGameMenu(self):
|
|
||||||
if self.gameMenu:
|
|
||||||
self.gameMenu.removeButtons()
|
|
||||||
self.gameMenu.picnicFunction = None
|
|
||||||
self.gameMenu = None
|
|
||||||
|
|
||||||
def setPosHpr(self, x, y, z, h, p, r):
|
|
||||||
self.picnicTable.setPosHpr(x, y, z, h, p, r)
|
|
||||||
|
|
||||||
def storeToonTrack(self, avId, track):
|
|
||||||
self.clearToonTrack(avId)
|
|
||||||
self.__toonTracks[avId] = track
|
|
||||||
|
|
||||||
def clearToonTrack(self, avId):
|
|
||||||
oldTrack = self.__toonTracks.get(avId)
|
|
||||||
if oldTrack:
|
|
||||||
oldTrack.pause()
|
|
||||||
cleanupDelayDeletes(oldTrack)
|
|
||||||
|
|
||||||
def clearToonTracks(self):
|
|
||||||
for avId in self.__toonTracks:
|
|
||||||
self.clearToonTrack(avId)
|
|
||||||
|
|
||||||
def showTimer(self):
|
|
||||||
self.clockNode.stop()
|
|
||||||
self.clockNode.countdown(self.timeLeft, self.timerFunc)
|
|
||||||
self.clockNode.show()
|
|
||||||
|
|
||||||
def setTimer(self, timerEnd):
|
|
||||||
self.clockNode.stop()
|
|
||||||
time = globalClockDelta.networkToLocalTime(timerEnd)
|
|
||||||
self.timeLeft = int(time - globalClock.getRealTime())
|
|
||||||
if self.gameWantTimer and (self.game is not None):
|
|
||||||
self.showTimer()
|
|
||||||
|
|
||||||
def setTimerFunc(self, function):
|
|
||||||
self.timerFunc = function
|
|
||||||
|
|
||||||
def allowWalk(self):
|
|
||||||
base.cr.playGame.getPlace().setState('walk')
|
|
||||||
|
|
||||||
def disallowWalk(self):
|
|
||||||
base.cr.playGame.getPlace().setState('stopped')
|
|
||||||
|
|
||||||
def enableChoiceButtons(self):
|
|
||||||
if (not self.game) or (not self.game.playing):
|
|
||||||
self.joinButton = DirectButton(
|
|
||||||
relief=None, text=TTLocalizer.PicnicTableJoinButton,
|
|
||||||
text_fg=(1, 1, 0.65, 1), text_pos=(0, -0.23), text_scale=0.8,
|
|
||||||
image=(self.upButton, self.downButton, self.rolloverButton),
|
|
||||||
image_color=(1, 0, 0, 1), image_scale=(20, 1, 11),
|
|
||||||
pos=(0, 0, 0.8), scale=0.15,
|
|
||||||
command=lambda self=self: self.joinButtonPushed())
|
|
||||||
else:
|
|
||||||
self.observeButton = DirectButton(
|
|
||||||
relief=None, text=TTLocalizer.PicnicTableObserveButton,
|
|
||||||
text_fg=(1, 1, 0.65, 1), text_pos=(0, -0.23), text_scale=0.8,
|
|
||||||
image=(self.upButton, self.downButton, self.rolloverButton),
|
|
||||||
image_color=(1, 0, 0, 1), image_scale=(20, 1, 11),
|
|
||||||
pos=(0, 0, 0.6), scale=0.15,
|
|
||||||
command=lambda self=self: self.observeButtonPushed())
|
|
||||||
self.exitButton = DirectButton(
|
|
||||||
relief=None, text=TTLocalizer.PicnicTableCancelButton,
|
|
||||||
text_fg=(1, 1, 0.65, 1), text_pos=(0, -0.23), text_scale=0.8,
|
|
||||||
image=(self.upButton, self.downButton, self.rolloverButton),
|
|
||||||
image_color=(1, 0, 0, 1), image_scale=(20, 1, 11), pos=(1, 0, 0.6),
|
|
||||||
scale=0.15, command=lambda self=self: self.cancelButtonPushed())
|
|
||||||
self.tutorialButton = DirectButton(
|
|
||||||
relief=None, text=TTLocalizer.PicnicTableTutorial,
|
|
||||||
text_fg=(1, 1, 0.65, 1), text_pos=(-0.05, -0.13), text_scale=0.55,
|
|
||||||
image=(self.upButton, self.downButton, self.rolloverButton),
|
|
||||||
image_color=(1, 0, 0, 1), image_scale=(20, 1, 11), pos=(-1, 0, 0.6),
|
|
||||||
scale=0.15, command=lambda self=self: self.tutorialButtonPushed())
|
|
||||||
self.disallowWalk()
|
|
||||||
|
|
||||||
def disableChoiceButtons(self):
|
|
||||||
if self.joinButton:
|
|
||||||
self.joinButton.destroy()
|
|
||||||
self.joinButton = None
|
|
||||||
if self.observeButton:
|
|
||||||
self.observeButton.destroy()
|
|
||||||
self.observeButton = None
|
|
||||||
if self.exitButton:
|
|
||||||
self.exitButton.destroy()
|
|
||||||
self.exitButton = None
|
|
||||||
if self.tutorialButton:
|
|
||||||
self.tutorialButton.destroy()
|
|
||||||
self.tutorialButton = None
|
|
||||||
|
|
||||||
def joinButtonPushed(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def observeButtonPushed(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def cancelButtonPushed(self):
|
|
||||||
self.allowWalk()
|
|
||||||
self.fsm.request('off')
|
|
||||||
|
|
||||||
def tutorialButtonPushed(self):
|
|
||||||
self.disableChoiceButtons()
|
|
||||||
self.gameMenu = PicnicGameSelectMenu(
|
|
||||||
self.tutorialFunction, PicnicGameGlobals.TutorialMenu)
|
|
||||||
|
|
||||||
def tutorialFunction(self, gameIndex):
|
|
||||||
if gameIndex == PicnicGameGlobals.CheckersGameIndex:
|
|
||||||
self.tutorial = CheckersTutorial(self.tutorialDone)
|
|
||||||
elif gameIndex == PicnicGameGlobals.ChineseCheckersGameIndex:
|
|
||||||
self.tutorial = ChineseCheckersTutorial(self.tutorialDone)
|
|
||||||
else:
|
|
||||||
self.cancelButtonPushed()
|
|
||||||
self.destroyGameMenu()
|
|
||||||
|
|
||||||
def tutorialDone(self):
|
|
||||||
self.fsm.request('off')
|
|
||||||
self.tutorial = None
|
|
|
@ -1,25 +0,0 @@
|
||||||
from direct.distributed import DistributedObjectAI
|
|
||||||
|
|
||||||
|
|
||||||
class DistributedGameTableAI(DistributedObjectAI.DistributedObjectAI):
|
|
||||||
def __init__(self, air):
|
|
||||||
DistributedObjectAI.DistributedObjectAI.__init__(self, air)
|
|
||||||
|
|
||||||
self.posHpr = (0, 0, 0, 0, 0, 0)
|
|
||||||
|
|
||||||
# Required Fields:
|
|
||||||
|
|
||||||
def setPosHpr(self, x, y, z, h, p, r):
|
|
||||||
self.posHpr = (x, y, z, h, p, r)
|
|
||||||
|
|
||||||
def getPosHpr(self):
|
|
||||||
return self.posHpr
|
|
||||||
|
|
||||||
# Receive Fields:
|
|
||||||
|
|
||||||
def requestJoin(self, seatIndex):
|
|
||||||
avId = self.air.getAvatarIdFromSender()
|
|
||||||
self.sendUpdateToAvatarId(avId, 'rejectJoin', [])
|
|
||||||
|
|
||||||
def requestExit(self):
|
|
||||||
pass
|
|
|
@ -636,7 +636,7 @@ class DistributedPicnicTable(DistributedNode.DistributedNode):
|
||||||
oldTrack = self.__toonTracks.get(avId)
|
oldTrack = self.__toonTracks.get(avId)
|
||||||
if oldTrack:
|
if oldTrack:
|
||||||
oldTrack.pause()
|
oldTrack.pause()
|
||||||
cleanupDelayDeletes(oldTrack)
|
DelayDelete.cleanupDelayDeletes(oldTrack)
|
||||||
|
|
||||||
def clearToonTracks(self):
|
def clearToonTracks(self):
|
||||||
keyList = []
|
keyList = []
|
||||||
|
|
|
@ -1,60 +1,344 @@
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
|
||||||
from direct.distributed.DistributedNodeAI import DistributedNodeAI
|
from direct.distributed.DistributedNodeAI import DistributedNodeAI
|
||||||
|
from direct.distributed.ClockDelta import *
|
||||||
|
from direct.fsm import ClassicFSM, State
|
||||||
|
from direct.fsm import State
|
||||||
|
from direct.fsm import StateData
|
||||||
|
from toontown.safezone import DistributedChineseCheckersAI
|
||||||
|
from toontown.safezone import DistributedCheckersAI
|
||||||
|
from toontown.safezone import DistributedFindFourAI
|
||||||
|
from toontown.safezone import GameGlobals
|
||||||
|
|
||||||
class DistributedPicnicTableAI(DistributedNodeAI):
|
class DistributedPicnicTableAI(DistributedNodeAI):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedPicnicTableAI")
|
|
||||||
|
def __init__(self, air, zone, name, x, y, z, h, p, r):
|
||||||
|
DistributedNodeAI.__init__(self, air)
|
||||||
|
self.name = name
|
||||||
|
self.zoneId = zone
|
||||||
|
self.air = air
|
||||||
|
self.seats = [
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None]
|
||||||
|
self.setPos(x, y, z)
|
||||||
|
self.setHpr(h, p, r)
|
||||||
|
self.playersSitting = 0
|
||||||
|
self.playerIdList = []
|
||||||
|
self.checkersZoneId = None
|
||||||
|
self.observers = []
|
||||||
|
self.allowPickers = []
|
||||||
|
self.hasPicked = False
|
||||||
|
self.game = None
|
||||||
|
self.gameDoId = None
|
||||||
|
self.isAccepting = True
|
||||||
|
|
||||||
def fillSlot(self, todo0, todo1, todo2, todo3, todo4, todo5, todo6, todo7, todo8, todo9):
|
def announceGenerate(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def emptySlot(self, todo0, todo1, todo2):
|
def delete(self):
|
||||||
pass
|
DistributedNodeAI.delete(self)
|
||||||
|
self.game = None
|
||||||
|
self.gameDoId = None
|
||||||
|
|
||||||
|
def setGameDoId(self, doId):
|
||||||
|
self.gameDoId = doId
|
||||||
|
self.game = self.air.doId2do.get(doId)
|
||||||
|
|
||||||
def requestTableState(self):
|
def requestTableState(self):
|
||||||
pass
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
self.getTableState()
|
||||||
|
|
||||||
def setTableState(self, todo0, todo1):
|
def getTableState(self):
|
||||||
pass
|
tableStateList = []
|
||||||
|
for x in self.seats:
|
||||||
|
if x == None:
|
||||||
|
tableStateList.append(0)
|
||||||
|
continue
|
||||||
|
tableStateList.append(x)
|
||||||
|
|
||||||
def setGameZone(self, todo0, todo1):
|
if self.game and self.game.fsm.getCurrentState().getName() == 'playing':
|
||||||
pass
|
self.sendUpdate('setTableState', [
|
||||||
|
tableStateList,
|
||||||
|
1])
|
||||||
|
else:
|
||||||
|
self.sendUpdate('setTableState', [
|
||||||
|
tableStateList,
|
||||||
|
0])
|
||||||
|
|
||||||
def setIsPlaying(self, todo0):
|
def sendIsPlaying(self):
|
||||||
pass
|
if self.game.fsm.getCurrentState().getName() == 'playing':
|
||||||
|
self.sendUpdate('setIsPlaying', [
|
||||||
|
1])
|
||||||
|
else:
|
||||||
|
self.sendUpdate('setIsPlaying', [
|
||||||
|
0])
|
||||||
|
|
||||||
def requestJoin(self, todo0, todo1, todo2, todo3, todo4, todo5, todo6):
|
def announceWinner(self, gameName, avId):
|
||||||
pass
|
self.sendUpdate('announceWinner', [
|
||||||
|
gameName,
|
||||||
|
avId])
|
||||||
|
self.gameDoId = None
|
||||||
|
self.game = None
|
||||||
|
|
||||||
def rejectJoin(self):
|
def requestJoin(self, si, x, y, z, h, p, r):
|
||||||
pass
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
if self.findAvatar(avId) != None:
|
||||||
|
self.notify.warning('Ignoring multiple requests from %s to board.' % avId)
|
||||||
|
return None
|
||||||
|
|
||||||
def requestObserve(self):
|
av = self.air.doId2do.get(avId)
|
||||||
pass
|
if av:
|
||||||
|
if av.hp > 0 and self.isAccepting and self.seats[si] == None:
|
||||||
|
self.notify.debug('accepting boarder %d' % avId)
|
||||||
|
self.acceptBoarder(avId, si, x, y, z, h, p, r)
|
||||||
|
else:
|
||||||
|
self.notify.debug('rejecting boarder %d' % avId)
|
||||||
|
self.sendUpdateToAvatarId(avId, 'rejectJoin', [])
|
||||||
|
else:
|
||||||
|
self.notify.warning('avid: %s does not exist, but tried to board a picnicTable' % avId)
|
||||||
|
|
||||||
def leaveObserve(self):
|
def acceptBoarder(self, avId, seatIndex, x, y, z, h, p, r):
|
||||||
pass
|
self.notify.debug('acceptBoarder %d' % avId)
|
||||||
|
if self.findAvatar(avId) != None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
isEmpty = True
|
||||||
|
for xx in self.seats:
|
||||||
|
if xx != None:
|
||||||
|
isEmpty = False
|
||||||
|
break
|
||||||
|
continue
|
||||||
|
|
||||||
def requestGameZone(self):
|
if isEmpty == True or self.hasPicked == False:
|
||||||
pass
|
self.sendUpdateToAvatarId(avId, 'allowPick', [])
|
||||||
|
self.allowPickers.append(avId)
|
||||||
|
|
||||||
def requestPickedGame(self, todo0):
|
if self.hasPicked == True:
|
||||||
pass
|
self.sendUpdateToAvatarId(avId, 'setZone', [
|
||||||
|
self.game.zoneId])
|
||||||
|
|
||||||
def requestExit(self):
|
self.seats[seatIndex] = avId
|
||||||
pass
|
self.acceptOnce(self.air.getAvatarExitEvent(avId), self._DistributedPicnicTableAI__handleUnexpectedExit, extraArgs = [
|
||||||
|
avId])
|
||||||
|
self.timeOfBoarding = globalClock.getRealTime()
|
||||||
|
if self.game:
|
||||||
|
self.game.informGameOfPlayer()
|
||||||
|
|
||||||
|
self.sendUpdate('fillSlot', [
|
||||||
|
avId,
|
||||||
|
seatIndex,
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
z,
|
||||||
|
h,
|
||||||
|
p,
|
||||||
|
r,
|
||||||
|
globalClockDelta.localToNetworkTime(self.timeOfBoarding),
|
||||||
|
self.doId])
|
||||||
|
self.getTableState()
|
||||||
|
|
||||||
|
def requestPickedGame(self, gameNum):
|
||||||
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
if self.hasPicked == False and avId in self.allowPickers:
|
||||||
|
self.hasPicked = True
|
||||||
|
numPickers = len(self.allowPickers)
|
||||||
|
self.allowPickers = []
|
||||||
|
self.pickGame(gameNum)
|
||||||
|
if self.game:
|
||||||
|
for x in range(numPickers):
|
||||||
|
self.game.informGameOfPlayer()
|
||||||
|
|
||||||
|
def pickGame(self, gameNum):
|
||||||
|
if self.game:
|
||||||
|
return
|
||||||
|
|
||||||
|
x = 0
|
||||||
|
for x in self.seats:
|
||||||
|
if x != None:
|
||||||
|
x += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
if gameNum == GameGlobals.ChineseCheckersGameIndex:
|
||||||
|
if simbase.config.GetBool('want-chinese', 1):
|
||||||
|
self.game = DistributedChineseCheckersAI.DistributedChineseCheckersAI(self.air, self.doId, 'chinese', self.getX(), self.getY(), self.getZ() + 2.8300000000000001, self.getH(), self.getP(), self.getR())
|
||||||
|
self.sendUpdate('setZone', [
|
||||||
|
self.game.zoneId])
|
||||||
|
|
||||||
|
elif gameNum == GameGlobals.CheckersGameIndex:
|
||||||
|
if x <= 2:
|
||||||
|
if simbase.config.GetBool('want-checkers', 1):
|
||||||
|
self.game = DistributedCheckersAI.DistributedCheckersAI(self.air, self.doId, 'checkers', self.getX(), self.getY(), self.getZ() + 2.8300000000000001, self.getH(), self.getP(), self.getR())
|
||||||
|
self.sendUpdate('setZone', [
|
||||||
|
self.game.zoneId])
|
||||||
|
|
||||||
|
elif gameNum == GameGlobals.FindFourGameIndex:
|
||||||
|
if x <= 2:
|
||||||
|
if simbase.config.GetBool('want-findfour', 1):
|
||||||
|
self.game = DistributedFindFourAI.DistributedFindFourAI(self.air, self.doId, 'findFour', self.getX(), self.getY(), self.getZ() + 2.8300000000000001, self.getH(), self.getP(), self.getR())
|
||||||
|
self.sendUpdate('setZone', [
|
||||||
|
self.game.zoneId])
|
||||||
|
|
||||||
def requestZone(self):
|
def requestZone(self):
|
||||||
pass
|
if not self.game:
|
||||||
|
return
|
||||||
|
|
||||||
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
self.sendUpdateToAvatarId(avId, 'setZone', [
|
||||||
|
self.game.zoneId])
|
||||||
|
|
||||||
def announceWinner(self, todo0, todo1):
|
def requestGameZone(self):
|
||||||
pass
|
if self.hasPicked == True:
|
||||||
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
if self.game:
|
||||||
|
self.game.playersObserving.append(avId)
|
||||||
|
|
||||||
def allowObserve(self):
|
self.observers.append(avId)
|
||||||
pass
|
self.acceptOnce(self.air.getAvatarExitEvent(avId), self.handleObserverExit, extraArgs = [
|
||||||
|
avId])
|
||||||
|
if self.game:
|
||||||
|
if self.game.fsm.getCurrentState().getName() == 'playing':
|
||||||
|
self.sendUpdateToAvatarId(avId, 'setGameZone', [
|
||||||
|
self.checkersZoneId,
|
||||||
|
1])
|
||||||
|
else:
|
||||||
|
self.sendUpdateToAvatarId(avId, 'setGameZone', [
|
||||||
|
self.checkersZoneId,
|
||||||
|
0])
|
||||||
|
|
||||||
def allowPick(self):
|
def leaveObserve(self):
|
||||||
pass
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
if self.game:
|
||||||
|
if avId in self.game.playersObserving:
|
||||||
|
self.game.playersObserving.remove(avId)
|
||||||
|
|
||||||
def setZone(self, todo0):
|
def handleObserverExit(self, avId):
|
||||||
pass
|
if self.game and avId in self.game.playersObserving:
|
||||||
|
if self.game:
|
||||||
|
self.game.playersObserving.remove(avId)
|
||||||
|
self.ignore(self.air.getAvatarExitEvent(avId))
|
||||||
|
|
||||||
|
def requestExit(self):
|
||||||
|
self.notify.debug('requestExit')
|
||||||
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
av = self.air.doId2do.get(avId)
|
||||||
|
if av:
|
||||||
|
if self.countFullSeats() > 0:
|
||||||
|
self.acceptExiter(avId)
|
||||||
|
else:
|
||||||
|
self.notify.debug('Player tried to exit after AI already kicked everyone out')
|
||||||
|
else:
|
||||||
|
self.notify.warning('avId: %s does not exist, but tried to exit picnicTable' % avId)
|
||||||
|
|
||||||
|
def acceptExiter(self, avId):
|
||||||
|
seatIndex = self.findAvatar(avId)
|
||||||
|
if seatIndex == None:
|
||||||
|
if avId in self.observers:
|
||||||
|
self.sendUpdateToAvatarId(avId, 'emptySlot', [
|
||||||
|
avId,
|
||||||
|
255,
|
||||||
|
globalClockDelta.getRealNetworkTime()])
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.seats[seatIndex] = None
|
||||||
|
self.ignore(self.air.getAvatarExitEvent(avId))
|
||||||
|
self.sendUpdate('emptySlot', [
|
||||||
|
avId,
|
||||||
|
seatIndex,
|
||||||
|
globalClockDelta.getRealNetworkTime()])
|
||||||
|
self.getTableState()
|
||||||
|
numActive = 0
|
||||||
|
for x in self.seats:
|
||||||
|
if x != None:
|
||||||
|
numActive = numActive + 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
if self.game:
|
||||||
|
self.game.informGameOfPlayerLeave()
|
||||||
|
self.game.handlePlayerExit(avId)
|
||||||
|
|
||||||
|
if numActive == 0:
|
||||||
|
self.isAccepting = True
|
||||||
|
if self.game:
|
||||||
|
self.game.handleEmptyGame()
|
||||||
|
self.game.requestDelete()
|
||||||
|
self.game = None
|
||||||
|
self.hasPicked = False
|
||||||
|
|
||||||
|
def _DistributedPicnicTableAI__handleUnexpectedExit(self, avId):
|
||||||
|
self.notify.warning('Avatar: ' + str(avId) + ' has exited unexpectedly')
|
||||||
|
seatIndex = self.findAvatar(avId)
|
||||||
|
if seatIndex == None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
self.seats[seatIndex] = None
|
||||||
|
self.ignore(self.air.getAvatarExitEvent(avId))
|
||||||
|
if self.game:
|
||||||
|
self.game.informGameOfPlayerLeave()
|
||||||
|
self.game.handlePlayerExit(avId)
|
||||||
|
self.hasPicked = False
|
||||||
|
|
||||||
|
self.getTableState()
|
||||||
|
numActive = 0
|
||||||
|
for x in self.seats:
|
||||||
|
if x != None:
|
||||||
|
numActive = numActive + 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
if numActive == 0 and self.game:
|
||||||
|
simbase.air.deallocateZone(self.game.zoneId)
|
||||||
|
self.game.requestDelete()
|
||||||
|
self.game = None
|
||||||
|
self.gameDoId = None
|
||||||
|
|
||||||
|
def informGameOfPlayerExit(self, avId):
|
||||||
|
self.game.handlePlayerExit(avId)
|
||||||
|
|
||||||
|
def handleGameOver(self):
|
||||||
|
for x in self.observers:
|
||||||
|
self.acceptExiter(x)
|
||||||
|
self.observers.remove(x)
|
||||||
|
|
||||||
|
if self.game:
|
||||||
|
self.game.playersObserving = []
|
||||||
|
|
||||||
|
for x in self.seats:
|
||||||
|
if x != None:
|
||||||
|
self.acceptExiter(x)
|
||||||
|
continue
|
||||||
|
|
||||||
|
self.game = None
|
||||||
|
self.gameDoId = None
|
||||||
|
self.hasPicked = False
|
||||||
|
|
||||||
|
def findAvatar(self, avId):
|
||||||
|
for i in range(len(self.seats)):
|
||||||
|
if self.seats[i] == avId:
|
||||||
|
return i
|
||||||
|
continue
|
||||||
|
|
||||||
|
def countFullSeats(self):
|
||||||
|
avCounter = 0
|
||||||
|
for i in self.seats:
|
||||||
|
if i:
|
||||||
|
avCounter += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
return avCounter
|
||||||
|
|
||||||
|
def findAvailableSeat(self):
|
||||||
|
for i in range(len(self.seats)):
|
||||||
|
if self.seats[i] == None:
|
||||||
|
return i
|
||||||
|
continue
|
||||||
|
|
||||||
|
def setCheckersZoneId(self, zoneId):
|
||||||
|
self.checkersZoneId = zoneId
|
||||||
|
|
||||||
|
def setTableIndex(self, index):
|
||||||
|
self._tableIndex = index
|
||||||
|
|
||||||
|
def getTableIndex(self):
|
||||||
|
return self._tableIndex
|
||||||
|
|
5
toontown/safezone/GameGlobals.py
Normal file
5
toontown/safezone/GameGlobals.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
TutorialMenu = 1
|
||||||
|
GameMenu = 1
|
||||||
|
CheckersGameIndex = 0
|
||||||
|
ChineseCheckersGameIndex = 1
|
||||||
|
FindFourGameIndex = 2
|
160
toontown/safezone/GameMenu.py
Normal file
160
toontown/safezone/GameMenu.py
Normal file
|
@ -0,0 +1,160 @@
|
||||||
|
from pandac.PandaModules import *
|
||||||
|
from direct.distributed.ClockDelta import *
|
||||||
|
from direct.task.Task import Task
|
||||||
|
from direct.interval.IntervalGlobal import *
|
||||||
|
from TrolleyConstants import *
|
||||||
|
from direct.gui.DirectGui import *
|
||||||
|
from toontown.toonbase import TTLocalizer
|
||||||
|
from toontown.toonbase import ToontownGlobals
|
||||||
|
from toontown.safezone import GameGlobals
|
||||||
|
|
||||||
|
class GameMenu(DirectFrame):
|
||||||
|
|
||||||
|
def __init__(self, picnicFunction, menuType):
|
||||||
|
self.picnicFunction = picnicFunction
|
||||||
|
DirectFrame.__init__(
|
||||||
|
self,
|
||||||
|
pos=(0.0, 0.0, 0.85),
|
||||||
|
image_color=ToontownGlobals.GlobalDialogColor,
|
||||||
|
image_scale=(1.8, 0.9, 0.13),
|
||||||
|
text='',
|
||||||
|
text_scale=0.05)
|
||||||
|
self.buttonModels = loader.loadModel('phase_3.5/models/gui/inventory_gui.bam')
|
||||||
|
self.upButton = self.buttonModels.find('**//InventoryButtonUp')
|
||||||
|
self.downButton = self.buttonModels.find('**/InventoryButtonDown')
|
||||||
|
self.rolloverButton = self.buttonModels.find('**/InventoryButtonRollover')
|
||||||
|
self['image'] = DGG.getDefaultDialogGeom()
|
||||||
|
if menuType == GameGlobals.TutorialMenu:
|
||||||
|
self.title = DirectLabel(
|
||||||
|
self,
|
||||||
|
relief=None,
|
||||||
|
text=TTLocalizer.PicnicTableMenuTutorial,
|
||||||
|
text_pos=(0.0, -0.038),
|
||||||
|
text_fg=(1, 0, 0, 1),
|
||||||
|
text_scale=0.09,
|
||||||
|
text_font=ToontownGlobals.getSignFont(),
|
||||||
|
text_shadow=(1, 1, 1, 1))
|
||||||
|
else:
|
||||||
|
self.title = DirectLabel(
|
||||||
|
self,
|
||||||
|
relief=None,
|
||||||
|
text=TTLocalizer.PicnicTableMenuSelect,
|
||||||
|
text_pos=(0.0, -0.04),
|
||||||
|
text_fg=(1, 0, 0, 1),
|
||||||
|
text_scale=0.09,
|
||||||
|
text_font=ToontownGlobals.getSignFont(),
|
||||||
|
text_shadow=(1, 1, 1, 1))
|
||||||
|
self.selectionButtons = loader.loadModel('phase_6/models/golf/picnic_game_menu.bam')
|
||||||
|
btn1 = self.selectionButtons.find('**/Btn1')
|
||||||
|
btn2 = self.selectionButtons.find('**/Btn2')
|
||||||
|
btn3 = self.selectionButtons.find('**/Btn3')
|
||||||
|
self.ChineseCheckers = DirectButton(
|
||||||
|
self,
|
||||||
|
image=(btn1.find('**/checkersBtnUp'), btn1.find('**/checkersBtnDn'), btn1.find('**/checkersBtnHi'), btn1.find('**/checkersBtnUp')),
|
||||||
|
scale=0.36,
|
||||||
|
relief=0,
|
||||||
|
pos=(0, 0, -0.7),
|
||||||
|
command=self.chineseCheckersSelected)
|
||||||
|
self.Checkers = DirectButton(
|
||||||
|
self,
|
||||||
|
image=(btn2.find('**/regular_checkersBtnUp'), btn2.find('**/regular_checkersBtnDn'), btn2.find('**/regular_checkersBtnHi'), btn2.find('**/regular_checkersBtnUp')),
|
||||||
|
scale=0.36,
|
||||||
|
relief=0,
|
||||||
|
pos=(0.8, 0, -0.7),
|
||||||
|
command=self.checkersSelected)
|
||||||
|
self.FindFour = DirectButton(
|
||||||
|
self,
|
||||||
|
image=(btn3.find('**/findfourBtnUp'), btn3.find('**/findfourBtnDn'), btn3.find('**/findfourBtnHi'), btn3.find('**/findfourBtnUp')),
|
||||||
|
scale=0.36,
|
||||||
|
relief=0,
|
||||||
|
pos=(-0.8, 0, -0.7),
|
||||||
|
command=self.findFourSelected)
|
||||||
|
if not base.config.GetBool('want-checkers', 1):
|
||||||
|
self.Checkers['command'] = self.doNothing()
|
||||||
|
self.Checkers.setColor(0.7, 0.7, 0.7, 0.7)
|
||||||
|
if not base.config.GetBool('want-chinese-checkers', 1):
|
||||||
|
self.ChineseCheckers['command'] = self.doNothing()
|
||||||
|
self.ChineseCheckers.setColor(0.7, 0.7, 0.7, 0.7)
|
||||||
|
if not base.config.GetBool('want-find-four', 1):
|
||||||
|
self.FindFour['command'] = self.doNothing()
|
||||||
|
self.FindFour.setColor(0.7, 0.7, 0.7, 0.7)
|
||||||
|
self.chineseText = OnscreenText(
|
||||||
|
text='Chinese Checkers',
|
||||||
|
pos=(0, 0.56, -0.8),
|
||||||
|
scale=0.15,
|
||||||
|
fg=Vec4(1, 1, 1, 1),
|
||||||
|
align=TextNode.ACenter,
|
||||||
|
font=ToontownGlobals.getMinnieFont(),
|
||||||
|
wordwrap=7,
|
||||||
|
shadow=(0, 0, 0, 0.8),
|
||||||
|
shadowOffset=(-0.1, -0.1),
|
||||||
|
mayChange=True)
|
||||||
|
self.chineseText.setR(-8)
|
||||||
|
self.checkersText = OnscreenText(
|
||||||
|
text='Checkers',
|
||||||
|
pos=(0.81, -.1, -0.8),
|
||||||
|
scale=0.15,
|
||||||
|
fg=Vec4(1, 1, 1, 1),
|
||||||
|
align=TextNode.ACenter,
|
||||||
|
font=ToontownGlobals.getMinnieFont(),
|
||||||
|
wordwrap=7,
|
||||||
|
shadow=(0, 0, 0, 0.8),
|
||||||
|
shadowOffset=(0.1, -0.1),
|
||||||
|
mayChange=True)
|
||||||
|
self.findFourText = OnscreenText(
|
||||||
|
text='Find Four',
|
||||||
|
pos=(-0.81, -.08, -0.8),
|
||||||
|
scale=0.15,
|
||||||
|
fg=Vec4(1, 1, 1, 1),
|
||||||
|
align=TextNode.ACenter,
|
||||||
|
font=ToontownGlobals.getMinnieFont(),
|
||||||
|
wordwrap=8,
|
||||||
|
shadow=(0, 0, 0, 0.8),
|
||||||
|
shadowOffset=(-0.1, -0.1),
|
||||||
|
mayChange=True)
|
||||||
|
self.exitButton = DirectButton(
|
||||||
|
relief=None,
|
||||||
|
text=TTLocalizer.PicnicTableCancelButton,
|
||||||
|
text_fg=(1, 1, 0.65, 1),
|
||||||
|
text_pos=(0, -0.23),
|
||||||
|
text_scale=0.8,
|
||||||
|
image=(self.upButton, self.downButton, self.rolloverButton),
|
||||||
|
image_color=(1, 0, 0, 1),
|
||||||
|
image_scale=(20, 1, 11),
|
||||||
|
pos=(0, 0, -0.4),
|
||||||
|
scale=0.15,
|
||||||
|
command=lambda self=self: self.cancelButtonPushed())
|
||||||
|
self.findFourText.setR(-8)
|
||||||
|
self.checkersText.setR(8)
|
||||||
|
|
||||||
|
def delete(self):
|
||||||
|
self.removeButtons()
|
||||||
|
|
||||||
|
def removeButtons(self):
|
||||||
|
self.ChineseCheckers.destroy()
|
||||||
|
self.Checkers.destroy()
|
||||||
|
self.FindFour.destroy()
|
||||||
|
self.chineseText.destroy()
|
||||||
|
self.checkersText.destroy()
|
||||||
|
self.findFourText.destroy()
|
||||||
|
self.exitButton.destroy()
|
||||||
|
DirectFrame.destroy(self)
|
||||||
|
|
||||||
|
def checkersSelected(self):
|
||||||
|
self.picnicFunction(GameGlobals.CheckersGameIndex)
|
||||||
|
self.picnicFunction = lambda gameIndex: None
|
||||||
|
|
||||||
|
def chineseCheckersSelected(self):
|
||||||
|
self.picnicFunction(GameGlobals.ChineseCheckersGameIndex)
|
||||||
|
self.picnicFunction = lambda gameIndex: None
|
||||||
|
|
||||||
|
def findFourSelected(self):
|
||||||
|
self.picnicFunction(GameGlobals.FindFourGameIndex)
|
||||||
|
self.picnicFunction = lambda gameIndex: None
|
||||||
|
|
||||||
|
def cancelButtonPushed(self):
|
||||||
|
self.picnicFunction(-1)
|
||||||
|
self.picnicFunction = lambda gameIndex: None
|
||||||
|
|
||||||
|
def doNothing(self):
|
||||||
|
pass
|
|
@ -20,7 +20,7 @@ class ChineseTutorial(DirectFrame, FSM.FSM):
|
||||||
self.accept('stoppedAsleep', self.handleQuit)
|
self.accept('stoppedAsleep', self.handleQuit)
|
||||||
self['image'] = DGG.getDefaultDialogGeom()
|
self['image'] = DGG.getDefaultDialogGeom()
|
||||||
self.title = DirectLabel(self, relief=None, text='', text_pos=(0.0, 0.4), text_fg=(1, 0, 0, 1), text_scale=0.13, text_font=ToontownGlobals.getSignFont())
|
self.title = DirectLabel(self, relief=None, text='', text_pos=(0.0, 0.4), text_fg=(1, 0, 0, 1), text_scale=0.13, text_font=ToontownGlobals.getSignFont())
|
||||||
images = loader.loadModel('phase_6/models/golf/checker_tutorial')
|
images = loader.loadModel('phase_6/models/golf/checker_tutorial.bam')
|
||||||
images.setTransparency(1)
|
images.setTransparency(1)
|
||||||
self.iPage1 = images.find('**/tutorialPage1*')
|
self.iPage1 = images.find('**/tutorialPage1*')
|
||||||
self.iPage1.reparentTo(aspect2d)
|
self.iPage1.reparentTo(aspect2d)
|
||||||
|
@ -138,7 +138,7 @@ class CheckersTutorial(DirectFrame, FSM.FSM):
|
||||||
self.accept('stoppedAsleep', self.handleQuit)
|
self.accept('stoppedAsleep', self.handleQuit)
|
||||||
self['image'] = DGG.getDefaultDialogGeom()
|
self['image'] = DGG.getDefaultDialogGeom()
|
||||||
self.title = DirectLabel(self, relief=None, text='', text_pos=(0.0, 0.4), text_fg=(1, 0, 0, 1), text_scale=0.13, text_font=ToontownGlobals.getSignFont())
|
self.title = DirectLabel(self, relief=None, text='', text_pos=(0.0, 0.4), text_fg=(1, 0, 0, 1), text_scale=0.13, text_font=ToontownGlobals.getSignFont())
|
||||||
images = loader.loadModel('phase_6/models/golf/regularchecker_tutorial')
|
images = loader.loadModel('phase_6/models/golf/regularchecker_tutorial.bam')
|
||||||
images.setTransparency(1)
|
images.setTransparency(1)
|
||||||
self.iPage1 = images.find('**/tutorialPage1*')
|
self.iPage1 = images.find('**/tutorialPage1*')
|
||||||
self.iPage1.reparentTo(aspect2d)
|
self.iPage1.reparentTo(aspect2d)
|
||||||
|
@ -170,12 +170,12 @@ class CheckersTutorial(DirectFrame, FSM.FSM):
|
||||||
self.bNext = DirectButton(self, image=(gui.find('**/Horiz_Arrow_UP'),
|
self.bNext = DirectButton(self, image=(gui.find('**/Horiz_Arrow_UP'),
|
||||||
gui.find('**/Horiz_Arrow_DN'),
|
gui.find('**/Horiz_Arrow_DN'),
|
||||||
gui.find('**/Horiz_Arrow_Rllvr'),
|
gui.find('**/Horiz_Arrow_Rllvr'),
|
||||||
gui.find('**/Horiz_Arrow_UP')), image3_color=Vec4(1, 1, 1, 0.5), relief=None, text=TTLocalizer.ChineseTutorialNext, text3_fg=Vec4(0, 0, 0, 0.5), text_scale=0.05, text_pos=(0.0, -0.1), pos=(0.35, -0.3, -0.33), command=self.requestNext)
|
gui.find('**/Horiz_Arrow_UP')), image3_color=Vec4(1, 1, 1, 0.5), relief=None, text=TTLocalizer.ChineseTutorialNext, text3_fg=Vec4(0, 0, 0, 0.5), text_scale=0.05, text_pos=(0.0, -0.08), pos=(0.35, -0.3, -0.38), command=self.requestNext)
|
||||||
self.bPrev = DirectButton(self, image=(gui.find('**/Horiz_Arrow_UP'),
|
self.bPrev = DirectButton(self, image=(gui.find('**/Horiz_Arrow_UP'),
|
||||||
gui.find('**/Horiz_Arrow_DN'),
|
gui.find('**/Horiz_Arrow_DN'),
|
||||||
gui.find('**/Horiz_Arrow_Rllvr'),
|
gui.find('**/Horiz_Arrow_Rllvr'),
|
||||||
gui.find('**/Horiz_Arrow_UP')), image3_color=Vec4(1, 1, 1, 0.5), image_scale=(-1.0, 1.0, 1.0), relief=None, text=TTLocalizer.ChineseTutorialPrev, text3_fg=Vec4(0, 0, 0, 0.5), text_scale=0.05, text_pos=(0.0, -0.1), pos=(-0.35, -0.3, -0.33), command=self.requestPrev)
|
gui.find('**/Horiz_Arrow_UP')), image3_color=Vec4(1, 1, 1, 0.5), image_scale=(-1.0, 1.0, 1.0), relief=None, text=TTLocalizer.ChineseTutorialPrev, text3_fg=Vec4(0, 0, 0, 0.5), text_scale=0.05, text_pos=(0.0, -0.08), pos=(-0.35, -0.3, -0.38), command=self.requestPrev)
|
||||||
self.bQuit = DirectButton(self, image=(buttons.find('**/ChtBx_OKBtn_UP'), buttons.find('**/ChtBx_OKBtn_DN'), buttons.find('**/ChtBx_OKBtn_Rllvr')), relief=None, text=TTLocalizer.ChineseTutorialDone, text_scale=0.05, text_pos=(0.0, -0.1), pos=(0.0, -0.3, -0.33), command=self.handleQuit)
|
self.bQuit = DirectButton(self, image=(buttons.find('**/ChtBx_OKBtn_UP'), buttons.find('**/ChtBx_OKBtn_DN'), buttons.find('**/ChtBx_OKBtn_Rllvr')), relief=None, text=TTLocalizer.ChineseTutorialDone, text_scale=0.05, text_pos=(0.0, -0.1), pos=(0.0, -0.3, -0.38), command=self.handleQuit)
|
||||||
self.bQuit.hide()
|
self.bQuit.hide()
|
||||||
buttons.removeNode()
|
buttons.removeNode()
|
||||||
gui.removeNode()
|
gui.removeNode()
|
||||||
|
@ -257,3 +257,80 @@ class CheckersTutorial(DirectFrame, FSM.FSM):
|
||||||
if task != None:
|
if task != None:
|
||||||
task.done
|
task.done
|
||||||
return
|
return
|
||||||
|
|
||||||
|
class FindFourTutorial(DirectFrame, FSM.FSM):
|
||||||
|
|
||||||
|
def __init__(self, doneFunction, doneEvent = None, callback = None):
|
||||||
|
FSM.FSM.__init__(self, 'FindFourTutorial')
|
||||||
|
self.doneFunction = doneFunction
|
||||||
|
base.localAvatar.startSleepWatch(self.handleQuit)
|
||||||
|
self.doneEvent = doneEvent
|
||||||
|
self.callback = callback
|
||||||
|
self.setStateArray(['Page1', 'Page2', 'Quit'])
|
||||||
|
base.localAvatar.startSleepWatch(self.handleQuit)
|
||||||
|
DirectFrame.__init__(self, pos=(-0.7, 0.0, 0.0), image_color=ToontownGlobals.GlobalDialogColor, image_scale=(1.0, 1.5, 1.0), text='', text_scale=0.06)
|
||||||
|
self.accept('stoppedAsleep', self.handleQuit)
|
||||||
|
self['image'] = DGG.getDefaultDialogGeom()
|
||||||
|
self.title = DirectLabel(self, relief=None, text='', text_pos=(0.0, 0.4), text_fg=(1, 0, 0, 1), text_scale=0.13, text_font=ToontownGlobals.getSignFont())
|
||||||
|
buttons = loader.loadModel('phase_3/models/gui/dialog_box_buttons_gui')
|
||||||
|
gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui')
|
||||||
|
self.bNext = DirectButton(self, image=(gui.find('**/Horiz_Arrow_UP'),
|
||||||
|
gui.find('**/Horiz_Arrow_DN'),
|
||||||
|
gui.find('**/Horiz_Arrow_Rllvr'),
|
||||||
|
gui.find('**/Horiz_Arrow_UP')), image3_color=Vec4(1, 1, 1, 0.5), relief=None, text=TTLocalizer.ChineseTutorialNext, text3_fg=Vec4(0, 0, 0, 0.5), text_scale=0.05, text_pos=(0.0, -0.1), pos=(0.35, -0.3, -0.33), command=self.requestNext)
|
||||||
|
self.bPrev = DirectButton(self, image=(gui.find('**/Horiz_Arrow_UP'),
|
||||||
|
gui.find('**/Horiz_Arrow_DN'),
|
||||||
|
gui.find('**/Horiz_Arrow_Rllvr'),
|
||||||
|
gui.find('**/Horiz_Arrow_UP')), image3_color=Vec4(1, 1, 1, 0.5), image_scale=(-1.0, 1.0, 1.0), relief=None, text=TTLocalizer.ChineseTutorialPrev, text3_fg=Vec4(0, 0, 0, 0.5), text_scale=0.05, text_pos=(0.0, -0.1), pos=(-0.35, -0.3, -0.33), command=self.requestPrev)
|
||||||
|
self.bQuit = DirectButton(self, image=(buttons.find('**/ChtBx_OKBtn_UP'), buttons.find('**/ChtBx_OKBtn_DN'), buttons.find('**/ChtBx_OKBtn_Rllvr')), relief=None, text=TTLocalizer.ChineseTutorialDone, text_scale=0.05, text_pos=(0.0, -0.1), pos=(0.0, -0.3, -0.33), command=self.handleQuit)
|
||||||
|
self.bQuit.hide()
|
||||||
|
buttons.removeNode()
|
||||||
|
gui.removeNode()
|
||||||
|
self.request('Page1')
|
||||||
|
return
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
self.cleanup()
|
||||||
|
|
||||||
|
def enterPage1(self, *args):
|
||||||
|
self.bNext.show()
|
||||||
|
self.title['text'] = (TTLocalizer.ChineseTutorialTitle1,)
|
||||||
|
self['text'] = TTLocalizer.FindFourPage1
|
||||||
|
self['text_pos'] = (0.0, 0.23)
|
||||||
|
self['text_wordwrap'] = 13.5
|
||||||
|
self.bPrev['state'] = DGG.DISABLED
|
||||||
|
self.bPrev.hide()
|
||||||
|
self.bNext['state'] = DGG.NORMAL
|
||||||
|
|
||||||
|
def exitPage1(self, *args):
|
||||||
|
self.bPrev['state'] = DGG.NORMAL
|
||||||
|
|
||||||
|
def enterPage2(self, *args):
|
||||||
|
self.bPrev.show()
|
||||||
|
self.title['text'] = (TTLocalizer.ChineseTutorialTitle2,)
|
||||||
|
self['text'] = TTLocalizer.FindFourPage2
|
||||||
|
self['text_pos'] = (0.0, 0.28)
|
||||||
|
self['text_wordwrap'] = 12.5
|
||||||
|
self.bNext['state'] = DGG.DISABLED
|
||||||
|
self.bNext.hide()
|
||||||
|
self.bQuit.show()
|
||||||
|
|
||||||
|
def exitPage2(self, *args):
|
||||||
|
self.bQuit.hide()
|
||||||
|
|
||||||
|
def enterQuit(self, *args):
|
||||||
|
self.bNext.destroy()
|
||||||
|
self.bPrev.destroy()
|
||||||
|
self.bQuit.destroy()
|
||||||
|
DirectFrame.destroy(self)
|
||||||
|
|
||||||
|
def exitQuit(self, *args):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def handleQuit(self, task = None):
|
||||||
|
base.cr.playGame.getPlace().setState('walk')
|
||||||
|
self.forceTransition('Quit')
|
||||||
|
self.doneFunction()
|
||||||
|
if task != None:
|
||||||
|
task.done
|
||||||
|
return
|
Loading…
Reference in a new issue