def handleNextAction(self): """ Determines which method to call next and for which player If the last action has happened will pass request to scoring handler and return that response instead :return: [int playerNumber, int roundActionNumber, [Card card]] """ playerNumber = self.nextToAct cardsDealt = [] if (self.roundActionNumber == 1): cardsDealt = self.dealFirstHand(playerNumber) elif (self.roundActionNumber <= 9): cardsDealt = self.dealSubsequentRounds(playerNumber) else: tools.write_error("handleNextAction(): All action for this round has finished!") raise ValueError("All action for this round has finished!") return [playerNumber, self.roundActionNumber, cardsDealt]
def handleNextAction(self): """ Determines which method to call next and for which player If the last action has happened will pass request to scoring handler and return that response instead :return: [int playerNumber, int roundActionNumber, [Card card]] """ playerNumber = self.nextToAct cardsDealt = [] if (self.roundActionNumber == 1): cardsDealt = self.dealFirstHand(playerNumber) elif (self.roundActionNumber <= 9): cardsDealt = self.dealSubsequentRounds(playerNumber) else: tools.write_error( "handleNextAction(): All action for this round has finished!") raise ValueError("All action for this round has finished!") return [playerNumber, self.roundActionNumber, cardsDealt]
def execute_query(self, query): """ Connects to database and executes given query :param query: string SQL query :return: Result of query """ db = MySQLdb.connect(host=self.HOST, port=self.PORT, user=self.USER, passwd=self.PASS, db=self.DB) db.autocommit(True) cur = db.cursor() try: cur.execute(query) result = cur.fetchall() except Exception, e: db.close() error = "%s: %s" % (tools.get_formatted_datetime(), e) tools.write_error("There was an error executing an SQL query!") tools.write_error(error + "\n") return error