fix functions
This commit is contained in:
parent
0b1a03b5ac
commit
2c5c0148bf
@ -57,10 +57,10 @@ commands:Add('skill',{},'skill <username|mention|"me"> <game> <style> <sort?=ski
|
|||||||
rank = 1
|
rank = 1
|
||||||
count = 1
|
count = 1
|
||||||
end
|
end
|
||||||
time.Points = API:CalculatePoint(rank,count)
|
time.Points = API.CalculatePoint(rank,count)
|
||||||
time.Rank = rank
|
time.Rank = rank
|
||||||
time.MapCompletionCount = count
|
time.MapCompletionCount = count
|
||||||
time.Skill = API:FormatSkill((count-rank)/(count-1))
|
time.Skill = API.FormatSkill((count-rank)/(count-1))
|
||||||
time.SkillRaw = (count-rank)/(count-1)
|
time.SkillRaw = (count-rank)/(count-1)
|
||||||
test_a=test_a+(count-rank)
|
test_a=test_a+(count-rank)
|
||||||
test_b=test_b+(count-1)
|
test_b=test_b+(count-1)
|
||||||
@ -75,9 +75,9 @@ commands:Add('skill',{},'skill <username|mention|"me"> <game> <style> <sort?=ski
|
|||||||
points = points+time.Points
|
points = points+time.Points
|
||||||
end
|
end
|
||||||
local skillFinal = (test_a)/(test_b-1)
|
local skillFinal = (test_a)/(test_b-1)
|
||||||
local msg = 'Average Skill: '..API:FormatSkill(math.clamp(skillFinal,0,1))..'\n'..
|
local msg = 'Average Skill: '..API.FormatSkill(math.clamp(skillFinal,0,1))..'\n'..
|
||||||
'Points: '..points..'\n'..
|
'Points: '..points..'\n'..
|
||||||
pad(API,'Map',50)..' | '..pad(API,'Points')..' | '..pad(API,'Skill',7)..' | '.. pad(API,'Placement',14)..' | Time\n\n'
|
pad('Map',50)..' | '..pad('Points')..' | '..pad('Skill',7)..' | '.. pad('Placement',14)..' | Time\n\n'
|
||||||
|
|
||||||
for _,time in next,times do
|
for _,time in next,times do
|
||||||
-- msg = msg..'['..time.Rank..'/'..time.MapCompletionCount..'] '..time.Map..' ('..time.Skill..')\n'
|
-- msg = msg..'['..time.Rank..'/'..time.MapCompletionCount..'] '..time.Map..' ('..time.Skill..')\n'
|
||||||
@ -85,8 +85,8 @@ commands:Add('skill',{},'skill <username|mention|"me"> <game> <style> <sort?=ski
|
|||||||
local skill = time.Skill
|
local skill = time.Skill
|
||||||
local point = time.Points
|
local point = time.Points
|
||||||
local rankStr = time.Rank..'/'..time.MapCompletionCount
|
local rankStr = time.Rank..'/'..time.MapCompletionCount
|
||||||
local timeStr = API:FormatTime(time.Time)
|
local timeStr = API.FormatTime(time.Time)
|
||||||
msg = msg.. pad(API,mapStr,50)..' | '..pad(API,point)..' | '..pad(API,skill,7)..' | '.. pad(API,rankStr,14)..' | '..timeStr..'\n'
|
msg = msg.. pad(mapStr,50)..' | '..pad(point)..' | '..pad(skill,7)..' | '.. pad(rankStr,14)..' | '..timeStr..'\n'
|
||||||
end
|
end
|
||||||
local txt = './skill-'..API.GAMES[game]..'-'..API.STYLES[style]:lower()..'-'..user.name..'.txt'
|
local txt = './skill-'..API.GAMES[game]..'-'..API.STYLES[style]:lower()..'-'..user.name..'.txt'
|
||||||
local file=io.open(txt,'w+')
|
local file=io.open(txt,'w+')
|
||||||
|
@ -82,10 +82,10 @@ function formatTime(a)if a>86400000 then return'>1 day'end;local c=format_helper
|
|||||||
-- [[ STRAFESNET API ]] --
|
-- [[ STRAFESNET API ]] --
|
||||||
|
|
||||||
-- Get rank string from rank point
|
-- Get rank string from rank point
|
||||||
function API:FormatRank(n) return RANKS[1+math.floor(n*19)] end
|
function API.FormatRank(n) return RANKS[1+math.floor(n*19)] end
|
||||||
-- Get skill percentage from skill point
|
-- Get skill percentage from skill point
|
||||||
function API:FormatSkill(n) return r(n*100,3)..'%' end
|
function API.FormatSkill(n) return r(n*100,3)..'%' end
|
||||||
function API:FormatTime(n) return formatTime(n) end
|
function API.FormatTime(n) return formatTime(n) end
|
||||||
|
|
||||||
-- Time from id.
|
-- Time from id.
|
||||||
function API:GetTime(ID)
|
function API:GetTime(ID)
|
||||||
@ -180,79 +180,59 @@ end
|
|||||||
|
|
||||||
function API:GetMapCompletionCount(MAP_ID,STYLE_ID)
|
function API:GetMapCompletionCount(MAP_ID,STYLE_ID)
|
||||||
if not MAP_ID or not STYLE_ID then return 'empty id' end
|
if not MAP_ID or not STYLE_ID then return 'empty id' end
|
||||||
local _,headers = API:GetMapTimes(MAP_ID,STYLE_ID)
|
local _,headers = self:GetMapTimes(MAP_ID,STYLE_ID)
|
||||||
local pages = headers['Pagination-Count']
|
local pages = headers['Pagination-Count']
|
||||||
local res,h = API:GetMapTimes(MAP_ID,STYLE_ID,pages)
|
local res,h = self:GetMapTimes(MAP_ID,STYLE_ID,pages)
|
||||||
if not res then
|
if not res then
|
||||||
table.foreach(h,print)
|
table.foreach(h,print)
|
||||||
end
|
end
|
||||||
return ((pages-1)*200)+#res
|
return ((pages-1)*200)+#res
|
||||||
end
|
end
|
||||||
--cool doggo, aidan and me
|
--cool doggo, aidan and me
|
||||||
function API:CalculatePoint(rank,count)
|
function API.CalculatePoint(rank,count)
|
||||||
return RANK_CONSTANT_A*(math.exp(RANK_CONSTANT_B)-1)/(1-math.exp(math.max(-700, -RANK_CONSTANT_C*count)))*math.exp(math.max(-700, -RANK_CONSTANT_D*rank))+(1-RANK_CONSTANT_E)*(1+2*(count-rank))/(count*count)
|
return RANK_CONSTANT_A*(math.exp(RANK_CONSTANT_B)-1)/(1-math.exp(math.max(-700, -RANK_CONSTANT_C*count)))*math.exp(math.max(-700, -RANK_CONSTANT_D*rank))+(1-RANK_CONSTANT_E)*(1+2*(count-rank))/(count*count)
|
||||||
end
|
end
|
||||||
|
|
||||||
function API:Pad(str,n)
|
function API.Pad(str,n)
|
||||||
n = n or 20
|
n = n or 20
|
||||||
str = tostring(str)
|
str = tostring(str)
|
||||||
return str..string.rep(' ',n-#str)
|
return str..string.rep(' ',n-#str)
|
||||||
end
|
end
|
||||||
|
|
||||||
function API:CalculateDifference(v1,v2)
|
function API.CalculateDifference(v1,v2)
|
||||||
return math.abs(v1-v2)
|
return math.abs(v1-v2)
|
||||||
end
|
end
|
||||||
|
|
||||||
function API:CalculateDifferencePercent(v1,v2)
|
function API.CalculateDifferencePercent(v1,v2)
|
||||||
return math.abs((1-(v1/v2))*100)..'%'
|
return math.abs((1-(v1/v2))*100)..'%'
|
||||||
end
|
end
|
||||||
function API:GetUserFromAny(user,message)
|
function API:GetUserFromAny(user,message)
|
||||||
local str = user:match('^["\'](.+)[\'"]$')
|
local str = user:match('^["\'](.+)[\'"]$')
|
||||||
local num = user:match('^(%d+)$')
|
local num = user:match('^(%d+)$')
|
||||||
if str then
|
if str then
|
||||||
local roblox_user=API:GetRobloxInfoFromUsername(str)
|
local roblox_user=self:GetRobloxInfoFromUsername(str)
|
||||||
if not roblox_user.id then return 'User not found' end
|
if not roblox_user.id then return 'User not found' end
|
||||||
return roblox_user
|
return roblox_user
|
||||||
elseif num then
|
elseif num then
|
||||||
local roblox_user = API:GetRobloxInfoFromUserId(user)
|
local roblox_user = self:GetRobloxInfoFromUserId(user)
|
||||||
if not roblox_user.id then return 'Invalid user id' end
|
if not roblox_user.id then return 'Invalid user id' end
|
||||||
return roblox_user
|
return roblox_user
|
||||||
elseif user=='me' then
|
elseif user=='me' then
|
||||||
local me=message.author
|
local me=message.author
|
||||||
local roblox_user=API:GetRobloxInfoFromDiscordId(me.id)
|
local roblox_user=self:GetRobloxInfoFromDiscordId(me.id)
|
||||||
if not roblox_user.id then return 'You are not registered with the RoverAPI' end
|
if not roblox_user.id then return 'You are not registered with the RoverAPI' end
|
||||||
return roblox_user
|
return roblox_user
|
||||||
elseif user:match('<@%d+>') then
|
elseif user:match('<@%d+>') then
|
||||||
local user_id=user:match('<@(%d+)>')
|
local user_id=user:match('<@(%d+)>')
|
||||||
local member=message.guild:getMember(user_id)
|
local member=message.guild:getMember(user_id)
|
||||||
local roblox_user=API:GetRobloxInfoFromDiscordId(member.id)
|
local roblox_user=self:GetRobloxInfoFromDiscordId(member.id)
|
||||||
if not roblox_user.id then return 'User is not registered with the RoverAPI' end
|
if not roblox_user.id then return 'User is not registered with the RoverAPI' end
|
||||||
return roblox_user
|
return roblox_user
|
||||||
else
|
else
|
||||||
local roblox_user=API:GetRobloxInfoFromUsername(user)
|
local roblox_user=self:GetRobloxInfoFromUsername(user)
|
||||||
if not roblox_user.id then return 'User not found' end
|
if not roblox_user.id then return 'User not found' end
|
||||||
return roblox_user
|
return roblox_user
|
||||||
end
|
end
|
||||||
-- if user=='me' then
|
|
||||||
-- local me=message.author
|
|
||||||
-- local roblox_user=API:GetRobloxInfoFromDiscordId(me.id)
|
|
||||||
-- if not roblox_user.id then return 'You are not registered with the RoverAPI' end
|
|
||||||
-- return roblox_user
|
|
||||||
-- elseif user:match('<@%d+>') then
|
|
||||||
-- local user_id=user:match('<@(%d+)>')
|
|
||||||
-- local member=message.guild:getMember(user_id)
|
|
||||||
-- local roblox_user=API:GetRobloxInfoFromDiscordId(member.id)
|
|
||||||
-- if not roblox_user.id then return 'User is not registered with the RoverAPI' end
|
|
||||||
-- return roblox_user
|
|
||||||
-- elseif user:match('%d+')==user then
|
|
||||||
-- local roblox_user = API:GetRobloxInfoFromUserId(user)
|
|
||||||
-- if not roblox_user.id then return 'Invalid user id' end
|
|
||||||
-- return roblox_user
|
|
||||||
-- else
|
|
||||||
-- local roblox_user=API:GetRobloxInfoFromUsername(user)
|
|
||||||
-- if not roblox_user.id then return 'User not found' end
|
|
||||||
-- return roblox_user
|
|
||||||
-- end
|
|
||||||
return 'Something went wrong (this should generally not happen)'
|
return 'Something went wrong (this should generally not happen)'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user