1

我正在用 python 创建一个文本冒险,我希望它与传统的回合制游戏不同。但也不是 MUD 的实时游戏。我设计了一种方法,程序要求您在一定秒数内输入某个字符串。例如

while goblin != str('dead'):
    type 'slash at goblin' within 3 seconds.
    if you succeed the program prints "you slash at the goblin, the goblin is now dead"
    goblin == str('dead')
    if you fail the program prints "the goblin slashes at you (-5 hp)."
    hp == int(hp) - 5
    and restarts the loop.

关于我如何做到这一点的任何想法?如何强制程序在一定时间内输入命令?任何帮助将不胜感激 THnx!

4

0 回答 0