Post news 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...


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).


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
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.