fire-eggs / CivOne

An open source implementation of Sid Meier's Civilization 1 using C# and .NET.
Creative Commons Zero v1.0 Universal
20 stars 4 forks source link

`TribalHut` method code smell #145

Open fire-eggs opened 2 years ago

fire-eggs commented 2 years ago

The TribalHut method is implemented in a strange fashion.

It is implemented recursively to no real purpose.

The only call to the method that is non-recursive is to use the default parameter for a random result.

I suggest refactoring the method to remove the recursion. The switch (Common.Random.Next(0,4)) to go first and assign a local variable the desired result. The switch(result) to go second and use the local variable.