当前位置: 首页>>代码示例>>Python>>正文


Python inventory.Inventory类代码示例

本文整理汇总了Python中inventory.Inventory的典型用法代码示例。如果您正苦于以下问题:Python Inventory类的具体用法?Python Inventory怎么用?Python Inventory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Inventory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

def main(args):
    try:
        intry = Inventory()
        server_name = str(args[1]).strip()
        print(intry.getFloatingIpFromServerForNetwork(server_name))
    except IndexError:
        print("Usage: get_floating_ip <server_name>")
开发者ID:alexwang2015,项目名称:microservices,代码行数:7,代码来源:get_floating_ip.py

示例2: Game

class Game():   
    
    def __init__(self, gru_file=None):
        
        self.compiler = Compiler()
        if gru_file:
            self.stream = self.compiler.decompile(gru_file) 
        else:            
            self.stream = self.compiler.compile(None)   
        self.metadata = self.stream.metadata   
        self.flags = Flags(self.stream)
        self.wheel = Wheel(config)
        self.title = Title(config)
        self.inventory = Inventory(self.stream, self.flags, config)
        self.combiner = Combiner(self.stream, self.flags, self.inventory)
        self.page = Page(config, self.flags, self.combiner, self.inventory)
        self.state = State(self.stream, self.flags, self.inventory, self.wheel, self.combiner, self.title, self.page)               
        if self.metadata.has_key("start"):
            start = self.metadata["start"]
            self.state.update(start)
        else:
            self.state.update("start")

    def draw(self, tick):
        self.inventory.draw()
        self.wheel.draw()
        self.title.draw()
        self.page.draw(tick)

    
        
        
        
开发者ID:Teognis,项目名称:GruEngine,代码行数:28,代码来源:game.py

示例3: TestInventory

class TestInventory(unittest.TestCase):
    """
    A test class for the Inventory module.
    """

    def setUp(self):
        """
        set up data used in the tests.
        setUp is called before each test function execution.
        """        
        
        self.inv = Inventory()
        
        self.weapon = Weapon("Canon", 20)
        self.inv.addWeapon(self.weapon)
        
        
    def testInitialized(self):
        """
        Test if init goes good
        """

        self.assertEqual(self.weapon.name, "Canon")
        self.assertEqual(self.weapon.power, 20)
        
        self.assertEqual(len(self.inv.weapons), 1)
        self.assertEqual(self.inv.weapons[0], self.weapon)
开发者ID:ryuken,项目名称:gravity-snails,代码行数:27,代码来源:unittest_inventory.py

示例4: __init__

class Player:
  """The Player"""
  def __init__(self):
    self.inventory = Inventory()
    self.life = 100
    self.alive = True
    self.damage = 25

  def take_damage(self, amount):
    self.life -= amount
    if self.life <= 0:
      self.die()

  def die(self):
    print "You died!"
    exit(0)

  def add_item(self, item):
    self.inventory.add(item)

  def add_weapon(self, weapon):
    self.inventory.add(weapon)
    self.damage += weapon.damage

  def check_inventory(self):
    return(self.inventory)

  def equip_weapon(self, weapon):
    for item in inventory:
      if item.name == weapon:
        self.weapon = item
      else:
        return(False)
开发者ID:LeakyBucket,项目名称:LPTHW,代码行数:33,代码来源:player.py

示例5: decodeInventoryEntry_level1

def decodeInventoryEntry_level1(document):
    """
    Decodes a basic entry such as: '6 lobster cake' or '6' cakes
    @param document : NLP Doc object
    :return: Status if decoded correctly (true, false), and Inventory object
    """
    count = Inventory(str(document))
    for token in document:
        if token.pos_ == (u'NOUN' or u'NNS' or u'NN'):
            item = str(token)

            for child in token.children:
                if child.dep_ == u'compound' or child.dep_ == u'ad':
                    item = str(child) + str(item)
                elif child.dep_ == u'nummod':
                    count.amount = str(child).strip()
                    for numerical_child in child.children:
                        # this isn't arithmetic rather than treating it such as a string
                        count.amount = str(numerical_child) + str(count.amount).strip()
                else:
                    print "WARNING: unknown child: " + str(child) + ':'+str(child.dep_)

            count.item = item
            count.unit = item

    return count
开发者ID:Arttii,项目名称:spaCy,代码行数:26,代码来源:inventoryCount.py

示例6: __init__

    def __init__(self, g, player_new, dimentions, p = 0):
        LevelBase.__init__(self, g, player_new, dimentions)
        self.prevlevel = p
        self.title = 'Jail'
        # current level
        TW,TH = 32,32

        # load tile set
        g.tga_load_tiles(os.path.join("textures",  "tiles5.png"), (TW,TH), self.tdata)
        g.tga_load_level(os.path.join("levels",  "level19.tga"), 1)
        g.bounds = pygame.Rect(TW,TH,(len(g.tlayer[0])-2)*TW,(len(g.tlayer)-2)*TH)
        g.code_events(self.edata)

        # and an odd object called flutter box. flutter shutter (37, 13) 
        self.terrorist = Character("terrorist.png","faceterrorist.tga", g)
        self.terrorist.pos((3, 20))
        self.terrorist.direction = 0
        self.terrorist.faceup = 1

        self.flutterbox = Inventory(g, 'flutterbox')
        self.flutterbox.pos((37, 13))
        self.flutterswitch = Inventory(g, 'flutterswitch')
        self.flutterswitch.pos((37, 20))

        g.run_codes(self.cdata,(0,0,g.dimentions[0],g.dimentions[1]))
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:25,代码来源:level19.py

示例7: __init__

    def __init__(self, position=(0,0,0), rotation=(-20, 0), flying=False,
                 game_mode=G.GAME_MODE, username="", local_player=True):
        super(Player, self).__init__(position, rotation, health=7,
                                     max_health=10, attack_power=2.0 / 3,
                                     attack_range=4)
        self.inventory = Inventory(27)
        self.quick_slots = Inventory(9)
        self.armor = Inventory(4)
        self.flying = flying
        self.game_mode = game_mode
        self.strafe = [0, 0]
        self.dy = 0
        self.current_density = 1 # Current density of the block we're colliding with
        self._position = position
        self.last_sector = None
        self.last_damage_block = 0, 100, 0 # dummy temp value
        self.username = username
        self.local_player = local_player

        # for debug
        initial_items = [cake_block, torch_block, bed_item]
        for item in initial_items:
            self.inventory.add_item(item.id, item.max_stack_size)

        if not local_player:
            self.model = PlayerModel(position)
            self.momentum = (0,0,0)
开发者ID:ArionPorfirio,项目名称:Minecraft,代码行数:27,代码来源:player.py

示例8: test_010_validate_inventory

 def test_010_validate_inventory(self):
     i = Inventory()
     config = configparser.ConfigParser()
     config.read_file(open('./ansible.cfg'))
     box_list = [['local', '127.0.0.1', 'USER_NAME', 'USER_PASSWORD']]
     codes = {'local':'test'}
     ret, msg = i.generateInventory(config,box_list, "./test.hosts", codes, "")
     self.assertEqual(ret,True)
开发者ID:FourtekIT-incubator,项目名称:openebs,代码行数:8,代码来源:test_inventory.py

示例9: Level

class Level(LevelBase):
    prevlevel = 0
    dialog = 0
    pdialog = 0
    timer = 0
    oldPos = (0, 0)
    dialog = 0
    btimer = 0

    def __init__(self, g, player_new, dimentions, p=0):
        LevelBase.__init__(self, g, player_new, dimentions)
        self.prevlevel = p
        self.title = "Jail"
        # current level
        TW, TH = 32, 32

        # load tile set
        g.tga_load_tiles(os.path.join("textures", "tiles5.png"), (TW, TH), self.tdata)
        g.tga_load_level(os.path.join("levels", "level17.tga"), 1)
        g.bounds = pygame.Rect(TW, TH, (len(g.tlayer[0]) - 2) * TW, (len(g.tlayer) - 2) * TH)
        g.code_events(self.edata)

        self.vats = Inventory(g, "clonevat")
        self.vats.pos((18, 13))
        g.run_codes(self.cdata, (0, 0, g.dimentions[0], g.dimentions[1]))

    # ugly, ugly monsters
    def add_monster(self, g, r, a):
        # e = Enemy(self.g, (r.rect.x, r.rect.y), 'monster1')
        e = Monster1(self.g, (r.rect.x, r.rect.y))

    # upon moving
    def playerMove(self, g, r, a):
        if self.prevlevel == 18:
            g.player.rect.x, g.player.rect.y = r.rect.x, r.rect.y
            g.view.x = r.rect.x
            g.view.y = r.rect.y

    # when you're over a change level tile
    def change_level(self, g, r, a):
        if a.__class__.__name__ != "Player":
            return
        if g.player.pos[0] == 38:
            g.currentLevel = 18

        if g.player.pos[0] == 1:
            g.currentLevel = 16

    # level events
    def level_loop(self):
        g = self.g
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:51,代码来源:level17.py

示例10: from_disk

    def from_disk(self,path,url_prefix,inventory=None):
        """Create or extend inventory with resources from disk scan

        Assumes very simple disk path to URL mapping: chop path and
        replace with url_path. Returns the new or extended Inventory
        object.

        If a inventory is specified then items are added to that rather
        than creating a new one.

        mb = InventoryBuilder()
        m = inventory_from_disk('/path/to/files','http://example.org/path')
        """
        num=0
        # Either use inventory passed in or make a new one
        if (inventory is None):
            inventory = Inventory()
        # for each file: create Resource object, add, increment counter
        for dirpath, dirs, files in os.walk(path,topdown=True):
            for file_in_dirpath in files:
                try:
                    if self.exclude_file(file_in_dirpath):
                        continue
                    # get abs filename and also URL
                    file = os.path.join(dirpath,file_in_dirpath)
                    if (not os.path.isfile(file) or not (self.include_symlinks or not os.path.islink(file))):
                        continue
                    rel_path=os.path.relpath(file,start=path)
                    if (os.sep != '/'):
                        # if directory path sep isn't / then translate for URI
                        rel_path=rel_path.replace(os.sep,'/')
                    url = url_prefix+'/'+rel_path
                    file_stat=os.stat(file)
                except OSError as e:
                    sys.stderr.write("Ignoring file %s (error: %s)" % (file,str(e)))
                    continue
                mtime = file_stat.st_mtime
                lastmod = datetime.fromtimestamp(mtime).isoformat()
                r = Resource(uri=url,lastmod=lastmod)
                if (self.do_md5):
                    # add md5
                    r.md5=compute_md5_for_file(file)
                if (self.do_size):
                    # add size
                    r.size=file_stat.st_size
                inventory.add(r)
            # prune list of dirs based on self.exclude_dirs
            for exclude in self.exclude_dirs:
                if exclude in dirs:
                    dirs.remove(exclude)
        return(inventory)
开发者ID:edsu,项目名称:resync-simulator,代码行数:51,代码来源:inventory_builder.py

示例11: __init__

    def __init__(self, class_name, id=None):
        # Each agent has a unique id... should probably get rid of this and just let logic handle it
        if not id:
            self.id = next(Agent.newid)
        else:
            self.id = id
        
        self.class_name = class_name
        self.price_beliefs = {}
        self.observed_trading_range = {}
        self.inventory = Inventory()
        
        # FIXME: Using preloaded test values, this should be changed later
        self.money = 100

        self.price_beliefs = {key: {'min':.5, 'max':1.5} for key in self.inventory.goods}
        self.observed_trading_range = {key: [] for key in self.inventory.goods} # was keys
        self.lookback = 15

        # Add two fake trades so range exists
        for trade_range in self.observed_trading_range.values():
            trade_range.append(.5)
            trade_range.append(1.5)

        # This is temporary
        self.load_logic(manual_logic.agent_logic_data)
开发者ID:johny5w,项目名称:market_sim,代码行数:26,代码来源:agent.py

示例12: __init__

 def __init__(self, reference=None, **custom):
     if reference:
         try:
             data = get_character_data(reference)
         except ValueError:
             raise UnexistingCharacterException(
                 "The reference \"{}\" doesn't exist".format(reference))
         else:
             for key in LIST_CARAC:
                 if not key in data:
                     data[key] = get_character_data("unknown")[key]
     else:
         data = get_character_data("unknown")
     self._health = 0
     self._inventory = inventory.Inventory()
     self.name = self.operations(custom.get("name", data["name"]))
     self.maxhealth = self.operations(custom.get(
         "maxhealth", data["maxhealth"]))
     self.health = custom.get("health", self.maxhealth)
     self.range_attack = self.operations(custom.get(
         "range_attack", data["range_attack"]))
     self.attack = self.operations(custom.get(
         "attack", data["attack"]))
     self.defense = self.operations(custom.get(
         "defense", data["defense"]))
     self.initiative = self.operations(custom.get(
         "initiative", data["initiative"]))
     self.inventory = Inventory(custom.get("inventory", data.get("inventory", None)))
     self.abilities = self.operations(custom.get(
         "abilities", data["abilities"]))  # Not used in this version
     self.ref = reference
     self.weapon = self.inventory.weapons[0]  # Take the first
开发者ID:PaulEcoffet,项目名称:stonewallsgate,代码行数:32,代码来源:character.py

示例13: __init__

    def __init__(self, g, player_new, dimentions, p = 0):
        LevelBase.__init__(self, g, player_new, dimentions)
        self.prevlevel = p
        self.title = 'Office Complex Top'
        # current level
        TW,TH = 32,32

        # load tile set
        g.tga_load_tiles(os.path.join("textures",  "tiles6.png"), (TW,TH), self.tdata)
        g.tga_load_level(os.path.join("levels",  "level31.tga"), 1)
        g.bounds = pygame.Rect(TW,TH,(len(g.tlayer[0])-2)*TW,(len(g.tlayer)-2)*TH)
        g.code_events(self.edata)
        self.initBack('bg1.png', 730)

        self.backuptape = Inventory(g, 'tape', (37, 22))
        self.backuptape.pos((37, 22))
        self.backup = Character('backup.png', 'facebackup.png', g, 'backup')
        self.backup.pos((28, 25))
        self.backup.direction = 0
        if 'scene21' in g.saveData:
            self.backup.hidden = 1
        # coming back and saying high to the guy.
        if 'scene20' in g.saveData and not 'scene21' in g.saveData:
            del g.saveData['scene20']

        g.run_codes(self.cdata,(0,0,g.dimentions[0],g.dimentions[1]))
        self.coins = 0
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:27,代码来源:level31.py

示例14: __init__

    def __init__(self, name):
        """
        Constructor to create a team of snails
        @param name: The name of the team, which will displayed in various locations
        @return: Team object.
        """ 
        pygame.sprite.Group.__init__(self)
        
        self.name = name
        """ The name of the team"""
        
        self.hasTurn = False

        self.isAlive = True

        self.orderedSnailList = []

        self.gravity_direction = None

        self.inventory = Inventory(self.name)
        cannon = Cannon("Cannon", 20)
        balloonLauncher = BalloonLauncher("Balloon", 30)

        self.inventory.addWeapon(balloonLauncher)
        self.inventory.addWeapon(cannon)

        self.active_weapon = cannon

        self.colorIndex = None
开发者ID:ryuken,项目名称:gravity-snails,代码行数:29,代码来源:team.py

示例15: __init__

    def __init__(self):
        self.map = Map(START_LEVEL)
        # Enforce that a path does exist in the map
        while self.map.findPath() == None:
            self.map = Map(START_LEVEL)
        self.player = Player()
        self.inventory = Inventory()
        self.enemy_factory = EnemyFactory()
        self.user = User()

        self.invuln_turns = 0

        self.swap_weapon_to = None

        self.current_enemy = None
        self.level = START_LEVEL
        self.danger = 5
        self.hide_danger = 5
        self.escape_chance = 3
        self.items_dropped = 0 # a counter so we make sure they get shield, sword and bow chances first
        self.steps_left = MAX_STEPS
        self.escapes_remaining = NUM_ESCAPES
        self.encounter_sdorf = False

        self.dangers = []
        self.escape_chances = []
        self.hide_dangers = []

        self.seerdata = SeerData()
        self.init_dangers()
开发者ID:gaohongl,项目名称:183siege-reach,代码行数:30,代码来源:game.py


注:本文中的inventory.Inventory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。