# Decompiled with PyLingual (https://pylingual.io)
# Internal filename: Src\Predict.py
# Bytecode version: 3.9.0beta5 (3425)
# Source timestamp: 1970-01-01 00:00:00 UTC (0)

def Predict(data, given_string):
    result = []
    betPlace = None
    if given_string is not None:
        for item in data:
            substr = item[0]
            last_appearance = given_string.rfind(substr)
            if last_appearance != -1 and last_appearance == len(given_string) - len(substr):
                result = item
                if item[1][0] == 'P':
                    betPlace = 'Player'
                elif item[1][0] == 'B':
                    betPlace = 'Banker'
                break
    return (result, betPlace)

def LoadHistory(jsonMessage):
    stringWinner = ''.join(['P' if entry['winner'] == 'Player' else 'B' if entry['winner'] == 'Banker' else '' for entry in jsonMessage['args']['history_v2']])
    return stringWinner