def __init__(self, config, resource): QWidget.__init__(self) self.channels = resource["tabs"].widget(0).channels self.scripts = resource["scripts"] self.threadpool = resource["threadpool"] self.config = config # Create overall layout columns = QHBoxLayout(self) self.setup_file_list() columns.addWidget(self.file_list) edit_rows = QVBoxLayout() columns.addLayout(edit_rows) columns.setStretch(0, 1) columns.setStretch(1, 5) # Create edit_rows self.title_bar = func.label("Select or open file to edit.") edit_rows.addWidget(self.title_bar) self.editor = QPlainTextEdit() self.editor.textChanged.connect(self.text_modified) edit_rows.addWidget(self.editor) controls = QHBoxLayout() edit_rows.addLayout(controls) buttons = [ ["Open", self.open], ["New", self.new], ["Save", self.save], ["Check", self.check], ] for button in buttons: controls.addWidget(func.button(text=button[0], connect=button[1]))
def screen1(a, b, c): #for running screen 1 import pygame global p import functions leaderboard.winamount = (int)(c.get()) p[1].name = b.get() p[0].name = a.get() pygame.init() display_width = 1430 display_height = 800 white = (255, 255, 255) black = (0, 0, 0) yellow = (255, 255, 0) red = (255, 50, 0) blue = (0, 0, 255) green = (0, 255, 0) back = (100, 10, 100) gameExit = False while not gameExit: for event in pygame.event.get(): if event.type == pygame.QUIT: gameExit = True x = 615 y1 = 200 y2 = 300 y3 = 400 l = 200 h = 50 functions.gameDisplay.fill(back) img = pygame.image.load('images/monopolyimage.png') #adding image functions.gameDisplay.blit(img, (200, 0)) #adding start button functions.button("START", x, y1, l, h, yellow, blue, "next", red) #adding quit button functions.button("QUIT", x, y3, l, h, yellow, blue, "quit1", red) pygame.display.update()
def instructions(): #displays instruction text on new display instructions = True while instructions: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() functions.gameDisplay.fill(white) TextSurf, TextRect = functions.text_objects( "Welcome to Farm Life! A relaxing game about farming!", smallText) functions.gameDisplay.blit(TextSurf, (90, 125)) TextSurf, TextRect = functions.text_objects( "Go to the store and buy some seeds!", smallText) functions.gameDisplay.blit(TextSurf, (90, 140)) TextSurf, TextRect = functions.text_objects( "Plant them and fertilize them to grow!", smallText) functions.gameDisplay.blit(TextSurf, (90, 155)) TextSurf, TextRect = functions.text_objects( "Yellow plants mean they need more fertilizer, green plants mean they are ready to pick!", smallText) functions.gameDisplay.blit(TextSurf, (90, 170)) TextSurf, TextRect = functions.text_objects( "Pick and sell your grown plants back to the store!", smallText) functions.gameDisplay.blit(TextSurf, (90, 185)) TextSurf, TextRect = functions.text_objects( "Use your money to buy more plants and plots!", smallText) functions.gameDisplay.blit(TextSurf, (90, 200)) TextSurf, TextRect = functions.text_objects( "A Note: in the top left corner it shows you what is selected.", smallText, red) functions.gameDisplay.blit(TextSurf, (90, 225)) TextSurf, TextRect = functions.text_objects( "If it says “None” and you try to perform an action (like picking a plant) the game may crash!", smallText, red) functions.gameDisplay.blit(TextSurf, (90, 240)) functions.button("Back", 350, 510, 100, 50, silver, white, game_intro) pygame.display.update() functions.clock.tick(15)
def lie_detector(game_data, body, player_id): if body == 'take' or body == "don't take": done = functions.button(game_data['button_presses'], game_data['numbers'], player_id, body, game_data['roles']) if done: game_data['phase'] = 1 return LIE_DETECTOR_OVER else: return "Submitted" else: return INVALID_LIE_DETECTOR_INPUT
def Game(): Main_menu = True while Main_menu: events = pygame.event.get() functions.insert_image('MenuBackgound.jpg', 0, 0) functions.button((0, 89, 90), 650, 300, 200, 70, 'button3.png', functions.intro_game, events) functions.button((0, 89, 90), 650, 400, 200, 70, 'button2.png', functions.help, events) functions.button((0, 89, 90), 650, 500, 200, 70, 'button1.png', functions.see_highscores, events) functions.button((0, 89, 90), 650, 600, 200, 70, 'button5.png', functions.settings, events) functions.button((0, 89, 90), 650, 700, 200, 70, 'button4.png', exit, events) for event in events: if event.type == pygame.QUIT: pygame.quit() quit() pygame.display.update()
def get_controls(self): buttons = [ ["Read Cell", "Read Voltage of Connected Cell"], ["Start", "Start Cycle"], ["Pause", "Pause Cycle"], ["Resume", "Resume Cycle"], ["Stop", "Stop Cycle"], ] elements = [] for but in buttons: elements.append(func.button(*but, self.button)) return elements
def game_intro(): #start the game_intro loop. generates two buttons, one that runs main game_loop one that runs instructions intro = True while intro: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() functions.gameDisplay.fill(white) TextSurf, TextRect = functions.text_objects( 'Farm Life: Live your best farm life!', largeText) TextRect.center = ((functions.display_width / 2), (functions.display_height / 2)) functions.gameDisplay.blit(TextSurf, TextRect) functions.button("Farm!", 350, 450, 100, 50, silver, white, game_loop) functions.button("Instructions!", 350, 510, 100, 50, silver, white, instructions) pygame.display.update() functions.clock.tick(15)
def game_intro(): intro = True while intro: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() var.gameDisplay.fill(var.white) WelcomeImg = pygame.image.load('./003_Welcome/intro3pic.png') var.gameDisplay.blit(WelcomeImg, (0, 0)) #largeText = pygame.font.Font('freesansbold.ttf',60) #TextSurf, TextRect = functions.text_objects("PyTroleo", largeText) #TextRect.center = ((var.display_ancho/2),(var.display_alto/2)) #var.gameDisplay.blit(TextSurf,TextRect) #functions.button("PyPetrol",80, var.gameDisplay,350,150,100,50,var.white,var.white,"None") functions.button("Play", 20, var.gameDisplay, 220, 350, 100, 50, var.greenl, var.green, "Play") functions.button("Quit", 20, var.gameDisplay, 500, 350, 100, 50, var.redl, var.red, "Quit") #functions.button("by AJ Ovalles",16, var.gameDisplay,300,50,200,50,var.white,var.white,"None") pygame.display.update()
def __init__(self, config, resource): QWidget.__init__(self) self.path = config["record_dir"] + "/tests" self.threadpool = resource["threadpool"] self.log_list = QListWidget() self.log_list.itemClicked.connect(self.log_clicked) self.folder_list = QListWidget() self.folder_list.itemClicked.connect(self.folder_clicked) # Create overall layout columns = QHBoxLayout(self) list_rows = QVBoxLayout() columns.addLayout(list_rows) edit_rows = QVBoxLayout() columns.addLayout(edit_rows) columns.setStretch(0, 1) columns.setStretch(1, 5) list_rows.addWidget(self.folder_list) list_rows.addWidget(self.log_list) list_rows.setStretch(0, 1) list_rows.setStretch(1, 3) # create edit_rows self.title_bar = func.label("Select file on left to view log.") edit_rows.addWidget(self.title_bar) self.editor = QPlainTextEdit() edit_rows.addWidget(self.editor) controls = QHBoxLayout() edit_rows.addLayout(controls) # create control buttons buttons = [["Reload", "Update Logs", self.reload], ["Open Folder", "Show Log Folder", self.open_explorer]] for button in buttons: controls.addWidget(func.button(*button)) self.reload()
def game_loop(): #main game loop. determines what to display based on what pages are set to True in functions file crashed = False functions.characterSetUp("Bobby") print("GAME START") while crashed == False: functions.gameDisplay.fill(white) functions.rect(0, 400, 800, 200, lightYellow) for event in pygame.event.get(): if event.type == pygame.QUIT: crashed = True if functions.viewField == True: #creates fertilize, plant/pick, and store buttons. runs generateField function. #if Fertilize clicked runs functions.field.furtilize #if plant/pick clicked runs functions.plantPick #if store clicked runs functions.switchStore functions.threeButtons("Fertilize", "Plant/Pick", "Store", functions.field.furtilize, functions.plantPick, functions.switchStoreField, functions.selection, True) functions.generateField() elif functions.viewStore == True: #creates buy, sell, and field buttons. #if buy clicked runs functions.switchStoreBuy #if sell clicked runs functions.switchStoreSell #if field clicked runs functions.switchStoreField TextSurf, TextRect = functions.text_objects( "Welcome to the store!", largeText) functions.gameDisplay.blit( TextSurf, ((190), ((functions.display_height - 400) / 2))) functions.threeButtons("Buy", "Sell", "Field", functions.switchStoreBuy, functions.switchStoreSell, functions.switchStoreField, None, None) elif functions.buy == True: #creates back button. runs functions.generateStore function. #if back clicked runs functions.switchStoreBuy #if an item is selected, creates buy button #if sell button clicked runs functions.purchase functions.button("Back", 166.67, 450, 150, 100, silver, white, functions.switchStoreBuy) if functions.selection != None and functions.player.bank - functions.selection.cost > 0: functions.button("Buy", 483.37, 450, 150, 100, silver, white, functions.purchase, functions.selection, True) functions.generateStore() elif functions.viewSell == True: #creates back button. runs functions.showInv function. #if back clicked runs functions.switchStoreSell #if item is selected creates sell button #if sell is clicked runs functions.sell functions.button("Back", 166.67, 450, 150, 100, silver, white, functions.switchStoreSell) if functions.selection != None: functions.button("Sell", 483.37, 450, 150, 100, silver, white, functions.sell, functions.selection) functions.showInv() elif functions.plant == True: #creates back button. runs functions.showInv function. #if back clicked runs functions.switchFieldPlant #if item is selected creates plant button #if sell is clicked runs functions.plant functions.showInv() functions.button("Back", 166.67, 450, 150, 100, silver, white, functions.switchFieldPlant) if functions.selection != None: functions.button("Plant", 483.37, 450, 150, 100, silver, white, functions.field.plant, functions.selection, True) pygame.display.update() functions.clock.tick(60)
def game_loop(): global wellImg, skyImg, seisImg, subImg, fluiImg #global subImg, var.CoreSurf, fluiImg, var.FluiSurf, crashed #CREANDO SUPERFICIES TRASPARENTES var.BackSurf = pygame.Surface([var.display_ancho, var.display_alto], pygame.SRCALPHA, 32) var.SeisSurf = pygame.Surface([var.display_ancho, var.display_alto], pygame.SRCALPHA, 32) var.FluiSurf = pygame.Surface([var.display_ancho, var.display_alto], pygame.SRCALPHA, 32) var.CoreSurf = pygame.Surface([var.display_ancho, var.display_alto], pygame.SRCALPHA, 32) var.IndeSurf = pygame.Surface([var.display_ancho, var.display_alto], pygame.SRCALPHA, 32) var.ProdSurf = pygame.Surface([var.display_ancho, var.display_alto], pygame.SRCALPHA, 32) var.ObjeSurf = pygame.Surface([var.display_ancho, var.display_alto], pygame.SRCALPHA, 32) var.HudiSurf = pygame.Surface([var.display_ancho, var.display_alto], pygame.SRCALPHA, 32) wellImg = pygame.image.load('./010_demo/rig.png') wellImg = pygame.transform.scale(wellImg, (60, 80)) skyImg = pygame.image.load('./010_demo/cielo.jpeg') skyImg = pygame.transform.scale(skyImg, (var.display_ancho, 100)) var.BackSurf.blit(skyImg, (0, 0)) subImg = pygame.image.load('./010_demo/subsuelo.jpg') subImg = pygame.transform.scale(subImg, (var.display_ancho, 300)) seisImg = pygame.image.load('./010_demo/subsuelo_seis.jpg') seisImg = pygame.transform.scale(seisImg, (var.display_ancho, 300)) fluiImg = pygame.image.load('./010_demo/subsuelo_flui.png') fluiImg = pygame.transform.scale(fluiImg, (var.display_ancho, 300)) IndeImg = pygame.image.load('./010_demo/subsuelo_index.png') IndeImg = pygame.transform.scale(IndeImg, (var.display_ancho, 300)) var.IndeSurf.blit(IndeImg, (0, 100)) var.Budget_inic = 370 var.gameDisplay.fill(var.black) var.x = var.display_ancho * 0.4 var.y = 400 * 0.05 crashed = False LEFT = 1 startTime = time.time() var.x = randint(80, var.display_ancho - 100) plotseis(var.x, var.y) var.x = randint(80, var.display_ancho - 100) plotcore(var.x, var.y) var.x = randint(80, var.display_ancho - 10) plotcore(var.x, var.y) #POLIGONOS DE LOS YACIMIENTOS A B C while not crashed: for event in pygame.event.get(): if event.type == pygame.QUIT: quit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: var.x += -5 elif event.key == pygame.K_RIGHT: var.x += 5 elif event.key == pygame.K_DOWN: plotcore(var.x, var.y) var.costo += 50 # Se cobra el nucleo elif event.key == pygame.K_s: plotseis(var.x, var.y) var.costo += 100 if event.type == pygame.MOUSEBUTTONDOWN and event.button == LEFT: i, j = event.pos if 75 < j < 100: var.x = i elif 100 < j < 400: alfa = var.IndeSurf.get_at((i, j)) print(alfa) var.costo += 20 pygame.draw.rect(var.ProdSurf, alfa, (i, 100, 5, j - 100)) #print(event) #var.gameDisplay.blit(skyImg,(0,0)) well(var.x, var.y) var.Budget = var.Budget_inic - var.costo + var.rate # functions.button("Seismic",10,var.HudiSurf,100,0,100,20,var.greenl,var.green,"Seismic") crashed = functions.button("Next Oilfield >>", 10, var.HudiSurf, 600, 0, 100, 20, var.greenl, var.green, "Nextfield") elapsedTime = int(time.time() - startTime) functions.button("Budget: " + str(var.Budget) + " MMUSD", 12, var.HudiSurf, 0, 400, 200, 20, var.greenl, var.green, "None") # functions.button(str(var.rate) +" of 650 MMBls",12,var.HudiSurf, 300,400,200,20,var.greenl,var.green,"None") # functions.button(str(elapsedTime) +" of 250 weeks",12, var.HudiSurf, 600,400,200,20,var.greenl,var.green,"None") var.gameDisplay.blit(var.BackSurf, (0, 0)) var.gameDisplay.blit(var.SeisSurf, (0, 0)) var.gameDisplay.blit(var.CoreSurf, (0, 0)) var.gameDisplay.blit(var.FluiSurf, (0, 0)) var.gameDisplay.blit(var.ProdSurf, (0, 0)) var.gameDisplay.blit(var.ObjeSurf, (0, 0)) var.gameDisplay.blit(var.HudiSurf, (0, 0)) pygame.display.update() var.clock.tick(60)
def anticline(budgetinic): global wellImg, skyImg, seisImg, subImg, fluiImg, user_action #global subImg, var.CoreSurf, fluiImg, var.FluiSurf, crashed #print 'Entre a anticline con Budget: ', var.Budget_inic #CREANDO SUPERFICIES TRASPARENTES var.BackSurf = pygame.Surface([var.display_ancho, var.display_alto], pygame.SRCALPHA, 32) var.SeisSurf = pygame.Surface([var.display_ancho, var.display_alto], pygame.SRCALPHA, 32) var.FluiSurf = pygame.Surface([var.display_ancho, var.display_alto], pygame.SRCALPHA, 32) var.CoreSurf = pygame.Surface([var.display_ancho, var.display_alto], pygame.SRCALPHA, 32) var.IndeSurf = pygame.Surface([var.display_ancho, var.display_alto], pygame.SRCALPHA, 32) var.ProdSurf = pygame.Surface([var.display_ancho, var.display_alto], pygame.SRCALPHA, 32) var.ObjeSurf = pygame.Surface([var.display_ancho, var.display_alto], pygame.SRCALPHA, 32) var.HudiSurf = pygame.Surface([var.display_ancho, var.display_alto], pygame.SRCALPHA, 32) wellImg = pygame.image.load('./010_demo/rig.png') wellImg = pygame.transform.scale(wellImg, (80, 100)) skyImg = pygame.image.load('./010_demo/cielo.jpeg') skyImg = pygame.transform.scale(skyImg, (var.display_ancho, 100)) var.BackSurf.blit(skyImg, (0, 0)) subImg = pygame.image.load('./015_anticline/anticline.png') subImg = pygame.transform.scale(subImg, (var.display_ancho, 300)) seisImg = pygame.image.load('./015_anticline/anticlineSeis.png') seisImg = pygame.transform.scale(seisImg, (var.display_ancho, 300)) fluiImg = pygame.image.load('./015_anticline/anticlineflui.png') fluiImg = pygame.transform.scale(fluiImg, (var.display_ancho, 300)) IndeImg = pygame.image.load('./015_anticline/anticline_index.png') IndeImg = pygame.transform.scale(IndeImg, (var.display_ancho, 300)) var.IndeSurf.blit(IndeImg, (0, 100)) var.Budget_inic = budgetinic var.gameDisplay.fill(var.black) var.x = var.display_ancho * 0.4 var.y = 400 * 0.05 crashed = False LEFT = 1 user_action = 0 ifconter = 0 pick = np.array([[0, 0]]) startTime = time.time() var.costo = 0 var.rate = 0 BudgetOld = var.Budget cashFlow = 0 var.x = randint(80, var.display_ancho - 100) plotseis(var.x, var.y) var.x = randint(80, var.display_ancho - 100) plotcore(var.x, var.y) pygame.time.wait(27) var.x = randint(80, var.display_ancho - 10) plotcore(var.x, var.y) #STARTING THE MAIN LOOP while not crashed: ''' key = pygame.key.get_pressed() if key[pygame.K_LEFT]: var.x += -10 ''' for event in pygame.event.get(): if event.type == pygame.QUIT: quit() if event.type == pygame.KEYDOWN: #print 'teclas pisadas', pygame.key.get_pressed() if event.key == pygame.K_LEFT: var.x += -10 elif event.key == pygame.K_RIGHT: var.x += 10 elif event.key == pygame.K_DOWN: BudgetOld = var.Budget user_action = 1 plotcore(var.x, var.y) var.costo += 30 # Se cobra el nucleo elif event.key == pygame.K_s: BudgetOld = var.Budget user_action = 1 plotseis(var.x, var.y) var.costo += 100 if event.type == pygame.MOUSEBUTTONDOWN and event.button == LEFT: i, j = event.pos BudgetOld = var.Budget if 75 < j < 100: var.x = i elif 100 < j < 400: alfa = var.IndeSurf.get_at((i, j)) #print(alfa) var.costo += 15 #pygame.draw.rect(var.ProdSurf,alfa,(i,100,5,j-100)) #Drawing a rectangle like a well pygame.draw.circle(var.ProdSurf, alfa, (i, j), 5) if alfa == (0, 255, 0, 255): ifconter = ifconter + 1 picknew = [i, j] pick = np.vstack([pick, picknew]) #print 'Pick location',pick, ifconter densWell = clasi.hiercluscounter(pick[1:, :], 4) print 'Well Density :', densWell #sound = pygame.mixer.Sound("./70_SOUNDS/Cash.mp3") #sound.play(maxtime = 1000000) pygame.mixer.music.load('./70_SOUNDS/Cash.mp3') pygame.mixer.music.play(0) var.rate += 100 * (1.0 / densWell) print var.rate else: pygame.mixer.music.load('./70_SOUNDS/Error.mp3') pygame.mixer.music.play(0) #print(event) #var.gameDisplay.blit(skyImg,(0,0)) well(var.x, var.y) var.Budget = int(var.Budget_inic - var.costo + var.rate) cashFlow = var.Budget - BudgetOld # functions.button("Seismic",10,var.HudiSurf, #100,0,100,20,var.greenl,var.green,"Seismic") crashed = functions.button("Next Oilfield >>", 10, var.HudiSurf, 600, 0, 100, 20, var.greenl, var.green, "Nextfield") elapsedTime = int(time.time() - startTime) ''' myfont = pygame.font.SysFont("monospace", 15) label = myfont.render("Some text!", 1, (255,255,0)) var.HudiSurf.blit(label, (100, 100)) ''' if BudgetOld > var.Budget: functions.button( "Budget: " + str(var.Budget) + " MMUSD " + "(" + str(int(cashFlow)) + ")", 12, var.HudiSurf, 0, 400, 200, 20, var.redl, var.red, "None") else: functions.button( "Budget: " + str(var.Budget) + " MMUSD " + "(" + str(int(cashFlow)) + ")", 12, var.HudiSurf, 0, 400, 200, 20, var.greenl, var.green, "None") functions.button(" Spent: " + str(int(var.costo)), 12, var.HudiSurf, 200, 400, 100, 20, var.redl, var.red, "None") functions.button(" Earned: " + str(int(var.rate)), 12, var.HudiSurf, 300, 400, 100, 20, var.greenl, var.green, "None") # functions.button(str(elapsedTime) +" of 250 weeks", #12, var.HudiSurf, 600,400,200,20,var.greenl,var.green,"None") var.gameDisplay.blit(var.BackSurf, (0, 0)) var.gameDisplay.blit(var.SeisSurf, (0, 0)) var.gameDisplay.blit(var.CoreSurf, (0, 0)) var.gameDisplay.blit(var.FluiSurf, (0, 0)) var.gameDisplay.blit(var.ProdSurf, (0, 0)) var.gameDisplay.blit(var.ObjeSurf, (0, 0)) var.gameDisplay.blit(var.HudiSurf, (0, 0)) pygame.display.update() var.clock.tick(60) #print 'Sali de anticline con Budget: ', var.Budget_inic return var.Budget_inic
def determine_response(data, from_number, body): """ Determine how to respond to a given text message, or None for no response. >>> determine_response({'123':{'numbers': ['#1', '#2', '#3']}}, '#1', 'start mission') "You are already enlisted in mission id1. Wait for the person who started the mission to text 'Start mission' or exit by texting 'Abort'" """ game_id = get_game_id(data, from_number) if game_id is None: print(data) # Not currently in a game if body == "begin enlisting": game_id = str(random.randint(0, 100000)) data[game_id] = {'numbers': [from_number]} return "Began Enlisting for " + game_id + ". Tell others to join by texting 'enlist me " \ + game_id + "' to this number without quotes. Start the mission by texting 'Start Mission'" elif ' '.join(body.split(" ")[:2]) == "enlist me": game_id = ''.join(body.split(" ")[2:]) print(data) if game_id in data: add_to_game(data[game_id], from_number) return "Successfully joined mission " + game_id else: return "This game id was not found." else: return NO_GAME_MESSAGE # Setting up a game if ' '.join( body.split(" ")[:2]) == "enlist me" or body == 'begin enlisting': return "You are already enlisted in mission " + game_id + ". " + IN_MISSION elif body == 'start mission': start_game(data[game_id]) elif body == 'abort': remove_from_game(data[game_id], from_number) return "You have left the mission." game_data = data[game_id] phase = game_data['phase'] if phase == 0: if body == 'take' or body == "don't take": done = functions.button(game_data['button_presses'], game_data['numbers'], from_number, body, game_data['roles']) if done: game_data['phase'] = 1 return None else: return "Submitted" else: functions.send_text() return "Please type in 'take' or 'don't take'." if phase == 1 and body == 'next phase': functions.espionage(game_data['numbers'], game_data['roles']) game_data['phase'] = 2 return None player_id = game_data["numbers"].index(from_number) if phase == 3: message = "Now beginning the excecution, submit your vote by Agent Name" functions.send_text(game_data["numbers"], [message] * len(game_data["numbers"])) game_data['phase'] = 3.5 return None if phase == 3.5: role = game_data['roles'][player_id] choice = body # expects a name results, revote = functions.excecution(role, choice, game_data["total_choices"], game_data["names"], game_data["roles"]) if results is not None: while revote: if revote: message = "There is too much disagreement, try voting again" functions.send_text(game_data["numbers"], len(game_data["numbers"] * [message])) results, revote = functions.excecution( role, choice, game_data["total_choices"], game_data["names"], game_data["roles"]) continue ind = game_data["roles"].index(1) bad_number = game_data["numbers"][ind] good_numbers = [ num for num, num_ind in zip(num_ind, game_data["numbers"], range(game_data["numbers"])) if num_ind != ind ] if results: message = "Sorry Comrad, You've been busted" functions.send_text(bad_number, message) message = "Congrats Agents, You caught 'em" functions.send_text( good_numbers, [message for m in range(len(good_numbers))]) else: message = "Congrats Comrad, You know too much" functions.send_text(bad_number, message) message = "Agents Nooo, The sleeper has gotten away" functions.send_text( good_numbers, [message for m in range(len(good_numbers))]) phase += 1 results, revote = functions.excecution( role, choice, game_data["total_choices"], game_data["names"], game_data["roles"]) end_game() # phase 3: mission if phase == 2 and from_number == game_data['numbers'][0]: # get the mission list mission_list = body mission_list = mission_list.replace(",", "") mission_list = mission_list.replace(";", "") mission_list = mission_list.replace("/", "") mission_list = mission_list.split() game_data['mission_list'] = mission_list # TODO be more flexible with inputs mission_names = ' '.join([str(elem) for elem in mission_list]) functions.send_text( game_data["numbers"], ["Possible Agents:" for i in range(len(game_data["numbers"]))]) functions.send_text( game_data["numbers"], [game_data["names"] for i in range(len(game_data["numbers"]))]) game_data['phase'] = 2.25 return "Is this the mission you'd like: " + mission_names + "? Respond (Y/N)" if phase == 2.25 and from_number == game_data['numbers'][0]: functions.send_text( game_data["numbers"], [game_data["names"] for i in range(len(game_data["numbers"]))]) if "y" in body.lower(): functions.emergency_mission(game_data['roles'], game_data['mission_list'], game_data['names']) game_data['phase'] = 3 functions.emergency_mission(game_data['roles'], game_data['mission_list'], game_data['names']) if "n" in body.lower(): game_data['phase'] = 2 return "Please try again, send a list of the names you'd like to go on the mission" return None
def main(username): done = False i = 0 bg_main = pg.image.load("QImages\\road.jpg") playerImg = pg.image.load('vampire.png') pg.display.set_caption("Brain Rush!") pg.display.set_icon(playerImg) ImgList = [ pg.image.load('TutorialImages\\1.png'), pg.image.load('TutorialImages\\2.png'), pg.image.load('TutorialImages\\3.png'), pg.image.load('TutorialImages\\4.png'), pg.image.load('TutorialImages\\5.png'), pg.image.load('TutorialImages\\6.png'), pg.image.load('TutorialImages\\7.png'), pg.image.load('TutorialImages\\8.png'), pg.image.load('TutorialImages\\9.png'), pg.image.load('TutorialImages\\10.png'), pg.image.load('TutorialImages\\11.png') ] while not done: screen.blit(bg_main, (0, 0)) screen.blit(font.render('How To Play', True, (0, 0, 0)), (325, 40)) mouse = pg.mouse.get_pos() click = pg.mouse.get_pressed() functions.button('Back', 320, 550, 150, 32, screen) functions.button('>', 700, 300, 50, 40, screen) functions.button('<', 50, 300, 50, 40, screen) screen.blit(ImgList[i], (140, 80)) for event in pg.event.get(): if event.type == pg.QUIT: done = True pg.quit() if 470 > mouse[0] > 320 and 582 > mouse[1] > 550 and click[ 0] == 1 and not done: done = True homepage.main(username) if 750 > mouse[0] > 700 and 340 > mouse[1] > 300 and click[ 0] == 1 and not done: time.sleep(0.25) pg.event.wait() try: screen.blit(ImgList[i + 1], (140, 80)) i += 1 except: pass if 100 > mouse[0] > 50 and 340 > mouse[1] > 300 and click[ 0] == 1 and not done: time.sleep(0.25) pg.event.wait() try: if i == 0: i = 1 screen.blit(ImgList[i - 1], (140, 80)) i -= 1 except: pass try: pg.display.update() except: pass