From c95d039c1e226dea16af4ffa2f80e6faecb7439b Mon Sep 17 00:00:00 2001 From: Dimitris Date: Sat, 3 Feb 2024 22:06:04 +0200 Subject: [PATCH 1/5] My wordgame commit --- jarviscli/plugins/Wordgame.py | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 jarviscli/plugins/Wordgame.py diff --git a/jarviscli/plugins/Wordgame.py b/jarviscli/plugins/Wordgame.py new file mode 100644 index 000000000..c82bfabe1 --- /dev/null +++ b/jarviscli/plugins/Wordgame.py @@ -0,0 +1,52 @@ +import requests +from wonderwords import RandomWord +import time +import enchant + + + +def generateWord(letter): + r = RandomWord() + new_word=r.word(starts_with=letter) + return new_word + + +d = enchant.Dict("en_US") + +continue_playing='Y' +while continue_playing=='Y' or continue_playing=='y': + max_seconds_to_answer=int(input("Give how many seconds you would like to have to find your answers \n")) + rounds=int(input("Give the number of rounds after which you will win the game \n")) + current_rounds=1 + Continue=True + word=input("Give a word \n") + + while current_rounds<=rounds: + print("Round ",current_rounds) + jarvis_answer=generateWord(word[len(word)-1]) + print("Jarvis' answer is: ",jarvis_answer) + + start_time=time.time() + word=input("Give a word starting with the letter: \""+str(jarvis_answer[len(jarvis_answer)-1])+"\" , You have "+str(max_seconds_to_answer)+" seconds to answer! \n") + end_time=time.time() + time_to_answer=end_time-start_time + #print(time_to_answer) + current_rounds+=1 + + if time_to_answer>max_seconds_to_answer: + print("You were too late to answer! You lost. ") + break + + if word[0]!=jarvis_answer[len(jarvis_answer)-1]: + #print("Your word does not start with the last letter of jarvis' word! You lost. ") + print("Wrong answer! You lost. ") + break + + if (not d.check(word)) or len(word)<2: + print("Wrong word! You lost. ") + break + + if current_rounds>rounds: + print("Congratulations! You won all "+str(rounds)+" rounds against jarvis!") + + continue_playing=input("If you want to continue playing press Y/y, otherwise press N/n \n") \ No newline at end of file From 505ca6b57c9c2c7d2a322fe85d051a70616db5b8 Mon Sep 17 00:00:00 2001 From: jimnt Date: Mon, 5 Feb 2024 12:12:23 +0200 Subject: [PATCH 2/5] My changes in requirements.txt --- installer/requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/installer/requirements.txt b/installer/requirements.txt index 0c3946b0c..3d76dda07 100644 --- a/installer/requirements.txt +++ b/installer/requirements.txt @@ -48,3 +48,5 @@ yeelight haversine FlightRadarAPI github3.py +enchant +wonderwords From 6fdf5c769873f256db8f761c872cb541ebc98cf9 Mon Sep 17 00:00:00 2001 From: jimnt Date: Wed, 7 Feb 2024 12:19:04 +0200 Subject: [PATCH 3/5] Changed input,outputs with jarvis fuctions --- jarviscli/plugins/Wordgame.py | 82 +++++++++++++++++------------------ 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/jarviscli/plugins/Wordgame.py b/jarviscli/plugins/Wordgame.py index c82bfabe1..5bea2d917 100644 --- a/jarviscli/plugins/Wordgame.py +++ b/jarviscli/plugins/Wordgame.py @@ -2,51 +2,49 @@ from wonderwords import RandomWord import time import enchant - - +from plugin import plugin def generateWord(letter): r = RandomWord() new_word=r.word(starts_with=letter) return new_word - -d = enchant.Dict("en_US") - -continue_playing='Y' -while continue_playing=='Y' or continue_playing=='y': - max_seconds_to_answer=int(input("Give how many seconds you would like to have to find your answers \n")) - rounds=int(input("Give the number of rounds after which you will win the game \n")) - current_rounds=1 - Continue=True - word=input("Give a word \n") - - while current_rounds<=rounds: - print("Round ",current_rounds) - jarvis_answer=generateWord(word[len(word)-1]) - print("Jarvis' answer is: ",jarvis_answer) - - start_time=time.time() - word=input("Give a word starting with the letter: \""+str(jarvis_answer[len(jarvis_answer)-1])+"\" , You have "+str(max_seconds_to_answer)+" seconds to answer! \n") - end_time=time.time() - time_to_answer=end_time-start_time - #print(time_to_answer) - current_rounds+=1 - - if time_to_answer>max_seconds_to_answer: - print("You were too late to answer! You lost. ") - break - - if word[0]!=jarvis_answer[len(jarvis_answer)-1]: - #print("Your word does not start with the last letter of jarvis' word! You lost. ") - print("Wrong answer! You lost. ") - break - - if (not d.check(word)) or len(word)<2: - print("Wrong word! You lost. ") - break - - if current_rounds>rounds: - print("Congratulations! You won all "+str(rounds)+" rounds against jarvis!") - - continue_playing=input("If you want to continue playing press Y/y, otherwise press N/n \n") \ No newline at end of file +@plugin("Word_game") +def Word_game(jarvis): + d = enchant.Dict("en_US") + + continue_playing='Y' + while continue_playing=='Y' or continue_playing=='y': + max_seconds_to_answer=int(jarvis.input("Give how many seconds you would like to have to find your answers \n")) + rounds=int(jarvis.input("Give the number of rounds after which you will win the game \n")) + current_rounds=1 + Continue=True + word=jarvis.input("Give a word \n") + + while current_rounds<=rounds: + jarvis.say("Round ",current_rounds) + jarvis_answer=generateWord(word[len(word)-1]) + jarvis.say("Jarvis' answer is: ",jarvis_answer) + + start_time=time.time() + word=jarvis.input("Give a word starting with the letter: \""+str(jarvis_answer[len(jarvis_answer)-1])+"\" , You have "+str(max_seconds_to_answer)+" seconds to answer! \n") + end_time=time.time() + time_to_answer=end_time-start_time + current_rounds+=1 + + if time_to_answer>max_seconds_to_answer: + jarvis.say("You were too late to answer! You lost. ") + break + + if word[0]!=jarvis_answer[len(jarvis_answer)-1]: + jarvis.say("Your word does not start with the last letter of jarvis' word! You lost. ") + break + + if (not d.check(word)) or len(word)<2: + jarvis.say("Wrong word! You lost. ") + break + + if current_rounds>rounds: + jarvis.say("Congratulations! You won all "+str(rounds)+" rounds against jarvis!") + + continue_playing=jarvis.input("If you want to continue playing press Y/y, otherwise press N/n \n") \ No newline at end of file From 4b7977762471d3933a3afda68c2ec209b8c089b0 Mon Sep 17 00:00:00 2001 From: JimNtantakas <114806458+JimNtantakas@users.noreply.github.com> Date: Thu, 8 Feb 2024 17:19:53 +0200 Subject: [PATCH 4/5] Update and rename Wordgame.py to wordgame.py my new changes to make this plugin work properly --- .../plugins/{Wordgame.py => wordgame.py} | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) rename jarviscli/plugins/{Wordgame.py => wordgame.py} (58%) diff --git a/jarviscli/plugins/Wordgame.py b/jarviscli/plugins/wordgame.py similarity index 58% rename from jarviscli/plugins/Wordgame.py rename to jarviscli/plugins/wordgame.py index 5bea2d917..812690b53 100644 --- a/jarviscli/plugins/Wordgame.py +++ b/jarviscli/plugins/wordgame.py @@ -2,49 +2,58 @@ from wonderwords import RandomWord import time import enchant -from plugin import plugin +from plugin import plugin, complete, require +from colorama import Fore + + def generateWord(letter): r = RandomWord() new_word=r.word(starts_with=letter) return new_word -@plugin("Word_game") -def Word_game(jarvis): +@plugin("word_game") +def word_game(jarvis,s): d = enchant.Dict("en_US") continue_playing='Y' while continue_playing=='Y' or continue_playing=='y': - max_seconds_to_answer=int(jarvis.input("Give how many seconds you would like to have to find your answers \n")) - rounds=int(jarvis.input("Give the number of rounds after which you will win the game \n")) + max_seconds_to_answer=int(jarvis.input("Give how many seconds you would like to have to find your answers \n",color=Fore.GREEN)) + rounds=int(jarvis.input("Give the number of rounds after which you will win the game \n",color=Fore.GREEN)) current_rounds=1 - Continue=True - word=jarvis.input("Give a word \n") + + while (True): + word=jarvis.input("Give a word: \n",color=Fore.GREEN) + if not ((not d.check(word)) or len(word)<2): + break + else: + jarvis.say("Give a proper word!",color=Fore.RED) while current_rounds<=rounds: - jarvis.say("Round ",current_rounds) + jarvis.say("Round "+str(current_rounds),color=Fore.YELLOW) jarvis_answer=generateWord(word[len(word)-1]) - jarvis.say("Jarvis' answer is: ",jarvis_answer) + jarvis.say("Jarvis' answer is: "+jarvis_answer,color=Fore.YELLOW) start_time=time.time() - word=jarvis.input("Give a word starting with the letter: \""+str(jarvis_answer[len(jarvis_answer)-1])+"\" , You have "+str(max_seconds_to_answer)+" seconds to answer! \n") + word=jarvis.input("Give a word starting with the letter: \""+str(jarvis_answer[len(jarvis_answer)-1])+"\" , You have "+str(max_seconds_to_answer)+" seconds to answer! \n",color=Fore.GREEN) end_time=time.time() time_to_answer=end_time-start_time current_rounds+=1 if time_to_answer>max_seconds_to_answer: - jarvis.say("You were too late to answer! You lost. ") + jarvis.say("You were too late to answer! You lost. ",color=Fore.RED) break if word[0]!=jarvis_answer[len(jarvis_answer)-1]: - jarvis.say("Your word does not start with the last letter of jarvis' word! You lost. ") + jarvis.say("Your word does not start with the last letter of jarvis' word! You lost. ",color=Fore.RED) break if (not d.check(word)) or len(word)<2: - jarvis.say("Wrong word! You lost. ") + jarvis.say("Wrong word! You lost. ",color=Fore.RED) break if current_rounds>rounds: - jarvis.say("Congratulations! You won all "+str(rounds)+" rounds against jarvis!") + jarvis.say("Congratulations! You won all "+str(rounds)+" rounds against jarvis!",color=Fore.YELLOW) - continue_playing=jarvis.input("If you want to continue playing press Y/y, otherwise press N/n \n") \ No newline at end of file + continue_playing=jarvis.input("If you want to continue playing press Y/y, otherwise press N/n \n") + From 8b93f6aff0dc541fc15df35a153458782d7c2156 Mon Sep 17 00:00:00 2001 From: JimNtantakas <114806458+JimNtantakas@users.noreply.github.com> Date: Thu, 8 Feb 2024 17:21:31 +0200 Subject: [PATCH 5/5] Update requirements.txt updated requirements.txt to work with my plugin --- installer/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/requirements.txt b/installer/requirements.txt index 3d76dda07..5cfbfccd4 100644 --- a/installer/requirements.txt +++ b/installer/requirements.txt @@ -48,5 +48,5 @@ yeelight haversine FlightRadarAPI github3.py -enchant wonderwords +pyenchant