Example #1
0
 def debut_game(self, attente=2) :
     self.partie_on = True
     self.tour_on = False
     self.chrono_on = False
     self.tirage = tirage.tirage("")
     self.points_top = 0
     self.chrono = self.options.chrono
     self.init_vote()
     self.pa = partie.partie(self.options)
     self.options.game = None
     if self.options.log :
         self.log = logger.logger(self.pa.get_nom_partie())
     self.gr = grille.grille()
     self.jo.score_raz()
     self.info("Prochaine partie dans %d secondes" % attente)
     reactor.callLater(attente, self.first_tour)
Example #2
0
                        indice = i
                        break


#				indice=random.choice(list_indice,proba)
                print(indice)
                statePlayer = states[indice]
                self.playerPos = statePlayer.position

            if statePlayer.type == 2:

                if statePlayer.stateType == "fail":
                    print "you failed"
                    break
                if statePlayer.stateType == "sucess":
                    print "you win"
                    break
            print "player key " + str(statePlayer.key) + "player health" + str(
                statePlayer.health) + " player tresor " + str(
                    statePlayer.tresor) + " player sword " + str(
                        statePlayer.sword)

if __name__ == "__main__":
    grilleA = gr.grille("exemple2.txt")
    #grilleA.affichage((0,0))
    pdm = PDM(grilleA)
    #print(pdm.listState)
    #print(grilleA.size,grilleA.tab)

    pdm.play()
Example #3
0
        self.file_partie = os.path.join(rep, nom_partie)
        f = open(self.file_partie, "w")
        subprocess.call([pgm, '-d', self.options.dico, '-n', str(num), '-s', str(seed)], stdout = f)
        f.close()
        tree = ET.parse(self.file_partie)
        return tree

if __name__ == '__main__' :
    import dico
    import grille
    class options :
        def __init__(self) :
            self.dico = "../dic/ods5.dawg"
            self.game = "partie/p_20101231164246.partie"
            self.game = None

    d = dico.dico("../dic/ods5.dawg")
    g = grille.grille()
    c = coord.coord()
    o = options()
    pa = partie(o)
    for t, c, m, pts, tour in pa.liste :
        controle = g.controle(c, m, t)
        print tour, c,m,t, controle
        if controle <= 0 :
            print pts, g.point(c, m, controle == -1, d)
        else:
            print ">>> Controle non NUL"
        g.pose(c, m)
        print g
Example #4
0
    def __init__(self, parent, app, title) :
        wx.Frame.__init__(self, parent, title=title)
        self.app = app
        s = self.app.settings
        self.SetIcon(wx.Icon(app.settings["files_icone"], wx.BITMAP_TYPE_ICO))
        self.panel = wx.Panel(self)
        self.max_props = app.settings["max_props"]
        self.tour = 0
        fill = s["size_fill"]
        self.Bind(wx.EVT_CLOSE, self.app.exit)

        #Creation et dessin du timer
        timer_sizer  = self.cree_box_sizer("Temps")
        self.timer = wx.StaticText(self.panel, -1, str(utils.convert_time(0)))
        font = wx.Font(s["size_font_chrono"], wx.SWISS, wx.NORMAL, wx.NORMAL)
        self.timer.SetFont(font)
        timer_sizer.Add(self.timer, 0, wx.ALL|wx.EXPAND, fill)

        #Creation et dessin du tirage
        self.tirage = tirage.tirage(self.panel, self.app)
        tirage_sizer = self.cree_box_sizer("Tirage")
        tirage_sizer.Add((fill,0),0)
        tirage_sizer.Add(self.tirage, 1, wx.ALL|wx.EXPAND, fill)
        tirage_sizer.Add((fill,0),0)

        #Creation et dessin de la grille
        self.grille = grille.grille(self.panel, self.app)
        grille_sizer = self.cree_box_sizer("Grille")
        grille_sizer.Add(self.grille, 0, wx.ALL|wx.EXPAND, 0)

        #Creation des items dans la box messages
        msgs_sizer = self.cree_box_sizer("Messages")
        self.msgs = wx.TextCtrl(self.panel, -1, "", size=(app.settings["size_chat_size"], -1), style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_RICH)
        self.set_police_msgs(s["size_font_msgs"])
        msgs_sizer.Add(self.msgs, 1, wx.ALL|wx.EXPAND, fill)

        #Creation box proposition
        props_sizer = self.cree_box_sizer("Propositions", flag = wx.HORIZONTAL)
        self.props = wx.ComboBox(self.panel, -1, style=wx.CB_READONLY) 
        props_sizer.Add(self.props, 1, wx.ALL, fill) 
        self.buttonpose = wx.Button(self.panel, -1, "Poser", size=app.settings["size_button"])
        self.buttonpose.Enable(False)
        self.buttonpose.SetDefault() # important pour Windows pour capter la touche Entrée
        props_sizer.Add(self.buttonpose, 0, wx.ALL|wx.ALIGN_RIGHT, fill) 
        self.props.Bind(wx.EVT_COMBOBOX, self.props_click, self.props)
        self.buttonpose.Bind(wx.EVT_BUTTON, self.pose, self.buttonpose)
        self.buttonpose.Bind(wx.EVT_KEY_DOWN, self.app.OnKey)

        #Creation box score
        score_sizer = self.cree_box_sizer("Score", flag = wx.HORIZONTAL)
        self.score = wx.StaticText(self.panel, -1, "")
        font = wx.Font(s["size_font_score"], wx.SWISS, wx.NORMAL, wx.NORMAL)
        self.score.SetFont(font)
        score_sizer.Add(self.score, 1, wx.ALL, fill) 
        buttscore = wx.Button(self.panel, -1, "Scores", size=app.settings["size_button"])
        score_sizer.Add(buttscore, 0, wx.ALL|wx.ALIGN_RIGHT, fill) 
        buttscore.Bind(wx.EVT_BUTTON, self.show_score, buttscore)

        #Creation du chat
        chat_sizer = self.cree_box_sizer("Chat", flag = wx.HORIZONTAL)
        self.txtchatin = wx.TextCtrl(self.panel, -1, "", style=wx.TE_PROCESS_ENTER)
        chat_sizer.Add(self.txtchatin,1, wx.ALL, fill)
        self.txtchatin.Bind(wx.EVT_TEXT_ENTER, self.chat_enter, self.txtchatin)

        # cadres boutons 
        bouton_sizer = self.cree_box_sizer("Commandes", flag = wx.HORIZONTAL)
        #box = wx.StaticBox(self.panel, label = "Commandes")
        boutons = [ 
                    ("Restart", self.button_restart),
                    ("Alpha", self.button_alpha),
                    ("Random", self.button_random),
                    ("Next", self.button_next),
                    ("Précédent", self.button_pose_last),
                ]
        if s["user_admin"] :
            boutons.insert(3, ("Chrono", self.button_chrono))
        bouton_in_sizer = wx.GridSizer(rows=1, cols=len(boutons), hgap=fill, vgap=fill)
        for label, handler in boutons :
            bouton = wx.Button(self.panel, label=label, size=app.settings["size_button"])
            bouton_in_sizer.Add(bouton, flag = wx.ALIGN_CENTER)
            bouton.Bind(wx.EVT_BUTTON, handler, bouton)
        bouton_sizer.Add(bouton_in_sizer, proportion=1, flag = wx.EXPAND)

        #Barre de menu
        if  s["view_menu"] :
            menubar = wx.MenuBar()

            menu1 = wx.Menu()
            menu1.Append(101,"Quitter\tCtrl-Q")
            self.Bind(wx.EVT_MENU, self.app.exit, id=101)

            menubar.Append(menu1,"Fichier")
            menupol = wx.Menu()
            for i in range(8,14) :
                menupol.Append(200+i,str(i),"Changer la police des messages serveur", wx.ITEM_RADIO)
                self.Bind(wx.EVT_MENU, self.menu_police, id=200+i)
            pset = s["size_font_msgs"]
            menupol.Check(200+pset, True)
            self.set_police_msgs(pset)

            menu2 = wx.Menu()
            menu2.AppendMenu(299,"Taille police", menupol)
            menubar.Append(menu2,"Options")

            menu3 = wx.Menu()
            menu3.Append(301,"A propos")
            menubar.Append(menu3,"Aide")
            self.Bind(wx.EVT_MENU, self.about, id=301)

            self.SetMenuBar(menubar)

        #Barre de status
        if  s["view_status"] :
            self.st = self.CreateStatusBar()
            self.st.SetFieldsCount(4)
            self.st.SetStatusWidths(s['size_status'])
            self.set_status_next(0)
            self.set_status_restart(0)

        #Sizers
        sizer1 = wx.BoxSizer(wx.HORIZONTAL)

        sizer2 = wx.BoxSizer(wx.VERTICAL)
        sizer2.Add(msgs_sizer,   1, wx.EXPAND)
        sizer2.Add(props_sizer,  0, wx.EXPAND)
        sizer2.Add(score_sizer,  0, wx.EXPAND)
        sizer2.Add(bouton_sizer, 0, wx.EXPAND)
        sizer2.Add(chat_sizer,   0, wx.EXPAND)
        sizer2.Add( (fill,fill), 0)

        sizer = wx.GridBagSizer(hgap=fill, vgap=fill) 

        if  s["view_layout"] == "alt" :
            sizer1.Add(tirage_sizer, 1, flag = wx.EXPAND)
            sizer1.Add( (fill,fill))
            sizer1.Add(timer_sizer, flag = wx.EXPAND)
            sizer.Add(grille_sizer, pos=(0,0))
            sizer2.Add(sizer1, flag = wx.EXPAND)
            sizer.Add(sizer2, pos=(0,1),  flag = wx.EXPAND)
            sizer.AddGrowableCol(1) 
        else :
            sizer1.Add(timer_sizer, flag = wx.EXPAND)
            sizer1.Add((fill,fill))
            sizer1.Add(tirage_sizer, 1, flag = wx.EXPAND)
            sizer.Add(sizer1, pos=(0,0), flag = wx.EXPAND)
            sizer.Add(grille_sizer, pos=(1,0))
            sizer.Add(sizer2, pos=(0,1), span=(2,1), flag = wx.EXPAND)
            sizer.AddGrowableCol(1)

        self.panel.SetSizer(sizer) 
        sizer.Fit(self)
Example #5
0
 def __init__(self):
     GrilleB = gl.grille()
     GrilleA = GrilleB.genere_grille()
     Grille = gl.grille(GrilleA)
     self.Grille = Grille
Example #6
0
 def elemenate(self, x, y, grill=None):
     if (grill is None):
         self.Grille.elemenate(x, y)
     gl.grille(grill).elemenate(x, y)
Example #7
0
 def shoot(self, x, y, nb_shoots=None, grill=None):
     if (grill is None):
         return self.Grille.shoot(x, y, nb_shoots)
     return gl.grille(grill).shoot(x, y, nb_shoots)
Example #8
0
    def __init__(self, parent, app, title) :
        super().__init__(parent=None, title=title, size=(1000, 800))
        # wx.Frame.__init__(self, parent, title=title)
        self.app = app
        s = self.app.settings
        self.SetIcon(wx.Icon(app.settings["files_icone"], wx.BITMAP_TYPE_ICO))
        self.panel = wx.Panel(self)
        self.max_props = app.settings["max_props"]
        self.tour = 0
        fill = s["size_fill"]
        self.Bind(wx.EVT_CLOSE, self.exit)

        #Creation et dessin du timer
        timer_sizer  = self.cree_box_sizer("Temps")
        self.timer = wx.StaticText(self.panel, -1, str(utils.convert_time(0)))
        font = wx.Font(s["size_font_chrono"], wx.SWISS, wx.NORMAL, wx.NORMAL)
        self.timer.SetFont(font)
        timer_sizer.Add(self.timer, 0, wx.ALL|wx.EXPAND, fill)

        #Creation et dessin du tirage
        self.tirage = tirage.tirage(self.panel, self.app)
        tirage_sizer = self.cree_box_sizer("Tirage")
        tirage_sizer.Add((fill,0),0)
        tirage_sizer.Add(self.tirage, 1, wx.ALL|wx.EXPAND, fill)
        tirage_sizer.Add((fill,0),0)

        #Creation et dessin de la grille
        self.grille = grille.grille(self.panel, self.app)
        grille_sizer = self.cree_box_sizer("Grille")
        grille_sizer.Add(self.grille, 0, wx.ALL|wx.EXPAND, 0)

        #Creation des items dans la box messages
        msgs_sizer = self.cree_box_sizer("Messages")
        self.msgs = wx.TextCtrl(self.panel, -1, "", size=(app.settings["size_chat_size"], -1), style=wx.TE_MULTILINE|wx.TE_READONLY)
        # self.set_police_msgs(s["size_font_msgs"])
        msgs_sizer.Add(self.msgs, 1, wx.ALL|wx.EXPAND, fill)

        #Creation box proposition
        props_sizer = self.cree_box_sizer("Propositions", flag = wx.HORIZONTAL)
        self.props = wx.ComboBox(self.panel, -1, style=wx.CB_READONLY)
        props_sizer.Add(self.props, 1, wx.ALL, fill)
        self.buttonpose = wx.Button(self.panel, -1, "Poser", size=app.settings["size_button"])
        self.buttonpose.Enable(False)
        self.buttonpose.SetDefault() # important pour Windows pour capter la touche Entrée
        props_sizer.Add(self.buttonpose, 0, wx.ALL|wx.ALIGN_RIGHT, fill)
        self.props.Bind(wx.EVT_COMBOBOX, self.props_click, self.props)
        self.buttonpose.Bind(wx.EVT_BUTTON, self.pose, self.buttonpose)
        self.buttonpose.Bind(wx.EVT_KEY_DOWN, self.app.OnKey)

        #Creation box score
        score_sizer = self.cree_box_sizer("Score", flag = wx.HORIZONTAL)
        self.score = wx.StaticText(self.panel, -1, "")
        font = wx.Font(s["size_font_score"], wx.SWISS, wx.NORMAL, wx.NORMAL)
        self.score.SetFont(font)
        score_sizer.Add(self.score, 1, wx.ALL, fill)
        buttscore = wx.Button(self.panel, -1, "Scores", size=app.settings["size_button"])
        score_sizer.Add(buttscore, 0, wx.ALL|wx.ALIGN_RIGHT, fill)
        buttscore.Bind(wx.EVT_BUTTON, self.show_score, buttscore)

        #Creation du chat
        chat_sizer = self.cree_box_sizer("Chat", flag = wx.HORIZONTAL)
        self.txtchatin = wx.TextCtrl(self.panel, -1, "", style=wx.TE_PROCESS_ENTER)
        chat_sizer.Add(self.txtchatin,1, wx.ALL, fill)
        self.txtchatin.Bind(wx.EVT_TEXT_ENTER, self.chat_enter, self.txtchatin)

        # cadres boutons
        bouton_sizer = self.cree_box_sizer("Commandes", flag = wx.HORIZONTAL)
        #box = wx.StaticBox(self.panel, label = "Commandes")
        boutons = [
                    ("Restart", self.button_restart),
                    ("Alpha", self.button_alpha),
                    ("Random", self.button_random),
                    ("Next", self.button_next),
                    ("Précédent", self.button_pose_last),
                ]
        if s["user_admin"] :
            boutons.insert(3, ("Chrono", self.button_chrono))
        bouton_in_sizer = wx.GridSizer(rows=1, cols=len(boutons), hgap=fill, vgap=fill)
        for label, handler in boutons :
            bouton = wx.Button(self.panel, label=label, size=app.settings["size_button"])
            bouton_in_sizer.Add(bouton, flag = wx.ALIGN_CENTER)
            bouton.Bind(wx.EVT_BUTTON, handler, bouton)
        bouton_sizer.Add(bouton_in_sizer, proportion=1, flag = wx.EXPAND)

        #Barre de menu
        if  s["view_menu"] :
            menubar = wx.MenuBar()

            menu1 = wx.Menu()
            menu1.Append(101,"Quitter\tCtrl-Q")
            self.Bind(wx.EVT_MENU, self.app.exit, id=101)

            menubar.Append(menu1,"Fichier")
            menupol = wx.Menu()
            for i in range(8,14) :
                menupol.Append(200+i,str(i),"Changer la police des messages serveur", wx.ITEM_RADIO)
                self.Bind(wx.EVT_MENU, self.menu_police, id=200+i)
            pset = s["size_font_msgs"]
            menupol.Check(200+pset, True)
            self.set_police_msgs(pset)

            menu2 = wx.Menu()
            menu2.Append(299,"Taille police", menupol)
            menubar.Append(menu2,"Options")

            menu3 = wx.Menu()
            menu3.Append(301,"A propos")
            menubar.Append(menu3,"Aide")
            self.Bind(wx.EVT_MENU, self.about, id=301)

            self.SetMenuBar(menubar)

        #Barre de status
        if  s["view_status"] :
            self.st = self.CreateStatusBar()
            self.st.SetFieldsCount(4)
            self.st.SetStatusWidths(s['size_status'])
            self.set_status_next(0)
            self.set_status_restart(0)

        #Sizers
        sizer1 = wx.BoxSizer(wx.HORIZONTAL)

        sizer2 = wx.BoxSizer(wx.VERTICAL)
        sizer2.Add(msgs_sizer,   1, wx.EXPAND)
        sizer2.Add(props_sizer,  0, wx.EXPAND)
        sizer2.Add(score_sizer,  0, wx.EXPAND)
        sizer2.Add(bouton_sizer, 0, wx.EXPAND)
        sizer2.Add(chat_sizer,   0, wx.EXPAND)
        sizer2.Add( (fill,fill), 0)

        sizer = wx.GridBagSizer(hgap=fill, vgap=fill)

        if  s["view_layout"] == "alt" :
            sizer1.Add(tirage_sizer, 1, flag = wx.EXPAND)
            sizer1.Add( (fill,fill))
            sizer1.Add(timer_sizer, flag = wx.EXPAND)
            sizer.Add(grille_sizer, pos=(0,0))
            sizer2.Add(sizer1, flag = wx.EXPAND)
            sizer.Add(sizer2, pos=(0,1),  flag = wx.EXPAND)
            sizer.AddGrowableCol(1)
        else :
            sizer1.Add(timer_sizer, flag = wx.EXPAND)
            sizer1.Add((fill,fill))
            sizer1.Add(tirage_sizer, 1, flag = wx.EXPAND)
            sizer.Add(sizer1, pos=(0,0), flag = wx.EXPAND)
            sizer.Add(grille_sizer, pos=(1,0))
            sizer.Add(sizer2, pos=(0,1), span=(2,1), flag = wx.EXPAND)
            sizer.AddGrowableCol(1)

        self.panel.SetSizer(sizer)
        sizer.Fit(self)