From 83f1e8f495201e47e1b28f52908fc1e26ae5121b Mon Sep 17 00:00:00 2001 From: Honza Date: Sun, 14 Apr 2024 22:24:29 +0200 Subject: [PATCH] some changes --- gesmain.py | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/gesmain.py b/gesmain.py index e231335..fbca28c 100644 --- a/gesmain.py +++ b/gesmain.py @@ -1,4 +1,4 @@ -import discord, csv, os, datetime +import discord, csv, os, datetime, random from discord import app_commands from discord.ext import commands @@ -35,6 +35,15 @@ async def logfile(guildid, process, message): file = open(f'guild_data/guild_{guildid}.log', 'a') file.write(f"[{time}] {process} {message}\n") +async def kratsi(val1, val2): + values = [val1, val2] + if val2 == val1: + return(random.choice(values)) + elif val1 > val2: + return(val2) + elif val2 > val1: + return(val1) + # # # @@ -98,10 +107,27 @@ async def guess(interaction: discord.Interaction, meaning: str): else: solution = (await precti(guildid, "fraze")).lower() + pzkratka = await precti(guildid, 'zkratka') guess = meaning.lower() - if solution != guess: - await interaction.response.send_message(f"{interaction.user.nick}'s guess **({meaning})** is incorrect!") + if solution != guess: + solution = solution.split(" ") + guess = guess.split(" ") + napoveda = "\n__but the words in this order are guessed correctly:__" + trefil = 0 + + for i in range(await kratsi(len(solution), len(guess))): + if guess[i] == solution[i]: + napoveda += f"\n {guess[i]}" + trefil = 1 + else: + napoveda += "\n XXX" + response = f"{interaction.user.nick}'s guess **({meaning})** is incorrect **({pzkratka})**!" + + if trefil == 1: + response += napoveda + + await interaction.response.send_message(response) if solution == guess: await interaction.response.send_message(f"{interaction.user.nick} have succesfully guessed {riddle_author.nick}'s riddle **({solution.lower()})**")