Exemplo n.º 1
0
 def __evaluate_inspect(condition_tmp: Condition = None,
                        game_status_tmp: GameStatus = None):
     evaluated = False
     LoggingController.logger.debug(
         "Evaluating: " + str(inspect.currentframe().f_code.co_name))
     # verify size of elements in the condition
     if len(condition_tmp.list) >= 2:
         inspect_type = condition_tmp.list[0]
         artifact_id = condition_tmp.list[1]
         store_name = condition_tmp.list[2]
         fourth_element = condition_tmp.list[3] if (len(condition_tmp.list)
                                                    == 3) else None
         fifth_element = condition_tmp.list[4] if (len(condition_tmp.list)
                                                   == 4) else None
         player = fourth_element if (
             fifth_element is not None and Helpers.is_player(
                 game_status_tmp, fourth_element)) else None
         role = fifth_element if (player is None and Helpers.is_role(
             game_status_tmp, fourth_element)) else None
         commitment_timing = fifth_element if (fifth_element
                                               is not None) else None
         data = {
             'inspect_type': inspect_type,
             'artifact_id': artifact_id,
             'store_name': store_name,
             'player': player,
             'role': role,
             'commitment_timing': commitment_timing
         }
         if inspect_type in InspectEvaluator.__options:
             evaluated = InspectEvaluator.__options[inspect_type].__func__(
                 data, evaluated, game_status_tmp)
     return evaluated
Exemplo n.º 2
0
 def __evaluate_move(effect_tmp: Effect = None,
                     game_status_tmp: GameStatus = None):
     LoggingController.logger.debug(
         "Evaluating: " + str(inspect.currentframe().f_code.co_name))
     # verify size of elements in the condition
     if len(effect_tmp.list) >= 3:
         permit_mandate = effect_tmp.list[0]
         which_move = effect_tmp.list[1]
         move_name = effect_tmp.list[2]
         fourth_element = None
         artifact = None
         player = None
         role = None
         if len(effect_tmp.list) == 4:
             fourth_element = effect_tmp.list[3]
             if Helpers.is_player(game_status_tmp, fourth_element):
                 player = fourth_element
             elif Helpers.is_role(game_status_tmp, fourth_element):
                 role = fourth_element
             if player is None and role is None:
                 artifact = fourth_element
         elif len(effect_tmp.list) == 5:
             artifact = effect_tmp.list[3]
             player_or_role = effect_tmp.list[4]
             if Helpers.is_player(game_status_tmp, player_or_role):
                 player = fourth_element
             elif Helpers.is_role(game_status_tmp, player_or_role):
                 role = fourth_element
         data = {
             'permit_mandate': permit_mandate,
             'which_move': which_move,
             'move_name': move_name,
             'artifact': artifact,
             'player': player,
             'role': role
         }
         if permit_mandate in MoveEvaluator.__options:
             game_status_tmp = MoveEvaluator.__options[
                 permit_mandate].__func__(game_status_tmp, data)
     return game_status_tmp