本文整理汇总了Python中inventory.Inventory.update方法的典型用法代码示例。如果您正苦于以下问题:Python Inventory.update方法的具体用法?Python Inventory.update怎么用?Python Inventory.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inventory.Inventory
的用法示例。
在下文中一共展示了Inventory.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_inventory
# 需要导入模块: from inventory import Inventory [as 别名]
# 或者: from inventory.Inventory import update [as 别名]
def update_inventory(self, inventory_report):
for inventory_diff in inventory_report.inventory_diffs:
log.info('Updating inventory for %s', inventory_diff.path)
try:
inventory_inventory = Inventory.read(inventory_diff.path, self.base_inventory_path)
except FileNotFoundError:
inventory_inventory = Inventory(inventory_diff.path)
inventory_inventory.update(inventory_diff.directories_missing_from_inventory,
inventory_diff.directories_missing_from_fs,
inventory_diff.files_missing_from_inventory,
inventory_diff.files_missing_from_fs,
inventory_diff.file_fixity_mismatch,
timestamp=inventory_diff.timestamp)
inventory_inventory.write(self.base_inventory_path)
示例2: Team
# 需要导入模块: from inventory import Inventory [as 别名]
# 或者: from inventory.Inventory import update [as 别名]
class Team(pygame.sprite.Group):
"""
This is the team class, which is the owner of a group of snails.
Several snails together form a team.
"""
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
def update(self, *args):
"""
Call the update of all the objects the team currently manages, this can include weapon, inventory and snails.
@param *args: Pass all the arguments to the the update of the sprites.
"""
pygame.sprite.Group.update(self,*args)
self.checkAlive()
if(self.inventory.visible and self.hasTurn):
tempWeapon = self.inventory.update(args[0])
if(not None == tempWeapon):
self.active_weapon = tempWeapon
if(not None == self.active_weapon):
self.active_weapon.update(*args)
def draw(self, surface):
"""
Draw all the objects the team currently manages, this can include weapon, inventory and snails.
@param surface: This is the surface created in the game class
"""
for sprite in self:
sprite.draw(surface)
#draw the inventory if team has turn
if(self.hasTurn):
self.active_weapon.draw(surface)
self.inventory.draw(surface)
if self.hasTurn and not None == self.active_weapon:
for snail in self.orderedSnailList:
if snail.hasTurn == True:
self.active_weapon.snail_rect = snail.rect
def addSnails(self, numberOfSnails):
"""
Add a number of snails to the teams, this creates snails objects.
"""
for i in range(0, numberOfSnails):
snail = Snail(self)
snail.id = i
self.add(snail)
self.orderedSnailList.append(snail)
self.orderedSnailList[len(self.orderedSnailList) - 1].hasTurn = True
def setGravity(self, direction):
"""
Set the gravity direction for the team
@param direction: An integer representing a value. Use enums.Direction.
"""
self.gravity_direction = direction
for s in self.sprites():
s.gravity_direction = direction
def setTeamImage(self, imageNumber):
"""
sets the image of the team using a number
the sprite's folder contains snails with 4 different colors
the number given will be used to select a different snail
"""
self.colorIndex = imageNumber
#.........这里部分代码省略.........