本文整理汇总了Python中Zone.Zone类的典型用法代码示例。如果您正苦于以下问题:Python Zone类的具体用法?Python Zone怎么用?Python Zone使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zone类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
def create(self, width, height, zonewidth, zoneheight):
"Créer une carte vierge"
assert width > 0
assert height > 0
assert zonewidth > 0
assert zoneheight > 0
# resize zones and the map widget
Zone.WIDTH = zonewidth
Zone.HEIGHT = zoneheight
self.resize(Zone.WIDTH, Zone.HEIGHT)
# build tile-items at first load
if not self.isEnabled():
self.build_tiles()
self.setEnabled(True)
self.set_cursor_visible(True)
self.width = width
self.height = height
del self.zones[:]
for i in xrange(width * height):
zone = Zone(self)
zone.fill_with_tile(0)
self.zones.append(zone)
self.filename = None
self.set_current_zone(0)
示例2: add_line
def add_line(self, where, tile_id):
assert where >= 0 and where <= self.height
for i in xrange(self.width):
zone = Zone(self)
zone.fill_with_tile(tile_id)
self.zones.insert(self.width * where, zone)
self.height += 1
self.set_current_zone(0)
示例3: add_column
def add_column(self, where, tile_id):
assert where >= 0 and where <= self.width
for i in xrange(where, len(self.zones) + self.height, self.width + 1):
zone = Zone(self)
zone.fill_with_tile(tile_id)
self.zones.insert(i, zone)
self.width += 1
self.set_current_zone(0)
示例4: test_get_random_zone_definitionKey_lvl1
def test_get_random_zone_definitionKey_lvl1(self):
random.choice = MonkeyPatches.mock_choice
lvl = 1
z = Zone.get_random_zone_definitionKey(lvl)
self.assertEqual(z,"emptySpace")
z = Zone.get_random_zone_definitionKey(lvl)
self.assertEqual(z,"gas")
z = Zone.get_random_zone_definitionKey(lvl)
self.assertEqual(z,"nebula")
z = Zone.get_random_zone_definitionKey(lvl)
self.assertEqual(z,"safeSpace")
self.assertRaises(StopIteration,Zone.get_random_zone_definitionKey,lvl)
示例5: test_load_zone_from_pk
def test_load_zone_from_pk(self):
pk = dbHelp.create_test_hero_using_test_values()
z1 = Zone("gas")
z1.maxMonsters = 10
z1.lvl = 10
z1.save_changes(pk)
z2 = Zone.construct_model_from_pk(z1.get_pk())
self.assertEqual(z1.get_description(),z2.get_description())
self.assertEqual(z1.get_fullName(),z2.get_fullName())
self.assertEqual(z1.maxMonsters,z2.maxMonsters)
self.assertEqual(z1.lvl,z2.lvl)
示例6: setTargetAddress
def setTargetAddress(self, addr):
"""
<method internal="yes">
<summary>
Set the target server address.
</summary>
<description>
<para>
This is a compatibility function for proxies that
override the routed target.
</para>
</description>
<metainfo>
<arguments>
<argument maturity="stable">
<name>addr</name>
<type></type>
<description>Server address</description>
</argument>
</arguments>
</metainfo>
</method>
"""
# NOTE: handling SockAddr types is a compatibility hack, as
# proxies might call setServer with a SockAddr instance
# instead of a tuple of SockAddrs
if isinstance(addr, SockAddrType):
self.target_address = (addr,)
else:
self.target_address = addr
self.target_zone = [Zone.lookup(a) for a in self.target_address]
示例7: __init__
def __init__( self, centroid=(0, 0, 0), size=10.0 ):
self.centroid = Vertex( *centroid )
self.size = float( size )
# generate min and max bounds for zone init
radius = self.size / 2.0
min_bound = Vertex( *[c - radius for c in self.centroid] )
max_bound = Vertex( *[c + radius for c in self.centroid] )
Zone.__init__( self, min_bound, max_bound )
self.selected_color = ( 0.7, 0.0, 0.1, 1.0 )
self.last_color = None
self.specular = ( 1.0, 1.0, 1.0, 1.0 )
self.shininess = 100.0
self.diffuse = ( 0.1, 0.0, 0.7, 1.0 )
示例8: test_load_zone_from_dict
def test_load_zone_from_dict(self):
from Zone import ZoneDBFields
zd = {
ZoneDBFields.DEFINITION_KEY: "gas"
}
z = Zone.construct_model_from_dict(zd)
self.assertEqual(z.get_fullName(),"Gas Planet Orbit")
示例9: setServerAddress
def setServerAddress(self, addr):
"""
<method internal="yes">
<summary>
Sets the server address and looks up the server zone and sets the server_zone property.
</summary>
</method>
"""
self.server_address = addr
self.server_zone = Zone.lookup(addr)
示例10: resolveZones
def resolveZones(name_list):
"""
Helper function to convert a list of zone
names to a list of Zone instnaces
"""
name_list = makeSequence(name_list)
for name in name_list:
if Zone.lookup_by_name(name) == None:
raise ValueError, "No zone was defined with that name; zone='%s'" % (name,)
示例11: _getSession
def _getSession(self, client_stream, client_local, client_listen, client_address):
"""<method internal="yes">
</method>
"""
result = getKZorpResult(client_address.family, client_stream.fd)
if result is None:
## LOG ##
# This message indicates that the KZorp result
# lookup has failed for this session.
##
log(None, CORE_POLICY, 0, "Unable to determine service, KZorp service lookup failed; bindto='%s'", (self.bindto[0], ))
return None
(client_zone_name, server_zone_name, dispatcher_name, service_name, rule_id) = result
service = Globals.services.get(service_name)
client_zone = Zone.lookupByName(client_zone_name)
server_zone = Zone.lookupByName(server_zone_name)
return MasterSession(service, client_stream, client_local, client_listen, client_address,
client_zone = client_zone, server_zone = server_zone, rule_id = rule_id, instance_id=getInstanceId(service.name))
示例12: test_define_zone
def test_define_zone(self):
random.choice = MonkeyPatches.mock_choice_first_index
random.randint = lambda l,u: 5
lvl = 6
visited = {}
z = Zone.construct_next_zone_choice(lvl,visited)
self.assertEqual(z[ZoneDBFields.FULL_NAME],"Empty Space")
self.assertEqual(z[ZoneDBFields.LVL],11)
self.assertEqual(z[ZoneDBFields.MAX_MONSTERS],5)
self.assertEqual(len(visited),1)
self.assertEqual(visited['emptySpace'],1)
z = Zone.construct_next_zone_choice(lvl,visited)
self.assertEqual(len(visited),1)
self.assertEqual(visited['emptySpace'],2)
self.assertEqual(z[ZoneDBFields.FULL_NAME],"Empty Space Alpha")
z = Zone.construct_next_zone_choice(lvl,visited,True)
self.assertEqual(z[ZoneDBFields.LVL],6)
self.assertEqual(len(visited),1)
self.assertEqual(visited['emptySpace'],3)
self.assertEqual(z[ZoneDBFields.FULL_NAME],"Empty Space Beta")
示例13: __init__
def __init__(self, client_stream, client_local, client_listen, client_address):
"""<method internal="yes">"""
self.client_stream = client_stream
self.client_local = client_local
self.client_listen = client_listen
self.client_address = client_address
if client_address is not None:
try:
self.client_zone = Zone.lookup(client_address)
except ZoneException:
self.client_zone = None
else:
self.client_zone = None
示例14: check_in_and_get_notices
def check_in_and_get_notices(heroPk,accountPk,checkinTimeUtc,utcOffset):
"""
this should be called on page load and should be used to get any notices
for the use
args:
heroPk:
we want a pymongo objectId for the hero table
accountPk:
we want a pymongo objectId for the hero table
checkinTimeUtc:
this needs to be that the user check in and it needs to be utc
utcOffset:
the time-zone offset from UTC, in minutes, for the current locale.
returns:
we return a dict with two elements: 'story' which will be a list of
huge things of text and 'zoneChoice' which is a list of dicts each
of which contain 'zonePk','description'
but zoneChoice may be none.
"""
from Hero import Hero
from Account import Account
hero = Hero.construct_model_from_pk(heroPk)
account = Account.construct_model_from_pk(accountPk)
lastCheckinTime = account.lastCheckInTime
account.lastCheckInTime = checkinTimeUtc
account.save_changes()
if not lastCheckinTime:
messages = build_first_time_checkin_messages(hero)
hero.save_changes()
return messages
if hero.isInZoneLimbo:
autoPickedZoneDict = random.choice(hero.zone.nextZoneReferenceList)
hero.zone = Zone.construct_model_from_dict(autoPickedZoneDict)
hero.monster = Monster.construct_new_monster(hero.zone.definitionKey,hero.zone.lvl)
timeDiffInDays = (checkinTimeUtc - lastCheckinTime)/(60*60*24)
if timeDiffInDays >= 1:
pass
示例15: test_zone_properties_default
def test_zone_properties_default(self):
testZoneKey = ZoneDefinitionFields.EMPTY_SPACE
z = Zone(testZoneKey)
z.suffix = "Alpha"
z.monstersKilled = 5
z.maxMonsters = 10
z.lvl = 4
pZPk = dbHelp.create_test_zone_obj(ZoneDefinitionFields.HOME).get_pk()
z.previousZoneReferencePK = pZPk
z.nextZoneReferenceList = [dbHelp.create_test_zone_dict(ZoneDefinitionFields.ASTEROID_FIELD),
dbHelp.create_test_zone_dict(ZoneDefinitionFields.GAS),
dbHelp.create_test_zone_dict(ZoneDefinitionFields.NEBULA)]
self.assertEqual(z.definitionKey, testZoneKey)
self.assertEqual(z.get_fullName(), ZoneDefinition.get_name_for_key(testZoneKey) + " Alpha")
self.assertEqual(z.suffix,"Alpha")
self.assertEqual(z.monstersKilled, 5)
self.assertEqual(z.maxMonsters,10)
self.assertEqual(z.lvl, 4)
self.assertEqual(z.get_description(),ZoneDefinition.get_description_for_key(testZoneKey))
self.assertEqual(z.previousZoneReferencePK,pZPk)
self.assertListEqual(z.nextZoneReferenceList,[dbHelp.create_test_zone_dict(ZoneDefinitionFields.ASTEROID_FIELD),
dbHelp.create_test_zone_dict(ZoneDefinitionFields.GAS),
dbHelp.create_test_zone_dict(ZoneDefinitionFields.NEBULA)])