Add a Controller Class for Running the Game #18
Labels
No labels
bug
ci
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: SlothBusters/gruppe02-slothbusters-projekt3-catan#18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/controller-implementation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Changes made in this PR will add a new
Controller
class which is able to run and handle aSiedlerGame
.Merging this PR will close #6
Nicely done. I couldn't find any apparent bugs and the documentation is good. I suppose any potential issues will eventually surface when we're done writing tests for the game.
@ -0,0 +49,4 @@
/**
* Runs a Catan game.
*/
public void run() {
Overall very good. Inline comments would drastically improve readability in my opinion. Especially around the big for-blocks.
@ -0,0 +51,4 @@
*/
public void run() {
int playerCount = io.newIntInputReader().withMinVal(2).withMaxVal(4)
.read("What's the number of players you'd like to play with?");
This works nicely. However, TextIO's default response (
Expected an integer value between 2 and 4
) isn't too user friendly in my opinion. I think we should change it something more natural if it isn't too much work. This would be low priority, of course.Missing documentation?
Generally i like the structure of the code. The
TradeAction
andBuildSelectionAction
could also be implemented in just a simple method. This however would break the consistency of actions. So I would probably just leave it like that.I thought I started a review but apparently not...
The
getIO().getTextTerminal()...
spiel could be either abstracted into a separate class or into a methodprint(message, color)
. This would also reduce boilerplate code quite a bit.Maybe with an overloaded method that just takes a message and uses the previously defined color.
This does the same thing but without a variable. A bit less complexity.
This for loop could also be extracted into a separate method which could be used in the
runTurn()
method. This would probably also increase readability.@ -0,0 +49,4 @@
/**
* Runs a Catan game.
*/
public void run() {
This method is really long and could surly be split into
runInitialTurn()
andrunTurn()
. The variablesgame
andtextView
would become a field.Instead of having to override
getX/YCoordinatePrompt()
,fetchCoordinate()
could just have two arguments where the those prompts are given. This would make the classes smaller.This is never really used apart from giving TData to buildStructure.
buildStructure()
could ask the user itself and then the generics wouldn't be necessary and the classes are smallerWe are even allowed to use this as it was discussed in the presentation "04-2_do-while_switch_IT21ta_ZH.pdf" ;)
This class could be completly omited as it isn't really needed as a type in the type hierarchy. And if
getStructureInfo()
is removed as well, then it doesn't add much code.This constructor is never used. If it is necessary later, it is easy to add.
@ -0,0 +10,4 @@
/**
* Provides information about a street.
*/
public static class StreetInfo {
If the
getStructureInfo()
method is omitted, then this could be made private.Change all instances of
TData
toT
Request changes