本文整理汇总了Python中monster.Monster.place_on_map方法的典型用法代码示例。如果您正苦于以下问题:Python Monster.place_on_map方法的具体用法?Python Monster.place_on_map怎么用?Python Monster.place_on_map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monster.Monster
的用法示例。
在下文中一共展示了Monster.place_on_map方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: place_objects
# 需要导入模块: from monster import Monster [as 别名]
# 或者: from monster.Monster import place_on_map [as 别名]
def place_objects(self, room):
"""Place random objects in a room."""
# Choose random number of monsters
for i in xrange(SS.map_rand.randrange(cfg.MAX_ROOM_MONSTERS)):
x = SS.map_rand.randrange(room.x1 + 1, room.x2 - 1)
y = SS.map_rand.randrange(room.y1 + 1, room.y2 - 1)
# Don't place monsters on the up stairs, as that's where the player
# will be placed.
if not self.blocks_movement(x, y) and (x, y) != self.upstairs:
if SS.map_rand.randrange(0, 100) < 60:
mon = Monster(x, y, 'orc', ai=ai.StupidAI())
else:
mon = Monster(x, y, 'troll', ai=ai.StupidAI())
mon.place_on_map(self)
# Choose random number of items
for i in xrange(SS.map_rand.randrange(cfg.MAX_ROOM_ITEMS)):
x = SS.map_rand.randrange(room.x1 + 1, room.x2 - 1)
y = SS.map_rand.randrange(room.y1 + 1, room.y2 - 1)
if not self.blocks_movement(x, y):
dice = SS.map_rand.randrange(0, 100)
if dice < 40:
item = Item(x, y, 'healing potion')
elif dice < 40 + 20:
item = Item(x, y, 'scroll of fireball')
elif dice < 40 + 20 + 20:
item = Item(x, y, 'scroll of lightning')
else:
item = Item(x, y, 'scroll of confusion')
item.place_on_map(self)