/mastermind

Primary LanguageScalaMIT LicenseMIT

bannerImage


MAIN status codecov

RepoSize License Forks Watcher Reddit


Contributors

LarsBuergerr Smokey95
image image

Description

This is a implementation of the game Mastermind. The game is played against the computer. The game creates a secret code of four to five stones (depends on the chosen difficult) . The layer tries to guess the code. After each guess the player gets feedback about how many stones are in the right position and how many stones are in the wrong position. The game ends when the player guesses the code or when the player has used all his tries.

How to play

Icon Description
Courser shows the current selected color which is used when placing stones
Scroll down your mouse wheel to change the courser color and therefore the stone placing color
Place your guess on an empty stone in the current row (see point below)
Empty stone where you can place your hint (Shows the active row)
Hint that shows you that you guess a right color but at the wrong position
Hint that shows you that you guess a right color and at the right position

Win/Lose

You won the game if you guess the secret code so that all hint stones are red. You lose the game if you used all your tries and you did not guess the secret code.


07-Design Pattern Info

The following pattern are implemented:

Strategy:

The strategy pattern was used to select a gamemode according to userinput. See the implementation here

Factory:

The factory pattern replaces the original enum declaration of the stones. To show the difference the game-stones are implemented using the pattern, the hint-stones are still implemented as enum. See the implementation here

State:

The state pattern was used to keep track over current game state. There are events defined to switch the state of a game instance and methods to check the current state. See the implementation of the states here. The Events are defined here. To switch between states there is a handler (called request) implemented in game class here

Chain of Responsibility:

The Cain-of-Responsibility is used so analyze users input. See the implementation here and in the game class


Attribution

We thank the following people for their contributions to this project ( :) ):

Creator Content Link
Smashicons Mouse Scroll Icon Scroll Logo Template
Dave Gandy Undo Icon Undo Icon Template
Dave Gandy Reset Icon Reset Icon Template
Dave Gandy Save Icon Save Icon Template
Dave Gandy Load Icon Load Icon Template
Dave Gandy Help Icon Help Icon Template