Skip to content
Extraits de code Groupes Projets
Valider f280b90f rédigé par Loïc Wikle DUBARD's avatar Loïc Wikle DUBARD
Parcourir les fichiers

implementation du quizz

parent 56396ad9
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 81 ajouts et 2 suppressions
images/memes_images/on_the_side/nanithfuck.jpg

10,4 ko

images/memes_images/salt.jpg

40,9 ko

images/memes_images/smart.jpg

30,6 ko

images/memes_images/specials/avengers.jpg

30,3 ko

images/memes_images/specials/boyfriend.jpg

95,9 ko

images/memes_images/specials/godblessings.jpg

57,2 ko

images/memes_images/specials/homer.jpg

66,6 ko

images/memes_images/specials/thanos.jpg

42,5 ko

images/memes_images/specials/trash.jpg

73,8 ko

images/memes_images/specials/whatisthis.png

266 ko

images/memes_images/speechless.jpg

27,7 ko

images/memes_images/suicide.jpg

77,6 ko

images/memes_images/suprised.jpg

69,4 ko

images/memes_images/thanos.jpg

42,5 ko

images/memes_images/thisisfine.jpg

97,6 ko

images/memes_images/thisisnotfine.jpg

354 ko

images/memes_images/trash.jpg

73,8 ko

images/memes_images/whatisthis.png

266 ko

#!/usr/bin/python3
# module qui fait des memes
# -*- coding: utf-8 -*-
import PIL
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
class Memes(object):
images = {
"10guy": ["10guy.jpg"],
"euh": ["images/euh.jpg"],
"gangbang": ["gangbang.jpg"],
"killyou": ["killyou.jpg"],
"maths": ["maths.jpg"],
"mdr": ["mdr.jpg"],
"ohlala": ["ohlala.jpg"],
"ohlala2": ["ohlala2.jpg"],
"salt": ["salt.jpg"],
"smart": ["smart.jpg"],
"speechless": ["speechless.jpg"],
"suicide": ["suicide.jpg"],
"surprised": ["suprised.jpg"],
"goodchoice": ["goodchoice.jpg"],
"nanithefuck": ["nanithefuck.jpg"],
"badsurprise": ["badsurprise.jpg"],
"boyfriend": ["boyfriend.jpg"],
"thisisfine": ["thisisfine.jpg"],
"thisisnotfine": ["thisisnotfine.jpg"],
"depressing": ["depressing.jpg"],
"avengers": ["avengers.jpg"],
"godblessing": ["godblessings.jpg"],
"homer": ["homer.jpg"],
"thanos": ["thanos.jpg"],
"trash": ["trash.jpg"],
"whatisthis": ["whatisthis.png"]
}
def __init__(self, name, text1, text2='', rep='images/memes_images/'):
self.name = name
self.text1 = text1
self.text2 = text2
@staticmethod
def ecrire(draw, text, font, pos):
x, y = pos
for adj in range(3):
# move right
draw.text((x - adj, y), text, font=font, fill="black")
# move left
draw.text((x + adj, y), text, font=font, fill="black")
# move up
draw.text((x, y + adj), text, font=font, fill="black")
# move down
draw.text((x, y - adj), text, font=font, fill="black")
# diagnal left up
draw.text((x - adj, y + adj), text, font=font, fill="black")
# diagnal right up
draw.text((x + adj, y + adj), text, font=font, fill="black")
# diagnal left down
draw.text((x - adj, y - adj), text, font=font, fill="black")
# diagnal right down
draw.text((x + adj, y - adj), text, font=font, fill="black")
# create normal text on image
draw.text(pos, text, fill="white", font=font)
def get_image(self):
pass
if __name__ == '__main__':
meme1 = Memes(smart, 'test1', 'test2')
img = meme1.get_image()
...@@ -7,6 +7,7 @@ import requests ...@@ -7,6 +7,7 @@ import requests
from random import shuffle from random import shuffle
from googletrans import Translator from googletrans import Translator
import random
translator = Translator() translator = Translator()
...@@ -50,10 +51,12 @@ class Quizz(object): ...@@ -50,10 +51,12 @@ class Quizz(object):
return self._quizz['question'] return self._quizz['question']
def start(self): def start(self):
assert self._status == 0
if self._status == 0: if self._status == 0:
self._status = 1 self._status = 1
self._round = 1 self._round = 1
return random.choice(['Que la partie commence !', 'é zé bardi !']) + '\n' + self.get_question()
else:
return "Mais t'es trizo ou quoi ya déjà une partie qui tourne là !"
def get_round(self): def get_round(self):
return self._round return self._round
...@@ -77,7 +80,7 @@ class Quizz(object): ...@@ -77,7 +80,7 @@ class Quizz(object):
return self.reset() return self.reset()
if proposition == '!question': if proposition == '!question':
return self.get_question() return self.get_question()
if proposition == self._quizz['reponse']: if proposition.lower() == self._quizz['reponse'].lower() or (self._quizz['reponse'] == 'True' and 'vrai' in proposition.lower()) or (self._quizz['reponse'] == 'False' and 'faux' in proposition.lower()):
if personne in self._essais.keys(): if personne in self._essais.keys():
self._essais[personne] += 1 self._essais[personne] += 1
else: else:
...@@ -110,6 +113,8 @@ class Quizz(object): ...@@ -110,6 +113,8 @@ class Quizz(object):
self._essais = {} self._essais = {}
self._points = {} self._points = {}
self._round = 0 self._round = 0
return 'Et on recommence tout !'
if __name__ == "__main__": if __name__ == "__main__":
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter