我正在关注构建骰子扑克游戏的教科书示例。下面是一段我不太理解的代码片段,但它确实有效。那么在run方法下的while循环中,第二个条件就是TextInterface类中的wantToPlay方法必须为真,对吗?但是当我查看 wantToPlay 方法时,没有布尔结果,即它是否为真没有给出。有人可以解释这是如何工作的吗?
class PokerApp:
def run(self):
while self.money >= 10 and self.interface.wantToPlay():
self.playRound()
class TextInterface:
def wantToPlay(self):
ans = input("do you wish to try your luck? ")
return ans[0] in "yY"