Closed mwadle closed 2 months ago
Very elegant, as always :)
I think the bots should be able to do this too, mostly for completeness' sake. Do you mind extending their behavior accordingly? Probably the relevant part of the BotAI class could be refactored in a similar manner but I can do that later.
Very good point. I'll work on adding the behavior to the bots this weekend.
I pushed the change. I don't really know a reliable way to test this, but I figure its a straightforward change.
If you want, I could take a stab at trying to refactor part of the botAI class sometime this week. I think I see a way to try to make the AI more efficient at using existing units rather than purchasing new ones.
I say it seems straightforward, but I messed it up. Pushed a new commit that is hopefully better.
Also if I refactor I might also try to normalize the calculation to figure out if the kingdom can afford the upgraded unit, and check it more consistently.
I ran some unit tests and could at least test that your code was called and nothing blew up, which is good enough for me ;)
Feel free to do any refactoring in the BotAi class and send a PR. Not sure why the income is not checked in all cases. Maybe because combining existing units is not as impactful on the income as buying new ones. It's been a while since i wrote it.
Thanks for your contribution!
Rework unit combination logic to allow two spearmen to be combined.
Not sure if two spearmen are supposed to be able to be combined, but if so this will allow for it.