kalkulus avatar

Updates to spltools. Classes for Brawl data

kalkulus

Published: 18 Oct 2024 › Updated: 18 Oct 2024Updates to spltools. Classes for Brawl data

Updates to spltools. Classes for Brawl data

Image created with Bing Image Generator.

I've begun work on an updated version of this post Celebrating 200 Splinterlands Brawls. A compilation of historical guild results and top brawlers. . That one was after we passed 200 Brawls. Now we have passed 250 and its time to do another one. Unfortunately, I was too busy the last weeks to time the post with the completion of brawl #250. Nevertheless, the update is coming soon.

I could have just used the same code I did last time, and had the post up already. But I wanted to take the chance to update spltools with code to work with guild data. Therefore, it will be a bit longer before that post is ready.

In this post I will go over the code I have added to spltools so far in this process. I'm also copying some of the code that I usually use to produce brawl reports.

Summary of updates
  • Class to download and work with brawl data.
  • Class to contain player brawl results.
  • Example script for using these classes.
  • New urls added to settings.py (Tournaments url, and some artwork urls).

separator.png

New class: Brawl

I added a class for working with brawl data:


image.png

With the functions collapsed, the class summarizes to:

image.png

We have the init function, an internal function to fetch the brawl data, a string representation of the class, the function print_results, which prints results for each player in the guild we specify and a function to print a markdown table with the brawl results:

image.png

The output of this function produces tables like this:

GuildWinsLossesCrowns SPS Merits
Absalom90+3840148117.9508457
Aggressive Gamblers83+3847140111.4997333
PeakMonsters Legion90+2422131105.0497486
PeakMonsters [Vikings]57+387311087.5415762
PeakMonsters [CHAMPS]44+38869575.5624976
Team Possible Diamond37+38938669.1114914
Roaring Twenties41+15486551.6033714
Druids20+7373124.8801624
HD HYBORIAN DREAM10+4501512.901714

You might have seen these tables before if you clicked into one of my brawl reports.

New class: BrawlerResults

This class is a simple container that we use to store a player's results in a specific brawl. It collects the relevant data from the dictionary we get as part of the data returned by the call to find_brawl.


image.png

I also added a simple string representation, so that we can do:

print(brawler_result)  # Where b is an instance of BrawlerResults
> kalkulus, fray 6: 8 W, 0 L, 0 AW.

separator.png

Usage example

This file can be found at examples/brawl_data_example.py.

image.png

Output:

image.png

separator.png

Final words

Thank you for your attention. If you are interested in more posts about the spltools python package, you can find the previous ones here:

spltools update posts:

spltools update: Reward chest classes
spltools update: Checking which set a card belongs to
Initial spltools commit


If you have not yet joined Splinterlands please click the referral link below to get started.


Join Splinterlands


Best wishes
@Kalkulus

separator.png

Leave Updates to spltools. Classes for Brawl data to:

Written by

Read more #splinterlands posts


Best Posts From kalkulus

We have not curated any of kalkulus's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From kalkulus