magowiz / Castle-Age-Autoplayer

Auto player for Castle Age game on Facebook.
http://caaplayer.freeforums.org
20 stars 30 forks source link

Workerization #200

Closed Artifice closed 9 years ago

Artifice commented 9 years ago

Major rewrite of almost all files to make CAAP code more compartmentalized and hopefully simpler to understand. Previously, when trying to work on something like the monster worker, I would have to make changes in caap_mainloop.js, caap_base.js, monster.js, caap_monster.js, and caap_monsterdash.js. Adding a new worker would require opening a similar number of files and chasing variable and function names all over.

To simplify the code, I've implemented a basic worker structure and am pulling the settings required for a worker out of all the other files and into one file for one worker. For example, the monster worker is worker_monster.js. As part of this, I'm also removing a lot of duplicate code from many workers. For example, monster, battle, guild battles, town, army, and recon all had their own functions for load, save, getitem, setitem, and deleteitem. These routines have been deleted, and replaced with standardized getRecord, setRecord, deleteRecord functions in the worker.js file and used by all the other workers. Also, I updated the get and set find functions from a for (var i = ...) structure to use array mapping and indexOf, which is about 80 times faster.

Other areas still need to be fully moved over to the new system, such as guild records, essence, gifting, conquest, etc. The dashboard functions for each worker still require modifications to the caap_dashboard.js file. Quest worker is still not a separate file, but rather buried inside of caap_base.js. I'll clean those up as I get around to working on them.

Other stuff

Monster Fix to use level up general when making a big stamina hit on a monster before levelling up. Fix general level multipliers for monsters Fix for occasional miss of monster identifier, causing possible unlimited healing.

Generals Tune general changes to allow stat changes when at or above max if new general has same modifier as old general

Finder Changed name of tier from 1, 2, 3 to match game terms of "low," "mid," and "high." *Settings names have been changed, so you will need to reset your finder settings Note, guild feed review not implemented yet, even if it appears on the list Change Finder so all monsters will get first review, even if not set to scan at regular intervals. Fix to stop from using a charged crit general, like Banthus, on joining a monster when a big hit isn't possible. Add a keep watch function for Finder, so you can watch if your friends summon monsters, and automatically join them if you want. Add "keep" finder modifier to flag such monsters found searching friends' keeps, similar to "conq" modifier for conquest monsters. Add a name or picture name counter to the feed eval, so you can hunt a monster until it drops a certain amount of a particular item. For example, I'm hunting Valhallas to fill out my Item Archives, so here's my Valhalla finder string: valhalla:j[undermax == 0 && (stamina > 2000 || levelup) && life > 20]:s[needname('Eye of the Storm', 5) * 10 + needname('Tempest Elemental', 12) * 30 + needname('Stormcrusher', 12) * 40 + needname('Stormbinder', 12) \ 1 + 30 + life / 100]:burn needname is case insensitive, so "Stormcrusher" or "stormcrusher" both work. needpic works similarly, but requires full pic name, like "seamonster_map4.jpg" for the emerald serpent Atlantis map piece.

Guild Battles Fix for rogue smoke bomb attack

Other Remove item reports. The new record format broke this code.

1.99 MB (2,094,140 bytes) to 1.89 MB (1,982,519 bytes) ~5% decrease

51 files reduced to 35

Artifice commented 9 years ago

Thanks!

On Sun, Mar 1, 2015 at 10:08 PM, magowiz notifications@github.com wrote:

Merged #200 https://github.com/magowiz/Castle-Age-Autoplayer/pull/200.

— Reply to this email directly or view it on GitHub https://github.com/magowiz/Castle-Age-Autoplayer/pull/200#event-243948143 .

To avoid this the XP community uses Refactoring. Refactoring is the term used when improving the internal design of a system without changing the external behaviour. Code Rot is the reverse of this, which I call ‘Refuctoring’. -- Dave Chaplin http://www.byte-vision.com/ProductivityArticle.aspx