本文整理汇总了Python中inventory.Inventory.replace_item方法的典型用法代码示例。如果您正苦于以下问题:Python Inventory.replace_item方法的具体用法?Python Inventory.replace_item怎么用?Python Inventory.replace_item使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inventory.Inventory
的用法示例。
在下文中一共展示了Inventory.replace_item方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Game
# 需要导入模块: from inventory import Inventory [as 别名]
# 或者: from inventory.Inventory import replace_item [as 别名]
#.........这里部分代码省略.........
# Always allowed to ignore items
validOptions.append('9')
toAppend = ' [9: Ignore]'
if self._isMssgTooLong(pickupMssg, toAppend):
self.messages.append(pickupMssg)
pickupMssg = ''
toAppend = toAppend[1:]
pickupMssg += toAppend
# self.messages.append("[1: Pick up with MH] [2: Pick up with OH] [3: Don't pick up]")
self.messages.append(pickupMssg)
self.printScreen()
y_or_n = self.user.__move__(self.getDataForAI("ITEM"))
while y_or_n not in validOptions:
self.messages.append("Please enter " + '/'.join(validOptions))
self.printScreen()
y_or_n = self.user.__move__(self.getDataForAI("ITEM"))
if y_or_n == '1':
# pick up item
self.inventory.equip_main_hand(self.current_enemy.item)
self.printScreen()
if not USE_AI:
time.sleep(2)
elif y_or_n == '2':
self.inventory.equip_offhand(self.current_enemy.item)
self.printScreen()
if not USE_AI:
time.sleep(2)
elif y_or_n == '8':
self.inventory.add_to_pack(self.current_enemy.item)
elif y_or_n != '9':
# Items in inventory are keys 3-7
self.inventory.replace_item(int(y_or_n) - 3, self.current_enemy.item)
elif self.player.isDead():
self.printScreen()
if not USE_AI: time.sleep(2)
raise Defeat("You have been defeated.")
def checkEvent(self):
pass
random.seed()
event_value = random.uniform(0, 1)
encounter_chance = 0.03 + BASE_ENEMY_ENCOUNTER_CHANCE * self.danger
if self.player.hiding:
h_event_value = random.uniform(0, 1)
h_encounter_chance = 0.03 + BASE_HIDE_ENCOUNTER_CHANCE * self.hide_danger
if h_event_value <= h_encounter_chance:
encounter_chance = 1
else:
encounter_chance = -1
if STORY_MODE and self.map.stevendorf and not self.map.boss_fight:
self.map.boss_fight = True
self.current_enemy = self.enemy_factory.generateEnemy(self.level, boss=self.map.stevendorf or self.encounter_sdorf, dorfweap=14)
self.runEvent()
elif event_value <= encounter_chance and not self.invuln_turns:
# spawn an enemy TODO generator
self.current_enemy = self.enemy_factory.get_next_enemy()
self.runEvent()
self.current_enemy = None