本文整理汇总了Python中host.Host.getRequest方法的典型用法代码示例。如果您正苦于以下问题:Python Host.getRequest方法的具体用法?Python Host.getRequest怎么用?Python Host.getRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类host.Host
的用法示例。
在下文中一共展示了Host.getRequest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from host import Host [as 别名]
# 或者: from host.Host import getRequest [as 别名]
def __init__(self, player, end=False, good=False):
"""
The end paramter denotes whether or not this room is the end.
If it's the end, the player just needs to pass whatever scenario is here and then exit successfully
If not the end, the room will spawn other connected rooms and continue
If "good" is false, this room will have bad things in it
"""
import random
from scenery import SceneDescriptors
from monster import Monster
from bestiary import Bestiary
from angel import Angel
from host import Host
from people import People
from player import Player
self._description = SceneDescriptors.getScene(good)
if good:
self._creature = Angel()
print "The angel", self._creature.name, "appears before you. It is", self._creature.description, ". It", Host.getRequest()
print "Your choices are: "
resp = People.getResponses()
for key, val in enumerate(resp):
print key, ".", resp[val]
print "Now, what will you do? Select a number"
choice = ''
invalid = True
while invalid:
choice = raw_input("-->")
if int(choice) > len(resp)-1:
print "That number is invalid! Try again"
elif int(choice) < 0:
print "That number isn't even a positive number! Try again"
else:
print "You selected", choice
invalid = False
choiceType = resp.keys()[int(choice)]
choiceText = resp[choiceType] # always prints only one from each good, bad, wierd list anyway
typeMap = {
'good': True,
'bad': False,
'weird': False
}
if typeMap[choiceType]:
print "The angel bestows upon you", self._creature.pointsGiven, "health and", self._creature.disappears
player.changeHealth(self._creature.pointsGiven)
else:
print "The angel is annoyed. It smites you and takes away", self._creature.pointsGiven, "health"
player.changeHealth(-1 * self._creature.pointsGiven)
print "You now have", player.health, "health left"
else:
self._creature = Monster()
print "The monster", self._creature.name, "appears before you. It is", self._creature.description
print "Your choices are: "
resp = People.getDefenses()
for key, val in enumerate(resp):
print key, ".", resp[val]
print "Now, how will you defend yourself? Select a number"
choice = ''
invalid = True
while invalid:
choice = raw_input("-->")
if int(choice) > len(resp)-1:
print "That number is invalid! Try again"
elif int(choice) < 0:
print "That number isn't even a positive number! Try again"
else:
print "You selected", choice
invalid = False
choiceType = resp.keys()[int(choice)]
choiceText = resp[choiceType] # always prints only one from each good, bad, wierd list anyway
typeMap = {
'good': True,
'bad': False,
'weird': False
}
if typeMap[choiceType]:
print "The monster", self._creature.death
else:
print "The monster", self._creature.attack, "and you lose", self._creature.pointsTaken
player.changeHealth(self._creature.pointsTaken)
print "You now have", player.health, "health left"