Example #1
0
    def testverifiewinJeu(self):

        init = Jeu("Hollande", "Obama", contreIa=True)

        assert not init.verifiewin(1)
        assert not init.verifiewin(0)
        assert not init.verify()
        init.joueur1.nombreCapture = 30

        assert init.verifiewin(0)
        assert not init.verifiewin(1)
        assert init.verify()

        init.joueur1.nombreCapture = 3
        init.joueur2.nombreCapture = 0
        for i in range(6, 12):

            init.plateau.cases[i].graines = 0
        for i in range(4):
            init.plateau.cases[i].graines = 2
        for i in range(4, 6):
            init.plateau.cases[i].graines = 0

        assert not init.verifiewin(1)
        assert init.verifiewin(0)
        assert init.verify()
Example #2
0
def delete_Jeu(Jeu):
        try:
                cur.execute("""DELETE FROM EnsJeux WHERE Jeu_id = ?""",(Jeu.get_Jeu_id(),))
                conn.commit()
                cur.execute("""DELETE FROM EnsExemplaires WHERE Jeu_id = ?""",(Jeu.get_Jeu_id(),))
                conn.commit()
        except:
                print ("Erreur lors de la suppression !")
Example #3
0
    def testJeuclone(self, contreIa=False):

        init = Jeu(" Hollande", " Obama", contreIa)

        clo = init.clone()

        assert clo.tour == init.tour

        self.testJoueur(clo=clo.joueur1, clo1=init.joueur1)
        self.testPlateau(p=clo.plateau, clo1=init.plateau)
Example #4
0
    def testjouerJeu(self):

        init = Jeu("Hollande", " Obama", contreIa=False)
        tour = init.tour
        assert init.jouer(3) == None
        """ il y'a pas d'erreur par consequent on retourne tout simplement None"""
        assert init.tour == tour + 1
        assert init.plateau.cases[3].graines == 0
        assert init.jouer(3) == 0
        """ on verifie que lorsqu'on joue dans la 3eme case, il y'a plus de plus de graines dans cette dernière """
Example #5
0
    def testnotationJeu(self):

        init = Jeu("Hollande", " Obama", contreIa=False)

        assert init.notation(0) == 0
        assert init.notation(1) == 0
        init.joueur2.nombreCapture = 5
        init.joueur1.nombreCapture = 2
        assert init.notation(0) == -60
        assert init.notation(1) == 60

        init.plateau.cases[2].graines = 2
        assert init.notation(0) == -62
Example #6
0
    def __init__(self):
        # On définie la fenetre de jeu
        Frame.__init__(self)
        # Et on lui donne les dimensions initiale
        self.master.geometry("900x600")
        # On donne ensuite un titre à cette fenêtre
        self.master.title(" Jeu de Demineur")

        # On créer une instance mbar de MenuBar
        # C'est la barre qui se situe en haut de la fenêtre et
        # qui permet de paramètrer le jeu.
        self.mbar = MenuBar(self)
        # On place ceci en indiquant quelques paramètres.
        self.mbar.pack(side=TOP, expand=NO, fill=X)

        # De même on créer une instance jeu de Jeu.
        # C'est le cadre de jeu , celui sur lequel la grille
        # est dessinée.
        self.jeu = Jeu(self)
        # On place ceci en indiquant quelques paramètres
        # notemment celui expand qui permet au cadre de prendre
        # le maximum de place
        self.jeu.pack(
            side=LEFT,
            expand=YES,
            fill=BOTH,
        )

        # De même on créer une instance affichage d'Afficahge
        # C'est le cadre situé à droite de la fenêtre de jeu
        # il permet un affichage de l'évolution de la partie.
        self.affichage = Affichage(self)
        # On place ceci en indiquant quelques paramètres
        self.affichage.pack(side=RIGHT, expand=NO, fill=BOTH)

        # Ici on utilise la fonction pack du module tkinter.
        self.pack()

        # Pour lancer la musique pendant le jeu on a besoin de
        # lancer une fonction particulière en fonction du système
        # d'exploitation sur lequel le programme tourne et donc
        # d'enregistrer le nom du système dans une variable global
        # Ici on va determiner sur quelle systeme le jeu tourne
        global operatingSystem
        # On initialise une variable qui va enregistrer le nom du
        # systeme
        operatingSystem = 'none'
        # On attribut a cette variable le nom du system grace a la
        # librairie platform
        operatingSystem = platform.system()
        print('Demineur : Le jeu tourne actuellement sous :', operatingSystem)
Example #7
0
 def afficheJeu(n, Jeux, k=0):
     n[0]=n[0]+k
     r = n[2]-n[1]
     if (r>20): r=20
     if (n[0]<n[1]):
         n[0]=n[1]
     if (n[0]+r>n[2]):
         n[0]=n[2]-r
     j=3
     
     for i in range(n[0],n[0]+r):
         Label(fcatalogue, text=str(Jeux[i][1]), bg="orange", width = 25).grid(row=j, column=1)
         Label(fcatalogue, text=str(Jeux[i][2]), bg="orange", width = 10).grid(row=j, column=2)
         Label(fcatalogue, text=str(Jeux[i][3]), bg="orange", width = 10).grid(row=j, column=3)
         Label(fcatalogue, text=str(Jeux[i][4]), bg="orange", width = 10).grid(row=j, column=4)
         Label(fcatalogue, text=str(Jeux[i][5]), bg="orange", width = 15).grid(row=j, column=5)
         Label(fcatalogue, text=str(Jeux[i][6]), bg="orange", width = 15).grid(row=j, column=6)
         Label(fcatalogue, text=str(Jeux[i][7]), bg="orange", width = 15).grid(row=j, column=7)
         Label(fcatalogue, text=str(Jeux[i][8]), bg="orange", width = 15).grid(row=j, column=8)
         if (modeAdmin):
             Button(fcatalogue, text="Modifier", command = rien,bg="blue", width=13,activebackground="blue").grid(row=j, column=9) #partial(formulaireJeu,Jeux[i][0])
             Button(fcatalogue, text="Créer extension", command = partial(formulaireExt, -1, Jeux[i][0]),bg="cyan", width=13,activebackground="cyan").grid(row=j, column=14)
         else:
             Button(fcatalogue, text="Détail", command = partial(afficheFicheJeu,Jeux[i][0]) ,bg="blue", width=13,activebackground="blue").grid(row=j, column=9)
             
         if (Jeu.aDesExtensions(Jeux[i][0])):
             Button(fcatalogue, text="Extensions", command = partial(lancerExtension, Jeux[i][0], modeAdmin),bg="red", width=13,activebackground="red").grid(row=j, column=10)
         Button(fcatalogue, text="Emprunt", command = partial(lancerEmprunt, Jeux[i][0]),bg="green", width=13,activebackground="green").grid(row=j, column=11)
         Button(fcatalogue, text="Reserv", command = partial(lancerReserv, Jeux[i][0]),bg="red", width=13,activebackground="red").grid(row=j, column=12)
         if (modeAdmin):
             Button(fcatalogue, text="Supprimer", command = rien,bg="yellow", width=13,activebackground="red").grid(row=j, column=13)
         j=j+1
Example #8
0
    def testplayIA(self):

        jeu = Jeu("Hollande", " Obama", contreIa=True)
        tour = jeu.tour
        jeu.joueur1.play(jeu)

        assert jeu.tour == tour + 1
Example #9
0
def afficheExtensions(idJeu, modeAdmin):
    
    def retourCatalogue():
        fextension.destroy()
        return catalogue()

    def lancerEmprunt(i):
        fextension.destroy()
        return formulaireEmprunt(i)

    def lancerReserv(i):
        fextension.destroy()
        return reserver(i)
    
    fextension=Tk()
    fextension.title("Extension(s) du jeu ")
    fextension.grid_columnconfigure(0,weight=1)
    fextension.grid_rowconfigure(20,weight=21)

    p = PanedWindow(fextension, orient = HORIZONTAL, height=100, width=600)
    p.grid(row=1, column=1, columnspan=4)
    p.add(Label(p, text="Bonjour pseudo", bg="white", anchor=CENTER, width=20))
    p.add(Button(p, text="Retour au catalogue", bg="orange", activebackground="orange", borderwidth=10, width=20, command= retourCatalogue ))
    if (modeAdmin):
        p.add(Button(p, text="Ajouter Extension", bg="cyan", activebackground="cyan", borderwidth=10, width=20, command=rien))
    p.add(Button(p, text="Quitter", bg="white", activebackground="black", borderwidth=10, width=10, command = fextension.destroy ))
    
    if (Jeu.aDesExtensions(idJeu)==False):
        Label(fextension, text="Pas d'extension", bg="white", width=25).grid(row=2)
    else:
        Label(fextension, text="Nom Extension", bg="red", width=30).grid(row=2, column=2) #affiche "Nom Extension" au dessus des noms
        Label(fextension, text="Nom Jeu", bg="red", width=30).grid(row=2, column=1)
        j = Jeu.getExtensions(idJeu)
        k=3
        for i in j:
            Label(fextension, text=str(Extension.getNomExtension(i[0])), bg="white", width=25).grid(row=k, column=2)
            Label(fextension, text=str(Jeu.getNomJeu(Extension.getIdJeu(i[0]))), bg="white", width=25).grid(row=k, column=1)
            Button(fextension, text="Emprunt", command = partial(lancerEmprunt, i[0]),bg="green", width=13,activebackground="green").grid(row=k, column=4)
            Button(fextension, text="Reserv", command = partial(lancerReserv, i[0]),bg="red", width=13,activebackground="red").grid(row=k, column=5)
            Label(fextension, text="Quantité disponible", bg="red", width=30).grid(row=2, column=3)
            Label(fextension, text=Extension.getNbreTotalExtension(i[0]), bg="white", width=25).grid(row=k,column=3)
            if (modeAdmin):
                Button(fextension, text="Modifier", command = rien, bg="yellow", width=13, activebackground="yellow").grid(row=k, column=6)  
                Button(fextension, text="Supprimer", command=rien, bg="yellow", width=13, activebackground="yellow").grid(row=k, column=7)
            k=k+1
            
    fextension.mainloop()
Example #10
0
def reserver( numJeu,numAdh=0): #idJeu/extension + idAdherent + booléenJeu (Vrai si l'id en param est un Jeu, Faux si c'est une extension
    # + booléenExtension (Par défaut à faux, vrai si on ne réserve qu'UNE extension)
    def CallBackEmprunt(): #Fonction de confirmation DANS la fonction de fenetre.
        if askyesno("Confirmation", "Êtes-vous sûr de vouloir emprunt ce jeu ?"):
            return fResa.quit() #Ferme si "oui"
        else : return

    def retourJeu(numJeu):
        fResa.destroy()
        return ficheJeu(numAdh, numJeu)

    def retourCatalogue():
        fResa.destroy()
        return catalogue()
        
    fResa = Tk()
    fResa.title("Reservation du jeu " + str(Jeu.getNomJeu(numJeu)))
    fResa.grid_columnconfigure(0,weight=1)
    fResa.grid_rowconfigure(20,weight=21)

    p = PanedWindow(fResa, orient = HORIZONTAL, height=100, width=300)
    p.grid(row=1)
    p.add(Label(p, text="Bonjour Pseudo", bg="white", anchor=CENTER, width=20))
    p.add(Button(p, text="Retour au catalogue", bg="orange", activebackground="orange", borderwidth=10, width=20, command= retourCatalogue ))
    p.add(Button(p, text="Retour au jeu", bg="orange", activebackground="orange", borderwidth=10, width=20, command= partial(retourJeu, numJeu)))
    p.add(Button(p, text="Quitter", bg="white", activebackground="black", borderwidth=10, width=10, command = fResa.destroy ))
    
    pd = PanedWindow(fResa, orient = HORIZONTAL, height = 20, width = 400)
    pd.grid(row=2)
    pd.add(Label(pd, text="Date de début : ", anchor=CENTER, width= 20))
    ddd = Spinbox(pd, from_=1, to=31, width= 5)
    ddm = Spinbox(pd, from_=1, to=12, width= 5)
    ddy = Spinbox(pd, from_=2015, to=2017, width= 8)
    pd.add(ddd)
    pd.add(ddm)
    pd.add(ddy)
    

    pt = PanedWindow(fResa, orient = HORIZONTAL, height = 20, width = 400)
    pt.grid(row=3)
    pt.add(Label(pt, text="Date de fin : ", anchor=CENTER, width= 20))
    dfd = Spinbox(pt, from_=1, to=31, width= 5)
    dfm = Spinbox(pt, from_=1, to=12, width= 5)
    dfy = Spinbox(pt, from_=2015, to=2017, width= 8)
    pt.add(dfd)
    pt.add(dfm)
    pt.add(dfy)
    

    Button(fResa, text ="Reserver !", command = CallBackEmprunt).grid(row=4)

    fResa.mainloop()

    donneesEmprunt = [ddd.get(), ddm.get(), ddy.get(), dfd.get(), dfm.get(), dfy.get()]

    fResa.destroy()

    return donneesEmprunt
Example #11
0
def nombre_extensions_Jeu(Jeu):
	""" nombre_extensions: Jeu -> Entier, renvoie le nomrbe d'extension d'un jeu donné. Le jeu doit être dans EnsJeux"""

	if not(has_jeu(Jeu.get_Nom_jeu())):
		cur.execute =(""" SELECT COUNT (Extension_id) FROM EnsExtensions WHERE EnsExtensions.Jeu_id = ?""", (Jeu.get_Jeu_id()))
		result = cur.fetchone()
		return result[0]
	else:
		print "Impossible de récupérer le nombre d'extensions de ce jeu car il n'est pas dans la base"
Example #12
0
    def reinit(self):
        """Modele (modif)-> None
        Change la grille du jeu avec les nouveau paramètres."""

        x, y = self.__eLignes.get(), self.__eColonnes.get()

        if est_entier(x) and est_entier(y):
            self.__fCases.destroy()
            x, y = int(x), int(y)
            self.__jeu = Jeu(x, y)

            self.__fCases = tk.Frame(bd=3, bg="white", relief="sunken")
            self.__cases = self.createGrille(x, y)
            self.__fCases.grid(row=1, column=1, padx=10, pady=10)

            self.reinitLabels()
        else:
            self.__eLignes.delete(0, "end")
            self.__eColonnes.delete(0, "end")
Example #13
0
    def testgenererNoued(self):

        init = Jeu("Hollande", "Obama", contreIa=False)
        """ soit cet arbre,   
        
        
                                        # 5 #
        
                # 3 #                    # 5 #                     # 1 #
                   
                   
        # 12 #  # 10 #  # 3 #     # 5 #  # 8 #  # 10 #     # 1 #  # 11 #  # 12 #      
        
    
        """
        """ lorsqu'on utilise l'AlphaBeta"""

        l = [12, 10, 3, 5, 8, 10, 1, 11, 12]
        a = Arbre(jeu=init, nb=2, j=0, test=l)
        assert a.noeud.meilleurCoup == 1
        assert a.noeud.chiffre == 5
        assert a.noeud.valeurMoyenne == 3
        assert a.noeud.valeurExteme == 1
        """ lorsqu'on utilise pas l'AlphaBeta"""
        a2 = Arbre(jeu=init, nb=2, j=0, test=l, useAB=False)
        assert a2.noeud.meilleurCoup == 1
        assert a2.noeud.chiffre == 5

        assert a.nbNoeud < a2.nbNoeud

        jeu = Jeu("Hollande", " Obama", contreIa=False)

        a = Arbre(jeu=jeu, nb=4, j=0)
        a.printA()

        a1 = Arbre(jeu=jeu, nb=4, j=0, useAB=False)
        a1.printA()
        assert a1.noeud.meilleurCoup == a.noeud.meilleurCoup
        assert a1.noeud.chiffre == a.noeud.chiffre

        assert a.nbNoeud < a1.nbNoeud
Example #14
0
def insert(Jeu):
        """Fonction permettant d'inserer un jeu dans l'ensemble de Jeux
        #Jeu x EnsJeux => EnsJeux
        >>>EnsJeux.insert(Type Jeu)"""
        if not(has_Jeu(Jeu.get_Nom_jeu())):
                try:	
                        cur.execute("""INSERT INTO EnsJeux(Jeu_id,Nom_jeu,Annee,Editeur,AgeMini,NombreJoueurs,Description) VALUES (?, ?, ?, ?, ?, ?, ?)""",jeu_to_table(Jeu))
                        conn.commit()
                        print("Jeu ajoute avec succes !")
                except:
                        print (jeu_to_table(Jeu))
                        print("Erreur lors de l'ajout du jeu")
        else:
                print("Erreur: Un jeu est deja enregistre au meme nom.")        
Example #15
0
    def __init__(self):

        self.jeu = Jeu()
        self.listeBateauJoueur1 = []
        self.screen = turtle.Screen()
        self.screen.title("Bataille Navale")
        self.screen.listen()
        self.screen.onclick(self.getcoords, btn=1)
        self.setScreenSize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT)
        self.setGrille()
        self.setButtons()
        self.start()
        self.boutonC.onclick(self.creerJeu)
        self.screen.listen()
        self.screen.mainloop()
Example #16
0
class Vuegrille:
    def __init__(self):

        self.jeu = Jeu()
        self.listeBateauJoueur1 = []
        self.screen = turtle.Screen()
        self.screen.title("Bataille Navale")
        self.screen.listen()
        self.screen.onclick(self.getcoords, btn=1)
        self.setScreenSize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT)
        self.setGrille()
        self.setButtons()
        self.start()
        self.boutonC.onclick(self.creerJeu)
        self.screen.listen()
        self.screen.mainloop()

    def start(self):

        self.bateau1 = MyTurtles()
        self.bateau1.penup()
        self.bateau1.speed(SPEED)
        self.bateau1.setx(300)
        self.bateau1.sety(200)
        bateauun = ((0, 0),

                    ((0 - 5), (DEFAULT_MARGIN - DEFAULT_MARGIN / 4) / 2),

                    (0, DEFAULT_MARGIN - DEFAULT_MARGIN / 4),

                    ((DEFAULT_MARGIN * 2) - DEFAULT_MARGIN / 2, DEFAULT_MARGIN - DEFAULT_MARGIN / 4),

                    (((DEFAULT_MARGIN * 2) - DEFAULT_MARGIN / 2) + 5, (DEFAULT_MARGIN - DEFAULT_MARGIN / 4) / 2),

                    ((DEFAULT_MARGIN * 2) - DEFAULT_MARGIN / 2, 0))
        turtle.addshape('bateauun', bateauun)
        self.bateau1.shape('bateauun')
        self.bateau1.penup()
        self.bateau1.fillcolor('white')
        self.bateau1.createBateau(2, self.bateau1.getcoords(self.bateau1.xcor(), self.bateau1.ycor()), "Torpilleur")
        self.listeBateauJoueur1.append(self.bateau1.bateau)
        self.bateau1.ondrag(self.bateau1.move)
        self.bateau1.onrelease(self.bateau1.changeOrientation, 3)

        self.bateau2 = MyTurtles()
        self.bateau2.penup()
        self.bateau2.speed(SPEED)
        self.bateau2.setx(250)
        self.bateau2.sety(200)
        bateaudeux = ((0, 0),

                      ((0 - 5), (DEFAULT_MARGIN - DEFAULT_MARGIN / 4) / 2),

                      (0, DEFAULT_MARGIN - DEFAULT_MARGIN / 4),

                      ((DEFAULT_MARGIN * 3) - DEFAULT_MARGIN / 2, DEFAULT_MARGIN - DEFAULT_MARGIN / 4),

                      (((DEFAULT_MARGIN * 3) - DEFAULT_MARGIN / 2) + 5, (DEFAULT_MARGIN - DEFAULT_MARGIN / 4) / 2),

                      ((DEFAULT_MARGIN * 3) - DEFAULT_MARGIN / 2, 0))
        turtle.addshape('bateaudeux', bateaudeux)
        self.bateau2.shape('bateaudeux')
        self.bateau2.fillcolor('red')
        self.bateau2.penup()
        self.bateau2.createBateau(3, self.bateau2.getcoords(self.bateau2.xcor(), self.bateau2.ycor()), "Sous-Marin")
        self.listeBateauJoueur1.append(self.bateau2.bateau)
        self.bateau2.ondrag(self.bateau2.move)
        self.bateau2.onrelease(self.bateau2.changeOrientation, 3)

        self.bateau3 = MyTurtles()
        self.bateau3.penup()
        self.bateau3.speed(SPEED)
        self.bateau3.setx(350)
        self.bateau3.sety(200)
        bateautrois = ((0, 0),

                      ((0 - 5), (DEFAULT_MARGIN - DEFAULT_MARGIN / 4) / 2),

                      (0, DEFAULT_MARGIN - DEFAULT_MARGIN / 4),

                      ((DEFAULT_MARGIN * 3) - DEFAULT_MARGIN / 2, DEFAULT_MARGIN - DEFAULT_MARGIN / 4),

                      (((DEFAULT_MARGIN * 3) - DEFAULT_MARGIN / 2) + 5, (DEFAULT_MARGIN - DEFAULT_MARGIN / 4) / 2),

                      ((DEFAULT_MARGIN * 3) - DEFAULT_MARGIN / 2, 0))
        turtle.addshape('bateautrois', bateautrois)
        self.bateau3.shape('bateautrois')
        self.bateau3.fillcolor('yellow')
        self.bateau3.penup()
        self.bateau3.createBateau(3, self.bateau3.getcoords(self.bateau3.xcor(), self.bateau3.ycor()), "Contre-Torpilleur")
        self.listeBateauJoueur1.append(self.bateau3.bateau)
        self.bateau3.ondrag(self.bateau3.move)
        self.bateau3.onrelease(self.bateau3.changeOrientation, 3)

        self.bateau4 = MyTurtles()
        self.bateau4.penup()
        self.bateau4.speed(SPEED)
        self.bateau4.setx(250)
        self.bateau4.sety(0)
        bateauquatre = ((0, 0),

                      ((0 - 5), (DEFAULT_MARGIN - DEFAULT_MARGIN / 4) / 2),

                      (0, DEFAULT_MARGIN - DEFAULT_MARGIN / 4),

                      ((DEFAULT_MARGIN * 4) - DEFAULT_MARGIN / 2, DEFAULT_MARGIN - DEFAULT_MARGIN / 4),

                      (((DEFAULT_MARGIN * 4) - DEFAULT_MARGIN / 2) + 5, (DEFAULT_MARGIN - DEFAULT_MARGIN / 4) / 2),

                      ((DEFAULT_MARGIN * 4) - DEFAULT_MARGIN / 2, 0))
        turtle.addshape('bateauquatre', bateauquatre)
        self.bateau4.shape('bateauquatre')
        self.bateau4.fillcolor('black')
        self.bateau4.penup()
        self.bateau4.createBateau(4, self.bateau4.getcoords(self.bateau4.xcor(), self.bateau4.ycor()), "Croiseur")
        self.listeBateauJoueur1.append(self.bateau4.bateau)
        self.bateau4.ondrag(self.bateau4.move)
        self.bateau4.onrelease(self.bateau4.changeOrientation, 3)

        self.bateau5 = MyTurtles()
        self.bateau5.penup()
        self.bateau5.speed(SPEED)
        self.bateau5.setx(300)
        self.bateau5.sety(0)
        bateaucinq = ((0, 0),

                      ((0 - 5), (DEFAULT_MARGIN - DEFAULT_MARGIN / 4) / 2),

                      (0, DEFAULT_MARGIN - DEFAULT_MARGIN / 4),

                      ((DEFAULT_MARGIN * 5) - DEFAULT_MARGIN / 2, DEFAULT_MARGIN - DEFAULT_MARGIN / 4),

                      (((DEFAULT_MARGIN * 5) - DEFAULT_MARGIN / 2) + 5, (DEFAULT_MARGIN - DEFAULT_MARGIN / 4) / 2),

                      ((DEFAULT_MARGIN * 5) - DEFAULT_MARGIN / 2, 0))
        turtle.addshape('bateaucinq', bateaucinq)
        self.bateau5.shape('bateaucinq')
        self.bateau5.fillcolor('gray')
        self.bateau5.penup()
        self.bateau5.createBateau(5, self.bateau5.getcoords(self.bateau5.xcor(), self.bateau5.ycor()), "Porte-Avion")
        self.listeBateauJoueur1.append(self.bateau5.bateau)
        self.bateau5.ondrag(self.bateau5.move)
        self.bateau5.onrelease(self.bateau5.changeOrientation, 3)



    def setButtons(self):
        # BOUTON PROTESTER
        self.boutonP = MyTurtles()
        self.boutonP.speed(SPEED)
        self.boutonP.pu()
        self.boutonP.setx(450)
        self.boutonP.sety(-160)
        self.boutonP.pd()
        self.boutonP.pencolor('goldenrod')
        self.boutonP.pensize(5)
        self.boutonP.fillcolor('gray')
        self.boutonP.begin_fill()

        for i in range(2):
            if (i == 1):
                self.boutonP.fd(75)
                self.boutonP.write('Protester', False, 'center', ('Arial', 14, 'bold'))
                self.boutonP.fd(75)
                self.boutonP.right(90)
            else:
                self.boutonP.fd(150)
                self.boutonP.right(90)
            self.boutonP.fd(30)
            self.boutonP.right(90)

        self.boutonP.end_fill()
        self.boutonP.hideturtle()

        # BOUTON ATTAQUER
        boutonA = MyTurtles()
        boutonA.speed(SPEED)
        boutonA.pu()
        boutonA.setx(450)
        boutonA.sety(-80)
        boutonA.pd()
        boutonA.pencolor('goldenrod')
        boutonA.pensize(5)
        boutonA.fillcolor('gray')
        boutonA.begin_fill()

        for i in range(2):
            if (i == 1):
                boutonA.fd(75)
                boutonA.write('Attaquer', False, 'center', ('Arial', 14, 'bold'))
                boutonA.fd(75)
                boutonA.right(90)
            else:
                boutonA.fd(150)
                boutonA.right(90)
            boutonA.fd(30)
            boutonA.right(90)

        boutonA.end_fill()
        boutonA.hideturtle()

        # BOUTON RÉPONSE
        boutonR = MyTurtles()
        boutonR.speed(SPEED)
        boutonR.pu()
        boutonR.setx(450)
        boutonR.sety(0)
        boutonR.pd()
        boutonR.pencolor('goldenrod')
        boutonR.pensize(5)
        boutonR.fillcolor('gray')
        boutonR.begin_fill()

        for i in range(2):
            if (i == 1):
                boutonR.fd(75)
                boutonR.write('Répondre', False, 'center', ('Arial', 14, 'bold'))
                boutonR.fd(75)
                boutonR.right(90)
            else:
                boutonR.fd(150)
                boutonR.right(90)
            boutonR.fd(30)
            boutonR.right(90)

        boutonR.end_fill()
        boutonR.hideturtle()

        # BOUTON COMMENCER
        self.boutonC = MyTurtles()
        self.boutonC.speed(SPEED)
        self.boutonC.pu()
        self.boutonC.setx(450)
        self.boutonC.sety(80)
        self.boutonC.pd()
        self.boutonC.pencolor('goldenrod')
        self.boutonC.pensize(5)
        self.boutonC.fillcolor('gray')
        self.boutonC.begin_fill()

        for i in range(2):
            if (i == 1):
                self.boutonC.fd(75)
                self.boutonC.write('Commencer', False, 'center', ('Arial', 14, 'bold'))
                self.boutonC.fd(75)
                self.boutonC.right(90)
            else:
                self.boutonC.fd(150)
                self.boutonC.right(90)
            self.boutonC.fd(30)
            self.boutonC.right(90)

        self.boutonC.end_fill()
        self.boutonC.shape('square')



    def setScreenSize(self, largeur, hauteur):
        self.screen.setup(largeur, hauteur)
        self.screen.bgpic("ressources/ocean.gif")

    def setGrille(self):
        animationgrille = turtle.Turtle()
        animationgrille.penup()
        animationgrille.speed(SPEED)
        animationgrille.setx(-DEFAULT_SCREEN_WIDTH / 2 + DEFAULT_MARGIN)
        animationgrille.sety(DEFAULT_SCREEN_HEIGHT / 2 - DEFAULT_MARGIN)

        for i in range(2):
            animationgrille.pendown()
            animationgrille.fillcolor('orange')
            animationgrille.begin_fill()
            for i in range(4):
                animationgrille.forward(DEFAULT_MARGIN * Grille.DEFAULT_SIZE)
                animationgrille.right(90)
            animationgrille.end_fill()
            animationgrille.penup()
            animationgrille.setx(-DEFAULT_SCREEN_WIDTH / 2 + 12 * DEFAULT_MARGIN)

        animationgrille.setx(-DEFAULT_SCREEN_WIDTH / 2 + DEFAULT_MARGIN)
        animationgrille.right(90)

        for i in range(Grille.DEFAULT_SIZE + 1):
            animationgrille.pendown()
            animationgrille.forward(DEFAULT_MARGIN * Grille.DEFAULT_SIZE)
            animationgrille.penup()
            animationgrille.sety(DEFAULT_SCREEN_HEIGHT / 2 - DEFAULT_MARGIN)
            animationgrille.setx(animationgrille.xcor() + DEFAULT_MARGIN)

        animationgrille.setx(-DEFAULT_SCREEN_WIDTH / 2 + DEFAULT_MARGIN)
        animationgrille.sety(DEFAULT_SCREEN_HEIGHT / 2 - DEFAULT_MARGIN)
        animationgrille.left(90)
        for i in range(Grille.DEFAULT_SIZE + 1):
            animationgrille.pendown()
            animationgrille.forward(DEFAULT_MARGIN * Grille.DEFAULT_SIZE)
            animationgrille.penup()
            animationgrille.sety(animationgrille.ycor() - DEFAULT_MARGIN)
            animationgrille.setx(-DEFAULT_SCREEN_WIDTH / 2 + DEFAULT_MARGIN)

        animationgrille.penup()
        animationgrille.setx(-DEFAULT_SCREEN_WIDTH / 2 + 12 * DEFAULT_MARGIN)
        animationgrille.sety(DEFAULT_SCREEN_HEIGHT / 2 - DEFAULT_MARGIN)
        animationgrille.right(90)

        for i in range(Grille.DEFAULT_SIZE + 1):
            animationgrille.pendown()
            animationgrille.forward(DEFAULT_MARGIN * Grille.DEFAULT_SIZE)
            animationgrille.penup()
            animationgrille.sety(DEFAULT_SCREEN_HEIGHT / 2 - DEFAULT_MARGIN)
            animationgrille.setx(animationgrille.xcor() + DEFAULT_MARGIN)

        animationgrille.setx(-DEFAULT_SCREEN_WIDTH / 2 + 12 * DEFAULT_MARGIN)
        animationgrille.sety(DEFAULT_SCREEN_HEIGHT / 2 - DEFAULT_MARGIN)
        animationgrille.left(90)
        for i in range(Grille.DEFAULT_SIZE + 1):
            animationgrille.pendown()
            animationgrille.forward(DEFAULT_MARGIN * Grille.DEFAULT_SIZE)
            animationgrille.penup()
            animationgrille.sety(animationgrille.ycor() - DEFAULT_MARGIN)
            animationgrille.setx(-DEFAULT_SCREEN_WIDTH / 2 + 12 * DEFAULT_MARGIN)
        animationgrille.hideturtle()

    def getcoords(self, x, y):
        self.screen.onclick(None, btn=1)
        print(x, y)
        grillex = int((x + (DEFAULT_SCREEN_WIDTH / 2 - DEFAULT_MARGIN)) / DEFAULT_MARGIN)
        grilley = int((y - (DEFAULT_SCREEN_HEIGHT / 2 - DEFAULT_MARGIN)) / (-DEFAULT_MARGIN))

        if (x > -11 * DEFAULT_MARGIN):
            grillex -= 11

        print(grillex, grilley, self.getcorner(x, y))
        self.screen.onclick(self.getcoords, btn=1)
        return grillex, grilley

    def getcorner(self, x, y):
        if x >= 0:
            cornerx = ((int(x / DEFAULT_MARGIN)) * DEFAULT_MARGIN)
        else:
            cornerx = ((int(x / DEFAULT_MARGIN) - 1) * DEFAULT_MARGIN)
        if y >= 0:
            cornery = ((int(y / DEFAULT_MARGIN) + 1) * DEFAULT_MARGIN)
        else:
            cornery = ((int(y / DEFAULT_MARGIN)) * DEFAULT_MARGIN)
        return cornerx, cornery

    def creerJeu(self, x, y):
        self.jeu.start(self.listeBateauJoueur1, self.listeBateauJoueur1)
Example #17
0
import numpy as np
import random
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
from tkinter import *
from Joueur import Joueur
from Croupier import Croupier
from JeuDeCarte import JeuDeCarte
from Jeu import Jeu
#from Interface import *
import django

if __name__ == "__main__":
    pass

    partie = Jeu()
    # fenetre = Tk()
    # fenetre.title("BlackJack")
    # fenetre.minsize(640,480)
    # fenetre.geometry("800x600+300+150")
    # label1 = Label(fenetre,text = "coucou")
    # label1.pack()

    # fenetre.mainloop()

    #interface = Interface(fenetre)

    #interface.mainloop()
    #interface.destroy()

    partie.jeu()
Example #18
0
class Modele:
    """[TKINTER] Gère l'interface d'une instance de Jeu.
    """

    def __init__(self):
        """Modele -> Modele
        Initialise l'interface et la loop du programme."""

        self.__master = tk.Tk()
        self.__master.title("Le jeu de la vie")
        self.__master.resizable(width=False, height=False)
        
        self.__jeu = Jeu(TX, TY)
        self.__time = TIME

        # UI
        fUI = tk.Frame()

        self.__lGen = tk.Label(fUI, text="GEN : 0", font=("Arial", 15))
        self.__lGen.pack()

        # Inputs
        fInputs = tk.Frame(fUI, bd=3, relief="sunken")

        self.__eNbCells = tk.Entry(fInputs, width="10", justify="center")
        self.__eNbCells.pack(pady=5)

        self.__bAlea = tk.Button(fInputs, text="Générer", width=BUTWIDTH,
                command=self.genAlea)
        self.__bAlea.pack(pady=5)

        fSep = tk.Frame(fInputs, bd=1, height=2, relief="sunken")
        fSep.pack(pady=10, fill="x")

        lLignes = tk.Label(fInputs, text="Lignes :")
        lLignes.pack()

        self.__eLignes = tk.Entry(fInputs, width=10, justify="center")
        self.__eLignes.pack()

        lLignes = tk.Label(fInputs, text="Colonnes :")
        lLignes.pack()

        self.__eColonnes = tk.Entry(fInputs, width=10, justify="center")
        self.__eColonnes.pack()

        self.__bReinit = tk.Button(fInputs, text="Modifier", width=BUTWIDTH,
                command=self.reinit)
        self.__bReinit.pack(pady=5)

        fInputs.pack(pady=5)
        # # #

        self.__lStable = tk.Label(fUI, text="N/A", padx=5, font=("Arial", 12), fg="orange")
        self.__lStable.pack(pady=15)


        # Timer
        fTimer = tk.Frame(fUI, bd=3, relief="sunken")

        self.__bSuiv = tk.Button(fTimer, text="Suivant", width=BUTWIDTH, command=self.suivant)
        self.__bSuiv.pack(pady=5)

        lTimer = tk.Label(fTimer, text="Timer :\n[5 ; 5000]")
        lTimer.pack()

        self.__eTimer = tk.Entry(fTimer, width=10, justify="center")
        self.__eTimer.pack()

        bTimer = tk.Button(fTimer, text="Changer", width=BUTWIDTH,
                command=self.changeTimer)
        bTimer.pack(pady=5)

        fTimer.pack(pady=5)
        # # #

        fUI.grid(row=1, column=0, rowspan=2)
        # # #

        # Start, Stop, Clear

        fButtons = tk.Frame(bd=2, relief="sunken")

        self.__bStart = tk.Button(fButtons, text="Start", width=BUTWIDTH,
                command=self.start)
        self.__bStart.grid(row=0, column=1, padx=5, pady=3)

        self.__bStop = tk.Button(fButtons, text="Stop", width=BUTWIDTH, state="disabled",
                command=self.stop)
        self.__bStop.grid(row=0, column=2, padx=5, pady=3)

        self.__bClear = tk.Button(fButtons, text="Clear", width=BUTWIDTH, command=self.clear)
        self.__bClear.grid(row=0, column=3, padx=5, pady=3)

        fButtons.grid(row=0, column=1, pady=5)
        # # #

        # Cases
        self.__fCases = tk.Frame(bd=3, bg="white", relief="sunken")
        self.__cases = self.createGrille(TX, TY)
        self.__fCases.grid(row=1, column=1, padx=10, pady=10)
        # # #

        self.__master.mainloop()

    def controllerClickCase(self, x, y):
        """Modele (modif), int, int -> function
        Renvoie la fonction 'clickCase' pour les coordonnées (x, y)."""

        def clickCase():
            """None -> None
            Change l'état de la cellule (x, y)."""

            color = ""
            if self.__jeu.etat(x, y) == False:
                self.__jeu.changeEtat(x, y, True)
                color = "black"
            else:
                self.__jeu.changeEtat(x, y, False)
                color = "white"
            
            self.__cases[x][y].configure(bg=color)
            
            self.reinitLabels()
            self.stopState()

        return clickCase

    def metAJour(self):
        """Modele (modif) -> None
        Met à jour l'interface."""

        for i in range(self.__jeu.tx()):
            for j in range(self.__jeu.ty()):
                if self.__jeu.etat(i, j):
                    self.__cases[i][j].configure(bg="black")
                else:
                    self.__cases[i][j].configure(bg="white")

    def clear(self):
        """Modele (modif) -> None
        Tue toutes les cellules."""

        if self.__jeu.nb_viv() != 0:
            for i in range(self.__jeu.tx()):
                for j in range(self.__jeu.ty()):
                    self.__jeu.changeEtat(i, j, False)
                    self.__cases[i][j].configure(bg="white")

            self.clearState()

    def suivant(self):
        """Modele (modif) -> None
        Passe à la génération suivante."""

        self.__jeu.etapeSuivante()
        
        if (self.__jeu.stable()):
            self.__lStable.configure(text="STABLE", fg="green")
            self.__lGen.configure(fg="green")
            self.__bSuiv.configure(state="disabled")
            self.__bReinit.configure(state="normal")
            self.__start = False

            if self.__jeu.nb_viv() != 0:
                self.__bStart.configure(state="disabled")
                self.__bStop.configure(state="disabled")
                self.__bClear.configure(state="normal")

            self.disableButtons(False)
        else:
            self.__lStable.configure(text="PAS STABLE", fg="red")
            self.__lGen.configure(text="GEN : " + str(self.__jeu.gen()), fg="red")

        self.metAJour()

        if (self.__start):
            self.__master.after(self.__time, self.suivant)

    def createGrille(self, tx, ty):
        """Modele, int, int -> list(list(Button))
        Renvoie une grille de bouttons."""

        cases = []
        for i in range(tx):
            ligne = []
            for j in range(ty):
                btn = tk.Button(self.__fCases, bg="white", relief="flat", bd=0,
                        command=self.controllerClickCase(i, j))
                btn.grid(row=i, column=j)
                ligne.append(btn)
            cases.append(ligne)
        
        return cases

    def reinit(self):
        """Modele (modif)-> None
        Change la grille du jeu avec les nouveau paramètres."""

        x, y = self.__eLignes.get(), self.__eColonnes.get()

        if est_entier(x) and est_entier(y):
            self.__fCases.destroy()
            x, y = int(x), int(y)
            self.__jeu = Jeu(x, y)

            self.__fCases = tk.Frame(bd=3, bg="white", relief="sunken")
            self.__cases = self.createGrille(x, y)
            self.__fCases.grid(row=1, column=1, padx=10, pady=10)

            self.reinitLabels()
        else:
            self.__eLignes.delete(0, "end")
            self.__eColonnes.delete(0, "end")

    def start(self):
        """Modele -> None
        Lance l'éxecution du jeu."""

        self.__start = True
        self.__bSuiv.invoke()

        if not self.__jeu.stable():
            self.startState()

    def stop(self):
        """Modele -> None
        Arrête l'éxecution du jeu."""
        
        self.__start = False
        self.stopState()
       
    def startState(self):
        """Modele (modif) -> None
        Affecte un état adapté aux boutons lorsque le jeu est en éxecution."""

        self.__bSuiv.configure(state="disabled")
        self.__bClear.configure(state="disabled")
        self.__bStart.configure(state="disabled")
        self.__bReinit.configure(state="disabled")
        self.__bStop.configure(state="normal")
        self.__bAlea.configure(state="disabled")
        self.disableButtons(True)

    def stopState(self):
        """Modele (modif) -> None
        Affecte un état adapté aux boutons lorsque le jeu n'est plus en éxecution."""

        self.__bStop.configure(state="disabled")
        self.__bSuiv.configure(state="normal")
        self.__bStart.configure(state="normal")
        self.__bClear.configure(state="normal")
        self.__bReinit.configure(state="normal")
        self.__bAlea.configure(state="normal")
        self.disableButtons(False)

    def clearState(self):
        """Modele (modif) -> None
        Affecte un état adapté aux boutons lorsque le jeu n'est plus en éxecution."""

        self.__lStable.configure(text="N/A", fg="orange")
        self.__lGen.configure(text="GEN : 0", fg="black")
        self.__bStart.configure(state="normal")
        self.__bStop.configure(state="disabled")
        self.__bSuiv.configure(state="normal")
        self.__bReinit.configure(state="normal")
        self.__bAlea.configure(state="normal")

    def reinitLabels(self):
        """Modele (modif) -> None
        Réinitialise le texte des labels."""

        self.__jeu.resetGen()
        self.__lGen.configure(text="GEN : 0", fg="black")
        self.__lStable.configure(text="N/A", fg="orange")

    def disableButtons(self, val):
        """Modele (modif), bool -> None
        Change l'état des bouttons."""

        s = "disabled"
        if (not val):
            s = "normal"

        for i in range(self.__jeu.tx()):
            for j in range(self.__jeu.ty()):
                self.__cases[i][j].configure(state=s)

    def changeTimer(self):
        """Modele -> None
        Change la valeur du timer."""

        t = self.__eTimer.get()
        if (est_entier(t) and 5 <= int(t) <= 5000):
            self.__time = int(t)
        else:
            self.__eTimer.delete(0, "end")

    def genAlea(self):
        """Modele (modif) -> None
        Génère aléatoirement un ensemble de cellules vivantes."""

        n = self.__eNbCells.get()
        if est_entier(n) and 1 <= int(n) <= (self.__jeu.tx() * self.__jeu.ty()) - self.__jeu.nb_viv():
            self.__jeu.placeVCelsRandom(int(n))
            self.metAJour()
            self.reinitLabels()
        else:
            self.__eNbCells.delete(0, "end")
Example #19
0
def formulaireExt(idExt = -1, idJeu = 0): #Par défaut, idExt =-1 => creation
    """Prend l'id d'une extension pour la modifier, ou -1 pour en creer une nouvelle"""
    
    FE = Tk()
    FE.title("Formulaire d'extension")
    FE.wm_attributes("-topmost" , -1) #Mets la fenetre au premier plan dès son apparition.
    idE = IntVar()
    idE.set(idExt)
    Creation = BooleanVar()            #Les variables declarée comme ceci semble être utilisable pour les fonctions imbriqué de Tkinter
    Creation.set(False)
    idJ = IntVar()
    idJ.set(idJeu)
    if idE.get() < 0 : #Cas de creation du Ext, valeur par defaut.
        NomJeuE = Jeu.getNomJeu(idJeu)
        nomE="Nom de l'extension"
        quantiteE=0
        Creation.set(True)
    else : #Extension existant, recuperation, des infos
        NomJeuE = Jeu.getNomJeu(idJeu)
        nomE=Extension.getNomExt(idE.get())
        quantiteE=Ext.getQuantiteExt(idE.get())
    
    def submit(): #Fonction de confirmation DANS la fonction de fenetre.
        if askyesno("Confirmation", "Enregister L'extension ?"):
            FE.quit()
            if Creation.get():
                Extension.ajoutExtension(idJ.get(),nomExt.get(),quantiteExt.get())
            else :
                Extension.setNomExt(idE.get(),nomExt.get())
                Ext.setQuantiteExt(idE.get(),quantiteExt.get())
            return FE.destroy() #Ferme après avoir enregistre.
        else : return

    def cancel(): #Ferme la fenetre
        if askyesno("Quitter", "Annuler le formulaire ?"):
            FE.quit() #Ferme la fenetre
            return FE.destroy() #N'enregistre rien
        else : return
    T1 = LabelFrame(FE, text="Formulaire de l'extension :")
    NJE = Label(FE, text="Nom du jeu de l'extension :")
    NE = Label(FE, text="Nom de l'extension :")
    QE = Label(FE, text="Nombre d'exemplaire total de l'extension :")
    AddE = Label(FE, text="Ajouter l'extension :")
    #Titre
    T1.pack()
    #Nom du jeu (recupère l'id du jeu dans la liste)
    NJE.pack()
    NomJeu = Label(FE, text =Jeu.getNomJeu(idJeu))
    NomJeu.pack() 
    #Nom de l'extension (champs à remplir)
    NE.pack()
    nomExt = StringVar()
    nomExt.set(nomE)
    NEI = Entry(FE,textvariable=nomExt,width=40)
    NEI.pack()
    #Quantite d'exemplaire de l'extension (gradutation)
    QE.pack()
    quantiteExt = IntVar()
    quantiteExt.set(quantiteE)
    QEI = Spinbox(FE, from_=0, to=999, textvariable=quantiteExt)
    QEI.pack()
    #Fin : Confirmation de l'ajout/modification du extension, appel de la fonction submit (sans parenthèses)
    AddE.pack()
    AddEI = Button(FE, text="Confirmer", command = submit)
    AddEI.pack()
    #Fin : Annulation.(marche pas encore)
    Cancel = Button(FE, text="Annuler", command = cancel)
    Cancel.pack()
    #Lancement de la fenetre
    FE.mainloop()
Example #20
0
 def lancerExtension(i, mode):
     fcatalogue.destroy()
     return afficheExtensions(i, mode)
     
     return catalogue(n, Jeu.getJeuByNom(r), ma)
Example #21
0
from Jeu import Jeu
from JoueurAlea import *

# Let's play

jeu = Jeu(True)  # type: Jeu
jeu.ajouterJoueur(JoueurAlea())
jeu.ajouterJoueur(JoueurAlea())
jeu.ajouterJoueur(JoueurAlea())
jeu.jouerPartie()
Example #22
0
from tkinter import *
from tkinter.messagebox import *
from Jeu import Jeu

#Configuration de la fenêtre
fenetre = Tk()
fenetre.config(bg="beige")
fenetre.title("Zombies !")
fenetre.resizable(width=FALSE, height=FALSE)
fenetre.geometry("672x672")  #32 pixels fois 21 cases
jeu = Jeu(fenetre)


def chargerNiveau(niveau):  #Charge le niveau
    jeu.afficher(niveau)


def recommencer():  #Recomence le niveau
    jeu.recommencer()


def quitter():  #Ferme la fenêtre
    fenetre.destroy()


def aideEditeur():
    texte = "Clic gauche pour poser un objet\nClic droit pour détruire un bloc\n\n"
    texte += "Pavé numérique:\n1 : Selectionner Mur\n2 : Selectionner Zombie\n3 : Selectionner Bouton\n4 : Selectionner Porte\n5 : Selectionner Drapeau\n\n"
    texte += "Il est impossible de supprimer un zombie ou une porte"
    showinfo("Aide Editeur", texte)
Example #23
0
def update(Jeu):
        """ Fonction permettant d'actualiser les infos d'un jeu dans l'ensemble de Jeux"""
        # A FAIRE !(Nom_jeu,Annee,Editeur,AgeMini,NombreJoueurs,Description,Categorie_id)
        try:
                cur.execute("""UPDATE EnsJeux SET Nom_jeu=?,Annee=?,Editeur=?,AgeMini=?,NombreJoueurs=?,Description=?,Categorie_id=? WHERE Jeu_id=?""", (Jeu.get_Nom_jeu(),Jeu.get_Annee(),Jeu.get_Editeur(),Jeu.get_AgeMini(),Jeu.get_NombreJoueurs(),Jeu.get_Description(),Jeu.get_Categorie_id(),Jeu.get_Jeu_id()))
                conn.commit()
                print ("Le jeu a bien été modifié !")
        except:
                print ("La modification du jeu à échouée")
                raise
Example #24
0
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 18 11:37:38 2017

@author: Maurelle Gohep
"""
from Jeu import Jeu
from Noeud import Arbre, Noeud
from Plateau import Plateau

if __name__ == "__main__":

    jeu = Jeu("jeanClaude", " obama", True)
    jeu.printC()
    i = 0
    while i == 0:
        jeu.jouerAuto()
        jeu.printC()

        if jeu.verifiewin(0):
            print(jeu.joueur1.nom + " à gagné")
            i = 1
        elif jeu.verifiewin(1):
            print(jeu.joueur2.nom + " à gagné")
            i = 1
        print("////////////////////////")

#     eurC=a.noeud.meilleurCoup
#     print(str(a.nbNoeud) + " feuills on été calculés. L'Ia a noté la grille à "+ str(a.noeud.chiffre))
#     print(jeu.printC())
#
Example #25
0
            self.on = False
            return True

        return False


if __name__ == '__main__':

    pygame.init()
    screen = pygame.display.set_mode((1280, 720))
    done = False
    c = pygame.time.Clock()
    bgg = pygame.image.load("img/wood.jpg")
    awa = pygame.image.load("img/awa.png")

    jeu = Jeu("Hollande", " Obama", contreIa=True)

    myfont = pygame.font.SysFont("monospace", 50)

    mouse = Mouse()

    while not done:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                done = True

        screen.blit(bgg, (0, 0))
        screen.blit(awa, (150, 150))
        jeu.printG(myfont, screen)

        if mouse.check():
Example #26
0
 def submit(): #Fonction de confirmation DANS la fonction de fenetre.
     if askyesno("Confirmation", "Enregister le jeu ?"):
         FJ.quit()
         if Creation.get():
             idJ.set(Jeu.ajoutJeu(nomJeu.get(),anneeJeu.get(),editeurJeu.get()))
         Jeu.setNomJeu(idJ.get(),nomJeu.get())
         Jeu.setAnneeJeu(idJ.get(),anneeJeu.get())
         Jeu.setAgeJeu(idJ.get(),ageJeu.
                       get())
         Jeu.setNbJoueurJeu(idJ.get(),nbJoueurJeu.get())
         Jeu.setQuantiteJeu(idJ.get(),quantiteJeu.get())
         Jeu.setAuteurJeu(idJ.get(),auteurJeu.get())
         Jeu.setIllustrateurJeu(idJ.get(),illustrateurJeu.get())
         Jeu.setEditeurJeu(idJ.get(),editeurJeu.get())
         Jeu.setEmpruntable(idJ.get(),Empbool.get())
         Jeu.setSynopsisJeu(idJ.get(),synopsisJeu.get())
         return FJ.destroy() #Ferme après avoir enregistre.
     else : return
Example #27
0
def catalogue(numAdherent=0, Jeux=Jeu.getAllJeu(), modeAdmin=False): #idAdherent
    def maj():
        # on arrive ici toutes les 1000 ms
        t=datetime.datetime.today()
        heure.set(t.strftime('%m/%d/%Y  %H:%M:%S'))
        fcatalogue.after(1000,maj)

    def retourMenu():
        fcatalogue.destroy()
        return menu(numAdherent)

    def afficheFicheJeu(i):
        fcatalogue.destroy()
        return ficheJeu(numAdherent, i)
    
    def lancerEmprunt(i):
        fcatalogue.destroy()
        return formulaireEmprunt(i)

    def lancerReserv(i):
        fcatalogue.destroy()
        return reserver(i)

    def lanceCatalogue(n, ma):
        r = entryRecherche.get()
        fcatalogue.destroy()

    def lancerExtension(i, mode):
        fcatalogue.destroy()
        return afficheExtensions(i, mode)
        
        return catalogue(n, Jeu.getJeuByNom(r), ma)

    def afficheJeu(n, Jeux, k=0):
        n[0]=n[0]+k
        r = n[2]-n[1]
        if (r>20): r=20
        if (n[0]<n[1]):
            n[0]=n[1]
        if (n[0]+r>n[2]):
            n[0]=n[2]-r
        j=3
        
        for i in range(n[0],n[0]+r):
            Label(fcatalogue, text=str(Jeux[i][1]), bg="orange", width = 25).grid(row=j, column=1)
            Label(fcatalogue, text=str(Jeux[i][2]), bg="orange", width = 10).grid(row=j, column=2)
            Label(fcatalogue, text=str(Jeux[i][3]), bg="orange", width = 10).grid(row=j, column=3)
            Label(fcatalogue, text=str(Jeux[i][4]), bg="orange", width = 10).grid(row=j, column=4)
            Label(fcatalogue, text=str(Jeux[i][5]), bg="orange", width = 15).grid(row=j, column=5)
            Label(fcatalogue, text=str(Jeux[i][6]), bg="orange", width = 15).grid(row=j, column=6)
            Label(fcatalogue, text=str(Jeux[i][7]), bg="orange", width = 15).grid(row=j, column=7)
            Label(fcatalogue, text=str(Jeux[i][8]), bg="orange", width = 15).grid(row=j, column=8)
            if (modeAdmin):
                Button(fcatalogue, text="Modifier", command = rien,bg="blue", width=13,activebackground="blue").grid(row=j, column=9) #partial(formulaireJeu,Jeux[i][0])
                Button(fcatalogue, text="Créer extension", command = partial(formulaireExt, -1, Jeux[i][0]),bg="cyan", width=13,activebackground="cyan").grid(row=j, column=14)
            else:
                Button(fcatalogue, text="Détail", command = partial(afficheFicheJeu,Jeux[i][0]) ,bg="blue", width=13,activebackground="blue").grid(row=j, column=9)
                
            if (Jeu.aDesExtensions(Jeux[i][0])):
                Button(fcatalogue, text="Extensions", command = partial(lancerExtension, Jeux[i][0], modeAdmin),bg="red", width=13,activebackground="red").grid(row=j, column=10)
            Button(fcatalogue, text="Emprunt", command = partial(lancerEmprunt, Jeux[i][0]),bg="green", width=13,activebackground="green").grid(row=j, column=11)
            Button(fcatalogue, text="Reserv", command = partial(lancerReserv, Jeux[i][0]),bg="red", width=13,activebackground="red").grid(row=j, column=12)
            if (modeAdmin):
                Button(fcatalogue, text="Supprimer", command = rien,bg="yellow", width=13,activebackground="red").grid(row=j, column=13)
            j=j+1

    
    fcatalogue = Tk()
    fcatalogue.title("Les jeux de la ludothèque")
    fcatalogue.grid_columnconfigure(0,weight=1)
    fcatalogue.grid_rowconfigure(20,weight=21)
    
    p = PanedWindow(fcatalogue, orient = HORIZONTAL, height=100, width=1000)
    p.grid(row=1, column=1, columnspan=11)
     
    heure = StringVar()
    p.add(Label(p, textvariable=heure, bg="red", anchor=CENTER,width=30))
    maj()

    rech=StringVar()
    rech.set("Faites une recherche ici !")

    entryRecherche = Entry(p, textvariable=rech, width = 30)
    p.add(entryRecherche)
    p.add(Button(p, text="Recherchez !", bg="orange", activebackground="orange", borderwidth=10, width=10, command= partial(lanceCatalogue,numAdherent,modeAdmin)))
    
    p.add(Label(p, text="Bonjour "+Adherent.getPseudo(numAdherent), bg="white", anchor=CENTER, width=10))
    if (modeAdmin):
        p.add(Button(p, text="Ajouter un jeu", bg="cyan", activebackground="cyan", borderwidth=10, width=10, command= rien))#partial(formulaireJeu,numAdh)))
    p.add(Button(p, text="Retour au menu principal", bg="orange", activebackground="orange", borderwidth=10, width=10, command= retourMenu ))
    p.add(Button(p, text="Quitter", bg="white", activebackground="black", borderwidth=10, width=10, command = fcatalogue.destroy ))

    Label(fcatalogue, text="Nom", bg="green", width = 23).grid(row=2, column=1)
    Label(fcatalogue, text="Année", bg="green", width = 8).grid(row=2, column=2)
    Label(fcatalogue, text="Age Min.", bg="green", width = 8).grid(row=2, column=3)
    Label(fcatalogue, text="Nb Joueur", bg="green", width = 8).grid(row=2, column=4)
    Label(fcatalogue, text="Disponibilité", bg="green", width = 13).grid(row=2, column=5)
    Label(fcatalogue, text="Auteur", bg="green", width = 13).grid(row=2, column=6)
    Label(fcatalogue, text="Illustrateur", bg="green", width = 15).grid(row=2, column=7)
    Label(fcatalogue, text="Editeur", bg="green", width = 13).grid(row=2, column=8)
    if (modeAdmin):
        Label(fcatalogue, text="Que faire ?", bg="green", width = 73).grid(row=2, column=9, columnspan=5)
    else:
        Label(fcatalogue, text="Que faire ?", bg="green", width = 73).grid(row=2, column=9, columnspan=4)

    numJeu=[0,0,len(Jeux)]
    flecheH = Button(fcatalogue, text="^", command = partial(afficheJeu, numJeu, Jeux, -20), bg="blue", width=5,activebackground="blue").grid(row=3, column=14)
    flecheB = Button(fcatalogue, text="v", command = partial(afficheJeu, numJeu, Jeux, 20), bg="blue", width=5,activebackground="blue").grid(row=22, column=14)
    afficheJeu(numJeu, Jeux)
    
        
    fcatalogue.mainloop()
Example #28
0
 def jeu(self):
     # Affichage du jeu
     self._initialiser()
     self.ecran = Jeu(self, self.config, self.vaisseau, self.listBullet,
                      app, self.groupeGlobal)
Example #29
0
def jeu_to_table(Jeu):
        # User -> List
        JeuTable=(Jeu.get_Jeu_id(),Jeu.get_Nom_jeu(),Jeu.get_Annee(),Jeu.get_Editeur(),Jeu.get_AgeMini(),Jeu.get_NombreJoueurs(),Jeu.get_Description(),Jeu.get_Categorie_id())
        return JeuTable
Example #30
0
from Case import Case
from Creature import Creature
from Jeu import Jeu

plateau_4x4 = [Case(x, y) for x in range(4) for y in range(4)]
mage = Creature("Mage noir", Case(0, 0))
scaven = Creature("Scaven", Case(3, 3))
listes_creatures = [mage, scaven]

print("++ PLATEAU DE CREATURES ++")
for x in range(4):
    for y in range(4):
        if scaven.position.x == x and scaven.position.y == y:
            print(" S ", end="")
        elif mage.position.x == x and mage.position.y == y:
            print(" M ", end="")
        else:
            print(" . ", end="")
    print()

print("++ PLATEAU DE CREATUREs ++")
print()
jeu = Jeu(plateau_4x4, listes_creatures)

while jeu.continuerJeu:
    jeu._set_actif(mage)
    mage.choisirCible(jeu)
    jeu._set_actif(scaven)
    scaven.choisirCible(jeu)
Example #31
0
def formulaireJeu(idJeu = -1): #Par défaut, -1 = creation
    """Prend l'id d'un jeu pour le modifier, ou -1 pour en creer un nouveau"""
    FJ = Tk()
    FJ.wm_attributes("-topmost" , -1) #Mets la fenetre au premier plan dès son apparition.
    idJ = IntVar()
    idJ.set(idJeu)
    Creation = BooleanVar()            #Les variables declarée comme ceci semble être utilisable pour les fonctions imbriqué de Tkinter
    Creation.set(False)
    if idJ.get() < 0 : #Cas de creation du jeu, valeur par defaut
        nomJ="Nom du jeu"
        anneeJ=1960
        ageJ=0
        nbJoueurJ="00-00"
        quantiteJ=0
        auteurJ="Auteur du jeu"
        illustrateurJ="Illustrateur du jeu"
        editeurJ="Editeur du jeu"
        estEmpruntableJ=False
        synopsisJ="Description sommaire du jeu."
        Creation.set(True)
    else : #Jeu existant, recuperation, des infos
        nomJ=Jeu.getNomJeu(idJ.get())
        anneeJ=Jeu.getAnneeJeu(idJ.get())
        ageJ=Jeu.getAgeJeu(idJ.get())
        nbJoueurJ=Jeu.getNbJoueurJeu(idJ.get())
        quantiteJ=Jeu.getQuantiteJeu(idJ.get())
        auteurJ=Jeu.getAuteurJeu(idJ.get())
        illustrateurJ=Jeu.getIllustrateurJeu(idJ.get())
        editeurJ=Jeu.getEditeurJeu(idJ.get())
        estEmpruntableJ=Jeu.estEmpruntable(idJ.get())
        synopsisJ=Jeu.getSynopsisJeu(idJ.get())

    def submit(): #Fonction de confirmation DANS la fonction de fenetre.
        if askyesno("Confirmation", "Enregister le jeu ?"):
            FJ.quit()
            if Creation.get():
                idJ.set(Jeu.ajoutJeu(nomJeu.get(),anneeJeu.get(),editeurJeu.get()))
            Jeu.setNomJeu(idJ.get(),nomJeu.get())
            Jeu.setAnneeJeu(idJ.get(),anneeJeu.get())
            Jeu.setAgeJeu(idJ.get(),ageJeu.
                          get())
            Jeu.setNbJoueurJeu(idJ.get(),nbJoueurJeu.get())
            Jeu.setQuantiteJeu(idJ.get(),quantiteJeu.get())
            Jeu.setAuteurJeu(idJ.get(),auteurJeu.get())
            Jeu.setIllustrateurJeu(idJ.get(),illustrateurJeu.get())
            Jeu.setEditeurJeu(idJ.get(),editeurJeu.get())
            Jeu.setEmpruntable(idJ.get(),Empbool.get())
            Jeu.setSynopsisJeu(idJ.get(),synopsisJeu.get())
            return FJ.destroy() #Ferme après avoir enregistre.
        else : return

    def cancel(): #Ferme la fenetre
        if askyesno("Quitter", "Annuler le formulaire ?"):
            FJ.quit() #Ferme la fenetre
            return FJ.destroy() #N'enregistre rien
        else : return
    T1 = LabelFrame(FJ, text="Formulaire de jeu :")
    NJ = Label(FJ, text="Nom du jeu :")
    AnJ = Label(FJ, text="Année de sortie du jeu :")
    AgJ = Label(FJ, text="Ages du public du jeu :")
    NbJ = Label(FJ, text="Nombre de joueur pour ce jeu($$-$$) :")
    QJ = Label(FJ, text="Nombre d'exemplaire total du jeu :")
    AJ = Label(FJ, text="Auteur du jeu :")
    IJ = Label(FJ, text="Illustrateur du jeu :")
    EJ = Label(FJ, text="Editeur du jeu :")
    Emp = Label(FJ, text="Ce jeu peut-etre Emprunté :")
    SJ =Label(FJ, text="Description du jeu (200caractères) :")
    AddJ = Label(FJ, text="Ajouter le jeu :")
    #Titre
    T1.pack()
    #Nom du jeu (champs à remplir)
    NJ.pack()
    nomJeu = StringVar()
    nomJeu.set(nomJ)
    NJI = Entry(FJ,textvariable=nomJeu,width=40)
    NJI.pack()
    #Annee Jeu (graduation)
    AnJ.pack()
    anneeJeu = IntVar()
    anneeJeu.set(anneeJ)
    AnJI = Spinbox(FJ, from_=1960, to = date.today().year, textvariable=anneeJeu)
    AnJI.pack()
    #Age joueurs(Champs à remplir)
    AgJ.pack()
    ageJeu=IntVar()
    ageJeu.set(ageJ)
    AgJI = Spinbox(FJ, from_=0, to = 20, textvariable=ageJeu)
    AgJI.pack()
    #Nombre de joueurs (graduation)
    NbJ.pack()
    nbJoueurJeu=StringVar()
    nbJoueurJeu.set(nbJoueurJ)
    NbJI = Entry(FJ, textvariable=nbJoueurJeu, width=45)
    NbJI.pack()
    #Quantite d'exemplaire du jeu (gradutation)
    QJ.pack()
    quantiteJeu = IntVar()
    quantiteJeu.set(quantiteJ)
    QJI = Spinbox(FJ, from_=0, to=999, textvariable=quantiteJeu)
    QJI.pack()
    #Auteur du jeu (champs à remplir)
    AJ.pack()
    auteurJeu=StringVar()
    auteurJeu.set(auteurJ)
    AJI = Entry(FJ, textvariable=auteurJeu, width = 45)
    AJI.pack()
    #Illustrateur du jeu (champs à remplir)
    IJ.pack()
    illustrateurJeu=StringVar()
    illustrateurJeu.set(illustrateurJ)
    IJI = Entry(FJ, textvariable=illustrateurJeu, width = 45)
    IJI.pack()
    #Editeur du jeu (champs à remplir)
    EJ.pack()
    editeurJeu=StringVar()
    editeurJeu.set(editeurJ)
    EJI = Entry(FJ, textvariable=editeurJeu, width = 45)
    EJI.pack()
    #Empruntable ou non ? (case à cocher)
    Emp.pack()
    Empbool = BooleanVar()
    Empbool.set(estEmpruntableJ)
    EmpI = Checkbutton(FJ, text="Est-il empruntable?", variable = Empbool)
    EmpI.pack()
    #Synospis du jeu (Champs à remplir)
    SJ.pack()
    synopsisJeu = StringVar()
    synopsisJeu.set(synopsisJ)
    SJI = Entry(FJ, textvariable=synopsisJeu, width = 45)
    SJI.pack()
    #Fin : Confirmation de l'ajout/modification du jeu, appel de la fonction submit (sans parenthèses)
    AddJ.pack()
    AddJI = Button(FJ, text="Confirmer", command = submit)
    AddJI.pack()
    #Fin : Annulation.(marche pas encore)
    Cancel = Button(FJ, text="Annuler", command = cancel)
    Cancel.pack()
    #Lancement de la fenetre
    FJ.mainloop()
Example #32
0
from Data import pygame, couleurs, width, height, myfont, screen, NOIR
from Raquette import Raquette
from Jeu import Jeu

pygame.display.set_caption("Ping")

# Pour limiter le nombre d'images par seconde
clock = pygame.time.Clock()

jeu = Jeu(1, 2)
jeu.mise_a_jour()

while True:
    if jeu.perdu:
        jeu.ecran_fin("Vous avez perdu")
    elif jeu.all_dead:
        jeu.ecran_fin("Vous avez gagné")
    else:
        jeu.gestion_evenements()
        jeu.mise_a_jour()
        jeu.affichage()

    pygame.display.flip()  # envoie de l'image à la carte graphique
    clock.tick(60)  # on attend pour ne pas dépasser 60 images/seconde
Example #33
0
    def __init__(self):
        """Modele -> Modele
        Initialise l'interface et la loop du programme."""

        self.__master = tk.Tk()
        self.__master.title("Le jeu de la vie")
        self.__master.resizable(width=False, height=False)
        
        self.__jeu = Jeu(TX, TY)
        self.__time = TIME

        # UI
        fUI = tk.Frame()

        self.__lGen = tk.Label(fUI, text="GEN : 0", font=("Arial", 15))
        self.__lGen.pack()

        # Inputs
        fInputs = tk.Frame(fUI, bd=3, relief="sunken")

        self.__eNbCells = tk.Entry(fInputs, width="10", justify="center")
        self.__eNbCells.pack(pady=5)

        self.__bAlea = tk.Button(fInputs, text="Générer", width=BUTWIDTH,
                command=self.genAlea)
        self.__bAlea.pack(pady=5)

        fSep = tk.Frame(fInputs, bd=1, height=2, relief="sunken")
        fSep.pack(pady=10, fill="x")

        lLignes = tk.Label(fInputs, text="Lignes :")
        lLignes.pack()

        self.__eLignes = tk.Entry(fInputs, width=10, justify="center")
        self.__eLignes.pack()

        lLignes = tk.Label(fInputs, text="Colonnes :")
        lLignes.pack()

        self.__eColonnes = tk.Entry(fInputs, width=10, justify="center")
        self.__eColonnes.pack()

        self.__bReinit = tk.Button(fInputs, text="Modifier", width=BUTWIDTH,
                command=self.reinit)
        self.__bReinit.pack(pady=5)

        fInputs.pack(pady=5)
        # # #

        self.__lStable = tk.Label(fUI, text="N/A", padx=5, font=("Arial", 12), fg="orange")
        self.__lStable.pack(pady=15)


        # Timer
        fTimer = tk.Frame(fUI, bd=3, relief="sunken")

        self.__bSuiv = tk.Button(fTimer, text="Suivant", width=BUTWIDTH, command=self.suivant)
        self.__bSuiv.pack(pady=5)

        lTimer = tk.Label(fTimer, text="Timer :\n[5 ; 5000]")
        lTimer.pack()

        self.__eTimer = tk.Entry(fTimer, width=10, justify="center")
        self.__eTimer.pack()

        bTimer = tk.Button(fTimer, text="Changer", width=BUTWIDTH,
                command=self.changeTimer)
        bTimer.pack(pady=5)

        fTimer.pack(pady=5)
        # # #

        fUI.grid(row=1, column=0, rowspan=2)
        # # #

        # Start, Stop, Clear

        fButtons = tk.Frame(bd=2, relief="sunken")

        self.__bStart = tk.Button(fButtons, text="Start", width=BUTWIDTH,
                command=self.start)
        self.__bStart.grid(row=0, column=1, padx=5, pady=3)

        self.__bStop = tk.Button(fButtons, text="Stop", width=BUTWIDTH, state="disabled",
                command=self.stop)
        self.__bStop.grid(row=0, column=2, padx=5, pady=3)

        self.__bClear = tk.Button(fButtons, text="Clear", width=BUTWIDTH, command=self.clear)
        self.__bClear.grid(row=0, column=3, padx=5, pady=3)

        fButtons.grid(row=0, column=1, pady=5)
        # # #

        # Cases
        self.__fCases = tk.Frame(bd=3, bg="white", relief="sunken")
        self.__cases = self.createGrille(TX, TY)
        self.__fCases.grid(row=1, column=1, padx=10, pady=10)
        # # #

        self.__master.mainloop()
Example #34
0
 def continuer(self):
     self._initialiser()
     self.ecran = Jeu(self, self.config, self.vaisseau, self.listBullet,
                      app, self.groupeGlobal)
     self.ecran.run()
Example #35
0
def ficheJeu(numAdherent, numJeu): #idAdherent + idJeu
    
    def retourCatalogue():
        fficheJeu.destroy()
        return catalogue(numAdherent)

    def lancerEmprunt(i):
        fficheJeu.destroy()
        return formulaireEmprunt(i)

    def lancerReserv(i):
        fficheJeu.destroy()
        return reserver(i)

    def lancerExtension(i):
        fficheJeu.destroy()
        return afficheExtensions(i)
    
    fficheJeu = Tk()
    fficheJeu.title(str(Jeu.getNomJeu(numJeu)))
    fficheJeu.grid_columnconfigure(0,weight=1)
    fficheJeu.grid_rowconfigure(20,weight=21)

    p = PanedWindow(fficheJeu, orient = HORIZONTAL, height=100, width=600)
    p.grid(row=1, column=1, columnspan=3)
    
    p.add(Label(p, text="Bonjour Pseudo", bg="white", anchor=CENTER, width=20))
    p.add(Button(p, text="Retour au catalogue", bg="orange", activebackground="orange", borderwidth=10, width=20, command= retourCatalogue ))
    p.add(Button(p, text="Quitter", bg="white", activebackground="black", borderwidth=10, width=10, command = fficheJeu.destroy ))

   
    Label(fficheJeu, text=str(Jeu.getNomJeu(numJeu)), bg="orange", width = 50, height=5, anchor = CENTER).grid(row=2, column=1, columnspan=3)

    Label(fficheJeu, text="Année de parution : ", bg="green", width = 15).grid(row=3, column=1)
    Label(fficheJeu, text=str(Jeu.getAnneeJeu(numJeu)), bg="orange", width = 15).grid(row=3, column=2)

    Label(fficheJeu, text="Age Mininimum : ", bg="green", width = 15).grid(row=4, column=1)
    Label(fficheJeu, text=str(Jeu.getAgeJeu(numJeu)), bg="orange", width = 15).grid(row=4, column=2)

    try:
        photo = PhotoImage(file="imageJeu/" + str(numJeu) + ".gif")
        canvas = Canvas(fficheJeu,width=350, height=200)
        canvas.create_image(0, 0, anchor=NW, image=photo)
        canvas.grid(row=3, rowspan=3, column=3)
    except:
        print ""

    Label(fficheJeu, text="Nombre de Joueurs : ", bg="green", width = 15).grid(row=5, column=1)
    Label(fficheJeu, text=str(Jeu.getNbJoueurJeu(numJeu)), bg="orange", width = 15).grid(row=5, column=2)

    Label(fficheJeu, text="Quantité en stock : ", bg="green", width = 15).grid(row=6, column=1)
    Label(fficheJeu, text=str(Jeu.getQuantiteJeu(numJeu)), bg="orange", width = 15).grid(row=6, column=2)
    
    Label(fficheJeu, text="Auteur : ", bg="green", width = 15).grid(row=7, column=1)
    Label(fficheJeu, text=str(Jeu.getAuteurJeu(numJeu)), bg="orange", width = 15).grid(row=7, column=2)

    Label(fficheJeu, text="Illustrateur : ", bg="green", width = 15).grid(row=8, column=1)
    Label(fficheJeu, text=str(Jeu.getIllustrateurJeu(numJeu)), bg="orange", width = 15).grid(row=8, column=2)
    
    Label(fficheJeu, text="Editeur : ", bg="green", width = 15).grid(row=9, column=1)
    Label(fficheJeu, text=str(Jeu.getEditeurJeu(numJeu)), bg="orange", width = 15).grid(row=9, column=2)

    Label(fficheJeu, text="Synopsis : ", bg="green", width = 15).grid(row=10, column=1)
    Label(fficheJeu, text=str(Jeu.getSynopsisJeu(numJeu)), bg="orange", width = 15).grid(row=10, column=2)

    Label(fficheJeu, text="Action", bg="green", width = 15).grid(row=7, column=3)
    Button(fficheJeu, text="Voir ses extensions", command = partial(lancerExtension,numJeu),bg="green", width=15,activebackground="green").grid(row=8, column=3)
    Button(fficheJeu, text="Emprunt", command = partial(lancerEmprunt, numJeu),bg="green", width=15,activebackground="green").grid(row=9, column=3)
    Button(fficheJeu, text="Reserv", command = partial(lancerReserv, numJeu),bg="red", width=15,activebackground="red").grid(row=10, column=3)

    fficheJeu.mainloop()
Example #36
0
import pygame # import de la librairire
from Jeu import Jeu
from Jeu import Route
pygame.init() # initialisation de  pygame
# Creacton de la classe Camion


pygame.display.set_caption("RoadBreaker")   #Ouverture de la fenêtre
screen = pygame.display.set_mode((1280,720)) #Ouverture de a surface

background = pygame.image.load('Assets/Images/Fond_Jour.png') #Appel de l'image de fond, stockage de l'image dans background

jeu = Jeu()

isRunning = True #Initalisation de la condition de boucle principale

compteurR=0


while isRunning :    #boucle principale
   
    screen.blit(background, (0, 0)) #Ajout de l'image de fond sur la surface. 
    
    if compteurR > 318:
        jeu.LaunchRoute()
        compteurR = 0    
    compteurR += 5
    
    print(jeu.Joueur.Santee)
    
    jeu.TouteRoute.draw(screen)
Example #37
0
from Creature import Creature
from Jeu import Jeu
from random import choice


def affiche_plateau(plateau, jeu):
    for i in plateau:
        listCreature = jeu.listesDesCreatures
        print(' . ')


max = 7
#creer plateau du jeu
print("creer plateau")
plateau = []
for x in range(max):
    for y in range(max):
        c = Case(x, y)
        plateau.append(c)

#creer 2 creatures
pokemon = Creature('Pokemon', Case(0, 0))
picachu = Creature('Picachu', Case(max - 1, max - 1))

jeu1 = Jeu(plateau, [pokemon, picachu], pokemon)

while jeu1.tour > 0:
    print(jeu1)
    choisiCible = jeu1.actif.choisirCible(jeu1)
    jeu1.deplacer(jeu1.actif, choisiCible)
Example #38
0
# Chargement des classes
display = Display()
couleurs = Couleurs(display.fenetre)
couleur_carte = {
    "Trèfle": [int(i) for i in range(13)],
    "Carreau": [int(i) for i in range(13, 26)],
    "Coeur": [int(i) for i in range(26, 39)],
    "Pique": [int(i) for i in range(39, 53)]
}
deck = Deck(display.fenetre)
deck.shuffle()
textes = Textes(display.fenetre)
p1 = Player_1(textes.font)
p2 = Player_2(textes.font)
defausse = Defausse(images)
jeu = Jeu(textes.font, p1, p2, display.fenetre)
quit_screen = Quit_screen(textes.font, display.fenetre, p1, p2)
mouse_h = Mouse_Handling(display.fenetre)

# Titre de la fenêtre
display.caption()

# Tirage du premier joueur
jeu.starting_player()
fin_partie = False

# Boucle principale
while True:
    # Taux de rafraîchissement
    clock.tick(60)
#---------------------------------------------------#
# bouton info
bouton3 = pygame.image.load("image/infobouton.png")
bouton3 = pygame.transform.scale(bouton3, (40, 40))
boutonPos3 = bouton3.get_rect()
boutonPos3.x = 420
boutonPos3.y = 352
#---------------------------------------------------#
# # bouton retour
# retour = pygame.image.load("image/retour.png")
# retour = pygame.transform.scale(retour, (40, 40))
# retourPos = retour.get_rect()
# retourPos.x = 480
# retourPos.y = 352

jeu = Jeu()
run = True
Info = False
# Retour = False

while run:  # la boucle du jeu (tant que 'run' est vrai, la boucle tourne sans cesse)

    fenetre.blit(Fond, (0, 0))

    if jeu.start:
        jeu.startGame(fenetre)
    elif Info:
        fenetre = pygame.display.set_mode((1500, 400))

        Fond = pygame.font.Font(None, 24)
        text = Fond.render("Instructions du jeu :", 1, (0, 255, 255))