playerOptions = utils.redOptions() if playerColor == 'red' else utils.blueOptions() playerOptions = [x.title() for x in playerOptions] playerMove = raw_input("%s "%playerOptions) try: responce = self.submitPlayerMove(playerMove) except utils.ServerException, e: continue print "%s Player picked %s"%(responce.get('computerColor').title(), responce.get('computerChoice').title()) print "Red: %s\nBlue: %s"%(responce['score'].get('red'), responce['score'].get('blue')) turnNum += -1 if __name__ == "__main__": ctrl = Controller() if len(sys.argv) > 1: # Check if any sys arguments were passed in while starting the game. if sys.argv[1] == '--commandLine': # Check if the command line flag was used print utils.gameInstructions() print "Point System:" print utils.getPointSystem() print "Welcome!" ctrl.newRawGame() else: # if an unrecognized flag is used display the help instructions print utils.getHelp() else: # if no sys arguments are passed then run the UI mode of game using Tk ctrl.newGameWindow()
def mainMenuClick(x, y, mainMenu, mainMenuNames, databaseInputBoxes, prevDatabasesMenu, prevConnect, prevDelete, newsqlConnect, newpsqlConnect, helpWin): itemName = mainMenuNav(mainMenu, x, y) (temp, databaseInputBoxesX) = databaseInputBoxes[0].getboxyx() databaseInputBoxesY = [] for i in range(0, 5): (inputY, temp) = databaseInputBoxes[i].getboxyx() databaseInputBoxesY.append(inputY) if itemName == mainMenuNames[0]: helpWin.clear() helpWin.refresh() prevDatabasesMenu.unhide(); for i in range(0, 5): databaseInputBoxes[i].unhide() prevConnect.unhide() prevDelete.unhide() newsqlConnect.unhide() newpsqlConnect.unhide() elif itemName == mainMenuNames[1]: # help helpWin.clear() helpWin.refresh() hide(databaseInputBoxes) hide([prevDatabasesMenu, prevConnect, newsqlConnect, newpsqlConnect]) helpWin.addstr(0, 0, getHelp("menu")) helpWin.refresh() elif itemName == mainMenuNames[2]: return "quit" elif prevConnect.itemAt(y, x): if prevDatabasesMenu.getSelected(): db = useDB(prevDatabasesMenu.getSelected()) if db is not None: hide(databaseInputBoxes) hide([prevDatabasesMenu, prevConnect, newsqlConnect, newpsqlConnect]) helpWin.clear() helpWin.refresh() return db return "failedOldConnect" elif prevDelete.itemAt(y, x): if prevDatabasesMenu.getSelected() is not None: deleteDBInfo(prevDatabasesMenu.getSelected()) prevDatabasesMenu.deSelectAll() prevDatabasesMenu.setItems(getNicknames()) prevDatabasesMenu.hide() prevDatabasesMenu.unhide() elif newsqlConnect.itemAt(y, x): if connectVia("sql", databaseInputBoxes): db = useDB(databaseInputBoxes[4].gather()) if db is not None: helpWin.clear() helpWin.refresh() return db else: deleteDBInfo(databaseInputBoxes[4].gather()) return "failedConnect" elif newpsqlConnect.itemAt(y, x): if connectVia("Psql", databaseInputBoxes): db = useDB(databaseInputBoxes[4].gather()) if db is not None: helpWin.clear() helpWin.refresh() return db else: deleteDBInfo(databaseInputBoxes[4].gather()) return "failedConnect" elif prevDatabasesMenu.itemAt(y, x): prevDatabasesMenu.selectOnlyItem(prevDatabasesMenu.itemAt(y, x)) elif x > databaseInputBoxesX: for i in range(4, -1, -1): if y > databaseInputBoxesY[i]: databaseInputBoxes[i].edit() break return None
tableMenu.setItems(tableNames) tableMenu.unhide() if len(tableNames) > 0: tableMenu.selectItem(tableNames[0]) mainPane.setResults(db.getTableInfo(tableMenu.getSelected())) mainPane.showResults(mainPane.getPageNum()) elif inTab == "Query": inputBox.unhide() elif inTab == "Search": inputBox.unhide() elif inTab == "Help": for b in helpButtons: b.unhide() b.selectOnlyItem(helpTab) helpWin.addstr(0, 0, getHelp(helpTab)) helpWin.refresh() # Be ready to capture a mouse click if mouseClick(): (mid, x, y, z, s) = curses.getmouse() # if the click in the tab bar at the top of the screen if y == 0: # select the tab at the x-position of the click newTab = tabs.selectTabAt(x) if newTab and newTab != inTab: inTab = newTab switchTab = True # Click anywhere on Main Menu page
playerOptions = [x.title() for x in playerOptions] playerMove = raw_input("%s " % playerOptions) try: responce = self.submitPlayerMove(playerMove) except utils.ServerException, e: continue print "%s Player picked %s" % (responce.get('computerColor').title( ), responce.get('computerChoice').title()) print "Red: %s\nBlue: %s" % (responce['score'].get('red'), responce['score'].get('blue')) turnNum += -1 if __name__ == "__main__": ctrl = Controller() if len(sys.argv) > 1: # Check if any sys arguments were passed in while starting the game. if sys.argv[1] == '--commandLine': # Check if the command line flag was used print utils.gameInstructions() print "Point System:" print utils.getPointSystem() print "Welcome!" ctrl.newRawGame() else: # if an unrecognized flag is used display the help instructions print utils.getHelp() else: # if no sys arguments are passed then run the UI mode of game using Tk ctrl.newGameWindow()