def event_TED(self): ##print(self.gennedlink.get()) ##print(self.linktype_Radio.get()) gamestate = str(Ted_Network.URL_request_State(Setting.gpin)) print('state:',gamestate) #gamestate = str(gamestate[0]) gamestate = str(gamestate[2])##is not array so hack for taking number print('statex:',gamestate) ##self.last_gamestate = int(gamestate if gamestate == '0': pass elif gamestate == '1': ##if self.reboot_gamestate == True:##allows for admin to reset clients if self.last_gamestate >= 3: ##input('restart') self.This_win.destroy() if Setting.ADMIN == True: ##Class_Win_MP_Adminpregame.Win_Main() print('rebooting session') start = Ted_Network.URL_startsession(Setting.gpin,Setting.apin) print('start:\n',start,'\n====') else: print('ignored admin part') Setting.InGame = True Win_Main_MP() elif gamestate == '2': self.processlinkgetter() elif gamestate == '3': ##self.reboot_gamestate = True pass elif gamestate == '4': ##self.reboot_gamestate = True pass else: print('gamestate error') self.last_gamestate = int(gamestate) ##move into gamestate bracket when done ##self.regetlinks() ##self.processlinkgetter()##moved to state 2 ## self.This_win.after(700, self.event_TED)
def sub_votedfor_link(self): ##button function to submit link for voting ##if self. varraypos = self.linkvote_Radio.get()-1#votearraypos if varraypos == -1: print('invalid entry') else: votedata = self.processlinkdata(self.regetlinks()[1]) if votedata == ['']: votedata = ['No link selected'] for x in range(6 - len(votedata)): votedata.append('No link selected') print(votedata[varraypos],' <> chosen:::') votedlink = votedata[varraypos] if votedlink == 'No link selected': print('link not valid No link selected') else:##submit voting request resp = Ted_Network.URL_votelink(str(Setting.gpin),str(Setting.ppin),str(varraypos+1)) if 'S' in resp: print('Success in voting!') self.enable_openwinning() self.disable_voting() else: print('sub of link failed error data',votedata,varraypos,votedlink,resp)
def prepgamejoin(self): name = self.G_pname_ent_var.get() gpin = self.G_join_ent_var.get() resp = net.URL_join_session(gpin,name) if gpin == '': print('no game pin entered!') self.G_ERR_LBL_VAR.set('ERR: No Game pin entered!') elif resp[0] == 'ERROR' or (resp[0] == 'F'): pass#do error label code here elif resp[0].upper() == 'S': if name == '': print('no name entered!') self.G_ERR_LBL_VAR.set('ERR: No Name Entered!') else: print('Joining game:'+gpin+'as'+str(name)) Setting.gpin = gpin Setting.ppin = str(resp[1]) Setting.pname = name ##self.This_win.after_cancel() self.This_win.destroy()#destroy the setup win Class_Win_MP_Main.Win_Main_MP()##start up window else: print('mysterious failure!')
def leavesession(self): if Setting.ADMIN == True: if messagebox.askokcancel('Are you sure?','ADMIN:Close session by leaving?'): ##pass self.close_session() else: if messagebox.askokcancel('Are you sure?','leave session?'): leave_DBG = Ted_Network.URL_leavegame(Setting.gpin,Setting.ppin) print('left session: data',leave_DBG) self.This_win.destroy()
def open_winning(self): #get and open winning link LINK = Ted_Network.URL_getwinning(Setting.gpin) if LINK[0] == 'F': messagebox.showinfo('erroropening winning link!', 'the winning link hasnt been decided yet!') print('invalid selection/link not ready yet') else: print(LINK,'WINNER!!!') if messagebox.askokcancel('winning link','the winning link is'+str(LINK[1])+'\nclick ok to open'): ##if 'https://' in LINK[1]: ## LINK[1] = LINK[1][ webbrowser.open(LINK[1])
def __init__(self): self.msb = Toplevel() self.msb_Gpin_VAR = StringVar() self.msb_Apin_VAR = StringVar() self.ERR_VAR = StringVar() msb_LF = LabelFrame(self.msb, text='your game pin and admin code') msb_gp_LBL = Label(msb_LF, textvariable=self.msb_Gpin_VAR) msb_gp_ENT = Entry(msb_LF, textvariable=self.msb_Gpin_VAR) msb_gp_inf_LBL = Label(msb_LF, text='game pin:') msb_ap_LBL = Label(msb_LF, textvariable=self.msb_Apin_VAR) msb_ap_ENT = Entry(msb_LF, textvariable=self.msb_Apin_VAR) msb_ap_inf_LBL = Label(msb_LF, text='admin pin:') msb_Launch_BUT = Button(self.msb, text='launch as admin') ##disabled atm self.msb_ADMIN_BUT = Button(self.msb, text='Set as admin of session', command=self.SET_ADMIN_MODE, state='disabled') # msb_ERR_LBL = Label(msb_LF, textvariable=self.ERR_VAR) msb_gp_inf_LBL.pack() msb_gp_LBL.pack() msb_gp_ENT.pack() msb_ap_inf_LBL.pack() msb_ap_LBL.pack() msb_ap_ENT.pack() self.msb_ADMIN_BUT.pack() msb_ERR_LBL.pack() msb_LF.pack() resp = net.URL_request_Gen() if resp[0] == 'ERROR' or (resp[0] == 'F'): #pass#do error label code here self.ERR_VAR.set('FAILED RESPONSE!') elif resp[0].upper() == 'S': print('Got AP+GP') self.msb_Gpin_VAR.set(resp[1]) self.msb_Apin_VAR.set(resp[2]) self.msb_ADMIN_BUT.config(state='normal') #Setting.apin = else: print('mysterious failure!') #self.msb.after(700,self.Event_TED) self.msb.mainloop()
def update_players(self): Playername_data = net.URL_getplayers(Setting.gpin) #,Setting.apin) print('RAW:', Playername_data) Playername_data = self.processlinkdata(Playername_data) if Playername_data == ['']: Playername_data = ['A:Empty Slot'] for x in range(6 - len(Playername_data)): Playername_data.append('Empty Slot') self.player1_label_LBL_VAR.set(Playername_data[0]) self.player2_label_LBL_VAR.set(Playername_data[1]) self.player3_label_LBL_VAR.set(Playername_data[2]) self.player4_label_LBL_VAR.set(Playername_data[3]) self.player5_label_LBL_VAR.set(Playername_data[4]) self.player6_label_LBL_VAR.set(Playername_data[5])
def sublink_proc(self): sub = Ted_Network.URL_sublink(Setting.gpin,Setting.ppin,self.gennedlink.get()) print('subdat',sub) if self.gennedlink.get() == '': #pass print('error:!nolink!') elif sub[0] == 'ERROR': print('error with link\nEDAT==========================\n') print(sub) #else: elif sub[0].upper() == 'S': self.disable_gen() self.enable_voting() self.sublink_BUT.config(state = 'disable')##disable submit button additionally print('sub sucess!!') else: print('error occurred') print('sub',sub)
def close_session(self): Ted_Network.URL_closesession(Setting.gpin,Setting.apin) self.This_win.destroy()
def redo_sess_BTN(self): ##if self.reboot_gamestate == True: if messagebox.askokcancel('are you sure?','create new session?'): resp = Ted_Network.URL_newround(Setting.gpin,Setting.apin) print('REBOOTING',Setting.gpin,Setting.apin,':',resp)
def regetlinks(Self):##gets links for voting #data = net.URL_getlinks(Setting.gpin) data = Ted_Network.URL_getlinks(Setting.gpin) print(data) return data
def session_start(self): print('starting session') start = net.URL_startsession(Setting.gpin, Setting.apin) print('start:\n', start, '\n====') self.This_win.destroy() #destroy the setup win Class_Win_MP_Main.Win_Main_MP() ##start up window
def session_close(self): dat = net.URL_closesession(Setting.gpin, Setting.apin) print('session closed:', dat) self.This_win.destroy() #destroy the setup win