Ejemplo n.º 1
0
def onStatsResponse(succeeded, player, stats):
	if not succeeded:
		if player == None:
			playerIndex = "unknown"
		else:
			playerIndex = player.index
		if g_debug: print "Stats request failed for player ", playerIndex, ": ", stats
		return

	if not player: 
		if g_debug: print "No player for stats response."
		return

	if g_debug: print "Stats response received for player %d, size %d." % (player.index, len(stats))

	if "<html>" in stats:
		print "The stats response seems wrong:"
		print stats
		print "<end-of-stats>"
		return
	
	# add medal values
	for key in globalKeysNeeded:
		if not key in stats:
			if g_debug: print "Key %s not found in stats response" % key
		else:
			value = host.pers_getStatsKeyVal(key)
			if value == "":
				print "No value for stats key %s." % key
			else:
			
				try:
					player.medals.globalKeys[key] = int(value)
					if g_debug: print "Key %s has value %d" % ( key, int(value) )
				except:
					print "Could not convert value: %s of key %s: to int." % (host.pers_getStatsKeyVal(key), key)
			
	#print stats
	
	# add rank
	if not 'rank' in stats:
		if g_debug: print "Key %s not found in stats response" % 'rank'
	else:
		rank = 0
		value = host.pers_getStatsKeyVal('rank')
		if value == "":
			print "No value for rank."
		else:
			try:
				rank = int(value)
			except:
				print "Could not convert rank %s to int." % value
				
		print "Setting GSI rank %d for player %d" % (rank, player.index)

		player.score.rank = rank
		player.stats.rank = rank
Ejemplo n.º 2
0
    def onStatsResponse(self, succeeded, player, stats):
        """Outputs details about the stats response of a player."""
        if 1 != self.__state:
            return 0

        if player is None:
            self.mm.error("Received stats for None player!")
            return 0

        if self.mm.isBattleField2():
            rank_key = "rank"
            if "<html>" in stats:
                self.mm.error("The stats response seems wrong:")
                self.mm.error(stats)
                self.mm.error("<end-of-stats>")
                return 0
        else:
            rank_key = "rnk"
            if "<html>" in stats or "server" not in stats:
                self.mm.error("The stats response seems wrong:")
                self.mm.error(stats)
                self.mm.error("<end-of-stats>")
                return 0

        if not rank_key in stats:
            self.mm.error("Rank not found for player %s!" % player.getName())
            return 0

        self.mm.info(
            "Rank %s received for player(%d,%d,%s)" %
            (host.pers_getStatsKeyVal(rank_key, player.getProfileId()),
             player.index, player.getProfileId(), player.getName()))
Ejemplo n.º 3
0
def onStatsResponse(succeeded, player, stats):
    if not succeeded:
        if player == None:
            playerIndex = "unknown"
        else:
            playerIndex = player.index
        if g_debug:
            print "medals.py[486]: Stats request failed for player ", playerIndex, ": ", stats
        return
    if not player:
        if g_debug: print "medals.py[489]: No player for stats response."
        return
    if g_debug:
        print "medals.py[491]: Stats response received for player %d, size %d." % (
            player.index, len(stats))

    if "<HTML>" in stats:
        print "medals.py[494]: The stats response seems wrong:"
        print "medals.py[495]: -|-|-|-|-|-|-|-|-|-|-|-|-"
        print stats
        print "medals.py[497]: -^-^-^-^-^-^-^-^-^-^-^-^-"
        return
    # add medal values
    print "medals.py[500]: -|-|-|-|-|-|-|-|-|-|-|-|-"
    print stats
    print "medals.py[502]:-^-^-^-^-^-^-^-^-^-^-^-^-"
    for key in globalKeysNeeded:
        if not key in stats:
            if g_debug:
                print "medals.py[506]: Key %s not found in stats response" % key
        else:
            if g_debug:
                print "medals.py[508]: Key %s -> %s" % (
                    key, host.pers_getStatsKeyVal(key, player.getProfileId()))
            value = int(host.pers_getStatsKeyVal(key, player.getProfileId()))
            player.medals.globalKeys[key] = value
    # add rank
    if not 'rnk' in stats:
        if g_debug:
            print "medals.py[517]: Key %s not found in stats response" % 'rnk'
    else:
        value = int(host.pers_getStatsKeyVal("rnk", player.getProfileId()))
        if g_debug:
            print "medals.py[520]: Player", player.index, "Rank:", value
        player.score.rank = value
        player.stats.rank = value
Ejemplo n.º 4
0
def onStatsResponse(succeeded, player, stats):
	if player == None:
		playerIndex = "unknown"
	else:
		playerIndex = player.index

	if not "rnk" in stats:
		if g_debug: print "rank.py[69]: rank not found, aborting"
		return

	if g_debug: print "rank.py[72]: Rank received for player ", playerIndex, ":", host.pers_getStatsKeyVal("rnk", player.getProfileId())
	if not player: return
	

	value = int( host.pers_getStatsKeyVal("rnk", player.getProfileId()) )
	if g_debug: print "rank.py[77]: Player",player.index,"Rank:", value
	player.score.rank = value
	player.stats.rank = value
Ejemplo n.º 5
0
def onStatsResponse(succeeded, player, stats):
	if not succeeded:
		if player == None:
			playerIndex = "unknown"
		else:
			playerIndex = player.index
		if g_debug: print "medals.py[486]: Stats request failed for player ", playerIndex, ": ", stats
		return
	if not player:
		if g_debug: print "medals.py[489]: No player for stats response."
		return
	if g_debug: print "medals.py[491]: Stats response received for player %d, size %d." % (player.index, len(stats))

	if "<HTML>" in stats:
		print "medals.py[494]: The stats response seems wrong:"
		print "medals.py[495]: -|-|-|-|-|-|-|-|-|-|-|-|-"
		print stats
		print "medals.py[497]: -^-^-^-^-^-^-^-^-^-^-^-^-"
		return
	# add medal values
	print "medals.py[500]: -|-|-|-|-|-|-|-|-|-|-|-|-"
	print stats
	print "medals.py[502]:-^-^-^-^-^-^-^-^-^-^-^-^-"
	for key in globalKeysNeeded:
		if not key in stats:
			if g_debug: print "medals.py[506]: Key %s not found in stats response" % key
		else:
			if g_debug: print "medals.py[508]: Key %s -> %s" % (key, host.pers_getStatsKeyVal(key, player.getProfileId()))
			value = int( host.pers_getStatsKeyVal(key, player.getProfileId()) )
			player.medals.globalKeys[key] = value
	# add rank
	if not 'rnk' in stats:
		if g_debug: print "medals.py[517]: Key %s not found in stats response" % 'rnk'
	else:
		value = int( host.pers_getStatsKeyVal("rnk", player.getProfileId()) )
		if g_debug: print "medals.py[520]: Player",player.index,"Rank:", value
		player.score.rank = value
		player.stats.rank = value
Ejemplo n.º 6
0
def onStatsResponse(succeeded, player, stats):
	if player == None:
		playerIndex = "unknown"
	else:
		playerIndex = player.index

	if not "rank" in stats:
		if g_debug: print "rank not found, aborting"
		return

	if g_debug: print "Rank received for player ", playerIndex, ":", host.pers_getStatsKeyVal("rank")
	if not player: return
	
	
	if not player: return
	
	if not "rank" in stats:
		if g_debug: print "Rank not found in stats response"
	else:
		value = host.pers_getStatsKeyVal("rank")
		if g_debug: print "Player %s Rank:%s" % (player.index, int(value))
		player.score.rank = int(value)
		player.stats.rank = int(value)
Ejemplo n.º 7
0
def onStatsResponse(succeeded, player, stats):
    if player == None:
        playerIndex = "unknown"
    else:
        playerIndex = player.index

    if not "rank" in stats:
        if g_debug: print "rank not found, aborting"
        return

    if g_debug:
        print "Rank received for player ", playerIndex, ":", host.pers_getStatsKeyVal(
            "rank")
    if not player: return

    if not player: return

    if not "rank" in stats:
        if g_debug: print "Rank not found in stats response"
    else:
        value = host.pers_getStatsKeyVal("rank")
        if g_debug: print "Player %s Rank:%s" % (player.index, int(value))
        player.score.rank = int(value)
        player.stats.rank = int(value)
Ejemplo n.º 8
0
def onStatsResponse(succeeded, player, stats):
    if not succeeded:
        if player == None:
            playerIndex = "unknown"
        else:
            playerIndex = player.index
        if g_debug:
            print "Stats request failed for player ", playerIndex, ": ", stats
        return

    if not player:
        if g_debug: print "No player for stats response."
        return

    if g_debug:
        print "Stats response received for player %d, size %d." % (
            player.index, len(stats))

    if "<html>" in stats:
        print "The stats response seems wrong:"
        print stats
        print "<end-of-stats>"
        return

    # add medal values
    for key in globalKeysNeeded:
        if not key in stats:
            if g_debug: print "Key %s not found in stats response" % key
        else:
            value = host.pers_getStatsKeyVal(key)
            if value == "":
                print "No value for stats key %s." % key
            else:

                try:
                    player.medals.globalKeys[key] = int(value)
                    if g_debug: print "Key %s has value %d" % (key, int(value))
                except:
                    print "Could not convert value: %s of key %s: to int." % (
                        host.pers_getStatsKeyVal(key), key)

    #print stats

    # add rank
    if not 'rank' in stats:
        if g_debug: print "Key %s not found in stats response" % 'rank'
    else:
        rank = 0
        value = host.pers_getStatsKeyVal('rank')
        if value == "":
            print "No value for rank."
        else:
            try:
                rank = int(value)
            except:
                print "Could not convert rank %s to int." % value

        print "Setting GSI rank %d for player %d" % (rank, player.index)

        player.score.rank = rank
        player.stats.rank = rank