【发布时间】:2019-04-24 14:56:36
【问题描述】:
如果一个用户达到一定金额,我对这个游戏有多个条件,那么如果其他用户达到他们的水平,他们偷的钱越多。
我在试图弄清楚逻辑时遇到了问题。我添加了 cmets 提问,但我只是不知道是否有更简单的方法来处理这类事情。
当我开始我的 if 语句时,我是从较小的值开始还是应该从较大的值开始?
# do I need to put a check and money(message.author) < 500000 here?
if money(message.author) >= 20000 and money(user) < 20000:
do_thing1()
# do I need to put a check and money(user) < 500000 here?
elif money(message.author) < 20000 and money(user) >= 20000:
do_thing1()
# do I need to put a check money(message.author) and money(user) < 500000 here?
elif money(message.author) >= 20000 and money(user) >= 20000:
do_thing2()
# do I need to put a check and money(user) >= 20000 here?
elif money(message.author) >= 500000 and money(user) < 500000:
do_thing2()
# do I need to put a check and money(message.author) >= 20000 here?
elif money(message.author) < 500000 and money(user) >= 500000:
do_thing2()
elif money(message.author) >= 500000 and money (user) >= 500000:
do_thing3()
【问题讨论】:
-
仔细观察,我认为我并没有在下面的答案中捕捉到所有内容。您究竟要处理哪些案例?
标签: python python-3.x discord.py