當前位置: 首頁>>代碼示例>>Python>>正文


Python Zone.Zone類代碼示例

本文整理匯總了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)
開發者ID:charafsalmi,項目名稱:ppd-paris-descartes,代碼行數:29,代碼來源:Map.py

示例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)
開發者ID:charafsalmi,項目名稱:ppd-paris-descartes,代碼行數:9,代碼來源:Map.py

示例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)
開發者ID:charafsalmi,項目名稱:ppd-paris-descartes,代碼行數:9,代碼來源:Map.py

示例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)
開發者ID:joelliusp,項目名稱:SpaceHabit,代碼行數:12,代碼來源:Test_Zone.py

示例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)
開發者ID:joelliusp,項目名稱:SpaceHabit,代碼行數:12,代碼來源:Test_Zone.py

示例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]
開發者ID:magwas,項目名稱:zorp,代碼行數:33,代碼來源:Session.py

示例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 )
開發者ID:philetus,項目名稱:l33tC4D,代碼行數:16,代碼來源:Box.py

示例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")
開發者ID:joelliusp,項目名稱:SpaceHabit,代碼行數:8,代碼來源:Test_Zone.py

示例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)
開發者ID:matepeter90,項目名稱:zorp,代碼行數:10,代碼來源:Session.py

示例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,)
開發者ID:akatrevorjay,項目名稱:zorp,代碼行數:10,代碼來源:Rule.py

示例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))
開發者ID:mochrul,項目名稱:zorp,代碼行數:20,代碼來源:Dispatch.py

示例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")
開發者ID:joelliusp,項目名稱:SpaceHabit,代碼行數:20,代碼來源:Test_Zone.py

示例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
開發者ID:matepeter90,項目名稱:zorp,代碼行數:14,代碼來源:Session.py

示例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
開發者ID:joelliusp,項目名稱:SpaceHabit,代碼行數:46,代碼來源:StartUpRoutine.py

示例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)])
開發者ID:joelliusp,項目名稱:SpaceHabit,代碼行數:24,代碼來源:Test_Zone.py


注:本文中的Zone.Zone類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。