def _info_casino(self, ctx):
"""Shows information about the server casino"""
# Variables
server = ctx.message.server
settings = super().check_server_settings(server)
players = len(super().get_server_memberships(server))
memberships = len(settings["Memberships"])
chip_exchange_rate = settings["System Config"]["Chip Rate"]
credit_exchange_rate = settings["System Config"]["Credit Rate"]
games = settings["Games"].keys()
if settings["System Config"]["Threshold Switch"]:
threshold = settings["System Config"]["Threshold"]
else:
threshold = "None"
# Create the columns through list comprehensions
multiplier = [x["Multiplier"] for x in settings["Games"].values()]
min_bet = [x["Min"] if "Min" in x else "None"
for x in settings["Games"].values()]
max_bet = [x["Max"] if "Max" in x else "None"
for x in settings["Games"].values()]
cooldown = [x["Cooldown"] for x in settings["Games"].values()]
cooldown_formatted = [self.time_format(x) for x in cooldown]
# Determine the ratio calculations for chips and credits
chip_ratio = str(Fraction(chip_exchange_rate).limit_denominator()).replace("/", ":")
credit_ratio = str(Fraction(credit_exchange_rate).limit_denominator()).replace("/", ":")
# If a fraction reduces to 1, we make it 1:1
if chip_ratio == "1":
chip_ratio = "1:1"
if credit_ratio == "1":
credit_ratio = "1:1"
# Build the table and send the message
m = list(zip(games, multiplier, min_bet, max_bet, cooldown_formatted))
m = sorted(m, key=itemgetter(0))
t = tabulate(m, headers=["Game", "Multiplier", "Min Bet", "Max Bet", "Cooldown"])
msg = (_("```Python\n{}\n\nCredit Exchange Rate: {}\nChip Exchange Rate: {}\n"
"Casino Members: {}\nServer Memberships: {}\nServer Threshold: "
"{}```").format(t, credit_ratio, chip_ratio, players, memberships, threshold))
await self.bot.say(msg)
评论列表
文章目录