Guest User

Untitled

a guest
Jul 4th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.72 KB | None | 0 0
  1. def getMatchStats(matchID,myplatform,guruplatform):
  2.     try:
  3.         datalog("\tGetting match {id}".format(id=matchID),end=", ")
  4.         info = smite.get_match_details(matchID)
  5.         firstrow = info[0]
  6.         rawseconds = firstrow["Time_In_Match_Seconds"]
  7.         minutes = rawseconds//60
  8.         seconds = rawseconds % 60
  9.         score1 = firstrow["Team1Score"]
  10.         difference1 = 4-score1
  11.         score2 = firstrow["Team2Score"]
  12.         difference2 = 4-score2
  13.         if difference1 < difference2:
  14.             score1 += difference1
  15.             score2 += difference1
  16.         else:
  17.             score1 += difference2
  18.             score2 += difference2
  19.         replyString = ""
  20.         replyString += "MatchID|Time|Mode|Region|Score|Duration\n:--|:--|:--|:--|:--|:--\n"
  21.         replyString += matchID
  22.         replyString += "|"
  23.         replyString += str(firstrow["Entry_Datetime"]) #Time
  24.         replyString += "|"
  25.         replyString += str(firstrow["name"]).replace(": ","") #Game Mode
  26.         replyString += "|"
  27.         replyString += str(firstrow["Region"]) #Region
  28.         replyString += "|"
  29.         replyString += str(score1) #Score 1
  30.         replyString += "-"
  31.         replyString += str(score2) #Score 2
  32.         replyString += "|"
  33.         replyString += str(minutes) #Minutes
  34.         replyString += ":"
  35.         replyString += str(seconds) #Seconds
  36.         replyString += "\n\n"
  37.         replyString += "[Lv] Player|Champion|Cred (CPM)|K/D/A|Dmg|Shield|Heal|Obj\n:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--\n"
  38.         for row in info:
  39.             winStr = ""
  40.             if row["Win_Status"] == "Winner":
  41.                 winStr = "**"
  42.             replyString += winStr
  43.             replyString += "["
  44.             replyString += str(row["Account_Level"]) #Account Level
  45.             replyString += "] "
  46.             replyString += str(row["playerName"]) #Account Name
  47.             replyString += winStr
  48.             replyString += "|"
  49.             replyString += winStr
  50.             replyString += "["
  51.             replyString += str(row["Reference_Name"]) #Champion
  52.             replyString += "](#/flair"
  53.             replyString += str(row["Reference_Name"]).replace("'", "").replace(" ","").lower() #Flair
  54.             replyString += ")"
  55.             replyString += winStr
  56.             replyString += "|"
  57.             replyString += winStr
  58.             tempGold = row["Gold_Earned"]
  59.             tempCPS = tempGold/rawseconds
  60.             tempCPM = tempCPS*60
  61.             replyString += str("{:,}".format(tempGold)) #Credits
  62.             replyString += " ("
  63.             replyString += str(int(round(tempCPM,0))) #CPM
  64.             replyString += ")"
  65.             replyString += winStr
  66.             replyString += "|"
  67.             replyString += winStr
  68.             replyString += str(row["Kills_Player"]) #Kills
  69.             replyString += "/"
  70.             replyString += str(row["Deaths"]) #Deaths
  71.             replyString += "/"
  72.             replyString += str(row["Assists"]) #Assists
  73.             replyString += winStr
  74.             replyString += "|"
  75.             replyString += winStr
  76.             replyString += "{:,}".format(row["Damage_Player"]) #Damage Dealt
  77.             replyString += winStr
  78.             replyString += "|"
  79.             replyString += winStr
  80.             replyString += "{:,}".format(row["Damage_Mitigated"]) #Shielding
  81.             replyString += winStr
  82.             replyString += "|"
  83.             replyString += winStr
  84.             replyString += "{:,}".format(row["Healing"]) #Healing
  85.             replyString += winStr
  86.             replyString += "|"
  87.             replyString += winStr
  88.             replyString += "{:,}".format(row["Objective_Assists"]) #Objective Time
  89.             replyString += winStr
  90.             replyString += "|\n"
  91.         replyString += "\n"
  92.         replyString += "*More info: [My Paladins](https://{myplatform}mypaladins.com/match/".format(myplatform=myplatform)
  93.         replyString += matchID
  94.         replyString += ") • [Paladins Guru](http://paladins.guru/match/{guruplatform}/".format(guruplatform=guruplatform)
  95.         replyString += matchID
  96.         replyString += ")*"
  97.         datalog("writing reply")
  98.         return(replyString)
  99.     except:
  100.         replyString = "The match '{matchID}' you specified could not be found. Trying looking on ".format(matchID=matchID)
  101.         replyString += "[My Paladins](https://{myplatform}mypaladins.com/match/".format(myplatform=myplatform)
  102.         replyString += matchID
  103.         replyString += ") or [Paladins Guru](http://paladins.guru/match/{guruplatform}/".format(guruplatform=guruplatform)
  104.         replyString += matchID
  105.         replyString += ") instead"
  106.         datalog("the API failed to find the match, writing reply")
  107.         return(replyString)
Advertisement
Add Comment
Please, Sign In to add comment