本文整理汇总了Python中inventory.Inventory.use_misc方法的典型用法代码示例。如果您正苦于以下问题:Python Inventory.use_misc方法的具体用法?Python Inventory.use_misc怎么用?Python Inventory.use_misc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inventory.Inventory
的用法示例。
在下文中一共展示了Inventory.use_misc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Game
# 需要导入模块: from inventory import Inventory [as 别名]
# 或者: from inventory.Inventory import use_misc [as 别名]
#.........这里部分代码省略.........
itemIndexOffset = 1
if self.inventory.get_main_hand():
itemIndexOffset += 1
if self.inventory.get_offhand():
itemIndexOffset += 1
for i in range(len(items)):
item = items[i]
keyPress = 'Press {} to swap to '.format(i + itemIndexOffset)
weaponMssg = '{0} (Type: {1}, Strength: {2}, Durability: {3})'.format(item['name'], item['type'], item['strength'], item['durability'])
self.messages.append(keyPress + weaponMssg)
self.printScreen()
try:
itemChoice = self.user.__move__(self.getDataForAI('SWAP'))
itemChoice = int(itemChoice[0]) - itemIndexOffset
self.messages = []
if not self.inventory.is_valid_item_index(itemChoice):
self.messages.append('Invalid command!')
return False
elif (handChoice == 'Main Hand' and self.inventory.swap_main_hand(itemChoice)) or \
(handChoice == 'Off-Hand' and self.inventory.swap_offhand(itemChoice)):
self.messages.append('Successfully swapped weapon to {}!'.format(handChoice))
validSwap = True
else:
self.messages.append('You cannot place a {} in your {}!'.format(items[itemChoice]['name'], handChoice))
return False
except ValueError:
self.messages.append("Invalid input!")
if not USE_AI: time.sleep(2)
# ATTACKING
elif decisions[0] == 'f':
self.playerStance = "OFFENSIVE"
result = self.inventory.use_misc("Fireballs")
if result:
playerDamage = ITEM_STRENGTHS["Fireballs"]
self.messages.append("You blast the {0} for {1} damage!".format(self.current_enemy.name, playerDamage))
self.current_enemy.damage(playerDamage)
else:
self.messages.append("You wave your hands around, but nothing happens.")
return True
elif decisions[0] == 'x':
self.playerStance = "OFFENSIVE"
# are we attacking with a ranged weapon?
ranged_items = self.inventory.get_equipped_ranged()
if ranged_items:
# deal the damage
playerAction = "shoot"
# for non-ranged weapons
else:
# deal the damage
playerAction = "hit"
if self.rangedEncounter and not self.inventory.get_equipped_ranged():
# Melee weapon is equipped during ranged encounter, therefore cannot do damage
return True
playerDamage = self.inventory.get_damage()
if (self.rangedEncounter):
playerDamage *= RANGE_COMBAT_FACTOR
# deal the damage and update
totalDamage = max(1, # Force player to do minimum 1 damage
int(playerDamage * (float(self.inventory.next_attack) / 3)))
self.current_enemy.damage(totalDamage)