You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@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.
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.
The text was updated successfully, but these errors were encountered:
Why not invert it and provide utility filters? Either by methods or by java.util.function.Predicates:
Instead of canBuild(myUnitType, SUFFICIENT_...) it'd be: hasResources.and(hasTech).and(canBuildAt(10,10)).and(canMakeMeASandwich).test(myUnitType)
Since Predicate also has or and negate it should suffice.
@dgant has mentioned how ambiguous
can
methods can be. Quoting from Discord: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:
e.g.
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
orfalse
for the method to use in its check.The text was updated successfully, but these errors were encountered: