def __init__(self): # TODO: init current player // PlayerInfo # TODO: init enemy players (self.__enemy_list) // PlayerInfo # TODO: Добавить обработку обновления открытых карт для TableGui self.__client_player = [] self.__enemy_list = [] playerInfo = PlayerInfo('Vasya', [Card('h', 'a'), Card('c', '9')], 1000, 0, 0) self.__players = [] self.__players.append(playerInfo) self.__players.append(PlayerInfo('1', [Card('h', 'a'), Card('c', '9')], 1000, 0, 0, True)) self.__players.append(PlayerInfo('2', [Card('h', 'a'), Card('c', '9')], 1000, 0, 0, True)) self.__players.append(PlayerInfo('3', [Card('h', 'a'), Card('c', '9')], 1000, 0, 0, True)) self.__players.append(PlayerInfo('4', [Card('h', 'a'), Card('c', '9')], 1000, 0, 0, True)) self.__players.append(PlayerInfo('5', [Card('h', 'a'), Card('c', '9')], 1000, 0, 0, True)) self.__players.append(PlayerInfo('6', [Card('h', 'a'), Card('c', '9')], 1000, 0, 0, True)) self.__players.append(PlayerInfo('7', [Card('h', 'a'), Card('c', '9')], 1000, 0, 0, True)) self.__players.append(PlayerInfo('8', [Card('h', 'a'), Card('c', '9')], 1000, 0, 0, True)) self.__player_order_dict = {} # self.__opened_cards = [] self.__opened_cards = [Card('h', 'a'), Card('c', '9'), Card('s', 'j'), Card('d', 'k'), Card('h', 'q')] self.__bank = 0 # crl - change receive list self.__crl_cards = [] self.__crl_bank = []
def writePlayerInfo(): #create csv file with prefixed header tags out = open(playerprofilepath,'a') tags = 'Player,From,To,Pos,Ht,Wt,DOB,College\n' out.write(tags) out.close() print("starting to get all players information...") urls = CompareMethods.getPlayersIndexUrls(True) for url in urls: href = mainurl + url PlayerInfo.getPlayerInfo(True, href, playerprofilepath) print ('Player Info All Done!') return;
def writePlayerInfo(): #create csv file with prefixed header tags out = open(playerprofilepath,'a') tags = 'Player,From,To,Pos,Ht,Wt,DOB,College\n' out.write(tags) out.close() print("starting to get all players information...") urls = CompareMethods.getPlayersIndexUrls(True) for url in urls: href = mainurl + url #active players #PlayerInfo.getPlayerInfo(True, href, activeplayerprofilepath) #players since 2000 PlayerInfo.getPlayerInfoSinceYear(href,playerprofilepath,year) print ('Player Info All Done!') return;
def btnInfo_pushed(self): #Call the PlayerInfo class self.playerInfo = PlayerInfo(self) #Show the window self.playerInfo.show() #Raise the window to the front of the desktop self.playerInfo.raise_() #Hide the current window self.hide()
def get_player_stats(self, info, id): url = "http://stats.nba.com/stats/playercareerstats?" api_params = {'PlayerID' : id,'LeagueID' : '00', 'PerMode' : 'PerGame'} x = rq.get(url, params=api_params).json() headers = x['resultSets'][1]['headers'] results = x['resultSets'][1]['rowSet'] info.set_ppg(results[0][headers.index('PTS')]) info.set_ast(results[0][headers.index('AST')]) info.set_reb(results[0][headers.index('REB')]) info.set_stl(results[0][headers.index('STL')])
def onNetPlayerInfo(msg): global State, thisHid, scr_wait, scr_play, thisInfo, thatInfo if msg.hid == thisHid: thisInfo = PlayerInfo.PlayerInfo(msg.nickname, msg.win, msg.lose, msg.draw, msg.breakC) else: thatInfo = PlayerInfo.PlayerInfo(msg.nickname, msg.win, msg.lose, msg.draw, msg.breakC) if State == "Wait": Global.Sound.play_sample("Bufan/res/Sound/Join.wav") # TODO 提取到单独函数中 if msg.hid == thisHid: # TODO 显示Avatar scr_wait.SetPlayerInfo(0, thisInfo.Nickname, thisInfo.Win, thisInfo.Lose, thisInfo.Draw, thisInfo.BreakC) else: scr_wait.SetPlayerInfo(1, thatInfo.Nickname, thatInfo.Win, thatInfo.Lose, thatInfo.Draw, thatInfo.BreakC) else: if msg.hid == thisHid: scr_play.SetPlayerInfo(0, thisInfo.Nickname, thisInfo.Win, thisInfo.Lose, thisInfo.Draw, thisInfo.BreakC) else: scr_play.SetPlayerInfo(1, thatInfo.Nickname, thatInfo.Win, thatInfo.Lose, thatInfo.Draw, thatInfo.BreakC)
def __init__(self): super().__init__() self.setGeometry(200, 100, 1280, 720) self.setFixedSize(1280, 720) self.setWindowTitle('Omok Game!!') self.main_layer = QGridLayout() self.setLayout(self.main_layer) self.isMouseEvent = False self.isSingle = False self.isGameEnd = False self.playerinfomanager = PlayerInfo.PlayerInfo( self, self.InitGameController, self.set_network_nickname) self.MainMenuScene = SceneLayer(self) self.playerinfomanager.name_layer_create(self.MainMenuScene) self.InitGameController()
def __init__(self, data, bots, config, section): (self.host, self.port, self.name, self.pswd) = data self._handle_data_reset() # Open the database for this bot. self.db = shelve.open("{0}@{1}.db".format( self.name, self.host).replace(".", "-").replace("/", "-"), writeback=True) # Store the list of bots. self._bots = bots self.config = config self.section = section # Initialize various classes. self.ch = CommandHandler(self) self.pi = PlayerInfo(self) self.kl = KillsLog(self) self.cmds = Commands(self) BaseSocket.__init__(self) self.commands_load() ts = time.time() self.who_stamp = ts + self.config.getint("General", "who_delay")
class SquadList(QMainWindow): def __init__(self, parent): super().__init__() self.parent =parent self.setWindowTitle("Squad List") #Button set up self.btnInfo = QPushButton("Info") self.btnHome = QPushButton("Home") self.btnNew = QPushButton("New") #Widget set up self.squad_list = QListWidget() self.VlayoutMAIN = QVBoxLayout() self.hlayout1 = QHBoxLayout() self.hlayout1.addWidget(self.btnNew) self.hlayout1.addWidget(self.btnInfo) self.hlayout1.addWidget(self.btnHome) self.VlayoutMAIN.addWidget(self.squad_list) self.VlayoutMAIN.addLayout(self.hlayout1) self.widget = QWidget() self.widget.setLayout(self.VlayoutMAIN) self.setCentralWidget(self.widget) #Running the refresh_List function self.refresh_List() #Button connections self.btnHome.clicked.connect(self.btnHome_pushed) self.btnInfo.clicked.connect(self.btnInfo_pushed) self.btnNew.clicked.connect(self.btnNew_pushed) def btnHome_pushed(self): #Show the parent window self.parent.show() #Close the current window self.close() def btnNew_pushed(self): #Call the AddPlayer class self.new_player = AddPlayer(self) #Show the window self.new_player.show() #Raise the window to the front of the desktop self.new_player.raise_() #Hide the current window self.hide() def btnInfo_pushed(self): #Call the PlayerInfo class self.playerInfo = PlayerInfo(self) #Show the window self.playerInfo.show() #Raise the window to the front of the desktop self.playerInfo.raise_() #Hide the current window self.hide() def refresh_List(self): #Get all the players from the database(all entries) players = g_database.GetAllPlayers() row = -1 #Clears the list self.squad_list.clear() #Runs the loop for each entry player in the players table for player in players: row = row+1 #Sets up a blank list name_list = "" #Adds the forename intial to the list name_list = name_list + (player[1][0]) + " " #Adds the surname to the list name_list = name_list + (player[2]) #Adds the player to the main list self.squad_list.addItem(name_list)
def get_player_bio(self, info, id): url = "http://stats.nba.com/stats/commonplayerinfo?" api_params = {'PlayerID' : id,'LeagueID' : '00'} x = rq.get(url, params=api_params).json() headers = x['resultSets'][0]['headers'] results = x['resultSets'][0]['rowSet'] info.set_birthday(results[0][headers.index('BIRTHDATE')]) info.set_school(results[0][headers.index('SCHOOL')]) info.set_height(results[0][headers.index('HEIGHT')]) info.set_weight(results[0][headers.index('WEIGHT')]) info.set_years_pro(results[0][headers.index('SEASON_EXP')]) info.set_team(results[0][headers.index('TEAM_NAME')])
def gen_html(df): f = open('report.html', 'w') head = """<html> <head>Report</head> """ body = "<body>" + df.to_html() + "</body>" message = head + body + "\n</html>" f.write(message) f.close() if __name__ == "__main__": nba = Nba() data = nba.get_data() nba.parse_data(data) player_name = input("Enter Player Name: ") info = info.PlayerInfo(player_name) id = nba.find_id(player_name) df = nba.get_player_bio(info, id) nba.get_player_stats(info, id) info.print_data() pic = nba.get_player_pic(id) check_pic(pic) gen_html(df)