Build this kind of game
Build attack waves that grow steadily and mix enemy types instead of sending one kind
Hand-written waves take hours, and waves picked at random sometimes send a trivial group after a hard one. Here is a way to give each wave a strength budget that always rises, then fill it with a varied mix and report how much is left over.
Decide who has won a battle, including when everyone loses in the same moment
An explosion kills the last unit of both sides at once, or a player has no soldiers left but still a barracks. A victory check that runs after every single death announces the wrong winner. Here is when to check, what counts as being alive, and how to call a draw.
Make units stop when they walk next to an enemy, but let them step away
A line of soldiers should block an enemy from running past it. The usual rule is easy to get half right: either units can slip by anyway, or a unit that starts next to an enemy is stuck forever. Here is the rule that does both jobs and what happens on the first step.
Zoom the map toward the mouse pointer instead of jumping to the middle
Zooming a big map should keep the thing you are pointing at under your finger. Many versions slide it away, or show empty space once the map gets smaller than the window. Here is the maths for a camera that zooms at the pointer and stays inside the map.