You are viewing a single comment's thread from:

RE: DrugWars: Custom JSON Operations

in #drugwars5 years ago

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.

Sort:  

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.

Coin Marketplace

STEEM 0.26
TRX 0.13
JST 0.032
BTC 61133.31
ETH 2887.29
USDT 1.00
SBD 3.64