Game Modules¶
shell¶
Takes input from user/s.
Control the game through parse the input and call the equivalent method to operate the work.
game¶
Process operations according to input taken in shell.py.
The instance of game class is created within shell.py. After analyzing the input, game object reach the equivalent method for processing
-
class
app.game.Game[source]¶ Bases:
objectGame Class.
-
create_player(player_amount)[source]¶ Create Players according to passed parameter.
Get info from shell.py, fit equivalent players with names. Turn computer_controller on/off.
-
roll()[source]¶ Reached by human players.
Call other methods to make operations depends on die rollments.
-
set_face(num)[source]¶ Set value in variable to hold dice face before automatic rolling.
This method used for testing purpose.
-
still_going= False¶
-
switcher()[source]¶ Switch between players.
Considering if the game has computer controller or not, based on that it calls a method to switch between players
-
win_pig= 50¶
-
dice¶
Present dice object used in the game.
highscore¶
The class accepts instances of players.
To be able to save scores at the end of the game. Player has ability to read score file when script runs
histogram¶
Recive players lists and organize printable style.
Considering players list score, each printed row equable the face that player got when he rolled dice.
intelligence¶
Controls the intelligence computer player.
According to chosen level the class make decision for next movement.
-
class
app.intelligence.Intelligence(level)[source]¶ Bases:
objectIntelligence Class.
-
cheat_decison()[source]¶ Create computer decision about cheating.
Use same boolean tuple to init decision.
-
get_inti_decision(player, dice_value)[source]¶ Return a method using currying approach to set level.
-
orders= (True, False, True)¶
-
Test Modules¶
test_game¶
Test game module.
-
class
test.test_game.TestGameClass(methodName='runTest')[source]¶ Bases:
unittest.case.TestCaseTest Game Class.
-
test_computer_turn_calls_switcher(mock_calls_switcher)[source]¶ Tests switcher callable by comuter-turn method.
-
test_dice¶
Test dice file.
test_highscore¶
Test highscore module.
test_histogram¶
Test Histogram module.
test_intelligence¶
Test intelligence module.
-
class
test.test_intelligence.TestIntelligenceClass(methodName='runTest')[source]¶ Bases:
unittest.case.TestCaseTest Histogram Class.
-
test_act_hard()[source]¶ act-hard method where it returns true when computer dicide to cheat.
The method returns True when dice-face between 2-5.
-
test_act_hard_calls_easy(mock_calls_act_easy)[source]¶ Tests act-hard calls easy when cheat_decison = False.
-
test_act_normal(mock_calls_act_easy)[source]¶ Tests act-normal returns True/False.
When computer-player score is less than 10, another test to assert it calls act-easy if the score higher that 10.
-