DrugWars: Custom JSON Operations

in #drugwars5 years ago

drugwars-pharma4.png

Today I picked up Level 4 Pharma on my main account and Level 4 Cocina on all my alt accounts. Now that the payout structure has changed heavily in favor of the Heist I'll have to focus more on drug production.

Personally I think it is a mistake to give the Heist such a high payout in this way. It is rewarding players who are playing badly and taking short-term gains.

Overvalued Heist

The Heist exists as an escape from being attacked by overwhelming force. It is a way to prevent your account from losing everything in the event that a stronger account has targeted you. It should not be the go-to means of extracting value from the game.

That being said, rewarding accounts for drug production is not a good long-term solution either. The key to this game will be an evolving combat system that rewards players for making the correct strategic decisions. I hope the @drugwars team has what it takes. So far, they seem to be doing a good job and I like where this is going.


If it were up to me, instead of increasing the Heist payout to 3% once per day I would have created three Heists per day (every 8 hours) at 1% each. However, this is a bit much to ask for a dev team that is scrambling to scale up as fast as they can to meet bandwidth demands and fix bugs.


Regardless, I think it's pretty obvious that the payout structure will continue to change as the game evolves.

drugwars-custom-json.png

Very surprisingly, it is trivially easy to post custom JSON operations to the blockchain that can play the game. In my experience, in the world of programming, nothing works on the first try. This did; giving testament to just how simple the process is.

<h1> DrugWars Bot </h1>

Player:
<input type="text" id="author" value="edicted"><br>
Posting Key:
<input type="password" id="posting_key"
       value="STM7KtxFtRj4jXcvmvbifcAzh1rXnBWJiGuTeZAyWnKBKBoZerT1G"><br>


<script src="https://unpkg.com/dsteem@^0.10.0/dist/dsteem.js"></script>

<script>

var client = new dsteem.Client('https://api.steemit.com')
var key = dsteem.PrivateKey.fromString(
        document.getElementById("posting_key").value)
var data = {
    id : "dw-unit",
    json : '{"username":"edicted","unit":"knifer","unit_amount":"1"}',
    required_auths : [],
    required_posting_auths : ['edicted']

}
client.broadcast.json(data, key).then(function(result){
   console.log('Included in block: ' + result.block_num)
}, function(error) {
   console.error(error)
})

</script>

This script created 1 knifer on my main account on the first try.
I was thoroughly impressed so I created another knifer just for fun.


If you want to try, simply save this script as an HTML file and double click the file. You'll have to copy/paste your posting key in on line 7 and change the account name to your account on line 19 and 21 in the "data" object where it says 'edicted'.


It's been five months since I've created a tutorial for dsteem. I've been avoiding programming for quite some time for whatever reason. I think I can use @drugwars as a way to jump back into it.


Going forward I'll be creating a @drugwars script that all my followers can use directly. All you'll have to do is copy/paste the code into an HTML file and run it. I'll be setting up timers so we can build stuff at 4AM without having to wake up. Stuff like that.

glider gif.gif

Steem on!

Sort:  

I'd like to see a trainer like that. The only reason I played Diablo was because I could give myself unlimited hitpoints, go to Diablo and set a portal. PK'ers were horrible in that game, and I'd make a message like 'These witches on lvl 10 are kicking my ass. Anyone wanna help?' and the PK'ers would come to take my stuff and suddenly Diablo was kicking their ass, and they either died (and I got their stuff) or they'd kill him without thinking, and the game would end. I laughed my ass off at them.

So, if you need testers to try out your DW trainer, I'm your huckleberry.

Thanks!

What is the actual point of this game? I've been mindlessly upgrading some stuff because a lot of people were hyping it up, but it seems that's the only thing you can do... click upgrade, wait, rinse and repeat. Fun and engaging gameplay is non-existent - I really don't get why it's so popular and people are so excited about it.

Anyway, maybe this helps with further development: https://github.com/emre/heisenberg (even if it is Python instead of JavaScript).

The development team was expecting to release the game and have plenty of time to develop it on the fly. Instead, for the past two weeks all they've done is try to stabilize their server. Expect rapid development to commence once they stabilize their scaling issues.

Awesome!
Looking forward to your progress and that final HTML ;)

Posted using Partiko Android

Any idea on when the battles will be back?

Posted using Partiko iOS

How complex are you going to make those scripts? Maybe fusing the script with a nice online platform you could actually make it so player could "set" a predetermined list of buildings that they want to build + everytime the resources surpass the max amount it auto sends them to the heist...

I'll start small and add to it.
Who knows how far I'll get.

everytime the resources surpass the max amount it auto sends them to the heist...

This would require me to "hack" the drugwars server and extract the information they have associated with my accounts. They have plenty of incentive to avoid giving me that information in a convenient container.

When it really comes down to it I'm still a super JavaScript noob and I have no idea how I would go about pinging their server for information.

I could also get around this by making a simple simulation that guesses what the information should be.

I'll give you just a hint, because figuring out the algorithms and logic is fun :)

Cached user resource amount and buildings level can be requested from api.drugwars.io, you have to combine that information with production rate of each building calculated at current level and elapsed time to now. After those steps you can estimated resources level at any point of time. No "hack" is needed you have just read the game JS, currently the code is not obfuscated so it is very easy.

you have just read the game JS

What's the easiest way to do that?

  1. Get the code
    1. Open Developer tools in Chrome
    2. Go to drugwars game page
    3. Copy the JS (in my case the last line was enough (line 137))
      js.jpeg
  2. Replace \n with new lines
  3. Format the code for e. g. using (https://www.freeformatter.com/javascript-beautifier.html)[https://www.freeformatter.com/javascript-beautifier.html]
  • Learn Websocket (API uses it)
    • Calls which are used by the game you can find also in Developer Tool, just switch the tab to correct one
  • Look for text next to interesting values for e. g. in if you want to know how are the values displayed next to "Current Capacity" HTML text
    1. look for the text it in the code
    2. Next to it you will find
      Blaze.View("lookup:calculate_capacity"
    3. Then look for definition of calculate_capacity function
      calculate_capacity: function () {
    4. Now you got the math which is behind the capacity calculation

I could also get around this by making a simple simulation that guesses what the information should be.

It actually looks like the web site does the same thing. It updates from the server one time and then runs a simulation locally in the browser to cut down on bandwidth.

When the script is run, does it ask for steemconnect auth?

no
steemconnect exists so you can trust a third party with your keys.
these scripts don't send the key anywhere.
right?

I don't get it then. It seems you are using ur public keys. So if i use ur script without changing anything, it will buy you one more unit?

No, I just changed my private key to a public key so I could post it on Steem.
Normally I would just leave that field blank but I feel like it's more obvious if I put something that looks like a valid key there.

Makes sense, thnks

Coin Marketplace

STEEM 0.26
TRX 0.11
JST 0.033
BTC 64678.67
ETH 3086.68
USDT 1.00
SBD 3.87