def _outputType(self, type, limit=None):
     if type not in self._type2id2len:
         return
     len2ids = invertDictLossless(self._type2id2len[type])
     lengths = len2ids.keys()
     lengths.sort()
     lengths.reverse()
     print '====='
     print '===== %s' % type
     count = 0
     stop = False
     for l in lengths:
         #len2ids[l].sort()
         pathStrList = list()
         for id in len2ids[l]:
             obj = self._id2container[id]
             #print '%s: %s' % (l, self._id2pathStr[id])
             pathStrList.append(self._id2pathStr[id])
             count += 1
             if (count & 0x7f) == 0:
                 yield None
         pathStrList.sort()
         for pathstr in pathStrList:
             print '%s: %s' % (l, pathstr)
         if limit is not None and count >= limit:
             return
Ejemplo n.º 2
0
 def _outputType(self, type, limit=None):
     if type not in self._type2id2len:
         return
     len2ids = invertDictLossless(self._type2id2len[type])
     lengths = list(len2ids.keys())
     lengths.sort()
     lengths.reverse()
     print('=====')
     print('===== %s' % type)
     count = 0
     stop = False
     for l in lengths:
         #len2ids[l].sort()
         pathStrList = list()
         for id in len2ids[l]:
             obj = self._id2container[id]
             #print '%s: %s' % (l, self._id2pathStr[id])
             pathStrList.append(self._id2pathStr[id])
             count += 1
             if (count & 0x7f) == 0:
                 yield None
         pathStrList.sort()
         for pathstr in pathStrList:
             print('%s: %s' % (l, pathstr))
         if limit is not None and count >= limit:
             return
    def _genFloorLayout(self):
        rng = self.getRng()
        startingRoomIDs = CountryClubRoomSpecs.BossbotCountryClubEntranceIDs
        middleRoomIDs = CountryClubRoomSpecs.BossbotCountryClubMiddleRoomIDs
        finalRoomIDs = CountryClubRoomSpecs.BossbotCountryClubFinalRoomIDs

        numBattlesLeft = ToontownGlobals.CountryClubNumBattles[
            self.countryClubId]

        finalRoomId = rng.choice(finalRoomIDs)
        numBattlesLeft -= CountryClubRoomSpecs.getNumBattles(finalRoomId)

        middleRoomIds = []
        middleRoomsLeft = self.numRooms - 2

        numBattles2middleRoomIds = invertDictLossless(
            CountryClubRoomSpecs.middleRoomId2numBattles)

        allBattleRooms = []
        for num, roomIds in numBattles2middleRoomIds.items():
            if num > 0:
                allBattleRooms.extend(roomIds)
        while 1:
            allBattleRoomIds = list(allBattleRooms)
            rng.shuffle(allBattleRoomIds)
            battleRoomIds = self._chooseBattleRooms(numBattlesLeft,
                                                    allBattleRoomIds)
            if battleRoomIds is not None:
                break

            CountryClubLayout.notify.info(
                'could not find a valid set of battle rooms, trying again')

        middleRoomIds.extend(battleRoomIds)
        middleRoomsLeft -= len(battleRoomIds)

        if middleRoomsLeft > 0:
            actionRoomIds = numBattles2middleRoomIds[0]
            for i in xrange(middleRoomsLeft):
                roomId = rng.choice(actionRoomIds)
                actionRoomIds.remove(roomId)
                middleRoomIds.append(roomId)

        roomIds = []

        roomIds.append(rng.choice(startingRoomIDs))

        middleRoomIds.sort()
        print 'middleRoomIds=%s' % middleRoomIds
        roomIds.extend(middleRoomIds)

        roomIds.append(finalRoomId)

        return roomIds
    def _genFloorLayout(self):
        rng = self.getRng()
        startingRoomIDs = CountryClubRoomSpecs.BossbotCountryClubEntranceIDs
        middleRoomIDs = CountryClubRoomSpecs.BossbotCountryClubMiddleRoomIDs
        finalRoomIDs = CountryClubRoomSpecs.BossbotCountryClubFinalRoomIDs

        numBattlesLeft = ToontownGlobals.CountryClubNumBattles[self.countryClubId]

        finalRoomId = rng.choice(finalRoomIDs)
        numBattlesLeft -= CountryClubRoomSpecs.getNumBattles(finalRoomId)

        middleRoomIds = []
        middleRoomsLeft = self.numRooms - 2

        numBattles2middleRoomIds = invertDictLossless(CountryClubRoomSpecs.middleRoomId2numBattles)

        allBattleRooms = []
        for num, roomIds in numBattles2middleRoomIds.items():
            if num > 0:
                allBattleRooms.extend(roomIds)
        while 1:
            allBattleRoomIds = list(allBattleRooms)
            rng.shuffle(allBattleRoomIds)
            battleRoomIds = self._chooseBattleRooms(numBattlesLeft,
                                                    allBattleRoomIds)
            if battleRoomIds is not None:
                break

            CountryClubLayout.notify.info('could not find a valid set of battle rooms, trying again')

        middleRoomIds.extend(battleRoomIds)
        middleRoomsLeft -= len(battleRoomIds)

        if middleRoomsLeft > 0:
            actionRoomIds = numBattles2middleRoomIds[0]
            for i in xrange(middleRoomsLeft):
                roomId = rng.choice(actionRoomIds)
                actionRoomIds.remove(roomId)
                middleRoomIds.append(roomId)

        roomIds = []

        roomIds.append(rng.choice(startingRoomIDs))

        middleRoomIds.sort()
        print 'middleRoomIds=%s' % middleRoomIds
        roomIds.extend(middleRoomIds)

        roomIds.append(finalRoomId)

        return roomIds
Ejemplo n.º 5
0
 def __init__(self, objects):
     self._objs = list(objects)
     self._type2objs = {}
     self._count2types = {}
     self._len2obj = {}
     type2count = {}
     for obj in self._objs:
         typ = itype(obj)
         type2count.setdefault(typ, 0)
         type2count[typ] += 1
         self._type2objs.setdefault(typ, [])
         self._type2objs[typ].append(obj)
         try:
             self._len2obj[len(obj)] = obj
         except:
             pass
     self._count2types = invertDictLossless(type2count)
Ejemplo n.º 6
0
 def __init__(self, objects):
     self._objs = list(objects)
     self._type2objs = {}
     self._count2types = {}
     self._len2obj = {}
     type2count = {}
     for obj in self._objs:
         typ = itype(obj)
         type2count.setdefault(typ, 0)
         type2count[typ] += 1
         self._type2objs.setdefault(typ, [])
         self._type2objs[typ].append(obj)
         try:
             self._len2obj[len(obj)] = obj
         except:
             pass
     self._count2types = invertDictLossless(type2count)
    def _genFloorLayout(self):
        rng = self.getRng()
        startingRoomIDs = MintRoomSpecs.CashbotMintEntranceIDs
        middleRoomIDs = MintRoomSpecs.CashbotMintMiddleRoomIDs
        finalRoomIDs = MintRoomSpecs.CashbotMintFinalRoomIDs
        numBattlesLeft = ToontownGlobals.MintNumBattles[self.mintId]
        finalRoomId = rng.choice(finalRoomIDs)
        numBattlesLeft -= MintRoomSpecs.getNumBattles(finalRoomId)
        middleRoomIds = []
        middleRoomsLeft = self.numRooms - 2
        numBattles2middleRoomIds = invertDictLossless(
            MintRoomSpecs.middleRoomId2numBattles)
        allBattleRooms = []
        for (num, roomIds) in numBattles2middleRoomIds.items():
            if num > 0:
                allBattleRooms.extend(roomIds)
                continue

        while None:
            allBattleRoomIds = list(allBattleRooms)
            battleRoomIds = self._chooseBattleRooms(numBattlesLeft,
                                                    allBattleRoomIds)
            if battleRoomIds is not None:
                break

            MintLayout.notify.info(
                'could not find a valid set of battle rooms, trying again')
        middleRoomIds.extend(battleRoomIds)
        middleRoomsLeft -= len(battleRoomIds)
        if middleRoomsLeft > 0:
            actionRoomIds = numBattles2middleRoomIds[0]
            for i in xrange(middleRoomsLeft):
                roomId = rng.choice(actionRoomIds)
                actionRoomIds.remove(roomId)
                middleRoomIds.append(roomId)

        roomIds = []
        roomIds.append(rng.choice(startingRoomIDs))
        rng.shuffle(middleRoomIds)
        roomIds.extend(middleRoomIds)
        roomIds.append(finalRoomId)
        return roomIds
Ejemplo n.º 8
0
MinActualTrickAptitude = 0.5
MaxActualTrickAptitude = 0.97
AptitudeIncrementDidTrick = 0.0005
MaxAptitudeIncrementGotPraise = 0.0003
MaxTrickFatigue = 0.65
MinTrickFatigue = 0.1
ScId2trickId = {
    21200: Tricks.JUMP,
    21201: Tricks.BEG,
    21202: Tricks.PLAYDEAD,
    21203: Tricks.ROLLOVER,
    21204: Tricks.BACKFLIP,
    21205: Tricks.DANCE,
    21206: Tricks.SPEAK
}
TrickId2scIds = invertDictLossless(ScId2trickId)
TrickAnims = {
    Tricks.JUMP: 'jump',
    Tricks.BEG: ('toBeg', 'beg', 'fromBeg'),
    Tricks.PLAYDEAD: ('playDead', 'fromPlayDead'),
    Tricks.ROLLOVER: 'rollover',
    Tricks.BACKFLIP: 'backflip',
    Tricks.DANCE: 'dance',
    Tricks.SPEAK: 'speak',
    Tricks.BALK: 'neutral'
}
TrickLengths = {
    Tricks.JUMP: 2.0,
    Tricks.BEG: 5.167,
    Tricks.PLAYDEAD: 15.21,
    Tricks.ROLLOVER: 8.0,
Ejemplo n.º 9
0
""" MsgTypesCMU module: defines the various message type codes as used
by the CMU ServerRepository/ClientRepository code in this directory.
It replaces the MsgTypes module, which is not used by the CMU
implementation. """

from direct.showbase.PythonUtil import invertDictLossless

MsgName2Id = {
    'SET_DOID_RANGE_CMU'                      : 9001,
    'CLIENT_OBJECT_GENERATE_CMU'              : 9002,
    'OBJECT_GENERATE_CMU'                     : 9003,
    'OBJECT_UPDATE_FIELD_CMU'                 : 9004,
    'OBJECT_DISABLE_CMU'                      : 9005,
    'OBJECT_DELETE_CMU'                       : 9006,
    'REQUEST_GENERATES_CMU'                   : 9007,
    'CLIENT_DISCONNECT_CMU'                   : 9008,
    'CLIENT_SET_INTEREST_CMU'                 : 9009,
    'OBJECT_SET_ZONE_CMU'                     : 9010,
    'CLIENT_HEARTBEAT_CMU'                    : 9011,
    'CLIENT_OBJECT_UPDATE_FIELD_TARGETED_CMU'  : 9011,

    'CLIENT_OBJECT_UPDATE_FIELD' : 120,  # Matches MsgTypes.CLIENT_OBJECT_SET_FIELD
    }

# create id->name table for debugging
MsgId2Names = invertDictLossless(MsgName2Id)

# put msg names in module scope, assigned to msg value
globals().update(MsgName2Id)
Ejemplo n.º 10
0
    'CLIENTAGENT_DECLARE_OBJECT': 1010,
    'CLIENTAGENT_UNDECLARE_OBJECT': 1011,
    'CLIENTAGENT_ADD_SESSION_OBJECT': 1012,
    'CLIENTAGENT_REMOVE_SESSION_OBJECT': 1013,
    'CLIENTAGENT_SET_FIELDS_SENDABLE': 1014,
    'CLIENTAGENT_OPEN_CHANNEL': 1100,
    'CLIENTAGENT_CLOSE_CHANNEL': 1101,
    'CLIENTAGENT_ADD_POST_REMOVE': 1110,
    'CLIENTAGENT_CLEAR_POST_REMOVES': 1111,
    'CLIENTAGENT_ADD_INTEREST': 1200,
    'CLIENTAGENT_ADD_INTEREST_MULTIPLE': 1201,
    'CLIENTAGENT_REMOVE_INTEREST': 1203,
}

# create id->name table for debugging
MsgId2Names = invertDictLossless(MsgName2Id)

# put msg names in module scope, assigned to msg value
globals().update(MsgName2Id)

# These messages are ignored when the client is headed to the quiet zone
QUIET_ZONE_IGNORED_LIST = [

    # We mustn't ignore updates, because some updates for localToon
    # are always important.
    #CLIENT_OBJECT_UPDATE_FIELD,

    # These are now handled. If it is a create for a class that is in the
    # uber zone, we should create it.
    #CLIENT_CREATE_OBJECT_REQUIRED,
    #CLIENT_CREATE_OBJECT_REQUIRED_OTHER,
Ejemplo n.º 11
0
    def _genFloorLayout(self):
        rng = self.getRng()

        # pick the rooms. Make sure we don't get any repeats.
        startingRoomIDs = MintRoomSpecs.CashbotMintEntranceIDs
        middleRoomIDs = MintRoomSpecs.CashbotMintMiddleRoomIDs
        finalRoomIDs = MintRoomSpecs.CashbotMintFinalRoomIDs

        # how many battles do we want?
        numBattlesLeft = ToontownGlobals.MintNumBattles[self.mintId]

        # pick the final room first, so we know how many battles we can
        # have in the middle rooms
        finalRoomId = rng.choice(finalRoomIDs)
        numBattlesLeft -= MintRoomSpecs.getNumBattles(finalRoomId)

        middleRoomIds = []
        middleRoomsLeft = self.numRooms - 2

        # we want to hit our target number of battles exactly.
        # pick the battle rooms we will use first, then fill in pure-action
        # rooms

        # get dict of numBattles->list of rooms
        numBattles2middleRoomIds = invertDictLossless(
            MintRoomSpecs.middleRoomId2numBattles)

        # get list of all battle rooms
        allBattleRooms = []
        for num, roomIds in numBattles2middleRoomIds.items():
            if num > 0:
                allBattleRooms.extend(roomIds)

        # Pick out a list of battle rooms that meets our quota exactly.
        while 1:
            # make a copy of the list of battle rooms, and shuffle it
            allBattleRoomIds = list(allBattleRooms)
            rng.shuffle(allBattleRoomIds)
            battleRoomIds = self._chooseBattleRooms(numBattlesLeft,
                                                    allBattleRoomIds)
            if battleRoomIds is not None:
                break
            MintLayout.notify.info(
                'could not find a valid set of battle rooms, trying again')

        middleRoomIds.extend(battleRoomIds)
        middleRoomsLeft -= len(battleRoomIds)

        if middleRoomsLeft > 0:
            # choose action rooms for the rest of the middle rooms
            actionRoomIds = numBattles2middleRoomIds[0]
            for i in xrange(middleRoomsLeft):
                roomId = rng.choice(actionRoomIds)
                actionRoomIds.remove(roomId)
                middleRoomIds.append(roomId)

        roomIds = []
        # pick a starting room
        roomIds.append(rng.choice(startingRoomIDs))
        # add the chosen middle room IDs in random order
        rng.shuffle(middleRoomIds)
        roomIds.extend(middleRoomIds)
        # add the chosen final room
        roomIds.append(finalRoomId)
        return roomIds
Ejemplo n.º 12
0
TempEnts = {
    'TE_EXPLOSION': 1,
    'TE_SPLAT': 2,
    'TE_DUSTCLOUD': 3,
    'TE_BULLET_RICOCHET': 4,
    'TE_DECAL_TRACE': 5,
    'TE_LASER': 6
}

globals().update(TempEnts)

from direct.showbase.PythonUtil import invertDictLossless
TempEntsInverted = invertDictLossless(TempEnts)
Ejemplo n.º 13
0
NonHappyMinActualTrickAptitude = 0.1
NonHappyMaxActualTrickAptitude = 0.6
MinActualTrickAptitude = 0.5
MaxActualTrickAptitude = 0.97
AptitudeIncrementDidTrick = 0.0005
MaxAptitudeIncrementGotPraise = 0.0003
MaxTrickFatigue = 0.65
MinTrickFatigue = 0.1
ScId2trickId = {21200: Tricks.JUMP,
 21201: Tricks.BEG,
 21202: Tricks.PLAYDEAD,
 21203: Tricks.ROLLOVER,
 21204: Tricks.BACKFLIP,
 21205: Tricks.DANCE,
 21206: Tricks.SPEAK}
TrickId2scIds = invertDictLossless(ScId2trickId)
TrickAnims = {Tricks.JUMP: 'jump',
 Tricks.BEG: ('toBeg', 'beg', 'fromBeg'),
 Tricks.PLAYDEAD: ('playDead', 'fromPlayDead'),
 Tricks.ROLLOVER: 'rollover',
 Tricks.BACKFLIP: 'backflip',
 Tricks.DANCE: 'dance',
 Tricks.SPEAK: 'speak',
 Tricks.BALK: 'neutral'}
TrickLengths = {Tricks.JUMP: 2.0,
 Tricks.BEG: 5.167,
 Tricks.PLAYDEAD: 15.21,
 Tricks.ROLLOVER: 8.0,
 Tricks.BACKFLIP: 4.88,
 Tricks.DANCE: 7.42,
 Tricks.SPEAK: 0.75,
Ejemplo n.º 14
0
        "sound/physics/wood/wood_solid_impact_bullet4.wav",
        "sound/physics/wood/wood_solid_impact_bullet5.wav"
    ],
                      impactDecals=[
                          "materials/decals/wood/shot1.mat",
                          "materials/decals/wood/shot2.mat",
                          "materials/decals/wood/shot3.mat",
                          "materials/decals/wood/shot4.mat",
                          "materials/decals/wood/shot5.mat"
                      ]),
    "tossable":
    SurfaceProperties(hardImpacts=["phase_4/audio/sfx/Golf_Hit_Barrier_2.ogg"],
                      softImpacts=["phase_4/audio/sfx/Golf_Hit_Barrier_1.ogg"])
}

SurfaceNameByClass = invertDictLossless(Surfaces)


def getSurfaceName(surf):
    return SurfaceNameByClass.get(surf, "default")


def getSurfaceFromContact(contact, battleZone=None):
    if not battleZone:
        battleZone = base

    hitNode = contact.getNode()

    if not isinstance(hitNode, BulletRigidBodyNode):
        return Surfaces["default"]
Ejemplo n.º 15
0
	'OTP_SERVER_ROOT_DO_ID': 4007,
	'CHANNEL_CLIENT_BROADCAST': 4014,
	'BAD_CHANNEL_ID': 0,
	'BAD_ZONE_ID': 0,
	'BAD_DO_ID': 0,
	'CONTROL_MESSAGE': 4001,
	'CONTROL_SET_CHANNEL': 2001,
	'CONTROL_REMOVE_CHANNEL': 2002,
	'CONTROL_SET_CON_NAME': 2004,
	'CONTROL_SET_CON_URL': 2005,
	'CONTROL_ADD_RANGE': 2008,
	'CONTROL_REMOVE_RANGE': 2009,
	'CONTROL_ADD_POST_REMOVE': 2010,
	'CONTROL_CLEAR_POST_REMOVE': 2011 }

MsgDirectorTypes = invertDictLossless(messageDirector)
globals().update(messageDirector)

clientAgent = {
    'CLIENT_AGENT_OPEN_CHANNEL': 3104,
    'CLIENT_AGENT_CLOSE_CHANNEL': 3105,
    'CLIENT_AGENT_SET_INTEREST': 3106,
    'CLIENT_AGENT_REMOVE_INTEREST': 3107 }

MsgDirectorTypes = invertDictLossless(clientAgent)
globals().update(clientAgent)

stateServer = {
    'STATESERVER_OBJECT_GENERATE_WITH_REQUIRED': 2001,
    'STATESERVER_OBJECT_GENERATE_WITH_REQUIRED_OTHER': 2003,
    'STATESERVER_OBJECT_UPDATE_FIELD': 2004,