thats a rather broad question there. I am making my own little browser game mainly to entertain myself and learn from the experience. In this game I have made a first version battle engine. Its not that difficult to make in an easy scripting language or something.
Maybe it doesnt help you, but here is how my first version works.
1. Each group/army (I dont use huge armies as I have some RPG elements for my inidividual soldiers) are divided into three rows.
2. First any archers in row 3 gets to shoot one shot
3. Row 1 and 2 go at eachother. Each unit in row 1 and 2 from both sides gets to attack once. The unit attacking will first search for targets in row 1. If its empty then row 2. When a unit has attacked another unit, this unit gets to retaliate.
4. Same as last point
5. Final round all surviving units gets an attack and targets are from all rows. Here the archers could get killed (they could also get killed earlier if there is no more targets in row 1/2 for one of the groups)
Each unit can have skills like Dragonslayer(+10 base damage against dragons), Swampcreature(+2 defense and attack in swamp) and such. These skills gives bonuses (or penalties) in certain conditions based on weather, terrain, opponent race, opponent type (cavalery, archer++)
This is rather simple, but gives endles opportunites for making interesting units and battles. In order to check for the skills and calculate each attack/defense I dont plan on huge armies. Instead my game plan on having a unit AI. I have a city which is your base, but the goal is to expand and create a kingdom. When units are winning battles they will get part of the loot (and the have a salary too). If you bring a successful unit with money back to your city the AI kicks in.
The unit will be spending on levelling up (if possible), healing potions, other potions, weapons, armour, drinking in the pub++ If a unit is out in the field he/she will use healing potion if below 70% health. In a city the potion is used if below 50% health. When a shopkeeper makes enough money he will upgrade his shop and offer more goodies. Its a bit of a Majesty touch there.
I have tons of other stuff in the game (kingdom prestige is important - the king have demands constantly - prestige can give units and stuff from the king).
I will probably never finish, but its fun to think about and slowly develop.