# Path: steamapi/getproplayerlist.py
# def requestGetProPlayerList():
#     URL = "https://api.steampowered.com/IDOTA2Fantasy_570/GetProPlayerList/v1?key=" + SteamAPIKey
# 
# Path: steamapi/getheroes.py
# def requestGetHeroes():
#     URL = "https://api.steampowered.com/IEconDOTA2_570/GetHeroes/v0001/?key=" + SteamAPIKey + "&language=en_us"
# 
# Path: steamapi/getgameitems.py
# def requestGetGameItems():
#     URL = "https://api.steampowered.com/IEconDOTA2_570/GetGameItems/v1/?key=" + SteamAPIKey + "&language=en_us"
# 
# Path: converter/timeconverter.py
# def unixTimeConverter(timeVar):
# def durationTimeConverter(timeVar):
# 
# Path: converter/playerconverter.py
# def playerConverter(playerID, playerSummariesJson=None, includeMMR=False):
# def getMMR(playerID):
#     MMR = None
#         MMR = getMMR(playerID)
#         MMR = {}


from steamapi.getproplayerlist import proPlayerDictionary
from steamapi.getheroes import heroDictionary
from steamapi.getgameitems import itemDictionary
from converter import timeconverter, playerconverter

def displayResult(matchJson, playerSummariesJson):

    introTemplate = '####&#009;\n#####&#009; ' \
                    'Hover to view match ID: {matchid} [DB](http://www.dotabuff.com/matches/{matchid})/' \
                    '[OD](https://www.opendota.com/matches/{matchid})/' \
                    '[STRATZ](https://stratz.com/match/{matchid})' \
                    '\n######&#009;\n\n' \
                    '[**{teamwinner} wins {winnerkills}-{loserkills} @ {time}**](#lumbdi "{additionalinformation}")\n\n'
    tableTemplate = 'Lvl | Hero | Player| K/D/A | LH/D | XPM | GPM | HD | HH | TD\n' \
                    ':--|:--:|:--|:--|:--|:--|:--|:--|:--|:--\n'
    tableLineTemplate = '{level}|{hero}|{account}|{kda}|{lhd}|{xpm}|{gpm}|{hd}|{hh}|{td}\n'
    dividerTemplate = '{level}||↑Radiant↑ ↓Dire↓ |{kda}|{lhd}|{xpm}|{gpm}|{hd}|{hh}|{td}\n'
    outtro = '\n\n---\n\n'

    #print(introTemplate + tableTemplate + tableLineTemplate + outtroTemplate)

    matchID = matchJson['result']["match_id"]
    if matchJson['result']['radiant_win']:
        teamwinner = 'Radiant'
        winnerkills = matchJson['result']["radiant_score"]
        loserkills = matchJson['result']["dire_score"]
    else:
        teamwinner = 'Dire'
        winnerkills = matchJson['result']["dire_score"]
        loserkills = matchJson['result']["radiant_score"]

# Path: steamapi/getproplayerlist.py
# def requestGetProPlayerList():
#     URL = "https://api.steampowered.com/IDOTA2Fantasy_570/GetProPlayerList/v1?key=" + SteamAPIKey
# 
# Path: steamapi/getheroes.py
# def requestGetHeroes():
#     URL = "https://api.steampowered.com/IEconDOTA2_570/GetHeroes/v0001/?key=" + SteamAPIKey + "&language=en_us"
# 
# Path: steamapi/getgameitems.py
# def requestGetGameItems():
#     URL = "https://api.steampowered.com/IEconDOTA2_570/GetGameItems/v1/?key=" + SteamAPIKey + "&language=en_us"
# 
# Path: converter/timeconverter.py
# def unixTimeConverter(timeVar):
# def durationTimeConverter(timeVar):
# 
# Path: converter/playerconverter.py
# def playerConverter(playerID, playerSummariesJson=None, includeMMR=False):
# def getMMR(playerID):
#     MMR = None
#         MMR = getMMR(playerID)
#         MMR = {}


# Path: displayreddit/drmatch.py
from steamapi.getproplayerlist import proPlayerDictionary
from steamapi.getheroes import heroDictionary
from steamapi.getgameitems import itemDictionary
from converter import timeconverter, playerconverter


def displayResult(matchJson, playerSummariesJson):

    introTemplate = '####&#009;\n#####&#009; ' \
                    'Hover to view match ID: {matchid} [DB](http://www.dotabuff.com/matches/{matchid})/' \
                    '[OD](https://www.opendota.com/matches/{matchid})/' \
                    '[STRATZ](https://stratz.com/match/{matchid})' \
                    '\n######&#009;\n\n' \
                    '[**{teamwinner} wins {winnerkills}-{loserkills} @ {time}**](#lumbdi "{additionalinformation}")\n\n'
    tableTemplate = 'Lvl | Hero | Player| K/D/A | LH/D | XPM | GPM | HD | HH | TD\n' \
                    ':--|:--:|:--|:--|:--|:--|:--|:--|:--|:--\n'
    tableLineTemplate = '{level}|{hero}|{account}|{kda}|{lhd}|{xpm}|{gpm}|{hd}|{hh}|{td}\n'
    dividerTemplate = '{level}||↑Radiant↑ ↓Dire↓ |{kda}|{lhd}|{xpm}|{gpm}|{hd}|{hh}|{td}\n'
    outtro = '\n\n---\n\n'

    #print(introTemplate + tableTemplate + tableLineTemplate + outtroTemplate)

    matchID = matchJson['result']["match_id"]
    if matchJson['result']['radiant_win']:
        teamwinner = 'Radiant'
        winnerkills = matchJson['result']["radiant_score"]
        loserkills = matchJson['result']["dire_score"]
    else:
        teamwinner = 'Dire'
        winnerkills = matchJson['result']["dire_score"]
        loserkills = matchJson['result']["radiant_score"]

    time = timeconverter.durationTimeConverter(matchJson['result']["duration"])