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)
def __init__(self, options) : self.options = options while True : tree = self.gen_part() tot = int(tree.find("resume/total").text) nbtour = int(tree.find("resume/nbtour").text) if tot >= options.minpoint and options.mintour <= nbtour <= options.maxtour : break self.liste = [] tour = 0 for e in tree.findall("tour"): n = e.find("tirage") ttt = tirage.tirage(n.text) n = e.find("coord") ccc = coord.coord(coo_str=n.text) n = e.find("mot") mmm = str(n.text) n = e.find("points") pts = int(n.text) tour += 1 self.liste.append( (ttt, ccc, mmm, pts, tour) )
point = point * multmot + totv # plus la prime de scrabble éventuele de 50 points if scrab : point += 50 return point, mot_nonex if __name__ == '__main__' : import coord import dico import tirage d = dico.dico("../dic/ods5.dawg") g = grille() t = tirage.tirage("TETESAU") c = coord.coord() c.fromstr("H8") m = "TATES" controle = g.controle(c, m, t) print controle if controle <= 0 : print g.point(c, m, controle, d) g.pose(c, m) print g t = tirage.tirage("AEPESTU") c.fromstr("7H") m = "EPATES" controle = g.controle(c, m, t)
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)
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)