Open FWDekker opened 5 years ago
Thanks for the PR @FWDekker, I like the change :)
I'd personally prefer opposite()
as a method instead of getOpposite()
, but don't have very strong feelings about this.
@casperboone I don't really have any strong feelings either so I've renamed it to opposite()
.
When Clyde runs away from the player, it looks up the opposite of the direction it would otherwise have gone in. To find the opposite, Clyde uses a hash map that maps each direction to its opposite. This PR replaces that hash map with a dedicated function in the
Direction
class.The default branch in the
getOpposite
method is not reachable because it is not possible to instantiate new instances of an enum class, but at the same time the code won't compile without it.