-
Notifications
You must be signed in to change notification settings - Fork 10
Description
@dgant has mentioned how ambiguous can methods can be. Quoting from Discord:
Maybe not buggy necessarily, but "canBuild" can mean a lot of different things and the differences are important
can this SCV build a Barracks at X,Y?
...do you mean now, or when i get the money?
...do you mean if there's no units standing at X, Y?
...do you mean if the SCV has a path to X, Y?
...do you mean once the tech to build it becomes available?
Maybe it would be beneficial to create some type of predicate data structure that can be fed into the method so that the user can choose exactly what he wants to check and when.
Something like:
canBuild(UnitType unitType, Predicates...)
e.g.
BW.canBuild(UnitType.Terran_Siege_Tank, SUFFICIENT_MINERALS, SUFFICIENT_GAS, TECH);
Where it will check if you have the minerals, gas, and the tech to build a siege tank.
It was also mentioned that maybe you want to check if an SCV can build at a certain location without units, so you could feed in the TilePosition and specify to check if anything is blocking the location but would be buildable, etc.
Another benefit of this would be if you want to know if you will have sufficient minerals in N amount of seconds to build a tank, you can feed in an already defined custom predicate that will return true or false for the method to use in its check.