billy-yoyo / RainbowSixSiege-Python-API

Asynchronous python api for rainbow six siege (r6sapi)
MIT License
130 stars 31 forks source link

Get K/D per season / current season #40

Closed RAYs3T closed 4 years ago

RAYs3T commented 4 years ago

Is there any way to get the K/D from the current / past seasons? Sure there is the total K/D over all season, but the current K/D would be more useful.

Ullizzzz commented 4 years ago

This is how i did it. Just dump season obj. and find kill/deaths. Change WhatSeasonIsThis to current season.

LookBack = 2 #How many seasons should we look up?
WhatSeasonIsThis = 14

SeasonStart = WhatSeasonIsThis-1
LookBackCount = 0

if LookBack > LookBackCount:
                while True:
                    season = await player.get_rank(R6data.RankedRegions.EU, SeasonStart)
                    SeasonStart = SeasonStart-1
                    SeasonName = SEASON_NAME[season.season]
                    if season.RANKS[season.max_rank] == "Unranked" :
                        print('notRanked')
                    else:
                        swinnloss = season.wins+float(season.losses)+season.abandons
                        if swinnloss != 0:
                            swl = season.wins/float(swinnloss)
                        else:
                            swl = 0
                        embed = discord.Embed()
                        embed.set_author(name=SeasonName)
                        embed.set_thumbnail(url=season.RANK_ICONS[season.max_rank])
                        embed.add_field(name="Highest ranks", value=season.RANKS[season.max_rank], inline=False)
                        embed.add_field(name="Season end MMR", value=round(season.mmr,2), inline=True)
                        embed.add_field(name="Season highest MMR", value=round(season.max_mmr,2), inline=True)
                        embed.add_field(name="Ranked games won", value=season.wins, inline=True)
                        embed.add_field(name="Ranked games lost", value=season.losses, inline=True)
                        embed.add_field(name="Abandoned games", value=season.abandons, inline=True)
                        if swinnloss != 0:
                            embed.add_field(name="Season W/L", value=round(swl*100, 2), inline=True)
                        else:
                            embed.add_field(name="Season W/L", value=round(swl, 2), inline=True)
                        await self.safe_send_message(self.get_channel(CHANS['genbotspam']), embed=embed)
                    LookBackCount = LookBackCount+1
                    if LookBack == LookBackCount:
                        break
RAYs3T commented 4 years ago

Good approach. I'll implement something similar. Thanks!