Game Handler

class afc.games.game_handler.GameHandler(game_status=GameStatus.IN_PROCESS, score=_Nothing.NOTHING, round=0, total_rounds=3, opponent_strategy=None)

A class to handle game logic within a Challenge block.

check_for_game_over()

Check if the game has ended.

get_opponent_move(user_move)

Get the opponent’s move based on the chosen strategy.

get_possible_actions()

Generate the possible actions based on the current game state.

abstract handle_action(user_move)

Handle a user action, updating the game state appropriately.

class afc.games.game_handler.GameStatus(value)

An enumeration.

class afc.games.rps_game.RPSGameHandler(game_status=GameStatus.IN_PROCESS, score=_Nothing.NOTHING, round=0, total_rounds=3, opponent_strategy=None)
class Choice(value)

An enumeration.

handle_action(user_move)

Handle a user action, updating the game state appropriately.

class afc.games.rps_game.RPSLSGameHandler(game_status=GameStatus.IN_PROCESS, score=_Nothing.NOTHING, round=0, total_rounds=3, opponent_strategy=None)

Extends the existing rules of Rock-Paper-Scissors with Lizard and Spock moves.

Rock crushes scissors and crushes lizard, scissors cuts paper and decapitates lizard, paper covers rock and disproves Spock, lizard poisons Spock and eats paper, Spock smashes scissors and vaporizes rock.

class Choice(value)

An enumeration.

handle_action(user_move)

Handle the user’s action, and let the opponent make a move according to its strategy.