Using Powershell To Gather Opponent Information, Track Earnings, and more in Splinterlands

in #splinterlands3 years ago

The Gist

In this post I will talk about a new powershell module I wrote to easily allow any player to interact with the Splinterlands API to do various tasks, including gathering information about your current opponent, get a breakdown of earnings, and more. Let's start off with one I think most people would be interested in, gathering information about your current opponent. There is currently another tool that allows you to gain information on your opponents battles, but it requires a license, so hopefully my tool evens the playing fields for all as it is completely free to use and open source.

Getting Information About Your Opponent

I would first like to say that I think the previous exploit of being able to see your opponents hand once they submitted it was a form of cheating and I am happy it has now been fixed. Also the guide to installing this module that has the below commands will be shown at the the end.

I was skeptical if I should even release the command I am about to show you, but I have decided that is not as helpful as it first seems and if everyone has it available to them then it is fair game. So what does this command do? Well it basically grabs your current opponents last 50 battles and crunches the numbers to give you a summary of the summoner's they must used along with the monsters they use most with that summoner. See the example below!

Powershell

Get-slPlayerOutstandingBattle -PlayerName mrpig29 | Get-slPlayerBattleSummary

Current Quest : Life - In Progess
Top Summoners : Bortus - 36% | Blue | magic: -1
                        Pirate Archer     | 94% | L: 1 | ranged: 1  | A: Blast
                        Sea Monster       | 89% | L: 1 | attack: 4  | A: Heal
                        Furious Chicken   | 67% | L: 1 |            | A:
                        Crustacean King   | 61% | L: 1 |            | A: Tank Heal
                        Axemaster         | 39% | L: 1 | ranged: 2  | A: Double Strike
                        Battering Ram     | 33% | L: 1 | attack: 1  | A: Opportunity

                Drake of Arnak - 22% | Gold | armor: 1
                        Djinn Chwala        | 91% | L: 1 | attack: 2  | A: Thorns
                        Furious Chicken     | 55% | L: 1 |            | A:
                        Kobold Miner        | 36% | L: 1 | attack: 1  | A: Sneak
                        Flame Monkey        | 27% | L: 1 | attack: 1  | A:
                        Serpentine Mystic   | 27% | L: 1 | magic: 1   | A: Affliction
                        Serpentine Spy      | 27% | L: 1 | attack: 2  | A: Opportunity

                Tyrus Paladium - 14% | White | armor: 1
                        Feral Spirit          | 71% | L: 1 | attack: 1  | A: Sneak
                        Armorsmith            | 57% | L: 1 |            | A: Repair
                        Shieldbearer          | 57% | L: 1 | attack: 2  | A: Taunt
                        Truthspeaker          | 57% | L: 1 |            | A: Protect
                        Venari Crystalsmith   | 43% | L: 1 | ranged: 1  | A: Tank Heal
                        Battering Ram         | 43% | L: 1 | attack: 1  | A: Opportunity

Top Monsters  : Furious Chicken - 52%
                Pirate Archer - 38%
                Sea Monster - 32%
                Battering Ram - 24%
                Crustacean King - 22%
                Djinn Chwala - 20%

So in the above example, the current opponent for mrpig29 uses the Bortus summoner 36% of the time. Additionally, when the players uses this summoner they use Pirate Archer 94% of the time! This will give some key insights of your opponents general strategy. Each time you run this command as shown above it will automatically filter out any colors that your current match has inactive. So the opponent might actually use a red summoner 50% of the time, but since that color splinter is not allowed for this particular match it is filtered out. One side note, if you just started a battle then sometimes the command will fail the first time. Just run it again and it usually works.

Now at first glance this information might seem to give you a HUGE advantage, but honestly seeing your opponents last 5 battles that Splinterlands already provides usually gives a clean enough snapshot of your opponents general strategy. Also, in higher level leagues where there are lot of rulesets and inactive colors, players usually have a pretty even spread of card and summoners that they use making this information even harder to read into. Let's not forget the time is always ticking and spending too much time looking your opponents data might leave less time thinking about your own hand.

The only information I feel is slightly unfair is knowing what your current opponent's quest is at the moment. In this case it was the life quest. However, in practice I have notice players often ignore the current quest in favor of putting up their strongest hand. If possible, I think it would be better if Splinterlands hides this information from the public API. However, since it is out there I think everyone should have easy access to it so no one has the upper hand.

Getting and Logging Transactions (Balance History)

For this section, I would like preface it by saying you should probably be playing the game for fun first and foremost (in my opinion). Trust me, there are faster and easier ways to make money than playing Splinterlands. That being said, many people like to track their earnings and I see many YouTubers have spreadsheets that they fill out. That process looked incredibly tedious to me, so why not write a Powershell function to quickly grab that information instead and crunch the numbers for you. The fist command I will show will allow you to grab different types of transactions for a user.

Powershell

 Get-slBalanceHistory -UserName mrpig29 -TokenType SPS -TransactionType claim_staking_rewards -Limit 5

player  token Amount type                  balance_end block_num created_date          counterparty
------  ----- ------ ----                  ----------- --------- ------------          ------------
mrpig29 SPS   0.001  claim_staking_rewards 5.707       59269254  11/17/2021 6:57:09 PM $SPS_STAKING_REWARDS
mrpig29 SPS   4.227  claim_staking_rewards 4.231       59269243  11/17/2021 6:56:36 PM $SPS_STAKING_REWARDS
mrpig29 SPS   0.004  claim_staking_rewards 202.519     59242180  11/16/2021 8:19:12 PM $SPS_STAKING_REWARDS
mrpig29 SPS   2.299  claim_staking_rewards 99.179      59242153  11/16/2021 8:17:51 PM $SPS_STAKING_REWARDS
mrpig29 SPS   2.295  claim_staking_rewards 95.314      59226455  11/16/2021 7:10:27 AM $SPS_STAKING_REWARDS

So in the above example I grab the last 5 SPS staking rewards claimed by the user mrpig29 (me). This would be equivalent to clicking on your username in Splinterlands, clicking "Balance History", then clicking the SPS tab and choosing "Claim Staking Rewards" from the drop-down menu. Pretty much any information you grab on that Balance History window you can get with this command. Now Splinterlands only provides the last 30 days for any of these transactions, so if you want to keep a log of these records you may want to start pulling this info daily or weekly and storing it in a csv file. This can easily be done using the below command.

Powershell

Get-slBalanceHistory -UserName mrpig29 -TokenType SPS -TransactionType claim_staking_rewards | Export-Csv -Path 'C:\users\mrpig29\spsStakingClaims.csv' -NoTypeInformation

The above command will shove all that information into a CSV file that you can open with excel.

Getting DEC Earnings Breakdown

The last command I want to discuss is Get-slDECRewardsSummary which will give you stats on your average earnings from battles, quests, and seasonal chests. I think this is probably the more interesting commands, especially players who are really focuses on the Earn part of Play to Earn. Lets see an example of the type of information this command outputs.

Powershell

 Get-slDECRewardsSummary -UserName mrpig29

RewardType RewardCount AvgReward AvgDailyDEC AvgRewardsPerDay Total    TotalDays
---------- ----------- --------- ----------- ---------------- -----    ---------
Battle     629         5.63      126         22               3540.104 28
Quest      17          11.35     7           1                193      27
Season     2           62        8           0                124      15
All        648         5.95      138         23               3857.104 28

This makes tracking your earning for the last 30 days much easier, no more filling in spreadsheets! Lets breakdown this breakdown of my DEC earnings. The first row are my battle rewards, which I have 629 of in the last 28 days. My average reward was 5.63 and my daily average was 126. In total I made 3,540.104 DEC from winning battles in the last 28 days. It then shows that I got a total of 193 DEC from 17 quest rewards, and 124 from by end of season chest. Lastly, it adds all these categories together on the last row. Note this does not include card rewards or credits from the chests you get from Quest and End of Season.

Installing PSSplinterlands Module

You might first wonder if this is even safe to install, and that should always be the first question you ask! The code is 100% open source and can be found on my Github. You can see that I have also have written many other API modules and even tools for other Crypto related things such as Chia and that particular tool was installed over 30,000 times.

Even if you have never used Powershell before installing this module, then this still should be very easy. You only need to run a single command and it will be installed from the Powershell Gallery. The command to run is shown below.

Powershell

Install-Module -Name PSSplinterlands -Repository PSGallery -Scope CurrentUser

You might run into some prompts saying PSGallery is untrusted gallery, this default behavior. Just type Y and hit enter. PSGallery is hosted by Microsoft, however that does not make everything on this site safe as there are 10,000's of modules which is why they have it as untrusted by default.

If you run into any problems you can see full install instructions on my Github.

Conclusion

I hope this article was different than most Splinterlands posts and that you try out the module I wrote. My main goal was to make it easy for normal players to have easy access to the Splinterlands API. There are many commands that are missing and that I want to add in the future, but I hope the ones I mentioned in this post are helpful to those reading this. If this guide was not enough and you want me to make YouTube video show more examples, then let me know in the comments. Lastly, If you find this tool or article useful please like it, comment and share it. Thanks for reading!

Acknowledgements

In the process of making this module I used the documentation provide by kiokizz github page, which provides documentation of Splinterland's API. Thank you so much! I also had to use the f12 dev tools quite bit even with this documentation though.

Sort:  

I really think this goes against the nature of the game as it is intended. Its definitely not against the rules or anything but I think it crosses that ethical borderline.

That said, very cool coding project!

I actually do agree and I personally do not use the battle summary command when I play. For one it is not as helpful as it first looks, especially in higher leagues. I decided to show everyone since there is a similar tool that is paid to use. I didn't think you should have to pay to have something that is available to everyone. I hope people find more use in the other commands :)

Hello @mrpig29! This is @indayclara from @ocd (Original Content Decentralized) team. We saw that you already posted your first blog here in Hive! Congratulations and welcome! Great to hear you are enjoying Splinterlands.

Anyways, the best way to start your journey here in Hive is do an awesome introduction post. You can choose on whatever information you would like to share and be creative as you want to be. This will help other Hivers get to know you and be comfortable supporting your works here.

It's also best to subscribe to other Communities you like and share your blogs there to have a wider range of audience. Or you can check out the Communities Incubation Program.

Also, letting you know since content on the Hive platform is monetized, using other people’s ideas or images could be considered as an offense and which is also viewed in a serious light on the blockchain. Here is a useful collection of resources about how plagiarism and abuse is viewed and handled on Hive.

If you are looking for tips and information as a Hive newbie, click here: Newbie guide. If you have questions, you can hop into Discord server and we'll gladly answer your questions. Feel free to tag @lovesniper @indayclara once you have made your awesome introduction post! See you around.

Is it possible to run this in a terminal on Ubuntu?

Yes I am doing it.

Great work! Nicely formatted output data and giving the opponents card pick rate is a cool addition. I'm sure this will be useful for a lot of people.