Ok, planning time.
I'm working on implementing armies and units and combat and...I realize that I have to design this out properly ahead of time. Not in an abstract sense, but in an actual 'how will the code work' sense.
So to start, we have Armies. Armies have a few core things we need. First, it needs to have a list of Units, and at least 1 unit in that list. So it'll need to have a starting unit. Next it'll need a Faction to belong to, so that will also have to be a starting attribute. Armies can also have a commander, although that I'll add in later and it should be determined based on the units assigned to that army. So I don't need to worry about that right now. We do need a position on the World Map, though, and we'll need a way to show units moving around on the world map.
Which means I need a World Map layer for Armies.
One thought I have is that there could be two types of Armies, Garrisons and Mobile armies. If I go that route, Garrisons would be automatic. Every single city would have a Garrison Army at the start of the game with whatever default units it needs to do so. All units produced in a city would automatically be assigned to the Garrison. Mobile armies, then, would need to be created OFF of other armies. This in itself is fine, since you'd want to be able to Split or Join armies as needed. I'm not sure if this is really necessary, though. It's not all that different from having a new army created if there isn't one in the city. It would answer the question of which army gets any new units produced, though, which could be useful. Otherwise it might not be too obvious to the player how units get added to armies if there is more than one army in a city.
Hmm. Ok, now you'd have an army with 1 or more units, it would have a faction and it would be somewhere in the world. All good stuff. Now what?
Well, we need to move it around. So we'd need some way to measure how fast the army can move as well as any terrain modifiers it gets from the units inside it. Obviously, it can only go as fast as its slowest units and would need all units to have a terrain modifier in order to apply that to the army as whole.
Might want to give the player the ability to nickname armies as well. Maybe use that with the Garrisons so that they get a default of [City] Garrison for those and Army # for the others? Probably reasonable as a start.
That's probably enough for the moment. I'm sure I'll think of more as I get that implemented.
Now for Units. Those are kind of complicated when we look at the list at the start. But we can get away with just having the basics, for now.
Let's take the Swordsman as our example:
Type: Swordsmen
Attack: 50
Defense: 20
Damage: 10
Figures: 100
Hit Points per figure: 10
Attacks per phase: 1
Phase: Melee
Morale: 100
Rank: Captain
Cost: 600
Upkeep: 720/13.85 (year/turn)
Build Time: 4
Pop Type: Male
Special: Shield
We're going to want most of that. Maybe leave out the Specials for now, just so we can get things rolling. They're complicated, and we don't need them yet. Nor do we need officers for the base unit aspects to work. So...strike a few of those out and we get our core. Now, we need to add in a link to the Army that the unit is part of, which is pretty easy. We can also give them the nickname capability. Not sure if we'll use it off the bat, but that's easy to code in so we can give them that to start with.
Once those are all done, I think I'll be able to have the game pop some armies and give them some units. Should be fairly straightforward, I think.
Next will be the interface options to let you select armies that belong to you (just 1 at the start) and move them around. And after that we get combat. AI to move around armies can come even later.
But one thing at a time. Let's get the armies and units out there first, then I can worry about making them do something.