本文整理汇总了Python中inventory.Inventory.drop方法的典型用法代码示例。如果您正苦于以下问题:Python Inventory.drop方法的具体用法?Python Inventory.drop怎么用?Python Inventory.drop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inventory.Inventory
的用法示例。
在下文中一共展示了Inventory.drop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Player
# 需要导入模块: from inventory import Inventory [as 别名]
# 或者: from inventory.Inventory import drop [as 别名]
#.........这里部分代码省略.........
elif self.shardCount == 0:
self.andWait(0)
self.level.output_buffer.add("You don't have any shards!")
return 0
elif self.health == self.maxHealth and self.shardCount > 0:
self.andWait(0)
self.level.output_buffer.add("You're already at max health.")
return 0
def move(self, direction):
temp = config.collideType.copy()
config.temp = temp
for entity in self.level.grid.get(
self.xpos + config.directions[direction][0], self.ypos + config.directions[direction][1]
):
collideType = entity.collide()
for key in collideType:
if collideType[key]:
temp[key] = collideType[key]
if temp["isPortal"]:
return 0
if temp["isObelisk"]:
return self.andWait(0)
if temp["isDoor"] and not temp["isOpen"]:
self.openDoor(config.directions[direction][0], config.directions[direction][1])
return 0
if not temp["blocksWalking"] and not temp["isEnemy"]:
tempNum = self.doMove(config.directions[direction][0], config.directions[direction][1])
self.postMoveDescribe()
return tempNum
elif temp["isEnemy"] and temp["initiatesCombat"]:
return self.doAttack(config.directions[direction][0], config.directions[direction][1])
else:
return self.andWait(0)
def postMoveDescribe(self):
# generalize this!
cell = self.level.grid.getCell(self.xpos, self.ypos)
for content in cell.getContents():
if isinstance(content, Item):
if content.name[0] in "aeiouy":
self.level.output_buffer.add("You're standing on an " + content.name + ".")
else:
self.level.output_buffer.add("You're standing on a " + content.name + ".")
def get(self):
grounded_item = self.level.grid.getItem(self.xpos, self.ypos)
if not isinstance(grounded_item, Item):
self.level.output_buffer.add("There's no item here!")
self.andWait(0)
return
elif not self.inventory.hasSpace(more=1):
self.level.output_buffer.add("You're carrying too many things to pick that up.")
self.andWait(0)
return
elif not self.inventory.hasWeightSpace(more=grounded_item.weight):
self.level.output_buffer.add("You're carrying too much weight to pick that up.")
self.andWait(0)
return
self.inventory.add(grounded_item)
if grounded_item.name[0] in "aeiouy":
self.level.output_buffer.add("You picked up an " + grounded_item.name + ".")
else:
self.level.output_buffer.add("You picked up a " + grounded_item.name + ".")
self.andWait(1)
def drop(self, letter):
if isinstance(self.inventory.get(letter), Item):
config.world.currentLevel.output_buffer.add("You dropped " + str(self.inventory.get(letter).name + "."))
self.inventory.drop(letter)
self.andWait(1)
else:
self.level.output_buffer.add("That item isn't in your inventory!")
self.andWait(0)
self.andWait(0)
def die(self, killer):
if self.lastObelisk == None:
self.level.output_buffer.clear()
self.level.output_buffer.add("You died! Game over.")
self.level.output_buffer.add("Press 'q' to quit.") # CHANGE TO SPACE
self.level.draw()
while True:
lineIn = unicurses.getch()
if lineIn == unicurses.CCHAR("q"):
unicurses.clear()
unicurses.refresh()
unicurses.endwin()
print("Be seeing you...")
exit()
else:
if self.lastObelisk.level != self.level:
self.level.output_buffer.clear()
self.lastObelisk.level.output_buffer.add("You died!")
self.lastObelisk.level.output_buffer.add("You are reborn in a flash of fire at an obelisk.")
if self.shardCount <= 0:
self.shardCount = 2
self.lastObelisk.level.output_buffer.add("You feel the obelisk lend you strength.")
config.world.swapViaDeath(self.lastObelisk)
config.player.health = config.player.maxHealth