Review Hangman
-
generated files here index.html should probably not be in git -
the elm-stuff folder containing the downloaded dependency packages among others should not be in git -
the Main module could be split into website generation and game logic -
it might be reasonable to use elm-format to have a consistent format -
some method method could probably be refactored into multiple smaller ones for example update, view -
fromJustString
can be replaced withMaybe.withDefault "Nothing"
-
it might be good to add a type alias Color for String as the String contains the Color in the svg -
in the model it is a bit unclear what the hangman Int should be, this might be remedied by renaming or by adding and using a type alias e.g. Lives for Int -
the galgenraten folder should be deleted as it is no longer used -
there are a couple unused imports, methods and parameter (after testing it appears that atom and visual studio code don't warn about unused items) -
you are generating a new random int on every input to the text field, it should be enough to generate a new int when starting a new game -
generateMaskedWord
andshow
are not so nice how they interleave spaces between the letters, also the name show is misleading -
insert spaces only in the view List.intersperse ' '
, this would make the show function easier and for generateMaskedWord one could doString.fromList <| List.map (\_ -> '_') s
to map each char in s to'_'
or alternativelyString.fromList <| List.repeat (List.length s) '_'
-
check could also be done simpler as:
check: List Char -> Maybe Char -> Bool
check list mayChar = Maybe.map (\c -> List.contains c list) mayChar |> Maybe.withDefault False
calls to check would be changed to `check fistList (List.head secondList)`
-
guessing a word of correct length starting with a letter contained in the solution does not fail, therefore once the fist letter is known one has infinite free guesses
Edited by Eduard Raimann