I'm recreating the Game of Thrones Board Game. If you've played it, then this post will be even easier for you to understand.
Simply put, the board is split in to territories.
A player can have as many units as they want, so long as there is only one in each territory.
For simplicity's sake;
A player is only allowed one territory to hold up to three men, and two territories to hold up to two each. (In the actual game these allowances change, but that doesn't affect this problem).
I've programmed the different territories as areas over a bunch of connected turfs, and the 'men' as objs.
How would you cycle through all the men (or territories), and discern whether the allowances have been met?
Furthermore, I'd like to test if a specific Territory can have another unit added and still meet the allowance. This bit seems the trickiest.
Foreseeable problem: the computer sees an army of two, and compares it to the allowance of three, and passes. But then sees an army of three, compares it to the allowance of two (as the three is taken) and then fails, despite the allowance being met.
Apparently, you have a certain allowance of how many territories can have 2 units, how many can have 3 units, etc., and you can have unlimited territories of 1 unit.
// these lists are all potential amounts associated with something This is untested code off the top of my head after googling the rulebook. There are probably better ways to do this. |
Loop through area turfs for soldiers, when you're done call checktroops()