def __check_inrole(condition_tmp: Condition = None, game_status_tmp: GameStatus = None): LoggingController.logger.debug( "Evaluating: " + str(inspect.currentframe().f_code.co_name)) match = False # check number of parameters supplied if len(condition_tmp.list) == 1: parameter = condition_tmp.list[0] player = game_status_tmp.players.get_player_by_name(parameter) if player is not None: if player.name in game_status_tmp.get_speakers(): match = True else: match = False else: match = True speakers = game_status_tmp.get_speakers() for speaker in speakers: player = game_status_tmp.players.get_player_by_name( speaker) role = parameter if role not in player.roles: match = False break return match
def update_collector(self, game_status_tmp: GameStatus = None): game_status_tmp.new_turn = self.__evaluate_next_player_by_turns(game_status_tmp) game_status_tmp.speakers = game_status_tmp.get_speakers() if game_status_tmp.all_players_did_move: game_status_tmp.turns_counter += 1 if game_status_tmp.turns.max is not None: if game_status_tmp.turns_counter >= game_status_tmp.turns.max: game_status_tmp.status = Status.TERMINATE GameEndController.finished = True return game_status_tmp
def handle(self, game_status_tmp: GameStatus = None): valid = MoveValidationController.__validate(game_status_tmp) if not valid: details = {"player_expected": game_status_tmp.get_speakers(), "player_got": game_status_tmp.last_interaction_move.playerName, "moves_expected": {"mandatory": [x.moveName for x in game_status_tmp.mandatory_moves[NEXT]], "available": [x.moveName for x in game_status_tmp.available_moves[NEXT]]}, "move_got": game_status_tmp.last_interaction_move.moveName} return None, ExceptionHandler("INVALID_MOVE", 400, payload=details) game_status_tmp = self.update_collector(game_status_tmp) self.update_flag() LoggingController.logger.debug("Handling in: " + str(type(self))) return game_status_tmp, None
def update_collector(self, game_status_tmp: GameStatus = None): if game_status_tmp.last_interaction_move: game_status_tmp = game_status_tmp.assign_speaker_assign_listener() game_status_tmp.speakers = game_status_tmp.get_speakers() game_status_tmp.current_speaker = game_status_tmp.last_interaction_move.playerName game_status_tmp.set_last_move_by_name(game_status_tmp.last_interaction_move.moveName) game_status_tmp.past_moves.append(game_status_tmp.last_interaction_move) game_status_tmp.set_did_move_flag(game_status_tmp.current_speaker) game_status_tmp.remove_interaction_move_from_moves(game_status_tmp.last_interaction_move) game_status_tmp.initial_turn = False game_status_tmp.clear_init_moves_dicts() else: LoggingController.logger.warning( "game_status_tmp.last_interaction_move: None\n\tLast move could not be parsed") GameEndController.finished = True return game_status_tmp
def update_collector(self, game_status_tmp: GameStatus = None): game_status_tmp.speakers = game_status_tmp.get_speakers() return game_status_tmp