• Register

The world of Let Thrones Beware is yours to conquer. Occupy countries, seize planets, dominate solar systems, and expand your sphere of influence across galaxies. Unlock a detailed technology tree containing hundreds of unique items that provide meaningful contributions to the progress of your society. Deploy your forces to conquer enemy territory and occupy their cities. Expand your reach to the stars and seize what is rightfully yours. Combine technologies to design and produce weapons of war based on your priorities.

Post news Report RSS Better combat through code review (A journey through the back-end code of Let Th

On this week's episode, we begin to dig into the code behind Let Thrones Beware in an effort to make it better.

Posted by on

I'm taking a different approach for the next series of blog updates; rather than just post updates completed features and previewing updates at a high level, I will be putting up a really detailed examination of what's changing, why it's changing, and how it's been coded!

Without further ado...

Problem


Old and busted

Right now, combat is functioning, but it's a mess of procedural functions and linear code. It's not very extensible, nor is it conducive to unit testing, which means that it can be a crap-shoot as to whether a feature update will break a bunch of unrelated functions and cause a catastrophic failure (which is what we don't want to see).

Now, since it's working properly right now, we could leave it well enough alone and never again touch combat, which is a solution, but it's honestly not a very good one. What if I want to add features down the road? The bailing wire and prayer approach has got to go, especially because the next game update is going to include ....

Hex based combat and support for more than two armies on the field at once! Wham! How cool is that? (It's awesome).

Solution


A sampling of the new and improved approach

What we're going to do is move to a wonderful world of objects everywhere! As you can see in the above shot, the new approach is entirely object-oriented. Rather than storing an army's unit data in a messy `ol array, the new system will put each unit into an object, encapsulating not only quantity and casualty data, but also weapon, armour, and platform objects so that each unit is a stand-alone. Another advantage of this new approach is that I'm able to reuse weapon, armour, and platform data, as well as the country technologies, between campaigns, rather than going back to the database with each combat the engine has to process.

This will end up being an involved process, as it'll involve creating systems for units, weapons, platforms, armour, as well as campaign management setup that includes logging, terrain, and army placement.

Next Time

Upgrading our database to support hex combat and persistent fields of battle!

Website - Dev Blog - Facebook - @afuriousengine - /r/LetThronesBeware

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: